This repository has been archived on 2026-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
payfrit-biz/api/admin/_scripts/debugDrinkStructure.cfm
John Mizerek 89ec86c9d2 Move 70 one-off admin scripts to api/admin/_scripts/ (gitignored)
Only quickTasks/ and scheduledTasks/ subdirectories remain tracked
since those are actively used by the portal.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 20:38:49 -08:00

76 lines
2.4 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfheader name="Cache-Control" value="no-store">
<cfscript>
// Find Fountain Drinks in In-N-Out (BusinessID 17) and show its hierarchy
response = { "OK": true };
try {
// Get Fountain Drinks item
qFountain = queryExecute("
SELECT ID, Name, ParentItemID, Price, IsCollapsible, RequiresChildSelection
FROM Items
WHERE BusinessID = 17 AND Name LIKE '%Fountain%'
", {}, { datasource: "payfrit" });
response["FountainDrinks"] = [];
for (row in qFountain) {
fountainItem = {
"ItemID": row.ID,
"Name": row.Name,
"Price": row.Price,
"IsCollapsible": row.IsCollapsible,
"RequiresChildSelection": row.RequiresChildSelection,
"Children": []
};
// Get children of this item
qChildren = queryExecute("
SELECT ID, Name, ParentItemID, Price, IsCollapsible, RequiresChildSelection, IsCheckedByDefault
FROM Items
WHERE ParentItemID = :parentId
ORDER BY SortOrder
", { parentId: row.ID }, { datasource: "payfrit" });
for (child in qChildren) {
childItem = {
"ItemID": child.ItemID,
"Name": child.Name,
"Price": child.Price,
"IsCollapsible": child.IsCollapsible,
"IsCheckedByDefault": child.IsCheckedByDefault,
"Grandchildren": []
};
// Get grandchildren
qGrandchildren = queryExecute("
SELECT ID, Name, Price, IsCheckedByDefault
FROM Items
WHERE ParentItemID = :parentId
ORDER BY SortOrder
", { parentId: child.ItemID }, { datasource: "payfrit" });
for (gc in qGrandchildren) {
arrayAppend(childItem.Grandchildren, {
"ItemID": gc.ItemID,
"Name": gc.Name,
"Price": gc.Price,
"IsCheckedByDefault": gc.IsCheckedByDefault
});
}
arrayAppend(fountainItem.Children, childItem);
}
arrayAppend(response.FountainDrinks, fountainItem);
}
} catch (any e) {
response["OK"] = false;
response["ERROR"] = e.message;
}
writeOutput(serializeJSON(response));
</cfscript>