Portal local development: - Add BASE_PATH detection to all portal files (login, portal.js, menu-builder, station-assignment) - Allows portal to work at /biz.payfrit.com/ path locally Menu Builder fixes: - Fix duplicate template options in getForBuilder.cfm query - Filter template children by business ID with DISTINCT New APIs: - api/portal/myBusinesses.cfm - List businesses for logged-in user - api/stations/list.cfm - List KDS stations - api/menu/updateStations.cfm - Update item station assignments - api/setup/reimportBigDeans.cfm - Full Big Dean's menu import script Admin utilities: - Various debug and migration scripts for menu/template management - Beacon switching, category cleanup, modifier template setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
81 lines
2.6 KiB
Text
81 lines
2.6 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>
|
|
|
|
<cftry>
|
|
<!--- Create Stations table if it doesn't exist --->
|
|
<cfset queryExecute("
|
|
CREATE TABLE IF NOT EXISTS Stations (
|
|
StationID INT AUTO_INCREMENT PRIMARY KEY,
|
|
StationBusinessID INT NOT NULL,
|
|
StationName VARCHAR(100) NOT NULL,
|
|
StationColor VARCHAR(7) DEFAULT '##666666',
|
|
StationSortOrder INT DEFAULT 0,
|
|
StationIsActive TINYINT(1) DEFAULT 1,
|
|
StationAddedOn DATETIME DEFAULT NOW(),
|
|
FOREIGN KEY (StationBusinessID) REFERENCES Businesses(BusinessID)
|
|
)
|
|
", [], { datasource = "payfrit" })>
|
|
|
|
<!--- Add ItemStationID column to Items table if it doesn't exist --->
|
|
<cftry>
|
|
<cfset queryExecute("
|
|
ALTER TABLE Items ADD COLUMN ItemStationID INT DEFAULT NULL
|
|
", [], { datasource = "payfrit" })>
|
|
<cfset stationColumnAdded = true>
|
|
<cfcatch>
|
|
<!--- Column likely already exists --->
|
|
<cfset stationColumnAdded = false>
|
|
</cfcatch>
|
|
</cftry>
|
|
|
|
<!--- Add foreign key if column was just added --->
|
|
<cfif stationColumnAdded>
|
|
<cftry>
|
|
<cfset queryExecute("
|
|
ALTER TABLE Items ADD FOREIGN KEY (ItemStationID) REFERENCES Stations(StationID)
|
|
", [], { datasource = "payfrit" })>
|
|
<cfcatch></cfcatch>
|
|
</cftry>
|
|
</cfif>
|
|
|
|
<!--- Create some default stations for business 1 (In and Out Burger) if none exist --->
|
|
<cfset qCheck = queryExecute("
|
|
SELECT COUNT(*) AS cnt FROM Stations WHERE StationBusinessID = 1
|
|
", [], { datasource = "payfrit" })>
|
|
|
|
<cfif qCheck.cnt EQ 0>
|
|
<cfset queryExecute("
|
|
INSERT INTO Stations (StationBusinessID, StationName, StationColor, StationSortOrder) VALUES
|
|
(1, 'Grill', '##FF5722', 1),
|
|
(1, 'Fry', '##FFC107', 2),
|
|
(1, 'Drinks', '##2196F3', 3),
|
|
(1, 'Expo', '##4CAF50', 4)
|
|
", [], { datasource = "payfrit" })>
|
|
<cfset defaultStationsCreated = true>
|
|
<cfelse>
|
|
<cfset defaultStationsCreated = false>
|
|
</cfif>
|
|
|
|
<cfset apiAbort({
|
|
"OK": true,
|
|
"MESSAGE": "Stations setup complete",
|
|
"StationColumnAdded": stationColumnAdded,
|
|
"DefaultStationsCreated": defaultStationsCreated
|
|
})>
|
|
|
|
<cfcatch>
|
|
<cfset apiAbort({
|
|
"OK": false,
|
|
"ERROR": "setup_failed",
|
|
"MESSAGE": cfcatch.message,
|
|
"DETAIL": cfcatch.detail
|
|
})>
|
|
</cfcatch>
|
|
</cftry>
|