68 lines
2.2 KiB
Text
68 lines
2.2 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(obj){
|
|
writeOutput(serializeJSON(obj));
|
|
abort;
|
|
}
|
|
|
|
if (!structKeyExists(request,"UserID") || !isNumeric(request.UserID) || request.UserID LTE 0){
|
|
apiAbort({OK=false,ERROR="not_logged_in"});
|
|
}
|
|
if (!structKeyExists(request,"BusinessID") || !isNumeric(request.BusinessID) || request.BusinessID LTE 0){
|
|
apiAbort({OK=false,ERROR="no_business_selected"});
|
|
}
|
|
</cfscript>
|
|
|
|
<cfquery name="q" datasource="#application.datasource#">
|
|
SELECT
|
|
lt.lt_Beacon_Businesses_ServicePointID AS lt_Beacon_Businesses_ServicePointID,
|
|
lt.BeaconID AS BeaconID,
|
|
b.BeaconName AS BeaconName,
|
|
lt.ServicePointID AS ServicePointID,
|
|
sp.ServicePointName AS ServicePointName,
|
|
lt.lt_Beacon_Businesses_ServicePointNotes AS lt_Beacon_Businesses_ServicePointNotes,
|
|
lt.CreatedAt AS CreatedAt
|
|
FROM lt_Beacon_Businesses_ServicePoints lt
|
|
INNER JOIN Beacons b
|
|
ON b.BeaconID = lt.BeaconID
|
|
AND b.BusinessID = lt.BusinessID
|
|
INNER JOIN ServicePoints sp
|
|
ON sp.ServicePointID = lt.ServicePointID
|
|
AND sp.BusinessID = lt.BusinessID
|
|
WHERE lt.BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
|
ORDER BY lt.lt_Beacon_Businesses_ServicePointID DESC
|
|
</cfquery>
|
|
|
|
<cfscript>
|
|
assignments = [];
|
|
i = 1;
|
|
|
|
for (i = 1; i <= q.recordCount; i = i + 1){
|
|
// Build keys EXACTLY as the admin UI expects (case-sensitive in JS)
|
|
row = {
|
|
"lt_Beacon_Businesses_ServicePointID": q["lt_Beacon_Businesses_ServicePointID"][i],
|
|
"BeaconID": q["BeaconID"][i],
|
|
"BeaconName": q["BeaconName"][i],
|
|
"ServicePointID": q["ServicePointID"][i],
|
|
"ServicePointName": q["ServicePointName"][i],
|
|
"lt_Beacon_Businesses_ServicePointNotes": q["lt_Beacon_Businesses_ServicePointNotes"][i],
|
|
"CreatedAt": q["CreatedAt"][i]
|
|
};
|
|
arrayAppend(assignments, row);
|
|
}
|
|
|
|
out = {
|
|
"OK": true,
|
|
"ERROR": "",
|
|
"BUSINESSID": (request.BusinessID & ""),
|
|
"COUNT": arrayLen(assignments),
|
|
"ASSIGNMENTS": assignments
|
|
};
|
|
</cfscript>
|
|
|
|
<cfoutput>#serializeJSON(out)#</cfoutput>
|