Initial commit with updated Auth and media ignored

This commit is contained in:
Hamza-Ayed
2026-04-28 13:04:27 +03:00
commit 67af97474c
477 changed files with 66444 additions and 0 deletions

42
ride/payment/add.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
require_once __DIR__ . '/../../connect.php';
$amount = filterRequest("amount");
$payment_method = filterRequest("payment_method");
$passengerID = filterRequest("passengerID");
$rideId = filterRequest("rideId");
$driverID = filterRequest("driverID");
$token = filterRequest("token");
// Retrieve token details from the database
$stmt = $con->prepare("SELECT * FROM payment_tokens WHERE token = :token AND isUsed = FALSE");
$stmt->execute(array(
':token' => $token
));
$tokenData = $stmt->fetch();
if ($tokenData) {
$sql = "INSERT INTO `payments` (`id`,`amount`, `payment_method`, `passengerID`, `rideId`, `driverID`)
VALUES ( SHA2(UUID(), 256),'$amount', '$payment_method', '$passengerID', '$rideId', '$driverID')";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
jsonSuccess(null, "Payment record created successfully");
// Mark the token as used in the database
$stmt = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE id = :tokenID");
$stmt->execute(array(
':tokenID' => $tokenData['id']
));
} else {
// Print a failure message
jsonError("Failed to save record");
}
} else {
jsonError("Invalid or already used token");
}

0
ride/payment/delete.php Normal file
View File

0
ride/payment/error_log Normal file
View File

61
ride/payment/get.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driverID = filterRequest("driverID");
$sql = "SELECT
p1.id,
p1.amount,
p2.total_amount,
p1.payment_method,
p1.isGiven,
p1.passengerID,
p1.rideId,
p1.driverID,
(
SELECT SUM(amount)
FROM payments
WHERE driverID = '$driverID'
AND DATE(created_at) = CURDATE()
) AS todayAmount,
p1.created_at,
p1.updated_at,
(
SELECT ROUND(AVG(CAST(rating AS DECIMAL(4,2))), 2)
FROM ratingDriver
WHERE driver_id = '$driverID'
) AS rating
FROM payments p1
JOIN (
SELECT driverID, SUM(amount) AS total_amount
FROM payments
WHERE isGiven = 'waiting'
GROUP BY driverID
) p2 ON p1.driverID = p2.driverID
WHERE p1.isGiven = 'waiting'
AND p1.driverID = '$driverID'
AND DATE(p1.created_at) = CURDATE(); ";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
// $response = array(
// "message" => "Payment data saved successfully",
// "id" => "0",
// "count" => $count,
// "data" => $rows
// );
// echo json_encode($response);
jsonSuccess($row);
}
else{
// Print a failure message
jsonError($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,64 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driverID = filterRequest("driverID");
$sql = "SELECT
(
SELECT
COUNT(*)
FROM
`ride`
WHERE
`ride`.`status` = 'Finished'
AND `ride`.`created_at` BETWEEN CURRENT_DATE() + INTERVAL 7 HOUR AND CURRENT_DATE() + INTERVAL 10 HOUR
AND `ride`.`driver_id` = '$driverID'
) AS morning_count,
(
SELECT
COUNT(*)
FROM
`ride`
WHERE
`ride`.`status` = 'Finished'
AND `ride`.`created_at` BETWEEN CURRENT_DATE() + INTERVAL 15 HOUR AND CURRENT_DATE() + INTERVAL 18 HOUR
AND `ride`.`driver_id` = '$driverID'
) AS afternoon_count,
(
SELECT
COALESCE(SUM(amount), 0) AS total_amount
FROM
payments
WHERE
isGiven = 'waiting' AND `driverID` = '$driverID'
) AS driver_total,
(
SELECT
COALESCE(SUM(price), 0) AS total_amount
FROM
ride
WHERE
`driver_id` = '$driverID'
AND `ride`.`status` = 'Finished'
AND `ride`.`created_at` > CURRENT_DATE() - INTERVAL 1 WEEK
) AS total_amount_last_week
FROM
dual
LIMIT 1;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
jsonSuccess($row);
}
else{
// Print a failure message
jsonError($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,39 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driverID = filterRequest("driverID");
$sql = "SELECT
driverID,
COALESCE(SUM(amount), 0) AS total_amount,
COALESCE(SUM(amount), 0) + COALESCE(
(
SELECT
SUM(`amount`)
FROM
`paymentsDriverPoints`
WHERE
`payment_method` = 'fromBudgetToPoints' AND `driverID` = '$driverID'
),
0
) AS diff
FROM
payments
WHERE
isGiven = 'waiting'
AND `payment_method` IN ('visa-in', 'visa', 'visaRide', 'TransferFrom', 'payout', 'TransferTo')
AND `driverID` = '$driverID'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
jsonSuccess($row);
}
else{
// Print a failure message
jsonError($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,29 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driver_id = filterRequest("driver_id");
$sql = "SELECT
COUNT(id) AS count
FROM
`ride`
WHERE
`ride`.`status` = 'Finished'
AND driver_id = '$driver_id'
AND created_at >= CURDATE();
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
jsonSuccess($row);
}
else{
// Print a failure message
jsonError($message = "No wallet record found");
}
?>

65
ride/payment/update.php Normal file
View File

@@ -0,0 +1,65 @@
<?php
require_once __DIR__ . '/../../connect.php';
$id = filterRequest("id");
// Create an empty array to store the column-value pairs
$columnValues = array();
// Check if each column is set in the request and add it to the array
if (isset($_POST["amount"])) {
$amount = filterRequest("amount");
$columnValues[] = "`amount` = '$amount'";
}
if (isset($_POST["payment_method"])) {
$payment_method = filterRequest("payment_method");
$columnValues[] = "`payment_method` = '$payment_method'";
}
if (isset($_POST["passengerID"])) {
$passengerID = filterRequest("passengerID");
$columnValues[] = "`passengerID` = '$passengerID'";
}
if (isset($_POST["rideId"])) {
$rideId = filterRequest("rideId");
$columnValues[] = "`rideId` = '$rideId'";
}
if (isset($_POST["driverID"])) {
$driverID = filterRequest("driverID");
$columnValues[] = "`driverID` = '$driverID'";
}
if (isset($_POST["created_at"])) {
$created_at = filterRequest("created_at");
$columnValues[] = "`created_at` = '$created_at'";
}
if (isset($_POST["updated_at"])) {
$updated_at = filterRequest("updated_at");
$columnValues[] = "`updated_at` = '$updated_at'";
}
if (isset($_POST["isGiven"])) {
$isGiven = filterRequest("isGiven");
$columnValues[] = "`isGiven` = '$isGiven'";
}
// Construct the SET clause of the update query using the column-value pairs
$setClause = implode(", ", $columnValues);
$sql = "UPDATE `payments` SET $setClause WHERE `id` = '$id'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
jsonSuccess($message = "Payment data updated successfully");
} else {
// Print a failure message
jsonError($message = "Failed to update payment data");
}
?>

View File

@@ -0,0 +1,19 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driverID = filterRequest("driverID");
$sql = "UPDATE `payments` SET `isGiven`='Paid' WHERE driverID='$driverID'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
jsonSuccess($message = "Payment data updated successfully");
} else {
// Print a failure message
jsonError($message = "Failed to update payment data");
}
?>