Files
intaleq_v3_pure_php/ride/kazan/update.php
2026-05-10 01:11:44 +03:00

42 lines
1.3 KiB
PHP

<?php
require_once __DIR__ . '/../../connect.php';
$id = filterRequest("id");
$allowedFields = [
"kazan", "comfortPrice", "speedPrice", "deliveryPrice",
"freePrice", "latePrice", "heavyPrice", "adminId", "naturePrice", "fuelPrice", "familyPrice"
];
$setParts = [];
$params = [];
foreach ($allowedFields as $field) {
if (isset($_POST[$field])) {
$value = filterRequest($field);
$setParts[] = "`$field` = :$field";
$params[":$field"] = $value;
}
}
if (empty($setParts)) {
jsonError("No valid fields to update.");
exit;
}
$sql = "UPDATE `kazan` SET " . implode(", ", $setParts) . " WHERE `id` = :id";
$params[":id"] = $id;
$stmt = $con->prepare($sql);
$stmt->execute($params);
// تسجيل العملية في السجل دائماً (حتى لو لم تتغير القيمة) لضمان الشفافية
$auditResult = logAudit($con, $user_id ?? 'unknown_admin', "تحديث عمولة/أسعار النظام (Kazan)", "kazan", $id, $params);
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Kazan data updated successfully. Audit: " . ($auditResult === true ? 'OK' : $auditResult));
} else {
// If no rows were changed but execute was successful, it might be because the data is the same
jsonSuccess(null, "Kazan data remains unchanged or updated. Audit: " . ($auditResult === true ? 'OK' : $auditResult));
}
?>