+
+
رفع فواتير 📤
+
سيقوم النظام بتحليل الفاتورة آلياً
+
-
-
-
-
-
-
-
-
- 📤
-
-
رفع فواتير جديدة
-
سيقوم النظام باستخراج البيانات آلياً باستخدام الذكاء الاصطناعي المتقدم
-
-
-
-
-
-
-
-
-
-
-
- 👥
-
-
إضافة مستخدم جديد
+
-
-
@@ -870,6 +435,7 @@
showAddTenantModal: false,
showUploadModal: false,
showViewModal: false,
+ showCompanyStatsModal: false,
isUploading: false,
isApproving: false,
globalError: '',
@@ -878,21 +444,11 @@
uploadData: { company_id: '' },
selectedFile: null,
currentInvoice: null,
+ companyStats: null,
init() {
if (!this.user) { window.location.href = '/login.php'; return; }
this.loadAll();
-
- // Confetti celebration on successful actions (optional enhancement)
- if (sessionStorage.getItem('celebrate')) {
- confetti({
- particleCount: 100,
- spread: 70,
- origin: { y: 0.6 },
- colors: ['#10b981', '#06b6d4', '#8b5cf6']
- });
- sessionStorage.removeItem('celebrate');
- }
},
setPage(p) {
@@ -900,13 +456,10 @@
this.loadAll();
},
- title() { return { dashboard: 'نظرة عامة', users: 'إدارة المستخدمين', companies: 'الشركات', invoices: 'الفواتير', tenants: 'المكاتب المحاسبية' }[this.page] || ''; },
- subtitle() { return { dashboard: 'تحليلات المنصة الذكية', users: 'إدارة أدوار الوصول والصلاحيات', companies: 'إدارة بيانات الشركات المسجلة', invoices: 'إدارة ومعالجة الفواتير المرفوعة', tenants: 'إدارة المكاتب المحاسبية الشريكة' }[this.page] || ''; },
+ title() { return { dashboard: 'لوحة التحكم', users: 'المستخدمون', companies: 'الشركات', invoices: 'إدارة الفواتير' }[this.page] || ''; },
+ subtitle() { return { dashboard: 'نظرة شاملة على الأداء', users: 'إدارة الصلاحيات والوصول', companies: 'إدارة بيانات الشركات والضرائب', invoices: 'معالجة واعتماد الفواتير المستخرجة' }[this.page] || ''; },
- showError(msg) {
- this.globalError = msg;
- setTimeout(() => this.globalError = '', 6000);
- },
+ showError(msg) { this.globalError = msg; setTimeout(() => this.globalError = '', 8000); },
token() { return localStorage.getItem('access_token'); },
async apiRequest(route, method = 'GET', body = null) {
@@ -919,20 +472,25 @@
};
if (body) options.body = JSON.stringify(body);
- const res = await fetch('/index.php?route=' + route, options);
-
- // Session Expired Check
- if (res.status === 401) {
- const json = await res.json();
- if (json.code === 'TOKEN_EXPIRED') {
- localStorage.clear();
- window.location.href = '/login.php';
- return null;
+ try {
+ const res = await fetch('/index.php?route=' + route, options);
+
+ // Session Expired logic
+ if (res.status === 401) {
+ const json = await res.json();
+ if (json.code === 'TOKEN_EXPIRED') {
+ localStorage.clear();
+ window.location.href = '/login.php';
+ return null;
+ }
}
- }
- const json = await res.json();
- return json.success ? json.data : (this.showError(json.message), null);
+ const json = await res.json();
+ return json.success ? json.data : (this.showError(json.message), null);
+ } catch (e) {
+ this.showError('فشل الاتصال بالخادم الرئيسي');
+ return null;
+ }
},
async apiGet(route) { return this.apiRequest(route); },
@@ -951,6 +509,14 @@
async loadStats() { this.stats = await this.apiGet('v1/dashboard/stats') || {}; },
async loadTenants() { this.tenants = await this.apiGet('v1/tenants') || []; },
+ async showCompanyStats(id) {
+ const data = await this.apiGet('v1/companies/stats&id=' + id);
+ if (data) {
+ this.companyStats = data;
+ this.showCompanyStatsModal = true;
+ }
+ },
+
async viewInvoice(id) {
const data = await this.apiGet('v1/invoices/view&id=' + id);
if (data) {
@@ -960,26 +526,18 @@
},
async approveInvoice(id) {
- if (!confirm('هل أنت متأكد من اعتماد الفاتورة وإرسالها إلى جوفوترة؟')) return;
+ if (!confirm('هل أنت متأكد من اعتماد الفاتورة؟')) return;
this.isApproving = true;
try {
const data = await this.apiRequest('v1/invoices/approve', 'POST', { id: id });
if (data) {
- // Trigger celebration
- confetti({
- particleCount: 150,
- spread: 100,
- origin: { y: 0.7 },
- colors: ['#10b981', '#06b6d4']
- });
- sessionStorage.setItem('celebrate', 'true');
-
- alert('✅ تم الاعتماد بنجاح!');
+ alert(data.message || '✅ تم الاعتماد بنجاح!');
this.viewInvoice(id);
this.loadInvoices();
+ this.loadStats();
}
} catch (e) {
- this.showError('خطأ غير متوقع: ' + e.message);
+ this.showError('خطأ تقني: ' + e.message);
} finally {
this.isApproving = false;
}
@@ -987,12 +545,16 @@
generateQRPng(base64Tlv) {
if (!base64Tlv) return '';
- const qr = new QRious({
- value: base64Tlv,
- size: 200,
- level: 'M'
- });
- return qr.toDataURL().split(',')[1];
+ try {
+ const qr = new QRious({
+ value: base64Tlv,
+ size: 300,
+ level: 'M'
+ });
+ return qr.toDataURL().split(',')[1];
+ } catch (e) {
+ return '';
+ }
},
handleFile(e) { this.selectedFile = e.target.files[0]; },
@@ -1004,19 +566,24 @@
formData.append('company_id', this.uploadData.company_id);
formData.append('invoice', this.selectedFile);
- const res = await fetch('/index.php?route=v1/invoices/upload', {
- method: 'POST',
- headers: { 'Authorization': 'Bearer ' + this.token() },
- body: formData
- });
- const json = await res.json();
- this.isUploading = false;
- if (json.success) {
- this.showUploadModal = false;
- this.loadInvoices();
- this.viewInvoice(json.data.id);
- } else {
- this.showError(json.message);
+ try {
+ const res = await fetch('/index.php?route=v1/invoices/upload', {
+ method: 'POST',
+ headers: { 'Authorization': 'Bearer ' + this.token() },
+ body: formData
+ });
+ const json = await res.json();
+ this.isUploading = false;
+ if (json.success) {
+ this.showUploadModal = false;
+ this.loadInvoices();
+ this.viewInvoice(json.data.id);
+ } else {
+ this.showError(json.message);
+ }
+ } catch (e) {
+ this.isUploading = false;
+ this.showError('فشل عملية الرفع');
}
},
diff --git a/scratch/debug_decrypt.php b/scratch/debug_decrypt.php
new file mode 100644
index 0000000..300c754
--- /dev/null
+++ b/scratch/debug_decrypt.php
@@ -0,0 +1,11 @@
+