## Deployment Guide

1. **Prerequisites**
   - PHP 8.1+, Composer, MySQL 8+, Apache/Nginx with mod_rewrite.
   - Enable PHP extensions: `pdo_mysql`, `openssl`, `mbstring`, `fileinfo`.

2. **Clone & install**
   ```bash
   cd /Applications/XAMPP/xamppfiles/htdocs
   git clone <repo> mutiaragroupapp
   cd mutiaragroupapp
   composer install
   ```

3. **Environment config**
   - Copy `config/config.example.php` → `config/config.php`.
   - Or set environment variables (`APP_NAME`, `BASE_URL`, `DB_*`, `MAIL_*`).

4. **Database**
   ```bash
   mysql -u root -p < sql/schema.sql
   ```
   - Default users created automatically (see README).

5. **Apache/Nginx**
   - Point virtual host to `public/`.
   - Enable `.htaccess` (Apache) or replicate rewrite rule in Nginx:
     ```
     try_files $uri $uri/ /index.php?$query_string;
     ```

6. **Permissions**
   ```bash
   chmod -R 775 public/uploads/claims public/uploads/branding storage/logs
   ```

7. **Testing**
   - Access `http://localhost/mutiaragroupapp/public`.
   - Login using default IDs (Admin `999999999999`, Approver `888888888888`, Staff `111111111111` – password sama seperti ID) dan hantar permohonan ujian.
   - Approver approves/rejects, admin validates exports.
   - Buka `Admin > Tetapan Syarikat` untuk memuat naik logo & maklumat syarikat; pastikan `public/uploads/branding` boleh ditulis.

8. **Email**
   - Configure SMTP credentials in `config/config.php`.
   - Ensure outbound mail ports open. Test via staff submission (approver email) and approval (admin email).

9. **Cron (optional)**
   - Schedule log cleanup/reporting scripts in `storage/logs`.

10. **Security hardening**
    - Update default passwords.
    - Force HTTPS, set proper file permissions, configure Web Application Firewall if available.

### Troubleshooting
- **White screen**: enable display errors in `php.ini` or check `storage/logs`.
- **Uploads failing**: ensure `public/uploads/claims` & `public/uploads/branding` writable and file < 10MB.
- **Emails not sending**: verify SMTP credentials and use TLS port 587.
- **PDF export blank**: ensure `dompdf/dompdf` installed and `php -m` shows `mbstring`.

