Portal local development: - Add BASE_PATH detection to all portal files (login, portal.js, menu-builder, station-assignment) - Allows portal to work at /biz.payfrit.com/ path locally Menu Builder fixes: - Fix duplicate template options in getForBuilder.cfm query - Filter template children by business ID with DISTINCT New APIs: - api/portal/myBusinesses.cfm - List businesses for logged-in user - api/stations/list.cfm - List KDS stations - api/menu/updateStations.cfm - Update item station assignments - api/setup/reimportBigDeans.cfm - Full Big Dean's menu import script Admin utilities: - Various debug and migration scripts for menu/template management - Beacon switching, category cleanup, modifier template setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
60 lines
1.7 KiB
Text
60 lines
1.7 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<!--- Only allow from localhost --->
|
|
<cfif NOT (cgi.remote_addr EQ "127.0.0.1" OR cgi.remote_addr EQ "::1" OR findNoCase("localhost", cgi.server_name))>
|
|
<cfoutput>#serializeJSON({"OK": false, "ERROR": "admin_only"})#</cfoutput>
|
|
<cfabort>
|
|
</cfif>
|
|
|
|
<cfscript>
|
|
/**
|
|
* Delete orphan Items at ParentID=0
|
|
* Orphan = ParentID=0, no children, not in ItemTemplateLinks
|
|
*/
|
|
|
|
response = { "OK": false, "deleted": 0, "orphans": [] };
|
|
|
|
try {
|
|
// Find orphans
|
|
qOrphans = queryExecute("
|
|
SELECT i.ItemID, i.ItemName, i.ItemBusinessID
|
|
FROM Items i
|
|
WHERE i.ItemParentItemID = 0
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM Items child WHERE child.ItemParentItemID = i.ItemID
|
|
)
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM ItemTemplateLinks tl WHERE tl.TemplateItemID = i.ItemID
|
|
)
|
|
ORDER BY i.ItemBusinessID, i.ItemName
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
orphanIDs = [];
|
|
for (orphan in qOrphans) {
|
|
arrayAppend(response.orphans, {
|
|
"ItemID": orphan.ItemID,
|
|
"ItemName": orphan.ItemName,
|
|
"BusinessID": orphan.ItemBusinessID
|
|
});
|
|
arrayAppend(orphanIDs, orphan.ItemID);
|
|
}
|
|
|
|
// Delete them by ID list
|
|
if (arrayLen(orphanIDs) > 0) {
|
|
queryExecute("
|
|
DELETE FROM Items WHERE ItemID IN (#arrayToList(orphanIDs)#)
|
|
", {}, { datasource: "payfrit" });
|
|
}
|
|
|
|
response["deleted"] = arrayLen(orphanIDs);
|
|
response["OK"] = true;
|
|
|
|
} catch (any e) {
|
|
response["ERROR"] = e.message;
|
|
response["DETAIL"] = e.detail;
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|