This repository has been archived on 2026-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
payfrit-biz/admin/servicepoints.cfm
John Mizerek 1210249f54 Normalize database column and table names across entire codebase
Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).

Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
  Addresses, Hours, Menus, Categories, Items, Stations, Orders,
  OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
  ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
  VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
  tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
  dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
  Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
  UserIsActive→IsActive, UserBalance→Balance, etc.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:39:12 -08:00

233 lines
6.4 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="text/html; charset=utf-8" reset="true">
<cfoutput>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Payfrit Admin - ServicePoints</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
input, button, select { padding: 8px; margin: 6px 0; width: 520px; max-width: 100%; }
button { width: auto; cursor: pointer; }
table { border-collapse: collapse; width: 100%; margin-top: 12px; }
th, td { border: 1px solid ##ddd; padding: 8px; }
th { background: ##f5f5f5; text-align: left; }
.row { display: flex; gap: 24px; flex-wrap: wrap; }
.card { border: 1px solid ##ddd; padding: 14px; border-radius: 10px; flex: 1; min-width: 320px; }
pre { background: ##111; color: ##0f0; padding: 10px; overflow: auto; border-radius: 8px; min-height: 140px; }
.warn { color: ##b00; font-weight: bold; }
.ok { color: ##060; font-weight: bold; }
</style>
</head>
<body>
<h2>ServicePoints</h2>
<div class="warn">Required: Name</div>
<div class="ok" id="jsStatus">(JS not loaded yet)</div>
<div class="row">
<div class="card">
<h3>Create / Update</h3>
<div>
<label>ServicePointID (blank = create)</label><br>
<input id="ServicePointID" placeholder="e.g. 12">
</div>
<div>
<label>Name (required)</label><br>
<input id="Name" placeholder="Front Counter" required>
</div>
<div>
<label>TypeID</label><br>
<input id="TypeID" placeholder="0">
</div>
<div>
<label>Code</label><br>
<input id="Code" placeholder="COUNTER">
</div>
<div>
<label>Description</label><br>
<input id="Description" placeholder="">
</div>
<div>
<label>SortOrder</label><br>
<input id="SortOrder" placeholder="0">
</div>
<div>
<label>IsActive</label><br>
<select id="IsActive">
<option value="1" selected>1 (Active)</option>
<option value="0">0 (Inactive)</option>
</select>
</div>
<button type="button" onclick="saveSP()">Save</button>
<button type="button" onclick="refresh()">Refresh List</button>
</div>
<div class="card">
<h3>Delete (soft)</h3>
<div>
<label>ServicePointID</label><br>
<input id="DelServicePointID" placeholder="e.g. 12">
</div>
<button type="button" onclick="deleteSP()">Delete</button>
<h3>Response</h3>
<pre id="resp"></pre>
</div>
</div>
<h3>ServicePoint List (click row to load)</h3>
<table>
<thead>
<tr>
<th>ServicePointID</th>
<th>Name</th>
<th>TypeID</th>
<th>Code</th>
<th>SortOrder</th>
<th>IsActive</th>
</tr>
</thead>
<tbody id="rows"></tbody>
</table>
<script>
(function boot(){
document.getElementById("jsStatus").textContent = "JS loaded OK - BusinessID: #request.BusinessID#";
})();
const BUSINESS_ID = #val(request.BusinessID)#;
function show(o){
document.getElementById("resp").textContent = JSON.stringify(o, null, 2);
}
const API_BASE = "/biz.payfrit.com/api";
async function api(path, bodyObj) {
const fullPath = API_BASE + path;
bodyObj = bodyObj || {};
bodyObj.BusinessID = BUSINESS_ID;
try {
const res = await fetch(fullPath, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(bodyObj)
});
const txt = await res.text();
try {
const parsed = JSON.parse(txt);
parsed._httpStatus = res.status;
parsed._path = fullPath;
return parsed;
} catch {
return { OK:false, ERROR:"non_json", RAW:txt, _httpStatus: res.status, _path: fullPath };
}
} catch (e) {
return { OK:false, ERROR:"network_error", MESSAGE:String(e), _path: fullPath };
}
}
function valIntOrNull(id){
const v = (document.getElementById(id).value||"").trim();
if (!v) return null;
const n = parseInt(v, 10);
return isNaN(n) ? null : n;
}
function valIntOrZero(id){
const n = valIntOrNull(id);
return n ? n : 0;
}
function escapeHtml(s){
return (""+s)
.replaceAll("&","&amp;")
.replaceAll("<","&lt;")
.replaceAll(">","&gt;")
.replaceAll('"',"&quot;")
.replaceAll("'","&##039;");
}
function loadIntoForm(sp){
document.getElementById("ServicePointID").value = sp.ID || "";
document.getElementById("Name").value = sp.Name || "";
document.getElementById("TypeID").value = (sp.TypeID ?? 0);
document.getElementById("Code").value = sp.Code || "";
document.getElementById("Description").value = sp.Description || "";
document.getElementById("SortOrder").value = (sp.SortOrder ?? 0);
document.getElementById("IsActive").value = ("" + (sp.IsActive ?? 1));
document.getElementById("DelServicePointID").value = sp.ID || "";
}
async function refresh() {
const out = await api("/servicepoints/list.cfm", {});
show(out);
const tbody = document.getElementById("rows");
tbody.innerHTML = "";
const items = out.SERVICEPOINTS || [];
for (const sp of items) {
const tr = document.createElement("tr");
tr.innerHTML = `
<td>${sp.ID}</td>
<td>${escapeHtml(sp.Name||"")}</td>
<td>${sp.TypeID}</td>
<td>${escapeHtml(sp.Code||"")}</td>
<td>${sp.SortOrder}</td>
<td>${sp.IsActive}</td>
`;
tr.style.cursor = "pointer";
tr.onclick = () => loadIntoForm(sp);
tbody.appendChild(tr);
}
}
async function saveSP() {
const name = (document.getElementById("Name").value || "").trim();
if (!name) {
show({ OK:false, ERROR:"missing_servicepoint_name", MESSAGE:"Name is required" });
return;
}
const body = {
ServicePointID: valIntOrNull("ServicePointID"),
Name: name,
TypeID: valIntOrZero("TypeID"),
Code: (document.getElementById("Code").value || "").trim(),
Description: (document.getElementById("Description").value || "").trim(),
SortOrder: valIntOrZero("SortOrder"),
IsActive: parseInt(document.getElementById("IsActive").value, 10)
};
if (!body.ServicePointID) delete body.ServicePointID;
const out = await api("/servicepoints/save.cfm", body);
show(out);
await refresh();
}
async function deleteSP() {
const id = valIntOrNull("DelServicePointID");
if (!id) { show({OK:false,ERROR:"missing_servicepoint_id"}); return; }
const out = await api("/servicepoints/delete.cfm", { ServicePointID: id });
show(out);
await refresh();
}
refresh();
</script>
</body>
</html>
</cfoutput>