payfrit-works/api/admin/debugEmployees.cfm
John Mizerek 0a10380639 Add template modifier support and fix KDS breadcrumbs
- setLineItem.cfm: Attach default children from ItemTemplateLinks
  (fixes drink choices not being saved for combos)
- listForKDS.cfm: Include ItemParentName for modifier categories
- kds.js: Display modifiers as "Category: Selection" format
- Various other accumulated fixes for menu builder, orders, and admin

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:45:06 -08:00

95 lines
2.8 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfscript>
data = {};
try {
requestBody = toString(getHttpRequestData().content);
if (len(requestBody)) data = deserializeJSON(requestBody);
} catch (any e) {}
// If Phone provided, look up user and their employee records
if (structKeyExists(data, "Phone") && len(data.Phone)) {
phone = reReplace(data.Phone, "[^0-9]", "", "all");
qUser = queryExecute("
SELECT UserID, UserFirstName, UserLastName, UserEmailAddress, UserContactNumber
FROM Users
WHERE REPLACE(REPLACE(REPLACE(UserContactNumber, '-', ''), '(', ''), ')', '') LIKE ?
OR UserContactNumber LIKE ?
", [
{ value: "%" & phone & "%", cfsqltype: "cf_sql_varchar" },
{ value: "%" & phone & "%", cfsqltype: "cf_sql_varchar" }
], { datasource: "payfrit" });
if (qUser.recordCount == 0) {
writeOutput(serializeJSON({ "OK": false, "ERROR": "user_not_found", "PHONE": phone }));
abort;
}
userId = qUser.UserID;
qEmployees = queryExecute("
SELECT e.EmployeeID, e.BusinessID, e.EmployeeStatusID,
CAST(e.EmployeeIsActive AS UNSIGNED) AS EmployeeIsActive,
b.BusinessName
FROM lt_Users_Businesses_Employees e
JOIN Businesses b ON e.BusinessID = b.BusinessID
WHERE e.UserID = ?
", [{ value: userId, cfsqltype: "cf_sql_integer" }], { datasource: "payfrit" });
employees = [];
for (row in qEmployees) {
arrayAppend(employees, {
"EmployeeID": row.EmployeeID,
"BusinessID": row.BusinessID,
"BusinessName": row.BusinessName,
"StatusID": row.EmployeeStatusID,
"IsActive": row.EmployeeIsActive
});
}
writeOutput(serializeJSON({
"OK": true,
"USER": {
"UserID": qUser.UserID,
"Name": trim(qUser.UserFirstName & " " & qUser.UserLastName),
"Email": qUser.UserEmailAddress,
"Phone": qUser.UserContactNumber
},
"EMPLOYEES": employees
}));
abort;
}
// Original behavior - list employees by BusinessID
businessId = structKeyExists(data, "BusinessID") ? val(data.BusinessID) : 17;
q = queryExecute("
SELECT EmployeeID, UserID, EmployeeStatusID, EmployeeIsActive,
CAST(EmployeeIsActive AS UNSIGNED) AS IsActiveInt
FROM lt_Users_Businesses_Employees
WHERE BusinessID = ?
", [{ value: businessId, cfsqltype: "cf_sql_integer" }], { datasource: "payfrit" });
rows = [];
for (r in q) {
arrayAppend(rows, {
"EmployeeID": r.EmployeeID,
"UserID": r.UserID,
"StatusID": r.EmployeeStatusID,
"RawIsActive": r.EmployeeIsActive,
"CastIsActive": r.IsActiveInt,
"ValRaw": val(r.EmployeeIsActive),
"ValCast": val(r.IsActiveInt),
"EqRaw1": r.EmployeeIsActive == 1,
"EqCast1": r.IsActiveInt == 1
});
}
writeOutput(serializeJSON({
"OK": true,
"ROWS": rows
}));
</cfscript>