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");
$sql = "SELECT * FROM `kazan` WHERE `country` = :country";
$stmt = $con->prepare($sql);
$stmt->bindParam(':country', $country, PDO::PARAM_STR);
$stmt->execute();
if (!empty($country)) {
$sql = "SELECT * FROM `kazan` WHERE `country` = :country";
$stmt = $con->prepare($sql);
$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);
if ($row) {
jsonSuccess($row);
} else {
jsonError("No Kazan record found");
jsonSuccess([], "No Kazan record found");
}
?>

View File

@@ -5,7 +5,7 @@ $id = filterRequest("id");
$allowedFields = [
"kazan", "comfortPrice", "speedPrice", "deliveryPrice",
"freePrice", "latePrice", "heavyPrice", "adminId", "createdAt", "naturePrice"
"freePrice", "latePrice", "heavyPrice", "adminId", "naturePrice", "fuelPrice", "familyPrice"
];
$setParts = [];
@@ -33,6 +33,7 @@ $stmt->execute($params);
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Kazan data updated successfully");
} 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
require_once __DIR__ . '/../../connect.php';
$promoCode = filterRequest("promoCode");
$promo_code = filterRequest("promo_code");
$amount = filterRequest("amount");
$description = filterRequest("description");
$passengerID = filterRequest("passengerID"); // يفترض أنه ID وليس قيمة مشفرة
$passengerID = filterRequest("passengerID");
if (empty($promo_code)) {
jsonError("Promo code is required");
exit;
}
$sql = "INSERT INTO `promos`(
`promo_code`, `amount`, `description`, `passengerID`,
`validity_start_date`, `validity_end_date`
)
VALUES (
:promoCode, :amount, :description, :passengerID,
NOW(), DATE_ADD(NOW(), INTERVAL 1 WEEK)
:promo_code, :amount, :description, :passengerID,
NOW(), DATE_ADD(NOW(), INTERVAL 1 MONTH)
)";
$stmt = $con->prepare($sql);
$stmt->bindValue(':promoCode', $promoCode);
$stmt->bindValue(':promo_code', $promo_code);
$stmt->bindValue(':amount', $amount);
$stmt->bindValue(':description', $description);
$stmt->bindValue(':passengerID', $passengerID);
$stmt->execute();
if ($stmt->rowCount() > 0) {
if ($stmt->execute()) {
jsonSuccess(null, "Promo data saved successfully");
} else {
jsonError("Failed to save promo data");

View File

@@ -3,27 +3,28 @@ require_once __DIR__ . '/../../connect.php';
$promo_code = filterRequest("promo_code");
$sql = "SELECT
`id`,
`promo_code`,
`amount`,
`description`,
`validity_start_date`,
`validity_end_date`
FROM
`promos`
WHERE
`promo_code` = :promo_code
AND CURDATE() BETWEEN validity_start_date AND validity_end_date";
if (!empty($promo_code)) {
$sql = "SELECT `id`, `promo_code`, `amount`, `description`, `passengerID`, `validity_start_date`, `validity_end_date`
FROM `promos`
WHERE `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);
} else {
$sql = "SELECT `id`, `promo_code`, `amount`, `description`, `passengerID`, `validity_start_date`, `validity_end_date` FROM `promos` ORDER BY id DESC";
$stmt = $con->prepare($sql);
}
$stmt = $con->prepare($sql);
$stmt->bindParam(':promo_code', $promo_code, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result) {
if ($result || (empty($promo_code) && is_array($result))) {
jsonSuccess($result);
} 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';
$id = filterRequest("id");
$promoCode = filterRequest("promoCode");
$description = filterRequest("description");
$validityStartDate = filterRequest("validityStartDate");
$validityEndDate = filterRequest("validityEndDate");
if (empty($id)) {
jsonError("ID is required for update");
exit;
}
$sql = "UPDATE `promos` SET
`promo_code` = :promoCode,
`description` = :description,
`validity_start_date` = :validityStartDate,
`validity_end_date` = :validityEndDate
WHERE `id` = :id";
$allowedFields = [
"promo_code", "amount", "description", "passengerID",
"validity_start_date", "validity_end_date"
];
$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->bindParam(':promoCode', $promoCode);
stmt->bindParam(':description', $description);
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");
if ($stmt->execute($params)) {
jsonSuccess(null, "Promo updated successfully");
} else {
jsonError("Failed to update promo data");
jsonError("Failed to update promo");
}
?>

View File

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