payfrit-api/api/stations/delete.php
John Mizerek 1f81d98c52 Initial PHP API migration from CFML
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.
2026-03-14 14:26:59 -07:00

24 lines
888 B
PHP

<?php
require_once __DIR__ . '/../helpers.php';
runAuth();
$data = readJsonBody();
$bizId = (int) ($data['BusinessID'] ?? 0);
$stationId = (int) ($data['StationID'] ?? 0);
if ($bizId <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'missing_businessid', 'MESSAGE' => 'BusinessID is required.']);
}
if ($stationId <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'missing_stationid', 'MESSAGE' => 'StationID is required.']);
}
try {
queryTimed("UPDATE Stations SET IsActive = 0 WHERE ID = ? AND BusinessID = ?", [$stationId, $bizId]);
queryTimed("UPDATE Items SET StationID = 0 WHERE StationID = ? AND BusinessID = ?", [$stationId, $bizId]);
jsonResponse(['OK' => true, 'ERROR' => '', 'StationID' => $stationId]);
} catch (Exception $e) {
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => 'Failed to delete station', 'DETAIL' => $e->getMessage()]);
}