Features: - Multi-menu support with time-based availability - Menu hours validation against business operating hours - Setup wizard now creates Menu records and links categories - New menus.cfm API for menu CRUD operations - Category schedule filtering (day/time based visibility) - Beacon UUID lookup API for customer app - Parent/child business relationships for franchises - Category listing API for menu builder Portal improvements: - Menu builder theming to match admin UI - Brand color picker fix - Header image preview improvements API fixes: - Filter demo/hidden businesses from restaurant list - Improved error handling throughout Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
76 lines
1.7 KiB
Text
76 lines
1.7 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>
|
|
function apiAbort(payload) {
|
|
writeOutput(serializeJSON(payload));
|
|
abort;
|
|
}
|
|
|
|
function readJsonBody() {
|
|
raw = toString(getHttpRequestData().content);
|
|
if (isNull(raw) || len(trim(raw)) EQ 0) return {};
|
|
try {
|
|
parsed = deserializeJSON(raw);
|
|
} catch(any e) {
|
|
apiAbort({ OK=false, ERROR="bad_json", MESSAGE="Invalid JSON body" });
|
|
}
|
|
if (!isStruct(parsed)) return {};
|
|
return parsed;
|
|
}
|
|
|
|
// Support GET param or POST body
|
|
parentBusinessId = 0;
|
|
if (structKeyExists(url, "BusinessID") && isNumeric(url.BusinessID)) {
|
|
parentBusinessId = int(url.BusinessID);
|
|
} else {
|
|
data = readJsonBody();
|
|
if (structKeyExists(data, "BusinessID") && isNumeric(data.BusinessID)) {
|
|
parentBusinessId = int(data.BusinessID);
|
|
}
|
|
}
|
|
|
|
if (parentBusinessId LTE 0) {
|
|
apiAbort({ OK=false, ERROR="missing_business_id", MESSAGE="BusinessID is required" });
|
|
}
|
|
|
|
try {
|
|
q = queryExecute(
|
|
"
|
|
SELECT
|
|
BusinessID,
|
|
BusinessName
|
|
FROM Businesses
|
|
WHERE BusinessParentBusinessID = :parentId
|
|
ORDER BY BusinessName
|
|
",
|
|
{ parentId = { value = parentBusinessId, cfsqltype = "cf_sql_integer" } },
|
|
{ datasource = "payfrit" }
|
|
);
|
|
|
|
rows = [];
|
|
for (i = 1; i <= q.recordCount; i++) {
|
|
arrayAppend(rows, {
|
|
"BusinessID": q.BusinessID[i],
|
|
"BusinessName": q.BusinessName[i]
|
|
});
|
|
}
|
|
|
|
writeOutput(serializeJSON({
|
|
"OK": true,
|
|
"ERROR": "",
|
|
"BUSINESSES": rows
|
|
}));
|
|
abort;
|
|
|
|
} catch (any e) {
|
|
apiAbort({
|
|
"OK": false,
|
|
"ERROR": "server_error",
|
|
"DETAIL": e.message
|
|
});
|
|
}
|
|
</cfscript>
|