# Prestige Portal update — read before deployment

## What this package does
Admin-only create/edit/cancel (server enforced), mandatory cancellation reason, immutable audit entries, role-scoped order visibility, staff assignment, stage updates, stage summary and CSV export for Excel.

## Important limitations
This is an incremental update, NOT yet the complete requested portal. **Native XLSX, PDF export, document uploads, notification delivery, and user management screens are not implemented.** CSV opens in Excel but is not an XLSX file. Existing legacy statuses (sampling, materials, sewing, inspection) remain visible but are not selectable for new updates. No live deployment or integration testing was performed.

## Deployment steps
1. Back up the existing portal files and export the current MySQL database using phpMyAdmin.
2. In phpMyAdmin, select database `theprestigetrade_prestige_portal` and import `sql/migrate.sql` **once**. This migration uses ALTER TABLE ADD COLUMN and is not rerunnable as-is.
3. In cPanel File Manager, upload/extract only the included `app/` and `public/` PHP files into the EXISTING portal project root, preserving `config.php` at the parent project root. Do not overwrite the live `.htaccess` with anything else; the provided `.htaccess` is from your original ZIP. Do not move the project root or change WordPress files.
4. Remove any old `setup_admin.php` from public and project root; never expose admin setup utilities via the web.
5. Log in and test with an admin, a staff user assigned to an order, a factory user, and a buyer user. Verify access controls and exports.
6. Ensure HTTPS is enabled, and turn ModSecurity back ON if previously disabled.

## Important access behavior
Staff can view only orders explicitly assigned by admin. Factory/buyer access is matched by their login email in order records. Only admins can create, edit, cancel. Staff/factory may post production stage updates to authorized active orders. Buyers have read-only access. Cancelled orders remain in reports.

## Rollback
Restore the backed-up PHP files. Database migration adds columns/table and is generally safe to leave in place. Do not drop columns or tables to roll back without a backup.

## Security
Do not upload config.php, tokens, private passwords or real customer data to ChatGPT. This package contains no database credentials. Keep config.php outside public web root.


## Shared team chat (new)
1. Back up your database. Import `sql/chat_migrate.sql` in phpMyAdmin once (after the main migration if not already applied).
2. Upload `public/chat.php` and the updated `app/bootstrap.php` to the matching live folders.
3. Sign in and select **Team Chat** in the navigation. Messages refresh every five seconds.
4. All four roles can read and post; every signed-in user sees the same messages. No attachments, private chats, or push notifications are included.
5. The chat uses the existing portal login and database; do not expose `sql/` or `app/` to the public web root.

## Private chat addition
Import `sql/private_chat_migrate.sql` into the existing portal MySQL database once. Upload `public/private_chat.php` and the updated `app/bootstrap.php` along with the other portal files. Private Chat appears in the navigation for logged-in users. Conversations are restricted to the two participants by SQL filtering and active-user validation. Messages refresh every 5 seconds. This is not end-to-end encrypted; hosting/database administrators may access stored messages.
