Fix prefixed column names in admin, beacon, task, assignment, chat, rating APIs
Updated all remaining SQL queries to use correct prefixed column names for ServicePoints, Users, Businesses, Addresses, tt_States, tt_Days, and Hours tables across 23 admin/infrastructure API files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
39448c5d91
commit
c62895e464
23 changed files with 180 additions and 179 deletions
|
|
@ -9,14 +9,14 @@ q = queryExecute("
|
|||
b.ID,
|
||||
b.UUID,
|
||||
b.Name,
|
||||
sp_link.BusinessID,
|
||||
sp_link.ID,
|
||||
biz.Name,
|
||||
sp.Name
|
||||
sp_link.ServicePointBusinessID AS BusinessID,
|
||||
sp_link.ServicePointID,
|
||||
biz.BusinessName,
|
||||
sp.ServicePointName AS Name
|
||||
FROM Beacons b
|
||||
LEFT JOIN ServicePoints sp_link ON sp_link.BeaconID = b.ID
|
||||
LEFT JOIN Businesses biz ON biz.ID = sp_link.BusinessID
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = sp_link.ID
|
||||
LEFT JOIN Businesses biz ON biz.BusinessID = sp_link.ServicePointBusinessID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = sp_link.ServicePointID
|
||||
WHERE b.IsActive = 1
|
||||
ORDER BY b.ID
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
|
@ -36,10 +36,10 @@ for (row in q) {
|
|||
|
||||
// Also get service points for reference
|
||||
spQuery = queryExecute("
|
||||
SELECT sp.ID, sp.Name, sp.BusinessID, b.Name
|
||||
SELECT sp.ServicePointID AS ID, sp.ServicePointName AS Name, sp.ServicePointBusinessID AS BusinessID, b.BusinessName AS Name
|
||||
FROM ServicePoints sp
|
||||
JOIN Businesses b ON b.ID = sp.BusinessID
|
||||
ORDER BY sp.BusinessID, sp.ID
|
||||
JOIN Businesses b ON b.BusinessID = sp.ServicePointBusinessID
|
||||
ORDER BY sp.ServicePointBusinessID, sp.ServicePointID
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
servicePoints = [];
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
<cfscript>
|
||||
// Check Big Dean's owner
|
||||
q = queryExecute("
|
||||
SELECT b.ID, b.Name, b.UserID
|
||||
SELECT b.BusinessID AS ID, b.BusinessName AS Name, b.BusinessUserID AS UserID
|
||||
FROM Businesses b
|
||||
WHERE b.ID = 27
|
||||
WHERE b.BusinessID = 27
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
// Get users
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ try {
|
|||
queryExecute("
|
||||
UPDATE ServicePoints
|
||||
SET BeaconID = NULL, AssignedByUserID = NULL
|
||||
WHERE BeaconID IN (7, 8, 9) AND BusinessID = :bizId
|
||||
WHERE BeaconID IN (7, 8, 9) AND ServicePointBusinessID = :bizId
|
||||
", { bizId: lazyDaisyID }, { datasource: "payfrit" });
|
||||
response.steps.append("Unassigned beacons 7, 8, 9 from service points");
|
||||
|
||||
|
|
@ -50,13 +50,13 @@ try {
|
|||
|
||||
// Get final status
|
||||
qFinal = queryExecute("
|
||||
SELECT sp.ID AS ServicePointID, sp.BeaconID, sp.BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.Name AS ServicePointName,
|
||||
biz.Name AS BusinessName
|
||||
SELECT sp.ServicePointID AS ServicePointID, sp.BeaconID, sp.ServicePointBusinessID AS BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.ServicePointName AS ServicePointName,
|
||||
biz.BusinessName AS BusinessName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
JOIN Businesses biz ON biz.ID = sp.BusinessID
|
||||
WHERE sp.BusinessID = :bizId AND sp.BeaconID IS NOT NULL
|
||||
JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.ServicePointBusinessID = :bizId AND sp.BeaconID IS NOT NULL
|
||||
ORDER BY sp.BeaconID
|
||||
", { bizId: lazyDaisyID }, { datasource: "payfrit" });
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ try {
|
|||
|
||||
// Get remaining employees
|
||||
qRemaining = queryExecute("
|
||||
SELECT e.ID, e.UserID, u.FirstName, u.LastName
|
||||
SELECT e.ID, e.UserID, u.UserFirstName AS FirstName, u.UserLastName AS LastName
|
||||
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.ID
|
||||
", [{ value: businessId, cfsqltype: "cf_sql_integer" }], { datasource: "payfrit" });
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ try {
|
|||
queryExecute("
|
||||
UPDATE ServicePoints
|
||||
SET BeaconID = NULL, AssignedByUserID = NULL
|
||||
WHERE BusinessID != :keepID AND BeaconID IS NOT NULL
|
||||
WHERE ServicePointBusinessID != :keepID AND BeaconID IS NOT NULL
|
||||
", { keepID: keepBusinessID }, { datasource: "payfrit" });
|
||||
response.steps.append("Unassigned beacons from other businesses' service points");
|
||||
|
||||
// Get list of businesses to delete
|
||||
qBiz = queryExecute("
|
||||
SELECT ID, Name FROM Businesses WHERE ID != :keepID
|
||||
SELECT BusinessID AS ID, BusinessName AS Name FROM Businesses WHERE BusinessID != :keepID
|
||||
", { keepID: keepBusinessID }, { datasource: "payfrit" });
|
||||
|
||||
deletedBusinesses = [];
|
||||
|
|
@ -54,7 +54,7 @@ try {
|
|||
|
||||
// Delete Hours for other businesses
|
||||
queryExecute("
|
||||
DELETE FROM Hours WHERE BusinessID != :keepID
|
||||
DELETE FROM Hours WHERE HoursBusinessID != :keepID
|
||||
", { keepID: keepBusinessID }, { datasource: "payfrit" });
|
||||
response.steps.append("Deleted hours from other businesses");
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ try {
|
|||
// Delete ServicePoints for other businesses
|
||||
try {
|
||||
queryExecute("
|
||||
DELETE FROM ServicePoints WHERE BusinessID != :keepID
|
||||
DELETE FROM ServicePoints WHERE ServicePointBusinessID != :keepID
|
||||
", { keepID: keepBusinessID }, { datasource: "payfrit" });
|
||||
response.steps.append("Deleted service points from other businesses");
|
||||
} catch (any e) {
|
||||
|
|
@ -100,17 +100,17 @@ try {
|
|||
|
||||
// Finally delete the businesses themselves
|
||||
queryExecute("
|
||||
DELETE FROM Businesses WHERE ID != :keepID
|
||||
DELETE FROM Businesses WHERE BusinessID != :keepID
|
||||
", { keepID: keepBusinessID }, { datasource: "payfrit" });
|
||||
response.steps.append("Deleted " & arrayLen(deletedBusinesses) & " businesses");
|
||||
|
||||
// Get beacon status
|
||||
qBeacons = queryExecute("
|
||||
SELECT sp.ID AS ServicePointID, sp.BeaconID, sp.BusinessID,
|
||||
b.UUID, biz.Name AS BusinessName, sp.Name AS ServicePointName
|
||||
SELECT sp.ServicePointID AS ServicePointID, sp.BeaconID, sp.ServicePointBusinessID AS BusinessID,
|
||||
b.UUID, biz.BusinessName AS BusinessName, sp.ServicePointName AS ServicePointName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
JOIN Businesses biz ON biz.ID = sp.BusinessID
|
||||
JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.BeaconID IS NOT NULL
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ try {
|
|||
|
||||
// Get service point Table 1
|
||||
qSP = queryExecute("
|
||||
SELECT ID FROM ServicePoints
|
||||
WHERE BusinessID = :bizID AND Name = 'Table 1'
|
||||
SELECT ServicePointID AS ID FROM ServicePoints
|
||||
WHERE ServicePointBusinessID = :bizID AND ServicePointName = 'Table 1'
|
||||
", { bizID: lazyDaisyID }, { datasource: "payfrit" });
|
||||
|
||||
if (qSP.recordCount == 0) {
|
||||
queryExecute("
|
||||
INSERT INTO ServicePoints (BusinessID, Name)
|
||||
INSERT INTO ServicePoints (ServicePointBusinessID, ServicePointName)
|
||||
VALUES (:bizID, 'Table 1')
|
||||
", { bizID: lazyDaisyID }, { datasource: "payfrit" });
|
||||
qSP = queryExecute("SELECT LAST_INSERT_ID() as id", {}, { datasource: "payfrit" });
|
||||
|
|
@ -62,24 +62,25 @@ try {
|
|||
queryExecute("
|
||||
UPDATE ServicePoints SET BeaconID = NULL, AssignedByUserID = NULL
|
||||
WHERE BeaconID = :beaconID
|
||||
|
||||
", { beaconID: beaconID }, { datasource: "payfrit" });
|
||||
|
||||
// Assign beacon to Table 1 service point
|
||||
queryExecute("
|
||||
UPDATE ServicePoints SET BeaconID = :beaconID, AssignedByUserID = 1
|
||||
WHERE ID = :spID AND BusinessID = :bizID
|
||||
WHERE ServicePointID = :spID AND ServicePointBusinessID = :bizID
|
||||
", { beaconID: beaconID, bizID: lazyDaisyID, spID: servicePointID }, { datasource: "payfrit" });
|
||||
response.steps.append("Assigned beacon " & beaconID & " to Table 1");
|
||||
}
|
||||
|
||||
// Get final status
|
||||
qFinal = queryExecute("
|
||||
SELECT sp.ID AS ServicePointID, sp.BeaconID, sp.BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.Name AS ServicePointName,
|
||||
biz.Name AS BusinessName
|
||||
SELECT sp.ServicePointID AS ServicePointID, sp.BeaconID, sp.ServicePointBusinessID AS BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.ServicePointName AS ServicePointName,
|
||||
biz.BusinessName AS BusinessName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
JOIN Businesses biz ON biz.ID = sp.BusinessID
|
||||
JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.BeaconID IS NOT NULL
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@
|
|||
<cftry>
|
||||
<!--- Get raw employee records --- >
|
||||
<cfset qEmployees = queryExecute("
|
||||
SELECT e.*, b.Name
|
||||
SELECT e.*, b.BusinessName AS Name
|
||||
FROM Employees e
|
||||
INNER JOIN Businesses b ON b.ID = e.BusinessID
|
||||
INNER JOIN Businesses b ON b.BusinessID = e.BusinessID
|
||||
WHERE e.UserID = ?
|
||||
ORDER BY b.Name ASC
|
||||
", [ { value = UserID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
|
||||
|
|
@ -46,9 +46,9 @@
|
|||
|
||||
<!--- Check for duplicate businesses --- >
|
||||
<cfset qDuplicates = queryExecute("
|
||||
SELECT Name, COUNT(*) AS cnt
|
||||
SELECT BusinessName AS Name, COUNT(*) AS cnt
|
||||
FROM Businesses
|
||||
GROUP BY Name
|
||||
GROUP BY BusinessName
|
||||
HAVING COUNT(*) > 1
|
||||
", [], { datasource = "payfrit" })>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ if (len(phone) == 0) {
|
|||
|
||||
// Find user by phone
|
||||
qUser = queryExecute("
|
||||
SELECT ID, FirstName, LastName, EmailAddress, ContactNumber
|
||||
SELECT UserID AS ID, UserFirstName AS FirstName, UserLastName AS LastName, UserEmailAddress AS EmailAddress, UserContactNumber AS ContactNumber
|
||||
FROM Users
|
||||
WHERE REPLACE(REPLACE(REPLACE(ContactNumber, '-', ''), '(', ''), ')', '') LIKE ?
|
||||
OR ContactNumber LIKE ?
|
||||
WHERE REPLACE(REPLACE(REPLACE(UserContactNumber, '-', ''), '(', ''), ')', '') LIKE ?
|
||||
OR UserContactNumber LIKE ?
|
||||
", [
|
||||
{ value: "%" & phone & "%", cfsqltype: "cf_sql_varchar" },
|
||||
{ value: "%" & phone & "%", cfsqltype: "cf_sql_varchar" }
|
||||
|
|
@ -40,9 +40,9 @@ userId = qUser.ID;
|
|||
qEmployees = queryExecute("
|
||||
SELECT e.ID, e.BusinessID, e.StatusID,
|
||||
CAST(e.IsActive AS UNSIGNED) AS IsActive,
|
||||
b.Name
|
||||
b.BusinessName AS Name
|
||||
FROM Employees e
|
||||
JOIN Businesses b ON e.BusinessID = b.ID
|
||||
JOIN Businesses b ON e.BusinessID = b.BusinessID
|
||||
WHERE e.UserID = ?
|
||||
", [{ value: userId, cfsqltype: "cf_sql_integer" }], { datasource: "payfrit" });
|
||||
|
||||
|
|
|
|||
|
|
@ -75,17 +75,17 @@ function buildAddressString(line1, line2, city, zipCode) {
|
|||
<cfif structKeyExists(url, "geocode") AND structKeyExists(url, "addressId")>
|
||||
<cfset addressId = val(url.addressId)>
|
||||
<cfquery name="addr" datasource="payfrit">
|
||||
SELECT Line1, Line2, City, ZIPCode
|
||||
FROM Addresses WHERE ID = <cfqueryparam value="#addressId#" cfsqltype="cf_sql_integer">
|
||||
SELECT AddressLine1 AS Line1, AddressLine2 AS Line2, AddressCity AS City, AddressZIPCode AS ZIPCode
|
||||
FROM Addresses WHERE AddressID = <cfqueryparam value="#addressId#" cfsqltype="cf_sql_integer">
|
||||
</cfquery>
|
||||
<cfif addr.recordCount GT 0>
|
||||
<cfset fullAddress = buildAddressString(addr.Line1, addr.Line2, addr.City, addr.ZIPCode)>
|
||||
<cfset geo = geocodeAddress(fullAddress)>
|
||||
<cfif geo.success>
|
||||
<cfquery datasource="payfrit">
|
||||
UPDATE Addresses SET Latitude = <cfqueryparam value="#geo.lat#" cfsqltype="cf_sql_decimal">,
|
||||
Longitude = <cfqueryparam value="#geo.lng#" cfsqltype="cf_sql_decimal">
|
||||
WHERE ID = <cfqueryparam value="#addressId#" cfsqltype="cf_sql_integer">
|
||||
UPDATE Addresses SET AddressLat = <cfqueryparam value="#geo.lat#" cfsqltype="cf_sql_decimal">,
|
||||
AddressLng = <cfqueryparam value="#geo.lng#" cfsqltype="cf_sql_decimal">
|
||||
WHERE AddressID = <cfqueryparam value="#addressId#" cfsqltype="cf_sql_integer">
|
||||
</cfquery>
|
||||
<cfoutput><div class="success">Geocoded Address ID #addressId#: #geo.lat#, #geo.lng#</div></cfoutput>
|
||||
<cfelse>
|
||||
|
|
@ -96,10 +96,10 @@ function buildAddressString(line1, line2, city, zipCode) {
|
|||
|
||||
<cfif structKeyExists(url, "geocodeAll")>
|
||||
<cfquery name="missing" datasource="payfrit">
|
||||
SELECT ID, Line1, Line2, City, ZIPCode
|
||||
SELECT AddressID AS ID, AddressLine1 AS Line1, AddressLine2 AS Line2, AddressCity AS City, AddressZIPCode AS ZIPCode
|
||||
FROM Addresses
|
||||
WHERE (Latitude IS NULL OR Latitude = 0)
|
||||
AND Line1 IS NOT NULL AND Line1 != ''
|
||||
WHERE (AddressLat IS NULL OR AddressLat = 0)
|
||||
AND AddressLine1 IS NOT NULL AND AddressLine1 != ''
|
||||
</cfquery>
|
||||
<cfset successCount = 0>
|
||||
<cfset failCount = 0>
|
||||
|
|
@ -108,9 +108,9 @@ function buildAddressString(line1, line2, city, zipCode) {
|
|||
<cfset geo = geocodeAddress(fullAddress)>
|
||||
<cfif geo.success>
|
||||
<cfquery datasource="payfrit">
|
||||
UPDATE Addresses SET Latitude = <cfqueryparam value="#geo.lat#" cfsqltype="cf_sql_decimal">,
|
||||
Longitude = <cfqueryparam value="#geo.lng#" cfsqltype="cf_sql_decimal">
|
||||
WHERE ID = <cfqueryparam value="#missing.ID#" cfsqltype="cf_sql_integer">
|
||||
UPDATE Addresses SET AddressLat = <cfqueryparam value="#geo.lat#" cfsqltype="cf_sql_decimal">,
|
||||
AddressLng = <cfqueryparam value="#geo.lng#" cfsqltype="cf_sql_decimal">
|
||||
WHERE AddressID = <cfqueryparam value="#missing.ID#" cfsqltype="cf_sql_integer">
|
||||
</cfquery>
|
||||
<cfset successCount = successCount + 1>
|
||||
<cfelse>
|
||||
|
|
@ -123,18 +123,18 @@ function buildAddressString(line1, line2, city, zipCode) {
|
|||
|
||||
<cfquery name="addresses" datasource="payfrit">
|
||||
SELECT
|
||||
b.ID,
|
||||
b.Name,
|
||||
a.ID,
|
||||
a.Line1,
|
||||
a.Line2,
|
||||
a.City,
|
||||
a.ZIPCode,
|
||||
a.Latitude,
|
||||
a.Longitude
|
||||
b.BusinessID,
|
||||
b.BusinessName AS Name,
|
||||
a.AddressID,
|
||||
a.AddressLine1 AS Line1,
|
||||
a.AddressLine2 AS Line2,
|
||||
a.AddressCity AS City,
|
||||
a.AddressZIPCode AS ZIPCode,
|
||||
a.AddressLat AS Latitude,
|
||||
a.AddressLng AS Longitude
|
||||
FROM Businesses b
|
||||
LEFT JOIN Addresses a ON b.AddressID = a.ID
|
||||
ORDER BY b.Name
|
||||
LEFT JOIN Addresses a ON b.BusinessAddressID = a.AddressID
|
||||
ORDER BY b.BusinessName
|
||||
</cfquery>
|
||||
|
||||
<cfset missingCount = 0>
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ try {
|
|||
q = queryExecute("
|
||||
SELECT e.ID, e.BusinessID, e.UserID, e.StatusID,
|
||||
CAST(e.IsActive AS UNSIGNED) AS IsActive,
|
||||
b.Name, u.FirstName, u.LastName
|
||||
b.BusinessName AS Name, u.UserFirstName AS FirstName, u.UserLastName AS LastName
|
||||
FROM Employees e
|
||||
JOIN Businesses b ON e.BusinessID = b.ID
|
||||
JOIN Users u ON e.UserID = u.ID
|
||||
JOIN Businesses b ON e.BusinessID = b.BusinessID
|
||||
JOIN Users u ON e.UserID = u.UserID
|
||||
WHERE e.BusinessID = ? AND e.UserID = ?
|
||||
", [
|
||||
{ value: businessId, cfsqltype: "cf_sql_integer" },
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ try {
|
|||
|
||||
// Get all service points for Lazy Daisy
|
||||
qServicePoints = queryExecute("
|
||||
SELECT ID, Name
|
||||
SELECT ServicePointID AS ID, ServicePointName AS Name
|
||||
FROM ServicePoints
|
||||
WHERE BusinessID = :bizID AND IsActive = 1
|
||||
ORDER BY SortOrder, ID
|
||||
WHERE ServicePointBusinessID = :bizID AND IsActive = 1
|
||||
ORDER BY SortOrder, ServicePointID
|
||||
", { bizID: lazyDaisyID }, { datasource: "payfrit" });
|
||||
|
||||
response.steps.append("Found " & qServicePoints.recordCount & " service points for Lazy Daisy");
|
||||
|
|
@ -53,7 +53,7 @@ try {
|
|||
queryExecute("
|
||||
UPDATE ServicePoints
|
||||
SET BeaconID = :beaconId, AssignedByUserID = 1
|
||||
WHERE ID = :spId AND BusinessID = :bizId
|
||||
WHERE ServicePointID = :spId AND ServicePointBusinessID = :bizId
|
||||
", {
|
||||
beaconId: newBeaconId,
|
||||
bizId: lazyDaisyID,
|
||||
|
|
@ -69,14 +69,14 @@ try {
|
|||
|
||||
// Get final status
|
||||
qFinal = queryExecute("
|
||||
SELECT sp.ID AS ServicePointID, sp.BeaconID, sp.BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.Name AS ServicePointName,
|
||||
biz.Name AS BusinessName
|
||||
SELECT sp.ServicePointID AS ServicePointID, sp.BeaconID, sp.ServicePointBusinessID AS BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.ServicePointName AS ServicePointName,
|
||||
biz.BusinessName AS BusinessName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
JOIN Businesses biz ON biz.ID = sp.BusinessID
|
||||
WHERE sp.BusinessID = :bizId AND sp.BeaconID IS NOT NULL
|
||||
ORDER BY sp.Name
|
||||
JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.ServicePointBusinessID = :bizId AND sp.BeaconID IS NOT NULL
|
||||
ORDER BY sp.ServicePointName
|
||||
", { bizId: lazyDaisyID }, { datasource: "payfrit" });
|
||||
|
||||
beacons = [];
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ try {
|
|||
// Hours: Mon-Thu: 11am-10pm, Fri-Sat: 11am-11pm, Sun: 11am-10pm
|
||||
|
||||
// Get California StateID
|
||||
qState = queryExecute("SELECT ID FROM tt_States WHERE Abbreviation = 'CA' LIMIT 1");
|
||||
stateId = qState.recordCount > 0 ? qState.ID : 5; // Default to 5 if not found
|
||||
qState = queryExecute("SELECT tt_StateID FROM tt_States WHERE tt_StateAbbreviation = 'CA' LIMIT 1");
|
||||
stateId = qState.recordCount > 0 ? qState.tt_StateID : 5; // Default to 5 if not found
|
||||
|
||||
// Check if Big Dean's already has an address
|
||||
existingAddr = queryExecute("
|
||||
SELECT ID FROM Addresses
|
||||
WHERE BusinessID = :bizId AND UserID = 0
|
||||
SELECT AddressID FROM Addresses
|
||||
WHERE AddressBusinessID = :bizId AND AddressUserID = 0
|
||||
", { bizId: businessId });
|
||||
|
||||
if (existingAddr.recordCount == 0) {
|
||||
// Insert new address
|
||||
queryExecute("
|
||||
INSERT INTO Addresses (UserID, BusinessID, AddressTypeID, Line1, City, StateID, ZIPCode, IsDeleted, AddedOn)
|
||||
INSERT INTO Addresses (AddressUserID, AddressBusinessID, AddressTypeID, AddressLine1, AddressCity, AddressStateID, AddressZIPCode, AddressIsDeleted, AddressAddedOn)
|
||||
VALUES (0, :bizId, '2', :line1, :city, :stateId, :zip, 0, NOW())
|
||||
", {
|
||||
bizId: businessId,
|
||||
|
|
@ -39,8 +39,8 @@ try {
|
|||
// Update existing address
|
||||
queryExecute("
|
||||
UPDATE Addresses
|
||||
SET Line1 = :line1, City = :city, StateID = :stateId, ZIPCode = :zip
|
||||
WHERE BusinessID = :bizId AND UserID = 0
|
||||
SET AddressLine1 = :line1, AddressCity = :city, AddressStateID = :stateId, AddressZIPCode = :zip
|
||||
WHERE AddressBusinessID = :bizId AND AddressUserID = 0
|
||||
", {
|
||||
bizId: businessId,
|
||||
line1: "1615 Ocean Front Walk",
|
||||
|
|
@ -53,7 +53,7 @@ try {
|
|||
|
||||
// Check existing hours for this business
|
||||
existingHours = queryExecute("
|
||||
SELECT COUNT(*) as cnt FROM Hours WHERE BusinessID = :bizId
|
||||
SELECT COUNT(*) as cnt FROM Hours WHERE HoursBusinessID = :bizId
|
||||
", { bizId: businessId });
|
||||
|
||||
if (existingHours.cnt == 0) {
|
||||
|
|
@ -64,39 +64,39 @@ try {
|
|||
// Sun: 11am-10pm (day 1)
|
||||
|
||||
// Sunday (1): 11am-10pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 1, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 1, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
|
||||
// Monday (2): 11am-10pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 2, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 2, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
|
||||
// Tuesday (3): 11am-10pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 3, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 3, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
|
||||
// Wednesday (4): 11am-10pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 4, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 4, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
|
||||
// Thursday (5): 11am-10pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 5, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 5, '11:00:00', '22:00:00')", { bizId: businessId });
|
||||
|
||||
// Friday (6): 11am-11pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 6, '11:00:00', '23:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 6, '11:00:00', '23:00:00')", { bizId: businessId });
|
||||
|
||||
// Saturday (7): 11am-11pm
|
||||
queryExecute("INSERT INTO Hours (BusinessID, DayID, OpenTime, ClosingTime) VALUES (:bizId, 7, '11:00:00', '23:00:00')", { bizId: businessId });
|
||||
queryExecute("INSERT INTO Hours (HoursBusinessID, HoursDayID, HoursOpenTime, HoursClosingTime) VALUES (:bizId, 7, '11:00:00', '23:00:00')", { bizId: businessId });
|
||||
|
||||
response["HOURS_ACTION"] = "inserted 7 days";
|
||||
} else {
|
||||
// Update existing hours
|
||||
// Mon-Thu: 11am-10pm
|
||||
queryExecute("UPDATE Hours SET OpenTime = '11:00:00', ClosingTime = '22:00:00' WHERE BusinessID = :bizId AND DayID IN (1, 2, 3, 4, 5)", { bizId: businessId });
|
||||
queryExecute("UPDATE Hours SET HoursOpenTime = '11:00:00', HoursClosingTime = '22:00:00' WHERE HoursBusinessID = :bizId AND HoursDayID IN (1, 2, 3, 4, 5)", { bizId: businessId });
|
||||
// Fri-Sat: 11am-11pm
|
||||
queryExecute("UPDATE Hours SET OpenTime = '11:00:00', ClosingTime = '23:00:00' WHERE BusinessID = :bizId AND DayID IN (6, 7)", { bizId: businessId });
|
||||
queryExecute("UPDATE Hours SET HoursOpenTime = '11:00:00', HoursClosingTime = '23:00:00' WHERE HoursBusinessID = :bizId AND HoursDayID IN (6, 7)", { bizId: businessId });
|
||||
response["HOURS_ACTION"] = "updated";
|
||||
}
|
||||
|
||||
// Update phone on Businesses table (if column exists)
|
||||
try {
|
||||
queryExecute("UPDATE Businesses SET Phone = :phone WHERE ID = :bizId", {
|
||||
queryExecute("UPDATE Businesses SET BusinessPhone = :phone WHERE BusinessID = :bizId", {
|
||||
phone: "(310) 393-2666",
|
||||
bizId: businessId
|
||||
});
|
||||
|
|
@ -107,35 +107,35 @@ try {
|
|||
|
||||
// Verify the data
|
||||
address = queryExecute("
|
||||
SELECT a.*, s.Abbreviation
|
||||
SELECT a.*, s.tt_StateAbbreviation AS Abbreviation
|
||||
FROM Addresses a
|
||||
LEFT JOIN tt_States s ON s.ID = a.StateID
|
||||
WHERE a.BusinessID = :bizId AND a.UserID = 0
|
||||
LEFT JOIN tt_States s ON s.tt_StateID = a.AddressStateID
|
||||
WHERE a.AddressBusinessID = :bizId AND a.AddressUserID = 0
|
||||
", { bizId: businessId });
|
||||
|
||||
hours = queryExecute("
|
||||
SELECT h.*, d.tt_DayName
|
||||
FROM Hours h
|
||||
JOIN tt_Days d ON d.ID = h.DayID
|
||||
WHERE h.BusinessID = :bizId
|
||||
ORDER BY h.DayID
|
||||
JOIN tt_Days d ON d.tt_DayID = h.HoursDayID
|
||||
WHERE h.HoursBusinessID = :bizId
|
||||
ORDER BY h.HoursDayID
|
||||
", { bizId: businessId });
|
||||
|
||||
response["OK"] = true;
|
||||
response["BUSINESS_ID"] = businessId;
|
||||
response["ADDRESS"] = address.recordCount > 0 ? {
|
||||
"line1": address.Line1,
|
||||
"city": address.City,
|
||||
"line1": address.AddressLine1,
|
||||
"city": address.AddressCity,
|
||||
"state": address.Abbreviation,
|
||||
"zip": address.ZIPCode
|
||||
"zip": address.AddressZIPCode
|
||||
} : "not found";
|
||||
|
||||
hoursArr = [];
|
||||
for (h in hours) {
|
||||
arrayAppend(hoursArr, {
|
||||
"day": h.tt_DayName,
|
||||
"open": timeFormat(h.OpenTime, "h:mm tt"),
|
||||
"close": timeFormat(h.ClosingTime, "h:mm tt")
|
||||
"open": timeFormat(h.HoursOpenTime, "h:mm tt"),
|
||||
"close": timeFormat(h.HoursClosingTime, "h:mm tt")
|
||||
});
|
||||
}
|
||||
response["HOURS"] = hoursArr;
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ try {
|
|||
|
||||
// Create service point for Table 1 if it doesn't exist
|
||||
qSP = queryExecute("
|
||||
SELECT ID FROM ServicePoints
|
||||
WHERE BusinessID = :bizID AND Name = 'Table 1'
|
||||
SELECT ServicePointID AS ID FROM ServicePoints
|
||||
WHERE ServicePointBusinessID = :bizID AND ServicePointName = 'Table 1'
|
||||
", { bizID: lazyDaisyID }, { datasource: "payfrit" });
|
||||
|
||||
if (qSP.recordCount == 0) {
|
||||
queryExecute("
|
||||
INSERT INTO ServicePoints (BusinessID, Name)
|
||||
INSERT INTO ServicePoints (ServicePointBusinessID, ServicePointName)
|
||||
VALUES (:bizID, 'Table 1')
|
||||
", { bizID: lazyDaisyID }, { datasource: "payfrit" });
|
||||
qSP = queryExecute("SELECT LAST_INSERT_ID() as id", {}, { datasource: "payfrit" });
|
||||
|
|
@ -44,19 +44,19 @@ try {
|
|||
// Assign beacon to Table 1 service point
|
||||
queryExecute("
|
||||
UPDATE ServicePoints SET BeaconID = :beaconID, AssignedByUserID = 1
|
||||
WHERE ID = :spID AND BusinessID = :bizID
|
||||
WHERE ServicePointID = :spID AND ServicePointBusinessID = :bizID
|
||||
", { beaconID: beaconID, bizID: lazyDaisyID, spID: servicePointID }, { datasource: "payfrit" });
|
||||
response.steps.append("Assigned beacon " & beaconID & " to Table 1");
|
||||
}
|
||||
|
||||
// Get final status
|
||||
qFinal = queryExecute("
|
||||
SELECT sp.ID AS ServicePointID, sp.BeaconID, sp.BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.Name AS ServicePointName,
|
||||
biz.Name AS BusinessName
|
||||
SELECT sp.ServicePointID AS ServicePointID, sp.BeaconID, sp.ServicePointBusinessID AS BusinessID,
|
||||
b.Name AS BeaconName, b.UUID, sp.ServicePointName AS ServicePointName,
|
||||
biz.BusinessName AS BusinessName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
JOIN Businesses biz ON biz.ID = sp.BusinessID
|
||||
JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.BeaconID IS NOT NULL
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
|
|
|
|||
|
|
@ -25,17 +25,17 @@ queryExecute("
|
|||
queryExecute("
|
||||
UPDATE ServicePoints
|
||||
SET BeaconID = NULL, AssignedByUserID = NULL
|
||||
WHERE BusinessID = :fromBiz AND BeaconID IS NOT NULL
|
||||
WHERE ServicePointBusinessID = :fromBiz AND BeaconID IS NOT NULL
|
||||
", { fromBiz: fromBiz }, { datasource: "payfrit" });
|
||||
|
||||
// Get current state
|
||||
q = queryExecute("
|
||||
SELECT sp.ID AS ServicePointID, sp.BeaconID, sp.BusinessID,
|
||||
b.Name AS BeaconName, biz.Name AS BusinessName,
|
||||
sp.Name AS ServicePointName
|
||||
SELECT sp.ServicePointID AS ServicePointID, sp.BeaconID, sp.ServicePointBusinessID AS BusinessID,
|
||||
b.Name AS BeaconName, biz.BusinessName AS BusinessName,
|
||||
sp.ServicePointName AS ServicePointName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
JOIN Businesses biz ON biz.ID = sp.BusinessID
|
||||
JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.BeaconID IS NOT NULL
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ queryExecute("
|
|||
queryExecute("
|
||||
UPDATE ServicePoints
|
||||
SET BeaconID = NULL, AssignedByUserID = NULL
|
||||
WHERE BeaconID = :beaconId AND BusinessID = :oldBizId
|
||||
WHERE BeaconID = :beaconId AND ServicePointBusinessID = :oldBizId
|
||||
", { beaconId: beaconId, oldBizId: oldBusinessId }, { datasource: "payfrit" });
|
||||
|
||||
// Get current state
|
||||
|
|
@ -35,13 +35,13 @@ q = queryExecute("
|
|||
b.UUID,
|
||||
b.Name AS BeaconName,
|
||||
b.BusinessID AS BeaconBusinessID,
|
||||
sp.ID AS ServicePointID,
|
||||
sp.Name AS ServicePointName,
|
||||
sp.BusinessID AS ServicePointBusinessID,
|
||||
biz.Name AS BusinessName
|
||||
sp.ServicePointID AS ServicePointID,
|
||||
sp.ServicePointName AS ServicePointName,
|
||||
sp.ServicePointBusinessID AS ServicePointBusinessID,
|
||||
biz.BusinessName AS BusinessName
|
||||
FROM Beacons b
|
||||
LEFT JOIN ServicePoints sp ON sp.BeaconID = b.ID
|
||||
LEFT JOIN Businesses biz ON biz.ID = b.BusinessID
|
||||
LEFT JOIN Businesses biz ON biz.BusinessID = b.BusinessID
|
||||
WHERE b.IsActive = 1
|
||||
ORDER BY b.ID
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
|
|
|||
|
|
@ -17,18 +17,18 @@ if (!structKeyExists(request, "BusinessID") || !isNumeric(request.BusinessID) ||
|
|||
|
||||
<cfquery name="q" datasource="payfrit">
|
||||
SELECT
|
||||
sp.ID AS ServicePointID,
|
||||
sp.ServicePointID AS ServicePointID,
|
||||
sp.BeaconID,
|
||||
sp.BusinessID,
|
||||
sp.ServicePointBusinessID AS BusinessID,
|
||||
sp.AssignedByUserID,
|
||||
b.Name AS BeaconName,
|
||||
b.UUID,
|
||||
sp.Name AS ServicePointName
|
||||
sp.ServicePointName AS ServicePointName
|
||||
FROM ServicePoints sp
|
||||
JOIN Beacons b ON b.ID = sp.BeaconID
|
||||
WHERE sp.BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
WHERE sp.ServicePointBusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
AND sp.BeaconID IS NOT NULL
|
||||
ORDER BY b.Name, sp.Name
|
||||
ORDER BY b.Name, sp.ServicePointName
|
||||
</cfquery>
|
||||
|
||||
<cfset assignments = []>
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ ServicePointID = int(data.ServicePointID);
|
|||
<!--- Validate Beacon is allowed for this Business:
|
||||
Owner (Beacons.BusinessID) OR join table (lt_BeaconsID_BusinessesID) OR parent's owner --->
|
||||
<cfquery name="qBiz" datasource="payfrit">
|
||||
SELECT ID, ParentBusinessID
|
||||
SELECT BusinessID, BusinessParentBusinessID AS ParentBusinessID
|
||||
FROM Businesses
|
||||
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
WHERE BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
LIMIT 1
|
||||
</cfquery>
|
||||
|
||||
|
|
@ -78,10 +78,10 @@ ServicePointID = int(data.ServicePointID);
|
|||
|
||||
<!--- Validate ServicePoint belongs to Business --->
|
||||
<cfquery name="qS" datasource="payfrit">
|
||||
SELECT ID
|
||||
SELECT ServicePointID
|
||||
FROM ServicePoints
|
||||
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePointID#">
|
||||
AND BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
WHERE ServicePointID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePointID#">
|
||||
AND ServicePointBusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
LIMIT 1
|
||||
</cfquery>
|
||||
<cfif qS.recordCount EQ 0>
|
||||
|
|
@ -91,9 +91,9 @@ ServicePointID = int(data.ServicePointID);
|
|||
|
||||
<!--- Check if this ServicePoint already has this beacon assigned --->
|
||||
<cfquery name="qDuplicate" datasource="payfrit">
|
||||
SELECT ID
|
||||
SELECT ServicePointID
|
||||
FROM ServicePoints
|
||||
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePointID#">
|
||||
WHERE ServicePointID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePointID#">
|
||||
AND BeaconID = <cfqueryparam cfsqltype="cf_sql_integer" value="#BeaconID#">
|
||||
LIMIT 1
|
||||
</cfquery>
|
||||
|
|
@ -107,8 +107,8 @@ ServicePointID = int(data.ServicePointID);
|
|||
UPDATE ServicePoints
|
||||
SET BeaconID = <cfqueryparam cfsqltype="cf_sql_integer" value="#BeaconID#">,
|
||||
AssignedByUserID = <cfqueryparam cfsqltype="cf_sql_integer" value="1">
|
||||
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePointID#">
|
||||
AND BusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
WHERE ServicePointID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ServicePointID#">
|
||||
AND ServicePointBusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#request.BusinessID#">
|
||||
</cfquery>
|
||||
|
||||
<cfoutput>#serializeJSON({
|
||||
|
|
|
|||
|
|
@ -48,13 +48,13 @@ beaconId = int(data.BeaconID);
|
|||
<!--- Get all businesses that have assignments to this beacon (via service points or join table) --->
|
||||
<cfquery name="qAssignments" datasource="payfrit">
|
||||
SELECT
|
||||
sp.BusinessID,
|
||||
sp.ID AS ServicePointID,
|
||||
sp.ServicePointBusinessID AS BusinessID,
|
||||
sp.ServicePointID AS ServicePointID,
|
||||
biz.BusinessName AS BusinessName,
|
||||
biz.BusinessParentBusinessID,
|
||||
sp.Name AS ServicePointName
|
||||
sp.ServicePointName AS ServicePointName
|
||||
FROM ServicePoints sp
|
||||
INNER JOIN Businesses biz ON biz.BusinessID = sp.BusinessID
|
||||
INNER JOIN Businesses biz ON biz.BusinessID = sp.ServicePointBusinessID
|
||||
WHERE sp.BeaconID = <cfqueryparam cfsqltype="cf_sql_integer" value="#beaconId#">
|
||||
AND sp.IsActive = 1
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ beaconId = int(data.BeaconID);
|
|||
INNER JOIN Businesses biz ON biz.BusinessID = lt.BusinessID
|
||||
WHERE lt.BeaconID = <cfqueryparam cfsqltype="cf_sql_integer" value="#beaconId#">
|
||||
AND lt.BusinessID NOT IN (
|
||||
SELECT sp2.BusinessID FROM ServicePoints sp2
|
||||
SELECT sp2.ServicePointBusinessID FROM ServicePoints sp2
|
||||
WHERE sp2.BeaconID = <cfqueryparam cfsqltype="cf_sql_integer" value="#beaconId#"> AND sp2.IsActive = 1
|
||||
)
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ beaconId = int(data.BeaconID);
|
|||
BusinessHeaderImageExtension
|
||||
FROM Businesses
|
||||
WHERE BusinessParentBusinessID = <cfqueryparam cfsqltype="cf_sql_integer" value="#parentBusinessID#">
|
||||
ORDER BY Name ASC
|
||||
ORDER BY BusinessName ASC
|
||||
</cfquery>
|
||||
<cfloop query="qChildBusinesses">
|
||||
<cfset arrayAppend(businesses, {
|
||||
|
|
|
|||
|
|
@ -39,22 +39,22 @@
|
|||
b.ID AS BeaconID,
|
||||
b.Name AS BeaconName,
|
||||
b.UUID,
|
||||
COALESCE(sp.ID, 0) AS ServicePointID,
|
||||
COALESCE(sp.Name, '') AS ServicePointName,
|
||||
COALESCE(sp.BusinessID, lt.BusinessID, b.BusinessID) AS BusinessID,
|
||||
biz.Name AS BusinessName,
|
||||
biz.ParentBusinessID,
|
||||
COALESCE(parent.Name, '') AS ParentBusinessName,
|
||||
(SELECT COUNT(*) FROM Businesses WHERE ParentBusinessID = biz.ID) AS ChildCount
|
||||
COALESCE(sp.ServicePointID, 0) AS ServicePointID,
|
||||
COALESCE(sp.ServicePointName, '') AS ServicePointName,
|
||||
COALESCE(sp.ServicePointBusinessID, lt.BusinessID, b.BusinessID) AS BusinessID,
|
||||
biz.BusinessName AS BusinessName,
|
||||
biz.BusinessParentBusinessID AS ParentBusinessID,
|
||||
COALESCE(parent.BusinessName, '') AS ParentBusinessName,
|
||||
(SELECT COUNT(*) FROM Businesses WHERE BusinessParentBusinessID = biz.BusinessID) AS ChildCount
|
||||
FROM Beacons b
|
||||
LEFT JOIN ServicePoints sp ON sp.BeaconID = b.ID
|
||||
LEFT JOIN lt_BeaconsID_BusinessesID lt ON lt.BeaconID = b.ID
|
||||
INNER JOIN Businesses biz ON COALESCE(sp.BusinessID, lt.BusinessID, b.BusinessID) = biz.ID
|
||||
LEFT JOIN Businesses parent ON biz.ParentBusinessID = parent.ID
|
||||
INNER JOIN Businesses biz ON COALESCE(sp.ServicePointBusinessID, lt.BusinessID, b.BusinessID) = biz.BusinessID
|
||||
LEFT JOIN Businesses parent ON biz.BusinessParentBusinessID = parent.BusinessID
|
||||
WHERE b.UUID IN (<cfqueryparam value="#arrayToList(cleanUUIDs)#" cfsqltype="cf_sql_varchar" list="true">)
|
||||
AND b.IsActive = 1
|
||||
AND biz.IsDemo = 0
|
||||
AND biz.IsPrivate = 0
|
||||
AND biz.BusinessIsDemo = 0
|
||||
AND biz.BusinessIsPrivate = 0
|
||||
</cfquery>
|
||||
|
||||
<cfset beacons = []>
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ try {
|
|||
m.MessageBody,
|
||||
m.IsRead,
|
||||
m.CreatedOn,
|
||||
u.FirstName as SenderName
|
||||
u.UserFirstName as SenderName
|
||||
FROM ChatMessages m
|
||||
LEFT JOIN Users u ON u.ID = m.SenderUserID
|
||||
LEFT JOIN Users u ON u.UserID = m.SenderUserID
|
||||
WHERE m.TaskID = :taskID AND m.ID > :afterID
|
||||
ORDER BY m.CreatedOn ASC
|
||||
", {
|
||||
|
|
@ -62,9 +62,9 @@ try {
|
|||
m.MessageBody,
|
||||
m.IsRead,
|
||||
m.CreatedOn,
|
||||
u.FirstName as SenderName
|
||||
u.UserFirstName as SenderName
|
||||
FROM ChatMessages m
|
||||
LEFT JOIN Users u ON u.ID = m.SenderUserID
|
||||
LEFT JOIN Users u ON u.UserID = m.SenderUserID
|
||||
WHERE m.TaskID = :taskID
|
||||
ORDER BY m.CreatedOn ASC
|
||||
", {
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@ try {
|
|||
// and no admin rating exists yet
|
||||
qTasks = queryExecute("
|
||||
SELECT t.ID, t.Title, t.CompletedOn, t.ClaimedByUserID, t.OrderID,
|
||||
u.FirstName AS WorkerFirstName, u.LastName AS WorkerLastName,
|
||||
u.UserFirstName AS WorkerFirstName, u.UserLastName AS WorkerLastName,
|
||||
o.ID, o.UserID,
|
||||
cu.FirstName AS CustomerFirstName, cu.LastName AS CustomerLastName,
|
||||
sp.Name,
|
||||
cu.UserFirstName AS CustomerFirstName, cu.UserLastName AS CustomerLastName,
|
||||
sp.ServicePointName AS Name,
|
||||
(SELECT COUNT(*) FROM TaskRatings r
|
||||
WHERE r.TaskID = t.ID
|
||||
AND r.Direction = 'admin_rates_worker') AS HasAdminRating
|
||||
FROM Tasks t
|
||||
INNER JOIN Users u ON u.ID = t.ClaimedByUserID
|
||||
INNER JOIN Users u ON u.UserID = t.ClaimedByUserID
|
||||
LEFT JOIN Orders o ON o.ID = t.OrderID
|
||||
LEFT JOIN Users cu ON cu.ID = o.UserID
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
|
||||
LEFT JOIN Users cu ON cu.UserID = o.UserID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = o.ServicePointID
|
||||
WHERE t.BusinessID = :businessID
|
||||
AND t.CompletedOn IS NOT NULL
|
||||
AND t.CompletedOn > DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@
|
|||
o.ServicePointID,
|
||||
o.Remarks,
|
||||
o.SubmittedOn,
|
||||
sp.Name AS ServicePointName,
|
||||
sp.TypeID AS ServicePointTypeID,
|
||||
u.ID AS CustomerUserID,
|
||||
u.FirstName,
|
||||
u.LastName,
|
||||
u.ContactNumber
|
||||
sp.ServicePointName AS ServicePointName,
|
||||
sp.ServicePointTypeID AS ServicePointTypeID,
|
||||
u.UserID AS CustomerUserID,
|
||||
u.UserFirstName AS FirstName,
|
||||
u.UserLastName AS LastName,
|
||||
u.UserContactNumber AS ContactNumber
|
||||
FROM Tasks t
|
||||
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
|
||||
LEFT JOIN Orders o ON o.ID = t.OrderID
|
||||
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
|
||||
LEFT JOIN Users u ON u.ID = o.UserID
|
||||
LEFT JOIN ServicePoints sp ON sp.ServicePointID = o.ServicePointID
|
||||
LEFT JOIN Users u ON u.UserID = o.UserID
|
||||
WHERE t.ID = ?
|
||||
", [ { value = TaskID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
|
||||
|
||||
|
|
@ -129,7 +129,7 @@
|
|||
SELECT b.UUID
|
||||
FROM ServicePoints sp_link
|
||||
INNER JOIN Beacons b ON b.ID = sp_link.BeaconID
|
||||
WHERE sp_link.ID = ?
|
||||
WHERE sp_link.ServicePointID = ?
|
||||
AND b.IsActive = 1
|
||||
LIMIT 1
|
||||
", [ { value = qTask.ServicePointID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@
|
|||
tt.Name AS TaskTypeName,
|
||||
tt.Icon AS TaskTypeIcon,
|
||||
tt.Color AS TaskTypeColor,
|
||||
b.Name AS BusinessName
|
||||
b.BusinessName AS BusinessName
|
||||
FROM Tasks t
|
||||
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
|
||||
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.BusinessID = t.BusinessID
|
||||
WHERE #whereSQL#
|
||||
ORDER BY t.ClaimedOn DESC
|
||||
", params, { datasource = "payfrit" })>
|
||||
|
|
|
|||
Reference in a new issue