Update: 2026-06-11 18:22:57

This commit is contained in:
Hamza-Ayed
2026-06-11 18:22:59 +03:00
parent c5170a88d2
commit 727068b668
629 changed files with 46050 additions and 46109 deletions

View File

@@ -0,0 +1,31 @@
<?php
include "../connect.php";
// Retrieve and sanitize input parameters
$phone = filterRequest("phone");
$note = filterRequest("note");
$editor = filterRequest("editor");
// SQL query to insert a new note into the notesForDriverService table
$sql = "INSERT INTO `notesForDriverService` ( `phone`, `note`, `editor`)
VALUES (:phone, :note, :editor)";
// Prepare the SQL statement
$stmt = $con->prepare($sql);
// Bind the parameters
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':editor', $editor);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
printSuccess($message = "note inserted successfully");
} else {
// Print a failure message
printFailure($message = "Failed to insert note");
}
?>

View File

@@ -0,0 +1,31 @@
<?php
include "../connect.php";
// Retrieve and sanitize input parameters
$phone = filterRequest("phone");
$note = filterRequest("note");
$editor = filterRequest("editor");
// SQL query to insert a new note into the notesForDriverService table
$sql = "INSERT INTO `notesForPassengerService` ( `phone`, `note`, `editor`)
VALUES (:phone, :note, :editor)";
// Prepare the SQL statement
$stmt = $con->prepare($sql);
// Bind the parameters
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':editor', $editor);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
printSuccess($message = "note inserted successfully");
} else {
// Print a failure message
printFailure($message = "Failed to insert note");
}
?>

View File

@@ -0,0 +1,26 @@
<?php
include "../connect.php";
// Retrieve and sanitize input parameters
$driverId = filterRequest("driverId");
$notes = filterRequest("notes");
// SQL query to insert a new note into the notesForDriverService table
$sql = "INSERT INTO `welcomeDriverCall`( `driverId`, `isCall`, `notes`) VALUES ('$driverId','1','$notes')";
// Prepare the SQL statement
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
printSuccess($message = "note inserted successfully");
} else {
// Print a failure message
printFailure($message = "Failed to insert note");
}
?>

View File

@@ -0,0 +1,30 @@
<?php
include "../connect.php";
// $driverID = filterRequest("driverID");
$sql = "SELECT
*
FROM
`driver`
LEFT JOIN `notesForDriverService` ON `notesForDriverService`.`phone` = driver.phone
WHERE
`notesForDriverService`.phone = driver.phone
AND MONTH(`driver`.`created_at`) = MONTH(CURRENT_DATE())
ORDER BY
`driver`.`created_at`
DESC;";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,43 @@
<?php
include "../connect.php";
// Retrieve and sanitize input parameters
$driverId = filterRequest("driverId");
$carPlate = filterRequest("carPlate");
// Start a transaction
$con->beginTransaction();
try {
// Update CarRegistration table
$sqlUpdate = "UPDATE `CarRegistration` SET `car_plate` = :carPlate WHERE `driverID` = :driverId";
$stmtUpdate = $con->prepare($sqlUpdate);
$stmtUpdate->bindParam(':carPlate', $carPlate);
$stmtUpdate->bindParam(':driverId', $driverId);
$stmtUpdate->execute();
// Check if the update was successful
if ($stmtUpdate->rowCount() > 0) {
// Insert into carPlateEdit table
$sqlInsert = "INSERT INTO `carPlateEdit` (`driverId`, `carPlate`, `isEdit`) VALUES (:driverId, :carPlate, 1)";
$stmtInsert = $con->prepare($sqlInsert);
$stmtInsert->bindParam(':driverId', $driverId);
$stmtInsert->bindParam(':carPlate', $carPlate);
$stmtInsert->execute();
// Commit the transaction
$con->commit();
// Print a success message
printSuccess("Car plate updated and edit record inserted successfully");
} else {
// Rollback the transaction if update failed
$con->rollBack();
printFailure("Failed to update car plate. No matching record found.");
}
} catch (PDOException $e) {
// Rollback the transaction if any error occurred
$con->rollBack();
printFailure("An error occurred: " . $e->getMessage());
}
?>

View File

