diff --git a/ride/kazan/get.php b/ride/kazan/get.php index b411b8b..d46ab22 100644 --- a/ride/kazan/get.php +++ b/ride/kazan/get.php @@ -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"); } ?> \ No newline at end of file diff --git a/ride/kazan/update.php b/ride/kazan/update.php index a496b71..eccda75 100644 --- a/ride/kazan/update.php +++ b/ride/kazan/update.php @@ -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"); } ?> \ No newline at end of file diff --git a/ride/promo/add.php b/ride/promo/add.php index f635b0f..7ff5c61 100755 --- a/ride/promo/add.php +++ b/ride/promo/add.php @@ -1,29 +1,32 @@ 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"); diff --git a/ride/promo/get.php b/ride/promo/get.php index ac8dcb6..6d18edf 100644 --- a/ride/promo/get.php +++ b/ride/promo/get.php @@ -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"); + } } ?> \ No newline at end of file diff --git a/ride/promo/update.php b/ride/promo/update.php index dd12d43..4e18765 100644 --- a/ride/promo/update.php +++ b/ride/promo/update.php @@ -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"); } ?> \ No newline at end of file diff --git a/serviceapp/getComplaintAllData.php b/serviceapp/getComplaintAllData.php index aa2a9cc..14ff6af 100644 --- a/serviceapp/getComplaintAllData.php +++ b/serviceapp/getComplaintAllData.php @@ -1,6 +1,5 @@ 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"); } ?> \ No newline at end of file diff --git a/serviceapp/update_complaint.php b/serviceapp/update_complaint.php new file mode 100644 index 0000000..955dada --- /dev/null +++ b/serviceapp/update_complaint.php @@ -0,0 +1,30 @@ +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"); +} +?>