- 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>
77 lines
2.2 KiB
Text
77 lines
2.2 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<cfscript>
|
|
/**
|
|
* Update Business Hours
|
|
*
|
|
* POST JSON:
|
|
* {
|
|
* "BusinessID": 37,
|
|
* "Hours": [
|
|
* { "dayId": 1, "open": "09:00", "close": "17:00" },
|
|
* { "dayId": 2, "open": "09:00", "close": "17:00" },
|
|
* ...
|
|
* ]
|
|
* }
|
|
*
|
|
* Days not in the Hours array are considered closed.
|
|
*/
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
requestBody = toString(getHttpRequestData().content);
|
|
if (!len(requestBody)) {
|
|
throw(message="No request body provided");
|
|
}
|
|
|
|
data = deserializeJSON(requestBody);
|
|
|
|
businessId = structKeyExists(data, "BusinessID") ? val(data.BusinessID) : 0;
|
|
if (businessId == 0) {
|
|
throw(message="BusinessID is required");
|
|
}
|
|
|
|
hours = structKeyExists(data, "Hours") && isArray(data.Hours) ? data.Hours : [];
|
|
|
|
// Delete all existing hours for this business
|
|
queryExecute("
|
|
DELETE FROM Hours WHERE HoursBusinessID = :bizID
|
|
", { bizID: businessId }, { datasource: "payfrit" });
|
|
|
|
// Insert new hours
|
|
for (h in hours) {
|
|
if (!isStruct(h)) continue;
|
|
|
|
dayId = structKeyExists(h, "dayId") ? val(h.dayId) : 0;
|
|
openTime = structKeyExists(h, "open") && isSimpleValue(h.open) ? h.open : "09:00";
|
|
closeTime = structKeyExists(h, "close") && isSimpleValue(h.close) ? h.close : "17:00";
|
|
|
|
if (dayId >= 1 && dayId <= 7) {
|
|
// Convert HH:MM to HH:MM:SS if needed
|
|
if (len(openTime) == 5) openTime = openTime & ":00";
|
|
if (len(closeTime) == 5) closeTime = closeTime & ":00";
|
|
|
|
queryExecute("
|
|
INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime)
|
|
VALUES (:bizID, :dayID, :openTime, :closeTime)
|
|
", {
|
|
bizID: businessId,
|
|
dayID: dayId,
|
|
openTime: openTime,
|
|
closeTime: closeTime
|
|
}, { datasource: "payfrit" });
|
|
}
|
|
}
|
|
|
|
response.OK = true;
|
|
response.hoursUpdated = arrayLen(hours);
|
|
|
|
} catch (any e) {
|
|
response.ERROR = e.message;
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|