@@ -0,0 +1,48 @@
<?php
include "../connect.php";
$phoneNumber = filterRequest("phone_number");
$sql = "SELECT
CR.`id`,
CR.`driverID`,
CR.`vin`,
CR.`car_plate`,
CR.`make`,
CR.`model`,
CR.`year`,
CR.`expiration_date`,
CR.`color`,
CR.`owner`,
CR.`color_hex`,
CR.`address`,
CR.`displacement`,
CR.`fuel`,
CR.`registration_date`,
CR.`created_at`
FROM
`CarRegistration` CR
WHERE
CR.`driverID` NOT IN(
SELECT DISTINCT
CPE.`driverId`
FROM
`carPlateEdit` CPE
)
LIMIT 10;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the records
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess($rows);
} else {
// Print a failure message
printFailure($message = "No Car verified yet found");
}
?>

View File

@@ -0,0 +1,169 @@
<?php
include "../connect.php";
// $driverID = filterRequest("driverID");
$sql = "SELECT
cm.`id`,
cm.`ride_id`,
cm.`passenger_id`,
cm.`driver_id`,
cm.`complaint_type`,
cm.`description`,
cm.`date_filed`,
cm.`statusComplaint`,
cm.`resolution`,
cm.`date_resolved`,
p.first_name AS passengerName,
d.name_arabic AS driverName,
d.gender,
ride.price AS priceOfRide,
ride.status AS rideStatus,
ride.carType ascarType,
ride.paymentMethod AS ridePaymentMethod,
ride.rideTimeFinish AS rideTimeFinish,
payments.amount as paymentFromPaymentTable,
payments.created_at as timeFromPaymentTable,
(
SELECT
AVG(rd.rating)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS avgRatingDriverFromPassengers,
(
SELECT
COUNT(*)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS countratingDriverFromPassengers,
(
SELECT
AVG(rp.rating)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS avgRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS countRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.driver_id = cm.driver_id
) countDriverRide,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.passenger_id = cm.passenger_id
) countPassengerRide,
(
SELECT
COALESCE(SUM(amount),
0) AS visaDriver
FROM
payments
WHERE
isGiven = 'waiting' AND `payment_method` IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND payments.`driverID` = cm.driver_id
) AS driverVisa,
(
SELECT
COALESCE(SUM(amount),
0) AS pointDriver
FROM
driverWallet dw
WHERE
dw.paymentMethod IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND dw.`driverID` = cm.driver_id
) AS driverWallet,
(
SELECT
COALESCE(SUM(pw.balance),
0)
FROM
passengerWallet pw
WHERE
pw.passenger_id = cm.passenger_id
) AS passengerWallet,
(
SELECT
token
FROM
driverToken
WHERE
driverToken.captain_id = cm.driver_id
) AS driverToken,
(
SELECT
token
FROM
tokens
WHERE
tokens.passengerID = cm.passenger_id
) AS passengerToken,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.passenger_id = cm.passenger_id AND cm.complaint_type = 'Passenger'
) AS countOfComplaintFromPassenger,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.driver_id = cm.driver_id AND cm.complaint_type = 'Driver'
) AS countOfComplaintFromDriver
FROM
`complaint` cm
LEFT JOIN passengers p ON
p.id = cm.`passenger_id`
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) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,171 @@
<?php
include "../connect.php";
$driverID = filterRequest("driver_id");
$sql = "SELECT
cm.`id`,
cm.`ride_id`,
cm.`passenger_id`,
cm.`driver_id`,
cm.`complaint_type`,
cm.`description`,
cm.`date_filed`,
cm.`statusComplaint`,
cm.`resolution`,
cm.`date_resolved`,
p.first_name AS passengerName,
d.name_arabic AS driverName,
d.gender,
ride.price AS priceOfRide,
ride.status AS rideStatus,
ride.carType AS carType,
ride.paymentMethod AS ridePaymentMethod,
ride.rideTimeFinish AS rideTimeFinish,
payments.amount AS paymentFromPaymentTable,
payments.created_at AS timeFromPaymentTable,
(
SELECT
AVG(rd.rating)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS avgRatingDriverFromPassengers,
(
SELECT
COUNT(*)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS countratingDriverFromPassengers,
(
SELECT
AVG(rp.rating)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS avgRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS countRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.driver_id = cm.driver_id
) countDriverRide,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.passenger_id = cm.passenger_id
) countPassengerRide,
(
SELECT
COALESCE(SUM(amount),
0) AS visaDriver
FROM
payments
WHERE
isGiven = 'waiting' AND `payment_method` IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND payments.`driverID` = cm.driver_id
) AS driverVisa,
(
SELECT
COALESCE(SUM(amount),
0) AS pointDriver
FROM
driverWallet dw
WHERE
dw.paymentMethod IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND dw.`driverID` = cm.driver_id
) AS driverWallet,
(
SELECT
COALESCE(SUM(pw.balance),
0)
FROM
passengerWallet pw
WHERE
pw.passenger_id = cm.passenger_id
) AS passengerWallet,
(
SELECT
token
FROM
driverToken
WHERE
driverToken.captain_id = cm.driver_id
) AS driverToken,
(
SELECT
token
FROM
tokens
WHERE
tokens.passengerID = cm.passenger_id
) AS passengerToken,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.passenger_id = cm.passenger_id AND cm.complaint_type = 'Passenger'
) AS countOfComplaintFromPassenger,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.driver_id = cm.driver_id AND cm.complaint_type = 'Driver'
) AS countOfComplaintFromDriver
FROM
`complaint` cm
LEFT JOIN passengers p ON
p.id = cm.`passenger_id`
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
WHERE
cm.driver_id = '$driverID'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = $sql);
}
?>

