# Final merged installation (Phases 1-11)

This package is the cumulative Hotel Food Service Platform through Phase 11. It contains the complete PHP application plus a consolidated MySQL installer:

`database/full-install.sql`

## Fresh cPanel installation

1. Create a MySQL 8+ database and database user in cPanel and grant that user all privileges on the new database.
2. Import `database/full-install.sql` in phpMyAdmin.
3. Copy `.env.example` to `.env` and enter the real URL and MySQL credentials.
4. Generate a production application key:
   `php bin/generate-key.php`
   Put the generated value into `APP_KEY` in `.env`.
5. Set a unique `SEED_ADMIN_EMAIL`, `SEED_ADMIN_USERNAME`, and a strong `SEED_ADMIN_PASSWORD` of at least 12 characters in `.env`.
6. Install PHP dependencies:
   `composer install --no-dev --optimize-autoloader`
7. Run the secure seed finalizer:
   `php bin/seed.php`
   This creates/updates the administrator password hash and issues cryptographically secure table/room QR records. The SQL file intentionally does not contain reusable default credentials or QR secrets.
8. Run production preparation and checks:
   `php bin/optimize.php`
   `php bin/check.php`
   `php bin/security-audit.php`
   `php bin/test.php`
9. Configure the domain document root to the package `public/` directory where cPanel permits it. Otherwise follow `DEPLOYMENT-CPANEL.md`.
10. Configure the cPanel cron described in `PRODUCTION-RUNBOOK.md`.

## Existing Phase 1-11 installation

Do not import `database/full-install.sql` over an existing production database. Keep using:

`php bin/migrate.php`

The consolidated installer is intended for a new, empty database. Existing installations should use migrations to preserve live transactional data safely.

## Logo

The genuine `cp-nav-logo-endorsed.svg` was not supplied during development. Add the original file as:

`public/assets/images/hotel-logo.svg`

Do not redraw or replace the official logo with a fabricated version.

## Database contents

The consolidated SQL includes all 15 migrations, schema migration markers, and the idempotent Crowne Plaza Riyadh RDC demo/master seed data. Sensitive runtime secrets, administrator password hashes, and QR tokens are created by PHP after deployment rather than being hard-coded into the SQL dump.

## cPanel MariaDB compatibility note

Some cPanel hosts identify the database service generically as MySQL while actually running MariaDB. Recent MariaDB releases can reject a `CHECK` constraint that references foreign-key columns using `ON DELETE SET NULL` with error `1901`. The merged installer omits only `chk_bill_context`; the same invariant is enforced by `BillingService` before a bill can be created. All other schema constraints remain unchanged.



## Phase 11 – Guest Waiting Experience & Promotions

After upgrading from the Phase 10/merged release:

```bash
php bin/migrate.php
php bin/seed.php   # optional demo Phase 11 promotions/events; use only when desired
php bin/check.php
php bin/test.php
```

Manage campaigns at `/admin/promotions`. The order status page loads eligible cards from `/api/v1/orders/{order}/engagement` while the guest waits. Promotion schedules use hotel-local time. Demo campaigns and events are placeholders and must be replaced with approved hotel content. Promotional discount fields are informational marketing metadata in Phase 11 and do not automatically change the current bill.

---

## Phase 12 licensing — required before production operations

Phase 12 is cumulative and introduces commercial license enforcement.

Before deploying to a hotel customer, generate your vendor signing key pair using the separate vendor license issuer tool. Put only its public key into the customer `.env`:

```env
LICENSE_PUBLIC_KEY_BASE64=<vendor-public-key>
```

After database import/migration and `php bin/seed.php`, obtain the server identity:

```bash
php bin/license-request.php activation-request.json
```

Issue a signed license on the vendor side and install it:

```bash
php bin/license-install.php license.json
php bin/license-status.php
```

Until a valid signed license is installed, operational hotel routes intentionally remain locked while administrator login, licensing and diagnostics remain available.
