# GlobRes Billing cPanel Install

This package is designed for a standard cPanel shared hosting account running PHP and MySQL/MariaDB.

## Requirements

- PHP 8.1 or newer, preferably PHP 8.2/8.3
- PHP extensions: `mysqli`, `pdo_mysql`, `zip`, `xml`, `xmlreader`, `simplexml`, `iconv`, `zlib`
- MySQL or MariaDB database
- Ability to import SQL with phpMyAdmin or cPanel Backup/Database tools

The `zip` extension is required for XLSX uploads and ZIP export files.

## Package Layout

The cPanel deployment ZIP contains:

```text
public_html/
database/promobi_billing_cpanel.sql
INSTALL-CPANEL.md
VERSION.txt
```

Upload the contents of `public_html/` into your domain or subdomain document root. Import the SQL file from `database/` into MySQL.

## Quick Install

1. In cPanel, create a MySQL database and database user.
2. Give the database user all privileges on that database.
3. Import `database/promobi_billing_cpanel.sql` into the new database using phpMyAdmin.
4. Upload the contents of `public_html/` into your domain or subdomain document root, for example `public_html/billing`.
5. In the uploaded app folder, copy `.env.cpanel.example` to `.env`.
6. Edit `.env` with your cPanel database details:

```text
APP_DEBUG=0
DB_HOST=localhost
DB_PORT=3306
DB_USER=cpaneluser_dbuser
DB_PASSWORD=your_password_here
DB_DATABASE=cpaneluser_dbname
```

7. Make sure these folders are writable by PHP:

```text
uploads
dump
logs
```

Usually cPanel works with `755` folders. If uploads or exports fail, set these folders to `775`.

8. Open your domain or subdomain in the browser.

Default local login:

```text
Username: local
Password: local
```

Change the password after deployment if this site is reachable by anyone outside your team.

## Monthly Use

1. Open Step 1 and upload the six source files.
2. Click Validate uploads and continue.
3. Run Step 2 to import and normalize the files.
4. Run Step 3 to transform and build the final transaction master.
5. Click Build File.
6. Download the ZIP, main CSV, or RFP CSV from the Export Ready screen.

Step 1 preprocessing:

- BillingDetail / RedX Transaction File is cleaned into `redxtx.csv`.
- RedX cleanup removes the report footer, Loyalty columns, PMS channel rows, and Channel Connect rows for Add To Tx hotels with `CCX/NC`.
- Xpress raw export is cleaned into `tourisofttx.csv` through the Xpress Per Night Clients mapping.

Export outputs:

- `On_Arrival_<name>.csv`
- `On_Arrival_RFP_<name>.csv`
- A ZIP containing both CSV files

Uploads support CSV, UTF-8 CSV, TSV/TXT, and XLSX. The app normalizes source data to UTF-8 and stores tables as `utf8mb4` so Arabic, Hebrew, Cyrillic, German umlauts, and other special characters are preserved when the source file contains them correctly.

## Troubleshooting

- If XLSX upload fails, enable the PHP `zip` extension in cPanel PHP Selector.
- If large uploads fail, confirm `.user.ini` is present and cPanel has loaded it, or raise `upload_max_filesize` and `post_max_size` in cPanel MultiPHP INI Editor.
- If the app says the database connection failed, recheck `.env` database name, user, password, host, and port.
- Check `logs/app.log` and `logs/php-error.log` from the Error Log page or cPanel File Manager.