View File

@@ -0,0 +1,131 @@
<?php
include "../connect.php";
$phone = filterRequest("phone");
$sql = "SELECT
COALESCE(
(
SELECT
COUNT(*)
FROM
`ride`
WHERE
`ride`.`driver_id` = d.id
),
0
) AS countRide,
COALESCE(
(
SELECT
AVG(`ratingDriver`.`rating`)
FROM
ratingDriver
WHERE
`ratingDriver`.`driver_id` = d.id
),
0
) AS rating,
COALESCE(
(
SELECT
SUM(pd.amount)
FROM
`payments` pd
WHERE
pd.driverID = d.id
),
0
) AS totalPayment,
COALESCE(
(
SELECT
SUM(dw.amount)
FROM
`driverWallet` dw
WHERE
dw.driverID = d.id
),
0
) AS totalDriverWallet,
COALESCE(
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.driver_id = d.id
),
0
) AS countComplaint,
COALESCE(
(
SELECT
COUNT(*)
FROM
driver_ride_scam scam
WHERE
scam.driverID = d.id
),
0
) AS countScam,
COALESCE(
(
SELECT
complaint.description
FROM
complaint
WHERE
complaint.driver_id = d.id
ORDER BY
complaint.date_resolved
DESC
LIMIT 1
),
''
) AS complaint, COALESCE(
(
SELECT
COUNT(*)
FROM
ratingPassenger
WHERE
ratingPassenger.driverID = d.id
),
0
) AS DRatingPassengersCount,
COALESCE(
(
SELECT
AVG(ratingPassenger.rating)
FROM
ratingPassenger
WHERE
ratingPassenger.driverID = d.id
),
0
) AS avgDRatingPassenger,
cr.*,
d.*
FROM
driver d
LEFT JOIN CarRegistration cr ON
cr.driverID = d.id
WHERE
d.`phone` = '$phone';
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,40 @@
<?php
include "../connect.php";
$sql = "SELECT
*
FROM
phone_verification
LEFT JOIN `notesForDriverService`
ON
`notesForDriverService`.`phone` = `phone_verification`.`phone_number`
WHERE
phone_verification.phone_number NOT IN(
SELECT
phone
FROM
driver
WHERE
phone IS NOT NULL
) AND phone_verification.created_at >= DATE_SUB(CURDATE(), INTERVAL 18 DAY)
ORDER BY
created_at
DESC
LIMIT 0, 200;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the records
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess($rows);
} else {
// Print a failure message
printFailure($message = "No Phone verified yet found");
}
?>

View File

@@ -0,0 +1,65 @@
<?php
include "../connect.php";
$sql = "SELECT
d.id,
d.phone,
d.email,
d.gender,
d.license_type,
d.national_number,
d.name_arabic,
d.name_english,
d.issue_date,
d.expiry_date,
d.license_categories,
d.address,
d.card_id,
d.occupation,
d.licenseIssueDate,
d.religion,
d.status,
d.birthdate,
d.site,
d.first_name,
d.last_name,
d.accountBank,
d.bankCode,
d.education,
d.employmentType,
d.maritalStatus,
d.fullNameMaritial,
d.expirationDate,
d.created_at,
d.updated_at,
wdc.id AS welcomId,
wdc.isCall,
wdc.notes,
wdc.createdAt AS welcomeCreatedAt
FROM
driver d
LEFT JOIN welcomeDriverCall wdc ON
wdc.driverId = d.id
WHERE
d.created_at BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND CURDATE() + INTERVAL 1 DAY
ORDER BY
d.created_at DESC;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the records
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess($rows);
} else {
// Print a failure message
printFailure($message = "No Phone verified yet found");
}
?>

