Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).
Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
Addresses, Hours, Menus, Categories, Items, Stations, Orders,
OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
UserIsActive→IsActive, UserBalance→Balance, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
158 lines
4.5 KiB
Text
158 lines
4.5 KiB
Text
<cfscript>
|
|
// Create a task (service bell request or photo task)
|
|
// Input for service bell: BusinessID, ServicePointID, TaskTypeID, Message
|
|
// Input for photo task: BusinessID, ItemID, TaskType, Instructions, PYTReward
|
|
// Output: { OK: true, TASK_ID: ... }
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
requestBody = toString(getHttpRequestData().content);
|
|
if (!len(requestBody)) {
|
|
throw("Request body is required");
|
|
}
|
|
|
|
jsonData = deserializeJSON(requestBody);
|
|
businessID = val(jsonData.BusinessID ?: 0);
|
|
|
|
if (businessID == 0) {
|
|
throw("BusinessID is required");
|
|
}
|
|
|
|
// Check if this is a service bell request (has TaskTypeID)
|
|
taskTypeID = val(jsonData.TaskTypeID ?: 0);
|
|
|
|
if (taskTypeID > 0) {
|
|
// Service bell task
|
|
servicePointID = val(jsonData.ServicePointID ?: 0);
|
|
orderID = val(jsonData.OrderID ?: 0);
|
|
userID = val(jsonData.UserID ?: 0);
|
|
message = jsonData.Message ?: "";
|
|
|
|
// Get task type info for display
|
|
taskTypeQuery = queryExecute("
|
|
SELECT Name, Color, Icon
|
|
FROM tt_TaskTypes
|
|
WHERE tt_TaskTypeID = :taskTypeID
|
|
", { taskTypeID: taskTypeID }, { datasource: "payfrit" });
|
|
|
|
taskTitle = message;
|
|
if (taskTypeQuery.recordCount && len(taskTypeQuery.Name)) {
|
|
taskTitle = taskTypeQuery.Name;
|
|
}
|
|
|
|
// Use message as details
|
|
taskDetails = message;
|
|
|
|
// Insert service bell task
|
|
queryExecute("
|
|
INSERT INTO Tasks (
|
|
BusinessID,
|
|
TaskTypeID,
|
|
CategoryID,
|
|
OrderID,
|
|
Title,
|
|
Details,
|
|
CreatedOn,
|
|
ClaimedByUserID
|
|
) VALUES (
|
|
:businessID,
|
|
:taskTypeID,
|
|
0,
|
|
:orderID,
|
|
:taskTitle,
|
|
:taskDetails,
|
|
NOW(),
|
|
0
|
|
)
|
|
", {
|
|
businessID: businessID,
|
|
taskTypeID: taskTypeID,
|
|
orderID: orderID,
|
|
taskTitle: taskTitle,
|
|
taskDetails: taskDetails
|
|
}, { datasource: "payfrit" });
|
|
|
|
} else {
|
|
// Legacy photo task
|
|
itemID = val(jsonData.ItemID ?: 0);
|
|
taskType = jsonData.TaskType ?: "employee_photo";
|
|
instructions = jsonData.Instructions ?: "";
|
|
pytReward = val(jsonData.PYTReward ?: 0);
|
|
|
|
// Get item info if itemID provided
|
|
itemName = "";
|
|
if (itemID > 0) {
|
|
itemQuery = queryExecute("
|
|
SELECT Name FROM Items WHERE ID = :itemID
|
|
", { itemID: itemID });
|
|
if (itemQuery.recordCount) {
|
|
itemName = itemQuery.Name;
|
|
}
|
|
}
|
|
|
|
// Create task description
|
|
taskDescription = "";
|
|
switch(taskType) {
|
|
case "employee_photo":
|
|
taskDescription = "Take a photo of: " & itemName;
|
|
break;
|
|
case "user_photo":
|
|
taskDescription = "Submit a photo of " & itemName & " to earn " & pytReward & " PYT";
|
|
break;
|
|
default:
|
|
taskDescription = instructions;
|
|
}
|
|
|
|
// Insert legacy task
|
|
queryExecute("
|
|
INSERT INTO Tasks (
|
|
BusinessID,
|
|
TaskItemID,
|
|
TaskType,
|
|
TaskDescription,
|
|
TaskInstructions,
|
|
TaskPYTReward,
|
|
TaskStatus,
|
|
CreatedOn
|
|
) VALUES (
|
|
:businessID,
|
|
:itemID,
|
|
:taskType,
|
|
:description,
|
|
:instructions,
|
|
:pytReward,
|
|
'pending',
|
|
NOW()
|
|
)
|
|
", {
|
|
businessID: businessID,
|
|
itemID: itemID,
|
|
taskType: taskType,
|
|
description: taskDescription,
|
|
instructions: instructions,
|
|
pytReward: pytReward
|
|
});
|
|
}
|
|
|
|
// Get the new task ID
|
|
result = queryExecute("SELECT LAST_INSERT_ID() as newID", {}, { datasource: "payfrit" });
|
|
taskID = result.newID;
|
|
|
|
response = {
|
|
"OK": true,
|
|
"TASK_ID": taskID,
|
|
"MESSAGE": "Task created successfully"
|
|
};
|
|
|
|
} catch (any e) {
|
|
response = {
|
|
"OK": false,
|
|
"ERROR": e.message,
|
|
"DETAIL": e.detail ?: ""
|
|
};
|
|
}
|
|
|
|
cfheader(name="Content-Type", value="application/json");
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|