first commit

This commit is contained in:
Hamza-Ayed
2026-06-09 08:40:31 +03:00
commit d8901e1a87
3161 changed files with 536187 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
require_once __DIR__ . '/../../connect.php';
$driver_id = filterRequest("driver_id");
try {
$sql = "
SELECT
DATE(r.created_at) as day,
COUNT(r.id) as trips,
COALESCE(SUM(r.price_for_driver), 0) as earnings,
COALESCE(SUM(TIMESTAMPDIFF(MINUTE, r.time, r.endtime))/60, 0) as hours
FROM `ride` r
WHERE r.driver_id = :driver_id
AND r.status = 'Finished'
AND r.created_at >= DATE(NOW()) - INTERVAL 6 DAY
GROUP BY DATE(r.created_at)
ORDER BY DATE(r.created_at) ASC
";
$stmt = $con->prepare($sql);
$stmt->bindParam(':driver_id', $driver_id, PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
jsonSuccess($rows);
} else {
jsonSuccess([]);
}
} catch (PDOException $e) {
// Return empty but log error
error_log("getWeeklyAggregate Error: " . $e->getMessage());
jsonError("Database error occurred");
}
?>