This commit is contained in:
Hamza-Ayed
2026-05-01 02:08:21 +03:00
parent 989f6332f9
commit e68dda58d3
7 changed files with 119 additions and 69 deletions

View File

@@ -3,16 +3,21 @@ require_once __DIR__ . '/../../connect.php';
$country = filterRequest("country"); $country = filterRequest("country");
$sql = "SELECT * FROM `kazan` WHERE `country` = :country"; if (!empty($country)) {
$stmt = $con->prepare($sql); $sql = "SELECT * FROM `kazan` WHERE `country` = :country";
$stmt->bindParam(':country', $country, PDO::PARAM_STR); $stmt = $con->prepare($sql);
$stmt->execute(); $stmt->bindParam(':country', $country, PDO::PARAM_STR);
} else {
$sql = "SELECT * FROM `kazan` ORDER BY id DESC";
$stmt = $con->prepare($sql);
}
$stmt->execute();
$row = $stmt->fetchAll(PDO::FETCH_ASSOC); $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($row) { if ($row) {
jsonSuccess($row); jsonSuccess($row);
} else { } else {
jsonError("No Kazan record found"); jsonSuccess([], "No Kazan record found");
} }
?> ?>

View File

@@ -5,7 +5,7 @@ $id = filterRequest("id");
$allowedFields = [ $allowedFields = [
"kazan", "comfortPrice", "speedPrice", "deliveryPrice", "kazan", "comfortPrice", "speedPrice", "deliveryPrice",
"freePrice", "latePrice", "heavyPrice", "adminId", "createdAt", "naturePrice" "freePrice", "latePrice", "heavyPrice", "adminId", "naturePrice", "fuelPrice", "familyPrice"
]; ];
$setParts = []; $setParts = [];
@@ -33,6 +33,7 @@ $stmt->execute($params);
if ($stmt->rowCount() > 0) { if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Kazan data updated successfully"); jsonSuccess(null, "Kazan data updated successfully");
} else { } else {
jsonError("Failed to update kazan data"); // 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");
} }
?> ?>

View File

@@ -1,29 +1,32 @@
<?php <?php
require_once __DIR__ . '/../../connect.php'; require_once __DIR__ . '/../../connect.php';
$promoCode = filterRequest("promoCode"); $promo_code = filterRequest("promo_code");
$amount = filterRequest("amount"); $amount = filterRequest("amount");
$description = filterRequest("description"); $description = filterRequest("description");
$passengerID = filterRequest("passengerID"); // يفترض أنه ID وليس قيمة مشفرة $passengerID = filterRequest("passengerID");
if (empty($promo_code)) {
jsonError("Promo code is required");
exit;
}
$sql = "INSERT INTO `promos`( $sql = "INSERT INTO `promos`(
`promo_code`, `amount`, `description`, `passengerID`, `promo_code`, `amount`, `description`, `passengerID`,
`validity_start_date`, `validity_end_date` `validity_start_date`, `validity_end_date`
) )
VALUES ( VALUES (
:promoCode, :amount, :description, :passengerID, :promo_code, :amount, :description, :passengerID,
NOW(), DATE_ADD(NOW(), INTERVAL 1 WEEK) NOW(), DATE_ADD(NOW(), INTERVAL 1 MONTH)
)"; )";
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindValue(':promoCode', $promoCode); $stmt->bindValue(':promo_code', $promo_code);
$stmt->bindValue(':amount', $amount); $stmt->bindValue(':amount', $amount);
$stmt->bindValue(':description', $description); $stmt->bindValue(':description', $description);
$stmt->bindValue(':passengerID', $passengerID); $stmt->bindValue(':passengerID', $passengerID);
$stmt->execute(); if ($stmt->execute()) {
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Promo data saved successfully"); jsonSuccess(null, "Promo data saved successfully");
} else { } else {
jsonError("Failed to save promo data"); jsonError("Failed to save promo data");

View File

@@ -3,27 +3,28 @@ require_once __DIR__ . '/../../connect.php';
$promo_code = filterRequest("promo_code"); $promo_code = filterRequest("promo_code");
$sql = "SELECT if (!empty($promo_code)) {
`id`, $sql = "SELECT `id`, `promo_code`, `amount`, `description`, `passengerID`, `validity_start_date`, `validity_end_date`
`promo_code`, FROM `promos`
`amount`, WHERE `promo_code` = :promo_code
`description`, AND CURDATE() BETWEEN validity_start_date AND validity_end_date";
`validity_start_date`, $stmt = $con->prepare($sql);
`validity_end_date` $stmt->bindParam(':promo_code', $promo_code, PDO::PARAM_STR);
FROM } else {
`promos` $sql = "SELECT `id`, `promo_code`, `amount`, `description`, `passengerID`, `validity_start_date`, `validity_end_date` FROM `promos` ORDER BY id DESC";
WHERE $stmt = $con->prepare($sql);
`promo_code` = :promo_code }
AND CURDATE() BETWEEN validity_start_date AND validity_end_date";
$stmt = $con->prepare($sql);
$stmt->bindParam(':promo_code', $promo_code, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC); $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result) { if ($result || (empty($promo_code) && is_array($result))) {
jsonSuccess($result); jsonSuccess($result);
} else { } else {
jsonError("Failed to retrieve promo records"); if (!empty($promo_code)) {
jsonError("Promo code not found or expired");
} else {
jsonSuccess([], "No promos found");
}
} }
?> ?>

