Add UserID and customer info to service bell tasks
- Store UserID when creating service bell tasks - Return CustomerID and CustomerName in listPending and listMine - Join Users table to fetch customer first/last name Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d8565deda1
commit
407f68655e
3 changed files with 36 additions and 5 deletions
|
|
@ -44,7 +44,7 @@ try {
|
||||||
// Use message as details
|
// Use message as details
|
||||||
taskDetails = message;
|
taskDetails = message;
|
||||||
|
|
||||||
// Insert service bell task with ServicePointID
|
// Insert service bell task with ServicePointID and UserID
|
||||||
queryTimed("
|
queryTimed("
|
||||||
INSERT INTO Tasks (
|
INSERT INTO Tasks (
|
||||||
BusinessID,
|
BusinessID,
|
||||||
|
|
@ -52,6 +52,7 @@ try {
|
||||||
TaskTypeID,
|
TaskTypeID,
|
||||||
CategoryID,
|
CategoryID,
|
||||||
OrderID,
|
OrderID,
|
||||||
|
UserID,
|
||||||
Title,
|
Title,
|
||||||
Details,
|
Details,
|
||||||
CreatedOn,
|
CreatedOn,
|
||||||
|
|
@ -62,6 +63,7 @@ try {
|
||||||
:taskTypeID,
|
:taskTypeID,
|
||||||
0,
|
0,
|
||||||
:orderID,
|
:orderID,
|
||||||
|
:userID,
|
||||||
:taskTitle,
|
:taskTitle,
|
||||||
:taskDetails,
|
:taskDetails,
|
||||||
NOW(),
|
NOW(),
|
||||||
|
|
@ -72,6 +74,7 @@ try {
|
||||||
servicePointID: servicePointID,
|
servicePointID: servicePointID,
|
||||||
taskTypeID: taskTypeID,
|
taskTypeID: taskTypeID,
|
||||||
orderID: orderID,
|
orderID: orderID,
|
||||||
|
userID: userID,
|
||||||
taskTitle: taskTitle,
|
taskTitle: taskTitle,
|
||||||
taskDetails: taskDetails
|
taskDetails: taskDetails
|
||||||
}, { datasource: "payfrit" });
|
}, { datasource: "payfrit" });
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@
|
||||||
t.ClaimedByUserID,
|
t.ClaimedByUserID,
|
||||||
t.ClaimedOn,
|
t.ClaimedOn,
|
||||||
t.CompletedOn,
|
t.CompletedOn,
|
||||||
|
t.UserID,
|
||||||
tc.Name AS CategoryName,
|
tc.Name AS CategoryName,
|
||||||
tc.Color AS CategoryColor,
|
tc.Color AS CategoryColor,
|
||||||
tt.Name AS TaskTypeName,
|
tt.Name AS TaskTypeName,
|
||||||
|
|
@ -84,13 +85,16 @@
|
||||||
tt.Color AS TaskTypeColor,
|
tt.Color AS TaskTypeColor,
|
||||||
b.Name AS BusinessName,
|
b.Name AS BusinessName,
|
||||||
t.ServicePointID,
|
t.ServicePointID,
|
||||||
sp.Name AS ServicePointName
|
sp.Name AS ServicePointName,
|
||||||
|
u.FirstName AS CustomerFirstName,
|
||||||
|
u.LastName AS CustomerLastName
|
||||||
FROM Tasks t
|
FROM Tasks t
|
||||||
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
|
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
|
||||||
LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID
|
LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID
|
||||||
LEFT JOIN Businesses b ON b.ID = t.BusinessID
|
LEFT JOIN Businesses b ON b.ID = t.BusinessID
|
||||||
LEFT JOIN Orders o ON o.ID = t.OrderID
|
LEFT JOIN Orders o ON o.ID = t.OrderID
|
||||||
LEFT JOIN ServicePoints sp ON sp.ID = COALESCE(t.ServicePointID, o.ServicePointID)
|
LEFT JOIN ServicePoints sp ON sp.ID = COALESCE(t.ServicePointID, o.ServicePointID)
|
||||||
|
LEFT JOIN Users u ON u.ID = t.UserID
|
||||||
WHERE #whereSQL#
|
WHERE #whereSQL#
|
||||||
ORDER BY t.ClaimedOn DESC
|
ORDER BY t.ClaimedOn DESC
|
||||||
", params, { datasource = "payfrit" })>
|
", params, { datasource = "payfrit" })>
|
||||||
|
|
@ -113,6 +117,14 @@
|
||||||
<cfset taskDetails = qTasks.Details>
|
<cfset taskDetails = qTasks.Details>
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
||||||
|
<cfset customerName = "">
|
||||||
|
<cfif NOT isNull(qTasks.CustomerFirstName) AND len(trim(qTasks.CustomerFirstName))>
|
||||||
|
<cfset customerName = qTasks.CustomerFirstName>
|
||||||
|
<cfif NOT isNull(qTasks.CustomerLastName) AND len(trim(qTasks.CustomerLastName))>
|
||||||
|
<cfset customerName = customerName & " " & qTasks.CustomerLastName>
|
||||||
|
</cfif>
|
||||||
|
</cfif>
|
||||||
|
|
||||||
<cfset arrayAppend(tasks, {
|
<cfset arrayAppend(tasks, {
|
||||||
"TaskID": qTasks.ID,
|
"TaskID": qTasks.ID,
|
||||||
"BusinessID": qTasks.BusinessID,
|
"BusinessID": qTasks.BusinessID,
|
||||||
|
|
@ -133,7 +145,9 @@
|
||||||
"TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications",
|
"TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications",
|
||||||
"TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0",
|
"TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0",
|
||||||
"ServicePointID": val(qTasks.ServicePointID),
|
"ServicePointID": val(qTasks.ServicePointID),
|
||||||
"ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName
|
"ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName,
|
||||||
|
"CustomerID": val(qTasks.UserID),
|
||||||
|
"CustomerName": customerName
|
||||||
})>
|
})>
|
||||||
</cfloop>
|
</cfloop>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,18 +65,22 @@
|
||||||
t.Details,
|
t.Details,
|
||||||
t.CreatedOn,
|
t.CreatedOn,
|
||||||
t.ClaimedByUserID,
|
t.ClaimedByUserID,
|
||||||
|
t.UserID,
|
||||||
tc.Name AS CategoryName,
|
tc.Name AS CategoryName,
|
||||||
tc.Color AS CategoryColor,
|
tc.Color AS CategoryColor,
|
||||||
tt.Name AS TaskTypeName,
|
tt.Name AS TaskTypeName,
|
||||||
tt.Icon AS TaskTypeIcon,
|
tt.Icon AS TaskTypeIcon,
|
||||||
tt.Color AS TaskTypeColor,
|
tt.Color AS TaskTypeColor,
|
||||||
t.ServicePointID,
|
t.ServicePointID,
|
||||||
sp.Name AS ServicePointName
|
sp.Name AS ServicePointName,
|
||||||
|
u.FirstName AS CustomerFirstName,
|
||||||
|
u.LastName AS CustomerLastName
|
||||||
FROM Tasks t
|
FROM Tasks t
|
||||||
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
|
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
|
||||||
LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID
|
LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID
|
||||||
LEFT JOIN Orders o ON o.ID = t.OrderID
|
LEFT JOIN Orders o ON o.ID = t.OrderID
|
||||||
LEFT JOIN ServicePoints sp ON sp.ID = COALESCE(t.ServicePointID, o.ServicePointID)
|
LEFT JOIN ServicePoints sp ON sp.ID = COALESCE(t.ServicePointID, o.ServicePointID)
|
||||||
|
LEFT JOIN Users u ON u.ID = t.UserID
|
||||||
WHERE #whereSQL#
|
WHERE #whereSQL#
|
||||||
ORDER BY t.CreatedOn ASC
|
ORDER BY t.CreatedOn ASC
|
||||||
", params, { datasource = "payfrit" })>
|
", params, { datasource = "payfrit" })>
|
||||||
|
|
@ -96,6 +100,14 @@
|
||||||
|
|
||||||
<cfset taskDetails = len(trim(qTasks.Details)) ? qTasks.Details : "">
|
<cfset taskDetails = len(trim(qTasks.Details)) ? qTasks.Details : "">
|
||||||
|
|
||||||
|
<cfset customerName = "">
|
||||||
|
<cfif NOT isNull(qTasks.CustomerFirstName) AND len(trim(qTasks.CustomerFirstName))>
|
||||||
|
<cfset customerName = qTasks.CustomerFirstName>
|
||||||
|
<cfif NOT isNull(qTasks.CustomerLastName) AND len(trim(qTasks.CustomerLastName))>
|
||||||
|
<cfset customerName = customerName & " " & qTasks.CustomerLastName>
|
||||||
|
</cfif>
|
||||||
|
</cfif>
|
||||||
|
|
||||||
<cfset arrayAppend(tasks, {
|
<cfset arrayAppend(tasks, {
|
||||||
"TaskID": qTasks.ID,
|
"TaskID": qTasks.ID,
|
||||||
"BusinessID": qTasks.BusinessID,
|
"BusinessID": qTasks.BusinessID,
|
||||||
|
|
@ -113,7 +125,9 @@
|
||||||
"TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications",
|
"TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications",
|
||||||
"TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0",
|
"TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0",
|
||||||
"ServicePointID": val(qTasks.ServicePointID),
|
"ServicePointID": val(qTasks.ServicePointID),
|
||||||
"ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName
|
"ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName,
|
||||||
|
"CustomerID": val(qTasks.UserID),
|
||||||
|
"CustomerName": customerName
|
||||||
})>
|
})>
|
||||||
</cfloop>
|
</cfloop>
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue