Files
Siro/backend/Admin/v2/financial/stats.php
2026-06-15 01:37:41 +03:00

35 lines
947 B
PHP

<?php
// Admin/v2/financial/stats.php
require_once __DIR__ . '/../../../connect.php';
if ($role !== 'admin' && $role !== 'super_admin') {
http_response_code(403);
echo json_encode(['error' => 'Unauthorized access.']);
exit;
}
try {
// إحصائيات مالية عامة
$stmt = $con->prepare("
SELECT
SUM(price_for_passenger) as total_revenue,
SUM(price_for_driver) as total_driver_pay,
SUM(price_for_passenger - price_for_driver) as total_platform_commission,
0 as cash_payments,
0 as digital_payments
FROM ride
WHERE status = 'Finished'
");
$stmt->execute();
$stats = $stmt->fetch(PDO::FETCH_ASSOC);
echo json_encode([
'status' => 'success',
'data' => $stats
]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
}
?>