Update: 2026-05-04 00:09:02

This commit is contained in:
Hamza-Ayed
2026-05-04 00:09:02 +03:00
parent 2ac63eef47
commit 8357add763
2 changed files with 32 additions and 13 deletions

View File

@@ -12,7 +12,11 @@ $db = Database::getInstance();
// 1. Super Admin sees ALL companies
if ($decoded['role'] === 'super_admin') {
$stmt = $db->query("SELECT * FROM companies WHERE deleted_at IS NULL");
$stmt = $db->prepare("SELECT c.*, t.name as tenant_name
FROM companies c
LEFT JOIN tenants t ON c.tenant_id = t.id
WHERE c.deleted_at IS NULL ORDER BY c.created_at DESC");
$stmt->execute();
}
// 2. Admin sees all companies in their tenant
else if ($decoded['role'] === 'admin') {

View File

@@ -54,20 +54,35 @@
<div id="content">
<!-- Dashboard -->
<div x-show="page === 'dashboard'">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">إجمالي الفواتير</p>
<p class="text-3xl font-bold mt-2" x-text="stats.total"></p>
<template x-if="user?.role === 'super_admin'">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">إجمالي فواتير المنصة</p>
<p class="text-3xl font-bold mt-2" x-text="stats.total_invoices"></p>
</div>
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">المكاتب النشطة</p>
<p class="text-3xl font-bold mt-2 text-emerald-500" x-text="stats.active_tenants"></p>
</div>
</div>
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">قيد المعالجة</p>
<p class="text-3xl font-bold mt-2 text-yellow-500" x-text="stats.pending"></p>
</template>
<template x-if="user?.role !== 'super_admin'">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">إجمالي الفواتير</p>
<p class="text-3xl font-bold mt-2" x-text="stats.total"></p>
</div>
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">قيد المعالجة</p>
<p class="text-3xl font-bold mt-2 text-yellow-500" x-text="stats.pending"></p>
</div>
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">تم الاعتماد</p>
<p class="text-3xl font-bold mt-2 text-emerald-500" x-text="stats.approved"></p>
</div>
</div>
<div class="p-6 bg-surface border border-gray-800 rounded">
<p class="text-gray-500 text-sm">تم الاعتماد</p>
<p class="text-3xl font-bold mt-2 text-emerald-500" x-text="stats.approved"></p>
</div>
</div>
</template>
</div>
<!-- Companies -->