توثيق كامل لهيكل الملفات وقاعدة البيانات والجداول المحاسبية للنظام المالي Complete documentation for file structure, database schema, and accounting tables of the financial system
admin.php — الواجهة — UIassets/js/app.js — المنطق — Logicapi/income.php — الحفظ — Savepages/receipts/receipt-income.php — الطباعة — Printadmin.phpassets/js/app.jsapi/expense.phppages/receipts/receipt-expense.phppages/receipts/receipt-cheque.phpadmin.phpassets/js/app.jsapi/deposit.phppages/receipts/receipt-deposit-entry.phppages/loans/loans-management.phpassets/js/app.jsapi/loan-accounting.phpapi/loans.phppages/loans/loan-reports/*assets/js/app.jsapi/reports.phppages/reports/*pages/admin/admin-panel.phpassets/js/users.jsapi/auth.phpassets/js/theme.jsassets/js/login.jsassets/css/styles.cssdatabase.sqlmigrations/*| الملفFile | الوظيفةPurpose |
|---|---|
| admin.php | الصفحة الرئيسية — النماذج والتقارير داخل التبويباتMain page — forms and reports inside tabs |
| index.php | تحويل تلقائي إلى شاشة تسجيل الدخولAuto-redirect to login screen |
| login.php | واجهة تسجيل الدخول + عرض اللوجو والملاحظاتLogin interface + logo and screen notes display |
| database.sql | قاعدة البيانات + الجداول Database schema + tables + seed data |
| DOCUMENTATION.md | توثيق سابق للمشروعPrevious project documentation |
| الملفFile | الوظيفةPurpose |
|---|---|
| api/auth.php | تسجيل الدخول / الخروج / الجلسة / إدارة المستخدمينLogin / logout / session / user management & password |
| api/income.php | حفظ عمليات القبض وربطها بقيود اليوميةSave income transactions and link to journal entries |
| api/deposit.php | حفظ عمليات الإيداع وربطها بقيود اليوميةSave deposit operations and link to journal entries |
| api/expense.php | حفظ عمليات الصرف وربطها بقيود اليوميةSave expense operations and link to journal entries |
| api/loan-accounting.php | المعالجة المحاسبية للسلف (منح / سداد / تعديل / إلغاء)Loan accounting processing (grant / repay / adjust / cancel) |
| api/loans.php | CRUD بيانات السلف التفصيلية وأقساطهاCRUD for detailed loan data and installments |
| api/receipts.php | حفظ وتحديث وصل المقبوضاتSave and update receipt vouchers |
| api/payments.php | حفظ وتحديث سندات الصرف والإيداعSave and update expense and deposit vouchers |
| api/reports.php | APIs التقارير: دفتر اليومية، كشف البنك، ميزان المراجعةReport APIs: journal book, bank statement, trial balance, loans |
| api/state-read.php | قراءة حالة النظام من SQL وإرجاعها للواجهةRead system state from SQL and return to UI uniformly |
| api/state-sync.php | مزامنة الحالة القديمة إلى SQL (انتقالي)Sync legacy state to SQL (transitional) |
| api/storage.php | تخزين إعدادات عامة بمفتاح/قيمةStore general settings as key/value pairs |
| الملفFile | الوظيفةPurpose |
|---|---|
| app.js | أكبر ملف منطق — النماذج، الجداول، APIs، الطباعة، التقارير، السلفCore logic file — forms, tables, API calls, printing, reports, loans |
| login.js | منطق صفحة تسجيل الدخول + ألوان الواجهةLogin page logic + UI color application |
| users.js | تحميل المستخدم الحالي + إدارة قائمة المستخدمين + auth APILoad current user + manage user list + auth API calls |
| idle-timeout.js | تسجيل خروج تلقائي + Loader + تحسينات الجداول والتصديرAuto logout + loader + table improvements & export |
| theme.js | تطبيق وتخزين الثيم المختارApply and store the selected theme |
| employee.js | منطق بوابة الموظف — عرض سلفه وتفاصيلهEmployee portal logic — display loans and details |
| general-ledger-sql.js | منطق صفحات الأستاذ العام على بيانات SQLGeneral ledger pages logic built on SQL data |
| الملفFile | الوظيفةPurpose |
|---|---|
| styles.css | ملف التنسيق الرئيسي — ألوان، جداول، أزرار، طباعة، responsiveMain stylesheet — colors, tables, buttons, print, responsive |
| الملفFile | الوظيفةPurpose |
|---|---|
| receipt-income.php | طباعة إيصال القبضPrint income receipt |
| receipt-expense.php | طباعة سند الصرفPrint expense voucher |
| receipt-cheque.php | طباعة الشيكPrint cheque |
| receipt-deposit-entry.php | طباعة مستند قيد الإيداعPrint deposit entry document |
| receipt-template.php | قالب عام / معاينة لقوالب الطباعةGeneric template / print preview |
| الملفFile | الوظيفةPurpose |
|---|---|
| loans-management.php | إدارة السلف — إضافة / تعديل / حذف / سدادLoan management — add / edit / delete / repay |
| loans-reports.php | صفحة تقارير السلفLoan reports page |
| loan-employee-record.php | سجل تفصيلي لموظف معيّن في السلفDetailed loan record for a specific employee |
| loan-schedule-details.php | تفاصيل جدول الأقساط لسلفة محددةInstallment schedule details for a specific loan |
| loan-reports/index.php | Dashboard السلف — المؤشرات والملخصاتLoans dashboard — KPIs and summaries |
| loan-reports/by-employee.php | تقرير السلف للموظفينLoans report by employee |
| loan-reports/by-department.php | تقرير السلف حسب الأقسامLoans report by department |
| loan-reports/upcoming-installments.php | تقرير الأقساط القادمةUpcoming installments report |
| loan-reports/aging-report.php | تقرير أعمار السلف والتأخيرLoan aging & overdue report |
| الملفFile | الوظيفةPurpose |
|---|---|
| reports-trial-balance.php | ميزان المراجعةTrial balance |
| reports-balance-sheet.php | الميزانية العموميةBalance sheet |
| reports-income-statement.php | قائمة الدخلIncome statement |
| reports-account-movements.php | حركة الحساباتAccount movements |
| reports-journal.php | دفتر اليوميةJournal book |
| reports-bank-statement.php | كشف حساب البنكBank statement |
| reports-income-log.php | سجل المقبوضاتReceipts log |
| reports-expense-log.php | سجل المصروفاتExpenses log |
| reports-expense-employees.php | سجل مصروفات الموظفينEmployee expenses log |
| reports-deposit-log.php | سجل الإيداعاتDeposits log |
| reports-loans-log.php | سجل السلفLoans log |
| الملفFile | الوظيفةPurpose |
|---|---|
| index.php | بوابة الأستاذ العام — قائمة الحساباتGeneral ledger gateway — chart of accounts |
| cashbox.php | حساب الصندوقCash box account |
| bank-ahli.php | حساب البنك الأهليAhli Bank account |
| loans.php | حساب السلفLoans account |
| monitoring.php | حساب مساهمة مراقباتMonitoring contribution account |
| rewards.php | حساب المكافآتRewards account |
| interest.php | حساب إيرادات الفوائدInterest revenue account |
| trusts.php | حساب الأماناتTrusts / deposits account |
| الملفFile | الوظيفةPurpose |
|---|---|
| admin-panel.php | لوحة الأدمن — المستخدمين، الإعدادات، التدقيق، تخصيص الواجهةAdmin panel — users, settings, audit, UI customization |
| admin-profile.php | الملف الشخصي + تغيير كلمة المرورUser profile + change password |
| transactions.php | صفحة "معاملاتي" المستقلةStandalone "My Transactions" page |
| الملفFile | الوظيفةPurpose |
|---|---|
| database.php | إعدادات الاتصال بقاعدة البياناتDatabase connection settings (host / user / pass / db) |
| db.php | دوال الاتصال (PDO) المعتمدة من كل ملفات APIPDO connection functions used by all API files |
| الملفFile | الوظيفةPurpose |
|---|---|
| 2026-04-13-add-is-adjustment.sql | ترقية تضيف حقل is_adjustment لتمييز قيود التسوياتMigration adding is_adjustment field to distinguish adjustment entries |
| جدول المصدرSource Table | الحقلField | جدول الهدفTarget Table | الحقلField | الوصفDescription | |
|---|---|---|---|---|---|
receipts | created_by | → | users | id | منشئ وصل القبضReceipt creator |
receipts | cancelled_by | → | users | id | ملغي وصل القبضReceipt canceller |
payments | created_by | → | users | id | منشئ حركة الصرفPayment creator |
payments | cancelled_by | → | users | id | ملغي حركة الصرفPayment canceller |
loans | created_by | → | users | id | منشئ السلفةLoan creator |
loans | cancelled_by | → | users | id | ملغي السلفةLoan canceller |
loan_payments | loan_id | → | loans | id | التسديد مرتبط بسلفة — CASCADE DELETEPayment linked to loan — CASCADE DELETE |
journal_entries | created_by | → | users | id | منشئ القيدEntry creator |
journal_lines | journal_entry_id | → | journal_entries | id | سطور القيد مرتبطة برأس القيدLines linked to parent entry |
journal_lines | account_id | → | accounts | id | كل سطر مرتبط بحساب محاسبيEach line linked to an account |
accounts | parent_id | → | accounts | id | شجرة الحسابات — SET NULL عند الحذفAccount tree — SET NULL on delete |
activity_logs | user_id | → | users | id | سجل التدقيق مرتبط بالمستخدمAudit log linked to user |
الإدخال (Form) ← الحفظ (API) ← التقارير ← الطباعةInput (Form) → Save (API) → Reports → Print templates
إذا كان النظام شغال على بيئة موجودة، أضف ترقية داخل migrations/If the system is running on an existing environment, add a migration inside migrations/ instead.
يجب أن تعتمد على journal_entries و journal_lines لأنها تمثل دفتر اليومية والأستاذ العام.Always rely on journal_entries and journal_lines — they represent the full journal and general ledger.
أي حركة مالية صحيحة يجب أن يكون لها سجل في جدول الحركة المناسب + قيد + سطور تفصيلية.Any valid financial movement must have a record in the appropriate table + a journal entry + detail lines.
كل سطر في journal_lines يجب أن يكون إما مدين فقط أو دائن فقط — لا يمكن أن يكون الطرفان أكبر من صفر معاً.Each journal_lines row must be either debit-only or credit-only — both sides cannot be greater than zero simultaneously.
ما زال موجوداً للتوافق مع إعدادات النظام — وليس بديلاً عن الجداول المحاسبية الأساسية.Kept for compatibility with system settings — not a substitute for the core accounting tables.