Fix prefixed column names in auth, orders, portal team, users search, workers APIs
Updated Users (UserID, UserFirstName, UserLastName, UserEmailAddress, UserContactNumber), ServicePoints (ServicePointID, ServicePointName, ServicePointTypeID), and Businesses (BusinessID, BusinessName, BusinessTaxRate, BusinessPhone) column references with proper prefixed names and AS aliases for API compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e92362f773
commit
39448c5d91
8 changed files with 46 additions and 46 deletions
|
|
@ -33,9 +33,9 @@ try {
|
|||
|
||||
// Look up the token
|
||||
qToken = queryExecute("
|
||||
SELECT ut.UserID, u.FirstName, u.LastName
|
||||
SELECT ut.UserID, u.UserFirstName AS FirstName, u.UserLastName AS LastName
|
||||
FROM UserTokens ut
|
||||
JOIN Users u ON u.ID = ut.UserID
|
||||
JOIN Users u ON u.UserID = ut.UserID
|
||||
WHERE ut.Token = :token
|
||||
LIMIT 1
|
||||
", { token: { value: token, cfsqltype: "cf_sql_varchar" } }, { datasource: "payfrit" });
|
||||
|
|
|
|||
|
|
@ -55,18 +55,18 @@ try {
|
|||
o.LastEditedOn,
|
||||
o.SubmittedOn,
|
||||
o.TipAmount,
|
||||
u.FirstName,
|
||||
u.LastName,
|
||||
u.ContactNumber,
|
||||
u.EmailAddress,
|
||||
sp.Name,
|
||||
sp.TypeID,
|
||||
b.Name,
|
||||
b.TaxRate
|
||||
u.UserFirstName AS FirstName,
|
||||
u.UserLastName AS LastName,
|
||||
u.UserContactNumber AS ContactNumber,
|
||||
u.UserEmailAddress AS EmailAddress,
|
||||
sp.ServicePointName AS Name,
|
||||
sp.ServicePointTypeID AS TypeID,
|
||||
b.BusinessName AS BizName,
|
||||
b.BusinessTaxRate AS TaxRate
|
||||
FROM Orders o
|
||||
LEFT JOIN Users u ON u.ID = o.UserID
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
|
||||
LEFT JOIN Businesses b ON b.ID = o.BusinessID
|
||||
LEFT JOIN Users u ON u.UserID = o.UserID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = o.ServicePointID
|
||||
LEFT JOIN Businesses b ON b.BusinessID = o.BusinessID
|
||||
WHERE o.ID = :orderID
|
||||
", { orderID: orderID });
|
||||
|
||||
|
|
@ -152,18 +152,18 @@ try {
|
|||
|
||||
// Get staff who worked on this order (from Tasks table) with pending rating tokens
|
||||
qStaff = queryExecute("
|
||||
SELECT DISTINCT u.ID, u.FirstName,
|
||||
SELECT DISTINCT u.UserID AS ID, u.UserFirstName AS FirstName,
|
||||
(SELECT r.AccessToken
|
||||
FROM TaskRatings r
|
||||
INNER JOIN Tasks t2 ON t2.ID = r.TaskID
|
||||
WHERE t2.OrderID = :orderID
|
||||
AND r.ForUserID = u.ID
|
||||
AND r.ForUserID = u.UserID
|
||||
AND r.Direction = 'customer_rates_worker'
|
||||
AND r.CompletedOn IS NULL
|
||||
AND r.ExpiresOn > NOW()
|
||||
LIMIT 1) AS RatingToken
|
||||
FROM Tasks t
|
||||
INNER JOIN Users u ON u.ID = t.ClaimedByUserID
|
||||
INNER JOIN Users u ON u.UserID = t.ClaimedByUserID
|
||||
WHERE t.OrderID = :orderID
|
||||
AND t.ClaimedByUserID > 0
|
||||
", { orderID: orderID });
|
||||
|
|
|
|||
|
|
@ -45,16 +45,16 @@ try {
|
|||
o.StatusID,
|
||||
o.SubmittedOn,
|
||||
o.ServicePointID,
|
||||
sp.Name,
|
||||
b.Name,
|
||||
sp.ServicePointName AS Name,
|
||||
b.BusinessName AS BizName,
|
||||
(SELECT COALESCE(SUM(oli.Price * oli.Quantity), 0)
|
||||
FROM OrderLineItems oli
|
||||
WHERE oli.OrderID = o.ID
|
||||
AND oli.IsDeleted = 0
|
||||
AND oli.ParentOrderLineItemID = 0) as Subtotal
|
||||
FROM Orders o
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
|
||||
LEFT JOIN Businesses b ON b.ID = o.BusinessID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = o.ServicePointID
|
||||
LEFT JOIN Businesses b ON b.BusinessID = o.BusinessID
|
||||
WHERE o.UserID = :userId
|
||||
AND o.BusinessID = :businessId
|
||||
AND o.StatusID IN (1, 2, 3)
|
||||
|
|
|
|||
|
|
@ -141,9 +141,9 @@
|
|||
<cfset qOrder = queryExecute(
|
||||
"
|
||||
SELECT o.ID, o.StatusID, o.OrderTypeID, o.BusinessID, o.ServicePointID,
|
||||
sp.Name
|
||||
sp.ServicePointName AS Name
|
||||
FROM Orders o
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = o.ServicePointID
|
||||
WHERE o.ID = ?
|
||||
LIMIT 1
|
||||
",
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@
|
|||
<!--- Verify order exists and get details --->
|
||||
<cfset qOrder = queryExecute("
|
||||
SELECT o.ID, o.StatusID, o.BusinessID, o.ServicePointID,
|
||||
sp.Name
|
||||
sp.ServicePointName AS Name
|
||||
FROM Orders o
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = o.ServicePointID
|
||||
WHERE o.ID = ?
|
||||
LIMIT 1
|
||||
", [ { value = OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ try {
|
|||
e.UserID,
|
||||
e.StatusID,
|
||||
CAST(e.IsActive AS UNSIGNED) AS IsActive,
|
||||
u.FirstName,
|
||||
u.LastName,
|
||||
u.EmailAddress,
|
||||
u.ContactNumber,
|
||||
u.UserFirstName AS FirstName,
|
||||
u.UserLastName AS LastName,
|
||||
u.UserEmailAddress AS EmailAddress,
|
||||
u.UserContactNumber AS ContactNumber,
|
||||
CASE e.StatusID
|
||||
WHEN 0 THEN 'Pending'
|
||||
WHEN 1 THEN 'Invited'
|
||||
|
|
@ -58,9 +58,9 @@ try {
|
|||
ELSE 'Unknown'
|
||||
END AS StatusName
|
||||
FROM Employees e
|
||||
JOIN Users u ON e.UserID = u.ID
|
||||
JOIN Users u ON e.UserID = u.UserID
|
||||
WHERE e.BusinessID = ?
|
||||
ORDER BY e.IsActive DESC, u.FirstName ASC
|
||||
ORDER BY e.IsActive DESC, u.UserFirstName ASC
|
||||
", [
|
||||
{ value: businessId, cfsqltype: "cf_sql_integer" }
|
||||
], { datasource: "payfrit" });
|
||||
|
|
|
|||
|
|
@ -38,22 +38,22 @@ try {
|
|||
|
||||
qUsers = queryExecute("
|
||||
SELECT
|
||||
u.ID,
|
||||
u.FirstName,
|
||||
u.LastName,
|
||||
u.EmailAddress,
|
||||
u.ContactNumber,
|
||||
u.UserID AS ID,
|
||||
u.UserFirstName AS FirstName,
|
||||
u.UserLastName AS LastName,
|
||||
u.UserEmailAddress AS EmailAddress,
|
||||
u.UserContactNumber AS ContactNumber,
|
||||
u.UserAvatarPath
|
||||
FROM Users u
|
||||
WHERE u.ID != :currentUserId
|
||||
WHERE u.UserID != :currentUserId
|
||||
AND (
|
||||
u.ContactNumber LIKE :searchTerm
|
||||
OR u.EmailAddress LIKE :searchTerm
|
||||
OR u.FirstName LIKE :searchTerm
|
||||
OR u.LastName LIKE :searchTerm
|
||||
OR CONCAT(u.FirstName, ' ', u.LastName) LIKE :searchTerm
|
||||
u.UserContactNumber LIKE :searchTerm
|
||||
OR u.UserEmailAddress LIKE :searchTerm
|
||||
OR u.UserFirstName LIKE :searchTerm
|
||||
OR u.UserLastName LIKE :searchTerm
|
||||
OR CONCAT(u.UserFirstName, ' ', u.UserLastName) LIKE :searchTerm
|
||||
)
|
||||
ORDER BY u.FirstName, u.LastName
|
||||
ORDER BY u.UserFirstName, u.UserLastName
|
||||
LIMIT 10
|
||||
", {
|
||||
currentUserId: { value: currentUserId, cfsqltype: "cf_sql_integer" },
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@
|
|||
e.BusinessID,
|
||||
MIN(e.StatusID) AS StatusID,
|
||||
MAX(e.IsActive) AS IsActive,
|
||||
b.Name,
|
||||
b.BusinessName AS Name,
|
||||
(SELECT COUNT(*) FROM Tasks t WHERE t.BusinessID = e.BusinessID AND t.ClaimedByUserID = 0) AS PendingTaskCount
|
||||
FROM Employees e
|
||||
INNER JOIN Businesses b ON b.ID = e.BusinessID
|
||||
INNER JOIN Businesses b ON b.BusinessID = e.BusinessID
|
||||
WHERE e.UserID = ? AND e.IsActive = b'1'
|
||||
GROUP BY e.BusinessID, b.Name
|
||||
ORDER BY b.Name ASC
|
||||
GROUP BY e.BusinessID, b.BusinessName
|
||||
ORDER BY b.BusinessName ASC
|
||||
", [ { value = UserID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
|
||||
|
||||
<cfset businesses = []>
|
||||
|
|
|
|||
Reference in a new issue