payfrit-api/api/servicepoints/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

29 lines
881 B
PHP

<?php
require_once __DIR__ . '/../helpers.php';
runAuth();
global $businessId;
$data = readJsonBody();
$bizId = $businessId;
if ($bizId <= 0) $bizId = (int) ($data['BusinessID'] ?? 0);
if ($bizId <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'no_business_selected']);
}
$servicePointId = (int) ($data['ServicePointID'] ?? 0);
if ($servicePointId <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'missing_servicepoint_id', 'MESSAGE' => 'ServicePointID is required']);
}
queryTimed("UPDATE ServicePoints SET IsActive = 0 WHERE ID = ? AND BusinessID = ?",
[$servicePointId, $bizId]);
$qCheck = queryOne("SELECT ID, IsActive FROM ServicePoints WHERE ID = ? AND BusinessID = ? LIMIT 1",
[$servicePointId, $bizId]);
if (!$qCheck) {
apiAbort(['OK' => false, 'ERROR' => 'not_found']);
}
jsonResponse(['OK' => true, 'ERROR' => '', 'ServicePointID' => $servicePointId]);