diff --git a/api/setup/saveWizard.cfm b/api/setup/saveWizard.cfm index ad6589f..cdce421 100644 --- a/api/setup/saveWizard.cfm +++ b/api/setup/saveWizard.cfm @@ -129,11 +129,11 @@ try { response.steps.append("Linked address to business"); // Create default task types for the business - // 1. Call Server (notifications icon, purple) + // 1. Call Staff (notifications icon, purple) // 2. Chat With Staff (chat icon, blue) // 3. Pay With Cash (payments icon, green) defaultTaskTypes = [ - { name: "Call Server", icon: "notifications", color: "##9C27B0", description: "Request server assistance" }, + { name: "Call Staff", icon: "notifications", color: "##9C27B0", description: "Request staff assistance" }, { name: "Chat With Staff", icon: "chat", color: "##2196F3", description: "Open a chat conversation" }, { name: "Pay With Cash", icon: "payments", color: "##4CAF50", description: "Request to pay with cash" } ]; @@ -152,7 +152,31 @@ try { sortOrder: { value: tt, cfsqltype: "cf_sql_integer" } }, { datasource: "payfrit" }); } - response.steps.append("Created 3 default task types (Call Server, Chat With Staff, Pay With Cash)"); + response.steps.append("Created 3 default task types (Call Staff, Chat With Staff, Pay With Cash)"); + + // Create default task categories for the business + defaultTaskCategories = [ + { name: "Service Point", color: "##F44336" }, // Red + { name: "Kitchen", color: "##FF9800" }, // Orange + { name: "Bar", color: "##9C27B0" }, // Purple + { name: "Cleaning", color: "##4CAF50" }, // Green + { name: "Management", color: "##2196F3" }, // Blue + { name: "Delivery", color: "##00BCD4" }, // Cyan + { name: "General", color: "##607D8B" } // Blue Grey + ]; + + for (tc = 1; tc <= arrayLen(defaultTaskCategories); tc++) { + taskCat = defaultTaskCategories[tc]; + queryTimed(" + INSERT INTO TaskCategories (BusinessID, Name, Color) + VALUES (:businessID, :name, :color) + ", { + businessID: { value: businessId, cfsqltype: "cf_sql_integer" }, + name: { value: taskCat.name, cfsqltype: "cf_sql_varchar" }, + color: { value: taskCat.color, cfsqltype: "cf_sql_varchar" } + }, { datasource: "payfrit" }); + } + response.steps.append("Created 7 default task categories"); // Save business hours from structured schedule if (structKeyExists(biz, "hoursSchedule") && isArray(biz.hoursSchedule)) { diff --git a/api/tasks/callServer.cfm b/api/tasks/callServer.cfm index ff87461..d74e295 100644 --- a/api/tasks/callServer.cfm +++ b/api/tasks/callServer.cfm @@ -164,7 +164,7 @@ try { apiAbort({ "OK": true, "TASK_ID": taskID, - "MESSAGE": "Server has been notified" + "MESSAGE": "Staff has been notified" }); } catch (any e) { diff --git a/api/tasks/create.cfm b/api/tasks/create.cfm index ee1a64e..cf31041 100644 --- a/api/tasks/create.cfm +++ b/api/tasks/create.cfm @@ -29,16 +29,43 @@ try { userID = val(jsonData.UserID ?: 0); message = jsonData.Message ?: ""; - // Get task type info for display + // Get task type info for display (including category) taskTypeQuery = queryTimed(" - SELECT Name, Color, Icon + SELECT Name, Color, Icon, TaskCategoryID FROM tt_TaskTypes WHERE ID = :taskTypeID ", { taskTypeID: taskTypeID }, { datasource: "payfrit" }); taskTitle = message; - if (taskTypeQuery.recordCount && len(taskTypeQuery.Name)) { - taskTitle = taskTypeQuery.Name; + categoryID = 0; + if (taskTypeQuery.recordCount) { + if (len(trim(taskTypeQuery.Name))) { + taskTitle = taskTypeQuery.Name; + } + if (!isNull(taskTypeQuery.TaskCategoryID) && isNumeric(taskTypeQuery.TaskCategoryID) && taskTypeQuery.TaskCategoryID > 0) { + categoryID = taskTypeQuery.TaskCategoryID; + } + } + + // If no category from task type, look up or create default "Service" category + if (categoryID == 0) { + catQuery = queryTimed(" + SELECT ID FROM TaskCategories + WHERE BusinessID = :businessID AND Name = 'Service' + LIMIT 1 + ", { businessID: businessID }, { datasource: "payfrit" }); + + if (catQuery.recordCount > 0) { + categoryID = catQuery.ID; + } else { + // Create the Service category + queryTimed(" + INSERT INTO TaskCategories (BusinessID, Name, Color) + VALUES (:businessID, 'Service', '##FF9800') + ", { businessID: businessID }, { datasource: "payfrit" }); + catResult = queryTimed("SELECT LAST_INSERT_ID() as newID", {}, { datasource: "payfrit" }); + categoryID = catResult.newID; + } } // Use message as details @@ -61,7 +88,7 @@ try { :businessID, :servicePointID, :taskTypeID, - 0, + :categoryID, :orderID, :userID, :taskTitle, @@ -73,6 +100,7 @@ try { businessID: businessID, servicePointID: servicePointID, taskTypeID: taskTypeID, + categoryID: categoryID, orderID: orderID, userID: userID, taskTitle: taskTitle, diff --git a/portal/portal.js b/portal/portal.js index eec25bf..63bdb9e 100644 --- a/portal/portal.js +++ b/portal/portal.js @@ -3302,8 +3302,8 @@ const Portal = {