# Dadi Jan Local ERP — PHP 8.3 Migration

This package preserves the Local ERP routes, customized visual theme, business
rules, table names, reports, and branded PDFs while updating runtime and library
compatibility.

## cPanel requirements

- PHP 8.3.x
- MariaDB 10.6+ or MySQL 8.0+
- PHP extensions: `mysqli`, `fileinfo`, `gd`, `mbstring`, `iconv`, `zlib`,
  `openssl`, `session`, and `json`
- Apache 2.4 with `.htaccess` support

## Configure before opening the site

1. In cPanel, copy `classes/config.local.inc.php.example` to
   `classes/config.local.inc.php`.
2. Put the newly rotated database and SMTP credentials in that new local file.
   Do not put credentials back into `config.inc.php`.
   Keep `DADI_PROJECT_URL` set to the exact installation URL, including
   `/sales/` at the end.
3. Set `classes/config.local.inc.php` to permission `600` using File Manager.
4. Keep directories at `755` and ordinary files at `644`. The upload directories
   `admin/employeepics` and `admin/product_wording` remain `755`; their local
   `.htaccess` files block script execution.
5. Select PHP 8.3 in cPanel MultiPHP Manager and enable the extensions above.
6. Import the supplied Local ERP SQL backup, then test on a staging URL first.

The archive previously contained live connection credentials. Rotate the old
database, cPanel/FTP/SFTP, SMTP, and administrator passwords before deployment.

## Compatible dependency versions

| Component | Version | Reason |
| --- | ---: | --- |
| PHP | 8.3.x | Target runtime |
| PHPMailer | 7.1.1 | Current library with legacy aliases retained |
| FPDF | 1.86 | Current FPDF line; existing PDF layouts retained |
| jQuery | 3.7.1 | jQuery Migrate 3.4.1 supports older theme plugins |
| Bootstrap | 3.4.1 | Latest Bootstrap 3 version compatible with this markup |
| DataTables | 1.13.11 | Latest compatible 1.x line |
| Chart.js | 2.9.4 | Latest compatible 2.x line |
| Materialize theme | Existing customized build | Preserves the current visual design |

## Included compatibility and security fixes

- Converted PHP short tags and removed PHP 7-only runtime calls.
- Added PHP 8-safe database result/error handling and legacy SQL-mode support.
- Applied the customer, invoice, payment, and bank-transaction save fixes.
- Fixed intermittent page-loader completion and sticky report headers.
- Fixed local-file image loading in FPDF and guarded output buffers.
- Fixed empty-string arithmetic in print reports and two-decimal report output.
- Replaced the legacy upload handler with MIME/type/size validation.
- Removed public diagnostics, development tests, backup configuration files,
  embedded credentials, and obsolete PHPMailer test utilities.
- Disabled directory listing and blocked executable files in upload folders.

## Database scope

This deployment is configured to use one Local ERP database for all legacy
connection slots. Only `DADI_DB_SERVER_LOCAL`, `DADI_DB_USER_LOCAL`,
`DADI_DB_PASSWORD`, and `DADI_DB_NAME_LOCAL` are required.

The supplied SQL dump contains 42 tables. It includes the Local ERP invoice,
payment, purchasing, stock, production, payroll, customer, and reporting tables.
The code also references `employee_mart`, `loan_mart`, and `salary_mart`, which
are absent from this dump. Those mart-only modules need a newer database backup
if they are used.

## Staging checklist

Test login and permissions, customers, products, purchases, invoices, customer
payments, bank transactions, refunds, stock, production, attendance, payroll,
all reports, CSV export, every PDF/print button, file uploads, and email. Keep
`display_errors` off and review the cPanel PHP error log if a page fails.
