🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 14:02
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user