View File

@@ -0,0 +1,65 @@
<?php
include "../connect.php";
$phone = filterRequest("phone");
$sql = "SELECT
p.*,
COALESCE(r.id, 0) AS ride_id,
COALESCE(r.start_location, '') AS start_location,
COALESCE(r.end_location, '') AS end_location,
COALESCE(r.date, '1970-01-01') AS ride_date,
COALESCE(r.time, '00:00:00') AS ride_time,
COALESCE(r.endtime, '00:00:00') AS ride_endtime,
COALESCE(r.price, 0) AS price,
COALESCE(r.passenger_id, 0) AS ride_passenger_id,
COALESCE(r.driver_id, 0) AS driver_id,
COALESCE(r.status, '') AS ride_status,
COALESCE(r.paymentMethod, '') AS ride_payment_method,
COALESCE(r.carType, '') AS car_type,
COALESCE(r.created_at, '1970-01-01 00:00:00') AS ride_created_at,
COALESCE(r.updated_at, '1970-01-01 00:00:00') AS ride_updated_at,
COALESCE(r.DriverIsGoingToPassenger, 0) AS driver_is_going_to_passenger,
COALESCE(r.rideTimeStart, '1970-01-01 00:00:00') AS ride_time_start,
COALESCE(r.rideTimeFinish, '1970-01-01 00:00:00') AS ride_time_finish,
COALESCE(r.price_for_driver, 0) AS price_for_driver,
COALESCE(r.price_for_passenger, 0) AS price_for_passenger,
COALESCE(r.distance, 0) AS distance,
COALESCE(pw.balance, 0) AS passenger_wallet_balance,
COALESCE(pay.amount, 0) AS passenger_payment_amount,
COALESCE(pay.payment_method, '') AS passenger_payment_method,
COALESCE(dw.amount, 0) AS driver_payment_amount,
COALESCE(dw.paymentMethod, '') AS driver_payment_method
FROM
passengers p
LEFT JOIN
ride r ON p.id = r.passenger_id
LEFT JOIN
passengerWallet pw ON p.id = pw.passenger_id
LEFT JOIN
payments pay ON r.id = pay.rideId
LEFT JOIN
driverWallet dw ON r.driver_id = dw.driverID AND pay.id = dw.paymentID
WHERE
p.phone = '$phone'
AND r.id = (
SELECT id
FROM ride
WHERE passenger_id = p.id
ORDER BY date DESC, time DESC
LIMIT 1
)";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,41 @@
<?php
include "../connect.php";
$sql = "SELECT
*
FROM
phone_verification_passenger
LEFT JOIN `notesForPassengerService`
ON
`notesForPassengerService`.`phone` = `notesForPassengerService`.`phone`
WHERE
phone_verification_passenger.phone_number NOT IN(
SELECT
phone
FROM
passengers
WHERE
phone IS NOT NULL
) AND phone_verification_passenger.created_at >= DATE_SUB(CURDATE(), INTERVAL 4 DAY)
ORDER BY
created_at
DESC
LIMIT 0, 25;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the records
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess($rows);
} else {
// Print a failure message
printFailure($message = "No Phone verified yet found");
}
?>

View File

@@ -0,0 +1,48 @@
<?php
include "../connect.php";
$current_month = date('m');
$current_year = date('Y');
// Get the first and last days of the current month.
$first_day_of_month = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-01'));
$last_day_of_month = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-' . cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year)));
// Create a SQL query to select the total passengers for each day in the current month.
$sql = "
WITH RECURSIVE date_series AS (
SELECT '$first_day_of_month' AS date
UNION ALL
SELECT DATE_ADD(date, INTERVAL 1 DAY)
FROM date_series
WHERE date < LEAST(CURDATE(), DATE_SUB('$last_day_of_month', INTERVAL 1 DAY))
)
SELECT
date_series.date AS day,
COALESCE(COUNT(passengers.id), 0) AS totalPassengers,
(SELECT COUNT(*) FROM passengers
WHERE passengers.created_at >= '$first_day_of_month'
AND passengers.created_at < '$last_day_of_month') AS totalMonthly
FROM
date_series
LEFT JOIN
passengers ON DATE(passengers.created_at) = date_series.date
WHERE
date_series.date >= '$first_day_of_month'
AND date_series.date < '$last_day_of_month'
GROUP BY
date_series.date
ORDER BY
date_series.date DESC
";
$stmt = $con->prepare($sql);
$stmt->execute();
$passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($passenger_data) {
// Print the passenger data as JSON
printSuccess($data = $passenger_data);
} else {
// Print a failure message
printFailure($message = "No passenger data found");
}
?>

