Complete port of all 163 API endpoints from Lucee/CFML to PHP 8.3. Shared helpers in api/helpers.php (DB, auth, request/response, security). PDO prepared statements throughout. Same JSON response shapes as CFML.
35 lines
1 KiB
PHP
35 lines
1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../helpers.php';
|
|
runAuth();
|
|
|
|
$data = readJsonBody();
|
|
$bizId = (int) ($data['BusinessID'] ?? 0);
|
|
|
|
if ($bizId <= 0) {
|
|
apiAbort(['OK' => false, 'ERROR' => 'missing_businessid', 'MESSAGE' => 'BusinessID is required.']);
|
|
}
|
|
|
|
try {
|
|
$rows = queryTimed("
|
|
SELECT ID, BusinessID, Name, Color, SortOrder
|
|
FROM Stations
|
|
WHERE BusinessID = ? AND IsActive = 1
|
|
ORDER BY SortOrder, ID
|
|
", [$bizId]);
|
|
|
|
$stations = [];
|
|
foreach ($rows as $r) {
|
|
$stations[] = [
|
|
'StationID' => (int) $r['ID'],
|
|
'BusinessID' => (int) $r['BusinessID'],
|
|
'Name' => $r['Name'],
|
|
'Color' => $r['Color'],
|
|
'SortOrder' => (int) $r['SortOrder'],
|
|
];
|
|
}
|
|
|
|
jsonResponse(['OK' => true, 'ERROR' => '', 'STATIONS' => $stations, 'COUNT' => count($stations)]);
|
|
|
|
} catch (Exception $e) {
|
|
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => 'DB error loading stations', 'DETAIL' => $e->getMessage()]);
|
|
}
|