Portal: - New business portal UI (portal/index.html, portal.css, portal.js) - Dashboard with real-time stats (orders today, revenue, pending, menu items) - Business info endpoint (api/businesses/get.cfm) - Portal stats endpoint (api/portal/stats.cfm) - Menu page links to existing full-featured menu editor Stripe Connect: - Onboarding endpoint (api/stripe/onboard.cfm) - Status check endpoint (api/stripe/status.cfm) - Payment intent creation (api/stripe/createPaymentIntent.cfm) - Webhook handler (api/stripe/webhook.cfm) Beacon APIs: - List all beacons (api/beacons/list_all.cfm) - Get business from beacon (api/beacons/getBusinessFromBeacon.cfm) Task System: - List pending tasks (api/tasks/listPending.cfm) - Accept task (api/tasks/accept.cfm) Other: - HUD interface for quick order status display - KDS debug/test pages - Updated Application.cfm with public endpoint allowlist - Order status check improvements 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
3 KiB
Text
98 lines
3 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>
|
|
/**
|
|
* Portal Dashboard Stats
|
|
* POST: { BusinessID: int }
|
|
* Returns: { OK: true, STATS: { ordersToday, revenueToday, pendingOrders, menuItems } }
|
|
*/
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
// Get request data
|
|
requestBody = toString(getHttpRequestData().content);
|
|
|
|
if (len(requestBody) == 0) {
|
|
response["ERROR"] = "Request body is required";
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
requestData = deserializeJSON(requestBody);
|
|
businessID = val(requestData.BusinessID ?: 0);
|
|
|
|
if (businessID == 0) {
|
|
response["ERROR"] = "BusinessID is required";
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
// Get today's date boundaries as strings for MySQL
|
|
todayStart = dateFormat(now(), "yyyy-mm-dd") & " 00:00:00";
|
|
todayEnd = dateFormat(now(), "yyyy-mm-dd") & " 23:59:59";
|
|
|
|
// Orders today count
|
|
qOrdersToday = queryExecute("
|
|
SELECT COUNT(*) as cnt
|
|
FROM Orders
|
|
WHERE OrderBusinessID = :businessID
|
|
AND OrderSubmittedOn >= :todayStart
|
|
AND OrderSubmittedOn <= :todayEnd
|
|
", {
|
|
businessID: businessID,
|
|
todayStart: { value: todayStart, cfsqltype: "cf_sql_varchar" },
|
|
todayEnd: { value: todayEnd, cfsqltype: "cf_sql_varchar" }
|
|
});
|
|
|
|
// Revenue today (sum of line items)
|
|
qRevenueToday = queryExecute("
|
|
SELECT COALESCE(SUM(li.OrderLineItemQuantity * li.OrderLineItemPrice), 0) as total
|
|
FROM Orders o
|
|
JOIN OrderLineItems li ON li.OrderLineItemOrderID = o.OrderID
|
|
WHERE o.OrderBusinessID = :businessID
|
|
AND o.OrderSubmittedOn >= :todayStart
|
|
AND o.OrderSubmittedOn <= :todayEnd
|
|
AND o.OrderStatusID >= 1
|
|
", {
|
|
businessID: businessID,
|
|
todayStart: { value: todayStart, cfsqltype: "cf_sql_varchar" },
|
|
todayEnd: { value: todayEnd, cfsqltype: "cf_sql_varchar" }
|
|
});
|
|
|
|
// Pending orders (status 1 = submitted, 2 = preparing)
|
|
qPendingOrders = queryExecute("
|
|
SELECT COUNT(*) as cnt
|
|
FROM Orders
|
|
WHERE OrderBusinessID = :businessID
|
|
AND OrderStatusID IN (1, 2)
|
|
", { businessID: businessID });
|
|
|
|
// Menu items count (items linked through categories)
|
|
qMenuItems = queryExecute("
|
|
SELECT COUNT(*) as cnt
|
|
FROM Items i
|
|
INNER JOIN Categories c ON c.CategoryID = i.ItemCategoryID
|
|
WHERE c.CategoryBusinessID = :businessID
|
|
AND i.ItemIsActive = 1
|
|
AND i.ItemParentItemID = 0
|
|
", { businessID: businessID });
|
|
|
|
response["OK"] = true;
|
|
response["STATS"] = {
|
|
"ordersToday": qOrdersToday.cnt,
|
|
"revenueToday": qRevenueToday.total,
|
|
"pendingOrders": qPendingOrders.cnt,
|
|
"menuItems": qMenuItems.cnt
|
|
};
|
|
|
|
} catch (any e) {
|
|
response["ERROR"] = e.message;
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|