Features: - Multi-menu support with time-based availability - Menu hours validation against business operating hours - Setup wizard now creates Menu records and links categories - New menus.cfm API for menu CRUD operations - Category schedule filtering (day/time based visibility) - Beacon UUID lookup API for customer app - Parent/child business relationships for franchises - Category listing API for menu builder Portal improvements: - Menu builder theming to match admin UI - Brand color picker fix - Header image preview improvements API fixes: - Filter demo/hidden businesses from restaurant list - Improved error handling throughout Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
85 lines
3 KiB
Text
85 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>
|
|
/**
|
|
* Create Menus table for multiple menu support
|
|
*
|
|
* Menus can have:
|
|
* - Name (e.g., "Lunch Menu", "Dinner Menu", "Happy Hour")
|
|
* - Active days (bitmask linked to business hours days)
|
|
* - Start/End times for when the menu is available
|
|
* - Sort order for display
|
|
*/
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
// Check if Menus table exists
|
|
qCheck = queryExecute("
|
|
SELECT 1 FROM INFORMATION_SCHEMA.TABLES
|
|
WHERE TABLE_SCHEMA = 'payfrit'
|
|
AND TABLE_NAME = 'Menus'
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
if (qCheck.recordCount > 0) {
|
|
response["OK"] = true;
|
|
response["MESSAGE"] = "Menus table already exists";
|
|
} else {
|
|
// Create Menus table
|
|
queryExecute("
|
|
CREATE TABLE Menus (
|
|
MenuID INT AUTO_INCREMENT PRIMARY KEY,
|
|
MenuBusinessID INT NOT NULL,
|
|
MenuName VARCHAR(100) NOT NULL,
|
|
MenuDescription VARCHAR(500) NULL,
|
|
MenuDaysActive INT NOT NULL DEFAULT 127,
|
|
MenuStartTime TIME NULL,
|
|
MenuEndTime TIME NULL,
|
|
MenuSortOrder INT NOT NULL DEFAULT 0,
|
|
MenuIsActive TINYINT NOT NULL DEFAULT 1,
|
|
MenuAddedOn DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
INDEX idx_menus_business (MenuBusinessID),
|
|
INDEX idx_menus_active (MenuBusinessID, MenuIsActive)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
response["OK"] = true;
|
|
response["MESSAGE"] = "Menus table created successfully";
|
|
response["SCHEMA"] = {
|
|
"MenuDaysActive": "Bitmask: 1=Sun, 2=Mon, 4=Tue, 8=Wed, 16=Thu, 32=Fri, 64=Sat (127 = all days)"
|
|
};
|
|
}
|
|
|
|
// Check if CategoryMenuID column exists in Categories table
|
|
qCatCol = queryExecute("
|
|
SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE TABLE_SCHEMA = 'payfrit'
|
|
AND TABLE_NAME = 'Categories'
|
|
AND COLUMN_NAME = 'CategoryMenuID'
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
if (qCatCol.recordCount == 0) {
|
|
// Add CategoryMenuID column to Categories table
|
|
queryExecute("
|
|
ALTER TABLE Categories
|
|
ADD COLUMN CategoryMenuID INT NULL DEFAULT NULL AFTER CategoryBusinessID,
|
|
ADD INDEX idx_categories_menu (CategoryMenuID)
|
|
", {}, { datasource: "payfrit" });
|
|
response["CATEGORIES_UPDATED"] = true;
|
|
response["CATEGORIES_MESSAGE"] = "Added CategoryMenuID column to Categories table";
|
|
} else {
|
|
response["CATEGORIES_UPDATED"] = false;
|
|
response["CATEGORIES_MESSAGE"] = "CategoryMenuID column already exists";
|
|
}
|
|
|
|
} catch (any e) {
|
|
response["ERROR"] = "server_error";
|
|
response["MESSAGE"] = e.message;
|
|
response["DETAIL"] = e.detail ?: "";
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|