payfrit-works/api/servicepoints/list.cfm
John Mizerek d4e0ae1162 Add branding features: header upload and brand color picker
- 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>
2026-01-18 12:14:24 -08:00

94 lines
2.8 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;
}
// Read JSON body once
data = {};
try {
raw = toString(getHttpRequestData().content);
if (len(trim(raw))) {
data = deserializeJSON(raw);
if (!isStruct(data)) data = {};
}
} catch (any e) {
data = {};
}
httpHeaders = getHttpRequestData().headers;
// Get BusinessID from: session > body > X-Business-ID header > URL
bizId = 0;
if (structKeyExists(request, "BusinessID") && isNumeric(request.BusinessID) && request.BusinessID GT 0) {
bizId = int(request.BusinessID);
}
if (bizId LTE 0 && structKeyExists(data, "BusinessID") && isNumeric(data.BusinessID) && data.BusinessID GT 0) {
bizId = int(data.BusinessID);
}
if (bizId LTE 0 && structKeyExists(httpHeaders, "X-Business-ID") && isNumeric(httpHeaders["X-Business-ID"]) && httpHeaders["X-Business-ID"] GT 0) {
bizId = int(httpHeaders["X-Business-ID"]);
}
if (bizId LTE 0 && structKeyExists(url, "BusinessID") && isNumeric(url.BusinessID) && url.BusinessID GT 0) {
bizId = int(url.BusinessID);
}
if (bizId LTE 0) {
apiAbort({ "OK": false, "ERROR": "missing_businessid" });
}
// Default behavior: only active service points unless onlyActive is explicitly false/0
onlyActive = true;
if (structKeyExists(data, "onlyActive")) {
if (isBoolean(data.onlyActive)) {
onlyActive = data.onlyActive;
} else if (isNumeric(data.onlyActive)) {
onlyActive = (int(data.onlyActive) EQ 1);
} else if (isSimpleValue(data.onlyActive)) {
onlyActive = (lcase(trim(toString(data.onlyActive))) EQ "true");
}
}
</cfscript>
<cfquery name="q" datasource="payfrit">
SELECT
ServicePointID,
ServicePointName,
ServicePointTypeID,
ServicePointCode,
ServicePointDescription,
ServicePointSortOrder,
ServicePointIsActive
FROM ServicePoints
WHERE ServicePointBusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#bizId#">
<cfif onlyActive>
AND ServicePointIsActive = 1
</cfif>
ORDER BY ServicePointSortOrder, ServicePointName
</cfquery>
<cfset servicePoints = []>
<cfloop query="q">
<cfset arrayAppend(servicePoints, {
"ServicePointID" = q.ServicePointID,
"ServicePointName" = q.ServicePointName,
"ServicePointTypeID" = q.ServicePointTypeID,
"ServicePointCode" = q.ServicePointCode,
"Description" = q.ServicePointDescription,
"SortOrder" = q.ServicePointSortOrder,
"IsActive" = q.ServicePointIsActive
})>
</cfloop>
<cfoutput>#serializeJSON({
"OK": true,
"ERROR": "",
"BusinessID": bizId,
"COUNT": arrayLen(servicePoints),
"SERVICEPOINTS": servicePoints
})#</cfoutput>