Setup wizard and tasks updates

- Setup wizard save improvements
- Call server task updates
- Task creation changes
- Portal JS updates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-07 15:18:01 -08:00
parent 30c175bafe
commit 2023e1b5d9
4 changed files with 63 additions and 11 deletions

View file

@ -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)) {

View file

@ -164,7 +164,7 @@ try {
apiAbort({
"OK": true,
"TASK_ID": taskID,
"MESSAGE": "Server has been notified"
"MESSAGE": "Staff has been notified"
});
} catch (any e) {

View file

@ -29,17 +29,44 @@ 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)) {
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
taskDetails = message;
@ -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,

View file

@ -3302,8 +3302,8 @@ const Portal = {
<div class="form-group">
<label>Category</label>
<select id="scheduledTaskCategory" class="form-input">
<option value="">None</option>
<select id="scheduledTaskCategory" class="form-input" required>
<option value="">Select a category...</option>
${categoryOptions}
</select>
</div>