19 lines
783 B
PHP
19 lines
783 B
PHP
<?php
|
|
// transit/vehicle/toggle.php — تفعيل/تعطيل مركبة
|
|
// POST: vehicle_id, is_active (1|0)
|
|
|
|
require_once __DIR__ . '/../../transit/connect_admin.php';
|
|
|
|
$vehicleId = filterRequest('vehicle_id', 'int');
|
|
$isActive = filterRequest('is_active', 'int');
|
|
if (!$vehicleId || $isActive === null) jsonError('vehicle_id and is_active are required', 400);
|
|
|
|
$chk = $transit_con->prepare("SELECT id FROM transit_vehicles WHERE id=? AND org_id=? LIMIT 1");
|
|
$chk->execute([$vehicleId, $transit_org_id]);
|
|
if (!$chk->fetch()) jsonError('Vehicle not found or access denied', 404);
|
|
|
|
$transit_con->prepare("UPDATE transit_vehicles SET is_active=? WHERE id=?")
|
|
->execute([$isActive ? 1 : 0, $vehicleId]);
|
|
|
|
jsonSuccess(['vehicle_id' => $vehicleId, 'is_active' => (bool)$isActive]);
|