Update: 2026-05-04 21:23:43

This commit is contained in:
Hamza-Ayed
2026-05-04 21:23:43 +03:00
parent ff1a5f8b8c
commit e5f8d8151d

View File

@@ -91,6 +91,7 @@
<p class="text-gray-500 mt-2 text-sm" x-text="subtitle()"></p>
</div>
<div class="flex items-center gap-4">
<button x-show="page==='tenants' && user?.role === 'super_admin'" @click="showAddTenantModal = true" class="bg-emerald-600 hover:bg-emerald-500 px-6 py-3 rounded-xl text-sm font-bold shadow-lg transition-all active:scale-95 btn-glow"> إضافة مكتب محاسبي</button>
<button x-show="page==='users'" @click="showAddUserModal = true" class="bg-emerald-600 hover:bg-emerald-500 px-6 py-3 rounded-xl text-sm font-bold shadow-lg transition-all active:scale-95 btn-glow"> إضافة مستخدم</button>
<button x-show="page==='companies'" @click="showAddCompanyModal = true" class="bg-emerald-600 hover:bg-emerald-500 px-6 py-3 rounded-xl text-sm font-bold shadow-lg transition-all active:scale-95 btn-glow"> إضافة شركة</button>
<button x-show="page==='invoices'" @click="showUploadModal = true" class="bg-emerald-600 hover:bg-emerald-500 px-6 py-3 rounded-xl text-sm font-bold shadow-lg transition-all active:scale-95 btn-glow">📤 رفع فواتير</button>
@@ -508,6 +509,42 @@
</div>
</div>
</div>
<!-- Add Tenant Modal (Super Admin Only) -->
<div x-show="showAddTenantModal" 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-2xl 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="createTenant" class="space-y-8">
<!-- Office Details -->
<div class="space-y-4">
<p class="text-xs font-bold text-gray-500 uppercase tracking-widest border-b border-gray-800 pb-2">بيانات المكتب</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<input type="text" x-model="newTenant.name" placeholder="اسم المكتب" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500 transition-colors" required>
<input type="email" x-model="newTenant.email" placeholder="بريد المكتب الرسمي" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500 transition-colors" required>
<input type="text" x-model="newTenant.phone" placeholder="رقم الهاتف" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500 transition-colors">
</div>
</div>
<!-- Manager Details -->
<div class="space-y-4">
<p class="text-xs font-bold text-gray-500 uppercase tracking-widest border-b border-gray-800 pb-2">بيانات مدير المكتب (المسؤول)</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<input type="text" x-model="newTenant.manager_name" placeholder="اسم المدير الكامل" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500 transition-colors" required>
<input type="email" x-model="newTenant.manager_email" placeholder="بريد المدير الخاص" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500 transition-colors" required>
<input type="password" x-model="newTenant.manager_password" placeholder="كلمة مرور المدير" class="w-full bg-gray-950 border border-gray-800 p-4 rounded-2xl outline-none focus:border-emerald-500 transition-colors" required>
</div>
</div>
<div class="flex gap-4 pt-4 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="showAddTenantModal = false" class="px-8 py-4 border border-gray-800 rounded-2xl hover:bg-gray-800 transition-colors">إلغاء</button>
</div>
</form>
</div>
</div>
<script>
document.addEventListener('alpine:init', () => {
@@ -519,10 +556,12 @@
showAddUserModal: false, showAddCompanyModal: false, showConnectModal: false,
showUploadModal: false, showViewModal: false, showCompanyStatsModal: false,
showAddTenantModal: false,
isBusy: false, globalError: '',
newUser: { name: '', email: '', password: '', role: 'accountant' },
newCompany: { name: '', tax_identification_number: '', commercial_registration_number: '', address: '' },
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,
@@ -592,6 +631,18 @@
this.isBusy = false;
},
async createTenant() {
this.isBusy = true;
const res = await this.apiRequest('v1/tenants/create', 'POST', this.newTenant);
if (res) {
this.showAddTenantModal = false;
this.newTenant = { name: '', email: '', phone: '', manager_name: '', manager_email: '', manager_password: '' };
this.loadAll();
alert('تم إضافة المكتب المحاسبي والمدير المسؤول بنجاح');
}
this.isBusy = false;
},
openConnectModal(company) {
this.currentCompany = company;
this.connectData.client_id = '';