Menu Builder - Required Selections: - Added "Selection Rules" section for modifier groups - Required (Yes/No) dropdown to mark if customer must select an option - Max Selections input (0 = unlimited) to limit selections - Visual "Required" badge (red) and "Max X" badge in modifier list - Updated saveFromBuilder.cfm to persist ItemRequiresChildSelection and ItemMaxNumSelectionReq to database Portal Fixes: - Fixed menu-builder link to include BASE_PATH for local dev - Fixed stats.cfm to not reference non-existent Categories table - Menu items count now uses ItemParentItemID > 0 (not ItemCategoryID) Stripe Configuration: - Added api/config/stripe.cfm for centralized Stripe key management - Supports test/live mode switching - Fee configuration variables (5% customer, 5% business, 2.9% + $0.30 card) Payment Intent API: - Updated createPaymentIntent.cfm with proper fee structure - Customer pays: subtotal + tax + tip + 5% Payfrit fee + card processing - Platform receives 10% total (5% from customer + 5% from business) - Saves fee breakdown to order record Beacon Management: - Updated switchBeacons.cfm to move beacons between businesses - Currently configured: Big Dean's (27) -> In-N-Out (17) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
3.1 KiB
Text
98 lines
3.1 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 (active items that have a parent category, excluding categories themselves)
|
|
// Categories are items with ItemParentItemID = 0 and ItemIsCollapsible = 0
|
|
qMenuItems = queryExecute("
|
|
SELECT COUNT(*) as cnt
|
|
FROM Items
|
|
WHERE ItemBusinessID = :businessID
|
|
AND ItemIsActive = 1
|
|
AND 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>
|