- Created listForKDS.cfm API endpoint for retrieving active orders - Filters by BusinessID and optional ServicePointID - Returns orders with StatusID 1-3 (New, Preparing, Ready) - Includes nested line items with item names - Joins customer and service point information - Created updateStatus.cfm API endpoint for order status transitions - Updates OrderStatusID (New -> Preparing -> Ready -> Completed) - Updates OrderLastEditedOn timestamp - Validates order exists before updating - Built complete HTML/JavaScript KDS web application - Real-time order display with configurable auto-refresh (default 5s) - Color-coded status cards: Blue (New), Orange (Preparing), Green (Ready) - Elapsed time tracking with visual warnings at 10min and 15min - Hierarchical line item display showing root items with nested modifiers - One-click status progression buttons - Persistent configuration (BusinessID, ServicePointID filter, refresh interval) - Responsive grid layout for multiple concurrent orders - Dark theme optimized for kitchen environments - Updated Application.cfm to allow public access to KDS endpoints 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
78 lines
2.2 KiB
Text
78 lines
2.2 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
|
|
<cffunction name="apiAbort" access="public" returntype="void" output="true">
|
|
<cfargument name="payload" type="struct" required="true">
|
|
<cfcontent type="application/json; charset=utf-8">
|
|
<cfoutput>#serializeJSON(arguments.payload)#</cfoutput>
|
|
<cfabort>
|
|
</cffunction>
|
|
|
|
<cffunction name="readJsonBody" access="public" returntype="struct" output="false">
|
|
<cfset var raw = getHttpRequestData().content>
|
|
<cfif isNull(raw) OR len(trim(raw)) EQ 0>
|
|
<cfreturn {}>
|
|
</cfif>
|
|
<cftry>
|
|
<cfset var data = deserializeJSON(raw)>
|
|
<cfif isStruct(data)>
|
|
<cfreturn data>
|
|
<cfelse>
|
|
<cfreturn {}>
|
|
</cfif>
|
|
<cfcatch>
|
|
<cfreturn {}>
|
|
</cfcatch>
|
|
</cftry>
|
|
</cffunction>
|
|
|
|
<cfset data = readJsonBody()>
|
|
<cfset OrderID = val( structKeyExists(data,"OrderID") ? data.OrderID : 0 )>
|
|
<cfset NewStatusID = val( structKeyExists(data,"StatusID") ? data.StatusID : 0 )>
|
|
|
|
<cfif OrderID LTE 0 OR NewStatusID LTE 0>
|
|
<cfset apiAbort({ "OK": false, "ERROR": "missing_params", "MESSAGE": "OrderID and StatusID are required.", "DETAIL": "" })>
|
|
</cfif>
|
|
|
|
<cftry>
|
|
<!--- Verify order exists --->
|
|
<cfset qOrder = queryExecute("
|
|
SELECT OrderID, OrderStatusID
|
|
FROM Orders
|
|
WHERE OrderID = ?
|
|
LIMIT 1
|
|
", [ { value = OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
|
|
|
|
<cfif qOrder.recordCount EQ 0>
|
|
<cfset apiAbort({ "OK": false, "ERROR": "not_found", "MESSAGE": "Order not found.", "DETAIL": "" })>
|
|
</cfif>
|
|
|
|
<!--- Update status --->
|
|
<cfset queryExecute("
|
|
UPDATE Orders
|
|
SET OrderStatusID = ?,
|
|
OrderLastEditedOn = ?
|
|
WHERE OrderID = ?
|
|
", [
|
|
{ value = NewStatusID, cfsqltype = "cf_sql_integer" },
|
|
{ value = now(), cfsqltype = "cf_sql_timestamp" },
|
|
{ value = OrderID, cfsqltype = "cf_sql_integer" }
|
|
], { datasource = "payfrit" })>
|
|
|
|
<cfset apiAbort({
|
|
"OK": true,
|
|
"ERROR": "",
|
|
"MESSAGE": "Order status updated successfully.",
|
|
"OrderID": OrderID,
|
|
"StatusID": NewStatusID
|
|
})>
|
|
|
|
<cfcatch>
|
|
<cfset apiAbort({
|
|
"OK": false,
|
|
"ERROR": "server_error",
|
|
"MESSAGE": "DB error updating order status",
|
|
"DETAIL": cfcatch.message
|
|
})>
|
|
</cfcatch>
|
|
</cftry>
|