diff --git a/app/modules_app/dashboard/stats.php b/app/modules_app/dashboard/stats.php new file mode 100644 index 0000000..b4a1d88 --- /dev/null +++ b/app/modules_app/dashboard/stats.php @@ -0,0 +1,37 @@ +query("SELECT COUNT(*) FROM invoices"); + $total = $stmt->fetchColumn(); + + // Pending Invoices + $stmt = $db->query("SELECT COUNT(*) FROM invoices WHERE status = 'pending'"); + $pending = $stmt->fetchColumn(); + + // Approved Invoices + $stmt = $db->query("SELECT COUNT(*) FROM invoices WHERE status = 'approved'"); + $approved = $stmt->fetchColumn(); +} catch (\Exception $e) { + // Fallback if table doesn't exist yet + $total = 0; + $pending = 0; + $approved = 0; +} + +json_success([ + 'total' => $total, + 'pending' => $pending, + 'approved' => $approved +]); diff --git a/public/index.php b/public/index.php index ff028fe..d58f3dd 100644 --- a/public/index.php +++ b/public/index.php @@ -20,6 +20,7 @@ $routes = [ 'v1/auth/refresh' => ['POST', 'auth/refresh.php'], 'v1/auth/logout' => ['POST', 'auth/logout.php'], 'v1/users' => ['GET', 'users/index.php'], + 'v1/dashboard/stats' => ['GET', 'dashboard/stats.php'], ]; if (isset($routes[$route])) { diff --git a/public/shell.php b/public/shell.php index 3899bd3..b5652db 100644 --- a/public/shell.php +++ b/public/shell.php @@ -50,15 +50,15 @@
إجمالي الفواتير
-1,240
+قيد المعالجة
-12
+تم الاعتماد
-1,228
+