- Add uploadHeader.cfm API for 1200px header images - Add saveBrandColor.cfm API for hex color storage - Add Branding section to menu builder sidebar - Fix header upload path and permissions - Various beacon and service point API improvements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
2.3 KiB
Text
70 lines
2.3 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<cfscript>
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
requestBody = toString(getHttpRequestData().content);
|
|
requestData = {};
|
|
if (len(requestBody)) {
|
|
requestData = deserializeJSON(requestBody);
|
|
}
|
|
|
|
businessID = val(requestData.BusinessID ?: 0);
|
|
confirmDelete = requestData.confirm ?: "";
|
|
|
|
if (businessID == 0) {
|
|
throw("BusinessID is required");
|
|
}
|
|
|
|
if (confirmDelete != "DELETE_ALL_DATA") {
|
|
throw("Must pass confirm: 'DELETE_ALL_DATA' to proceed");
|
|
}
|
|
|
|
// Get counts before deletion
|
|
qItemCount = queryExecute("SELECT COUNT(*) as cnt FROM Items WHERE ItemBusinessID = :bid", { bid: businessID }, { datasource: "payfrit" });
|
|
qCatCount = queryExecute("SELECT COUNT(*) as cnt FROM Categories WHERE CategoryBusinessID = :bid", { bid: businessID }, { datasource: "payfrit" });
|
|
|
|
// Get item IDs for this business to delete template links
|
|
qItemIds = queryExecute("SELECT ItemID FROM Items WHERE ItemBusinessID = :bid", { bid: businessID }, { datasource: "payfrit" });
|
|
itemIds = [];
|
|
for (row in qItemIds) {
|
|
arrayAppend(itemIds, row.ItemID);
|
|
}
|
|
|
|
deletedLinks = 0;
|
|
if (arrayLen(itemIds) > 0) {
|
|
// Delete template links for these items
|
|
queryExecute("DELETE FROM ItemTemplateLinks WHERE ItemID IN (:ids) OR TemplateItemID IN (:ids)",
|
|
{ ids: { value: arrayToList(itemIds), cfsqltype: "cf_sql_varchar", list: true } },
|
|
{ datasource: "payfrit" });
|
|
deletedLinks = arrayLen(itemIds);
|
|
}
|
|
|
|
// Delete all items for this business
|
|
queryExecute("DELETE FROM Items WHERE ItemBusinessID = :bid", { bid: businessID }, { datasource: "payfrit" });
|
|
|
|
// Delete all categories for this business
|
|
queryExecute("DELETE FROM Categories WHERE CategoryBusinessID = :bid", { bid: businessID }, { datasource: "payfrit" });
|
|
|
|
response = {
|
|
"OK": true,
|
|
"deleted": {
|
|
"items": qItemCount.cnt,
|
|
"categories": qCatCount.cnt,
|
|
"templateLinks": deletedLinks
|
|
},
|
|
"businessID": businessID
|
|
};
|
|
|
|
} catch (any e) {
|
|
response = {
|
|
"OK": false,
|
|
"ERROR": e.message
|
|
};
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|