View File

@@ -2,30 +2,39 @@
require_once __DIR__ . '/../../connect.php'; require_once __DIR__ . '/../../connect.php';
$id = filterRequest("id"); $id = filterRequest("id");
$promoCode = filterRequest("promoCode"); if (empty($id)) {
$description = filterRequest("description"); jsonError("ID is required for update");
$validityStartDate = filterRequest("validityStartDate"); exit;
$validityEndDate = filterRequest("validityEndDate"); }
$sql = "UPDATE `promos` SET $allowedFields = [
`promo_code` = :promoCode, "promo_code", "amount", "description", "passengerID",
`description` = :description, "validity_start_date", "validity_end_date"
`validity_start_date` = :validityStartDate, ];
`validity_end_date` = :validityEndDate
WHERE `id` = :id"; $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 `promos` SET " . implode(", ", $setParts) . " WHERE `id` = :id";
$params[":id"] = $id;
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindParam(':promoCode', $promoCode); if ($stmt->execute($params)) {
stmt->bindParam(':description', $description); jsonSuccess(null, "Promo updated successfully");
stmt->bindParam(':validityStartDate', $validityStartDate);
$stmt->bindParam(':validityEndDate', $validityEndDate);
stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Promo data updated successfully");
} else { } else {
jsonError("Failed to update promo data"); jsonError("Failed to update promo");
} }
?> ?>

View File

@@ -1,6 +1,5 @@
<?php <?php
require_once __DIR__ . '/../connect.php'; require_once __DIR__ . '/../connect.php';
// $driverID = filterRequest("driverID");
$sql = "SELECT $sql = "SELECT
cm.`id`, cm.`id`,
@@ -18,7 +17,7 @@ $sql = "SELECT
d.gender, d.gender,
ride.price AS priceOfRide, ride.price AS priceOfRide,
ride.status AS rideStatus, ride.status AS rideStatus,
ride.carType ascarType, ride.carType AS carType,
ride.paymentMethod AS ridePaymentMethod, ride.paymentMethod AS ridePaymentMethod,
ride.rideTimeFinish AS rideTimeFinish, ride.rideTimeFinish AS rideTimeFinish,
payments.amount as paymentFromPaymentTable, payments.amount as paymentFromPaymentTable,
@@ -152,32 +151,34 @@ LEFT JOIN driver d ON
d.id = cm.driver_id d.id = cm.driver_id
LEFT JOIN ride ON ride.id = cm.ride_id LEFT JOIN ride ON ride.id = cm.ride_id
left join payments on payments.rideId=cm.ride_id"; left join payments on payments.rideId=cm.ride_id";
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->execute(); $stmt->execute();
if ($stmt->rowCount() > 0) { $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($row) {
foreach ($row as &$item) { foreach ($row as &$item) {
if (isset($item['passengerName'])) { if (!empty($item['passengerName'])) {
$item['passengerName'] = $encryptionHelper->decryptData($item['passengerName']); $dec = $encryptionHelper->decryptData($item['passengerName']);
if ($dec) $item['passengerName'] = $dec;
} }
if (isset($item['driverName'])) { if (!empty($item['driverName'])) {
$item['driverName'] = $encryptionHelper->decryptData($item['driverName']); $dec = $encryptionHelper->decryptData($item['driverName']);
if ($dec) $item['driverName'] = $dec;
} }
if (isset($item['gender'])) { if (!empty($item['driverToken'])) {
$item['gender'] = $encryptionHelper->decryptData($item['gender']); $dec = $encryptionHelper->decryptData($item['driverToken']);
if ($dec) $item['driverToken'] = $dec;
} }
if (isset($item['driverToken'])) { if (!empty($item['passengerToken'])) {
$item['driverToken'] = $encryptionHelper->decryptData($item['driverToken']); $dec = $encryptionHelper->decryptData($item['passengerToken']);
} if ($dec) $item['passengerToken'] = $dec;
if (isset($item['passengerToken'])) {
$item['passengerToken'] = $encryptionHelper->decryptData($item['passengerToken']);
} }
} }
jsonSuccess($row); jsonSuccess($row);
} else { } else {
jsonError("No wallet record found"); // Return empty success for admin dashboard instead of error
jsonSuccess([], "No complaints found");
} }
?> ?>

View File

@@ -0,0 +1,30 @@
<?php
require_once __DIR__ . '/../connect.php';
$id = filterRequest("id");
$status = filterRequest("statusComplaint");
$resolution = filterRequest("resolution");
if ($id && $status) {
$sql = "UPDATE `complaint` SET `statusComplaint` = :status, `resolution` = :resolution";
if ($status == 'Resolved') {
$sql .= ", `date_resolved` = CURRENT_TIMESTAMP";
}
$sql .= " WHERE `id` = :id";
$stmt = $con->prepare($sql);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':resolution', $resolution);
$stmt->bindParam(':id', $id);
if ($stmt->execute()) {
jsonSuccess(null, "Complaint updated successfully");
} else {
jsonError("Failed to update complaint");
}
} else {
jsonError("Missing required fields");
}
?>