Update: 2026-05-04 21:34:28

This commit is contained in:
Hamza-Ayed
2026-05-04 21:34:28 +03:00
parent e5f8d8151d
commit 75f969f821
3 changed files with 122 additions and 3 deletions

View File

@@ -36,6 +36,7 @@ $routes = [
'v1/dashboard/stats' => ['GET', 'dashboard/stats.php'],
'v1/tenants' => ['GET', 'tenants/index.php'],
'v1/tenants/create' => ['POST', 'tenants/create.php'],
'v1/tenants/update' => ['POST', 'tenants/update.php'],
];
if (isset($routes[$route])) {

View File

@@ -274,7 +274,7 @@
</td>
<td class="p-6 text-xs text-gray-500 font-mono" x-text="t.created_at"></td>
<td class="p-6">
<button class="text-gray-500 hover:text-emerald-400 p-2 transition">⚙️</button>
<button @click="openEditTenantModal(t)" class="text-gray-500 hover:text-emerald-400 p-2 rounded-lg hover:bg-emerald-400/10 transition-all">⚙️</button>
</td>
</tr>
</template>
@@ -504,6 +504,45 @@
<div x-show="currentInvoice?.status === 'approved'" class="w-full bg-emerald-900/30 text-emerald-400 py-3 rounded-2xl font-bold text-center border border-emerald-900/50">
مدققة وموثقة محلياً
</div>
<!-- Edit Tenant Modal (Super Admin Only) -->
<div x-show="showEditTenantModal" x-cloak class="fixed inset-0 bg-black/90 flex items-center justify-center p-6 z-[140]">
<div class="bg-surface border border-gray-800 w-full max-w-xl p-10 rounded-[40px] shadow-2xl glass-elevated overflow-y-auto max-h-[90vh]">
<h3 class="text-2xl font-bold mb-8 text-emerald-400">تعديل بيانات المكتب</h3>
<form @submit.prevent="updateTenant" class="space-y-6">
<div>
<label class="block text-xs font-bold text-gray-500 uppercase mb-2">اسم المكتب</label>
<input type="text" x-model="currentTenant.name" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500" required>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-bold text-gray-500 uppercase mb-2">البريد الرسمي</label>
<input type="email" x-model="currentTenant.email" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500" required>
</div>
<div>
<label class="block text-xs font-bold text-gray-500 uppercase mb-2">رقم الهاتف</label>
<input type="text" x-model="currentTenant.phone" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500">
</div>
</div>
<div>
<label class="block text-xs font-bold text-gray-500 uppercase mb-2">حالة المكتب</label>
<select x-model="currentTenant.status" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500">
<option value="active">نشط (Active)</option>
<option value="suspended">معلق (Suspended)</option>
<option value="trial">تجريبي (Trial)</option>
</select>
</div>
<div class="flex gap-4 pt-6 border-t border-gray-800">
<button type="submit" class="flex-1 bg-emerald-600 hover:bg-emerald-500 py-4 rounded-2xl font-bold transition-all btn-glow" :disabled="isBusy">
<span x-show="!isBusy">💾 حفظ التعديلات</span>
<span x-show="isBusy"> جاري الحفظ...</span>
</button>
<button type="button" @click="showEditTenantModal = false" class="px-8 py-4 border border-gray-800 rounded-2xl hover:bg-gray-800 transition-colors">إلغاء</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@@ -556,7 +595,7 @@
showAddUserModal: false, showAddCompanyModal: false, showConnectModal: false,
showUploadModal: false, showViewModal: false, showCompanyStatsModal: false,
showAddTenantModal: false,
showAddTenantModal: false, showEditTenantModal: false,
isBusy: false, globalError: '',
newUser: { name: '', email: '', password: '', role: 'accountant' },
@@ -564,7 +603,7 @@
newTenant: { name: '', email: '', phone: '', manager_name: '', manager_email: '', manager_password: '' },
connectData: { client_id: '', secret_key: '', income_source_sequence: '1' },
uploadData: { company_id: '' },
currentCompany: null, currentInvoice: null, companyStats: null,
currentCompany: null, currentInvoice: null, companyStats: null, currentTenant: { name: '', email: '', phone: '', status: '' },
init() {
if (!this.user) { window.location.href = '/login.php'; return; }
@@ -643,6 +682,22 @@
this.isBusy = false;
},
openEditTenantModal(t) {
this.currentTenant = JSON.parse(JSON.stringify(t));
this.showEditTenantModal = true;
},
async updateTenant() {
this.isBusy = true;
const res = await this.apiRequest('v1/tenants/update', 'POST', this.currentTenant);
if (res) {
this.showEditTenantModal = false;
this.loadAll();
alert('تم تحديث بيانات المكتب بنجاح');
}
this.isBusy = false;
},
openConnectModal(company) {
this.currentCompany = company;
this.connectData.client_id = '';