diff --git a/app/modules_app/companies/create.php b/app/modules_app/companies/create.php index 9ee7d27..641e24f 100644 --- a/app/modules_app/companies/create.php +++ b/app/modules_app/companies/create.php @@ -48,8 +48,19 @@ try { ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); + // Determine tenant_id: Super Admin chooses, Admin uses own + $tenantId = null; + if ($decoded['role'] === 'super_admin') { + if (empty($data['tenant_id'])) { + json_error('يجب اختيار المكتب المحاسبي', 422); + } + $tenantId = $data['tenant_id']; + } else { + $tenantId = $decoded['tenant_id']; + } + $stmt->execute([ - $decoded['tenant_id'], // Correctly using tenant_id from JWT + $tenantId, $encryptedName, $encryptedNameEn, $data['tax_identification_number'], diff --git a/public/shell.php b/public/shell.php index 9e2bedd..c8faebc 100644 --- a/public/shell.php +++ b/public/shell.php @@ -4,12 +4,9 @@