View File

@@ -0,0 +1,114 @@
<?php
include "../connect.php";
$current_month = date('m');
$current_year = date('Y');
// Get the first and last days of the current month.
$first_day_of_month = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-01'));
$last_day_of_month = date('Y-m-t', strtotime($first_day_of_month));
// Create a SQL query to select the total duration for the driver for each day in the current month.
$sql = "WITH
RECURSIVE date_series AS(
SELECT
'$first_day_of_month' AS DATE
UNION ALL
SELECT
DATE_ADD(DATE, INTERVAL 1 DAY)
FROM
date_series
WHERE
DATE < LEAST(
CURDATE(), DATE_SUB('$last_day_of_month', INTERVAL 1 DAY))
)
SELECT
date_series.date AS day,
(
SELECT
COUNT(*)
FROM
`driver`
) AS totalDrivers,
(
SELECT
COUNT(*)
FROM
driver
WHERE
DATE(driver.created_at) = date_series.date
) AS dailyTotalDrivers,
(
SELECT
COUNT(*)
FROM
notesForDriverService
WHERE
DATE(
notesForDriverService.createdAt
) = date_series.date
) AS dailyTotalCallingDrivers,
(
SELECT
COUNT(*)
FROM
notesForDriverService n
JOIN driver d ON
n.phone = d.phone
WHERE
DATE(n.createdAt) = date_series.date
) AS dailyMatchingNotes,
(
SELECT
COUNT(*)
FROM
driver
WHERE
driver.created_at >= '$first_day_of_month' AND driver.created_at < '$last_day_of_month'
) AS totalMonthlyDrivers,
(
SELECT
COUNT(*)
FROM
notesForDriverService
WHERE
notesForDriverService.createdAt >= '$first_day_of_month' AND notesForDriverService.createdAt < '$last_day_of_month'
) AS totalMonthlyCallingDrivers,
(
SELECT
COUNT(*)
FROM
notesForDriverService n
JOIN driver d ON
n.phone = d.phone
WHERE
n.createdAt >= '$first_day_of_month' AND n.createdAt < '$last_day_of_month'
) AS totalMonthlyMatchingNotes
FROM
date_series
LEFT JOIN driver ON DATE(driver.created_at) = date_series.date
LEFT JOIN notesForDriverService ON DATE(
notesForDriverService.createdAt
) = date_series.date AND notesForDriverService.phone = driver.phone
WHERE
date_series.date >= '$first_day_of_month' AND date_series.date <= LEAST(
CURDATE(), DATE_SUB('$last_day_of_month', INTERVAL 1 DAY))
GROUP BY
date_series.date
ORDER BY
date_series.date
DESC
;
";
$stmt = $con->prepare($sql);
$stmt->execute();
$car_locations = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($car_locations) {
// Print the car location data as JSON
printSuccess($data = $car_locations);
} else {
// Print a failure message
printFailure($message = "No car locations found");
}
?>

View File

@@ -0,0 +1,57 @@
<?php
include "../connect.php";
// Get email and password from the request
$email = filterRequest('email');
$password = filterRequest('password');
// Check if email and password are provided
if (empty($email) || empty($password)) {
echo json_encode([
"status" => "failure",
"message" => "Email and password are required."
]);
exit();
}
// SQL to check for user with provided email
$sql = "SELECT * FROM `users` WHERE `email` = :email";
$stmt = $con->prepare($sql);
$stmt->bindParam(':email', $email);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
header('Content-Type: application/json'); // Ensure the response is JSON
if ($user) {
// Verify the password
if ($password=== $user['password']) {
// Password is correct
unset($user['password']); // Remove password from the response
echo json_encode([
"status" => "success",
"message" => "Login successful",
"data" => $user
]);
} else {
// Password is incorrect
echo json_encode([
"status" => "failure",
"message" => "Incorrect password",
"password"=>$password,
"password1"=>$user['password'],
]);
}
} else {
// User not found
echo json_encode([
"status" => "failure",
"message" => "User not found"
]);
}
$stmt = null; // Close the statement
$con = null; // Close the connection
exit(); // Ensure no further output