Fix service bell task creation for Android app

- Update create.cfm to handle TaskTypeID for service bell tasks
- Update hud.js to prefer TaskTypeColor/TaskTypeName for task display

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-27 20:52:59 -08:00
parent c5ebb24b39
commit d4cc4b4a6c
2 changed files with 166 additions and 61 deletions

View file

@ -1,6 +1,7 @@
<cfscript>
// Create a task (e.g., photo task for menu item)
// Input: BusinessID, ItemID, TaskType, Instructions, PYTReward
// 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 };
@ -13,15 +14,72 @@ try {
jsonData = deserializeJSON(requestBody);
businessID = val(jsonData.BusinessID ?: 0);
itemID = val(jsonData.ItemID ?: 0);
taskType = jsonData.TaskType ?: "employee_photo";
instructions = jsonData.Instructions ?: "";
pytReward = val(jsonData.PYTReward ?: 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 tt_TaskTypeName, tt_TaskTypeColor, tt_TaskTypeIcon
FROM tt_TaskTypes
WHERE tt_TaskTypeID = :taskTypeID
", { taskTypeID: taskTypeID }, { datasource: "payfrit" });
taskTitle = message;
if (taskTypeQuery.recordCount && len(taskTypeQuery.tt_TaskTypeName)) {
taskTitle = taskTypeQuery.tt_TaskTypeName;
}
// Use message as details
taskDetails = message;
// Insert service bell task
queryExecute("
INSERT INTO Tasks (
TaskBusinessID,
TaskTypeID,
TaskCategoryID,
TaskOrderID,
TaskTitle,
TaskDetails,
TaskAddedOn,
TaskClaimedByUserID
) 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) {
@ -46,7 +104,7 @@ try {
taskDescription = instructions;
}
// Insert task
// Insert legacy task
queryExecute("
INSERT INTO Tasks (
TaskBusinessID,
@ -75,9 +133,10 @@ try {
instructions: instructions,
pytReward: pytReward
});
}
// Get the new task ID
result = queryExecute("SELECT LAST_INSERT_ID() as newID");
result = queryExecute("SELECT LAST_INSERT_ID() as newID", {}, { datasource: "payfrit" });
taskID = result.newID;
response = {
@ -89,7 +148,8 @@ try {
} catch (any e) {
response = {
"OK": false,
"ERROR": e.message
"ERROR": e.message,
"DETAIL": e.detail ?: ""
};
}

View file

@ -225,17 +225,23 @@ const HUD = {
return `${mins}:${String(secs).padStart(2, '0')}`;
},
// Get category name - use task's category name if available, fall back to hardcoded
// Get category/task type name - prefer task type for service bell tasks
getCategoryName(task) {
if (task && task.TaskTypeName && task.TaskTypeName.length > 0) {
return task.TaskTypeName;
}
if (task && task.TaskCategoryName) {
return task.TaskCategoryName;
}
return this.categories[task?.TaskCategoryID]?.name || 'Task';
},
// Get category color - use task's category color if available, fall back to hardcoded
// Get category/task type color - prefer task type color for service bell tasks
getCategoryColor(task) {
if (task && task.TaskCategoryColor) {
if (task && task.TaskTypeColor && task.TaskTypeColor.length > 0 && task.TaskTypeColor !== '#9C27B0') {
return task.TaskTypeColor;
}
if (task && task.TaskCategoryColor && task.TaskCategoryColor !== '#888888') {
return task.TaskCategoryColor;
}
return this.categories[task?.TaskCategoryID]?.color || '#888888';
@ -361,6 +367,45 @@ function acceptTask() {
HUD.acceptTask();
}
function toggleFullscreen() {
const body = document.body;
const isMaximized = body.classList.contains('maximized');
if (isMaximized) {
// Restore normal view
body.classList.remove('maximized');
// Also exit native fullscreen if active
if (document.fullscreenElement) {
document.exitFullscreen().catch(() => {});
} else if (document.webkitFullscreenElement) {
document.webkitExitFullscreen();
}
} else {
// Maximize - hide header for more space
body.classList.add('maximized');
// Also try native fullscreen on desktop
const elem = document.documentElement;
if (elem.requestFullscreen) {
elem.requestFullscreen().catch(() => {});
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
}
}
}
// Exit maximized mode when exiting native fullscreen
document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
document.body.classList.remove('maximized');
}
});
document.addEventListener('webkitfullscreenchange', () => {
if (!document.webkitFullscreenElement) {
document.body.classList.remove('maximized');
}
});
// Initialize on load
document.addEventListener('DOMContentLoaded', () => {
HUD.init();