🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 14:02

This commit is contained in:
Hamza-Ayed
2026-05-03 14:02:18 +03:00
parent 0e27d96371
commit cb69abe221
8 changed files with 492 additions and 1149 deletions

View File

@@ -25,11 +25,11 @@ final class InvoiceController
$assignedCompanyId = $request->user->assigned_company_id ?? null;
if ($role === 'super_admin') {
$invoices = $this->invoiceModel->findByTenant($tenantId);
$stmt = $db->prepare("SELECT i.*, c.name as company_name FROM invoices i JOIN companies c ON i.company_id = c.id WHERE i.tenant_id = ? AND i.deleted_at IS NULL ORDER BY i.created_at DESC");
$stmt->execute([$tenantId]);
$invoices = $stmt->fetchAll();
} else {
// Filter by assigned company for admin, accountant, etc.
$db = \App\Core\Database::getInstance();
$stmt = $db->prepare("SELECT * FROM invoices WHERE tenant_id = ? AND company_id = ? AND deleted_at IS NULL ORDER BY created_at DESC");
$stmt = $db->prepare("SELECT i.*, c.name as company_name FROM invoices i JOIN companies c ON i.company_id = c.id WHERE i.tenant_id = ? AND i.company_id = ? AND i.deleted_at IS NULL ORDER BY i.created_at DESC");
$stmt->execute([$tenantId, $assignedCompanyId]);
$invoices = $stmt->fetchAll();
}