Update: 2026-05-15 14:23:28
This commit is contained in:
@@ -19,18 +19,18 @@ try {
|
||||
$tenantId = $decoded['tenant_id'];
|
||||
$userId = $decoded['user_id'];
|
||||
|
||||
// --- QUOTA CHECK ---
|
||||
QuotaMiddleware::checkInvoiceQuota($tenantId);
|
||||
// -------------------
|
||||
|
||||
$db = Database::getInstance();
|
||||
|
||||
$allowedRoles = ['admin', 'accountant', 'employee'];
|
||||
$allowedRoles = ['super_admin', 'admin', 'accountant', 'employee'];
|
||||
if (!in_array($decoded['role'], $allowedRoles)) {
|
||||
json_error('غير مصرح لك برفع الفواتير', 403);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- QUOTA CHECK (skip for super_admin ONLY) ---
|
||||
if ($decoded['role'] !== 'super_admin') {
|
||||
QuotaMiddleware::checkInvoiceQuota($tenantId);
|
||||
}
|
||||
// -------------------
|
||||
|
||||
// 2. Validate Request
|
||||
// استخدام $_POST للتعامل الآمن مع multipart/form-data
|
||||
$companyId = $_POST['company_id'] ?? null;
|
||||
@@ -197,7 +197,9 @@ try {
|
||||
}
|
||||
|
||||
$savedIds[] = $invoiceId;
|
||||
QuotaMiddleware::incrementInvoiceUsage($tenantId);
|
||||
if ($decoded['role'] !== 'super_admin') {
|
||||
QuotaMiddleware::incrementInvoiceUsage($tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
|
||||
Reference in New Issue
Block a user