# CT NAILS — Deployment Checklist

Deploy the site to `https://edurx.icu/ctnails/` (live folder: `public_html/ctnails` —
**no hyphen**; the old `ct-nails` folder name returned 404 on this host).

Do the steps **in this order**. Do not skip step 5 — without the database,
booking and admin cannot save anything.

## 1. Upload the zip

1. Upload `CTNAILS-Phase7-final.zip` to the server.
2. Unzip it so the folder is `public_html/ctnails/` with `public/` inside it
   (`public_html/ctnails/public/index.php` must exist).
3. Delete the zip file from the server afterwards.

## 2. Fix permissions

- Folders: `0755`
- Files: `0644`
- `uploads/` must be writable by the web server (`0755` is enough on most
  shared hosts; if uploads fail, set `uploads/` and its subfolders to `0775`).

## 3. Create the database

1. In cPanel → MySQL Databases, create a database (e.g. `username_ctnails`)
   and a database user with ALL PRIVILEGES on it.
2. Note the exact database name, username and password — you need them in step 4.

## 4. Import the database (in this exact order)

In cPanel → phpMyAdmin, select the database, then Import each file in order:

1. `database/schema.sql` — 19 tables
2. `database/seed.sql` — memberships, admin, categories, 12 services, 3 staff,
   opening hours, settings, sample coupon
3. `database/migrations/002_contact_messages.sql`
4. `database/migrations/003_staff_services.sql`
5. `database/migrations/004_payhere_loyalty.sql`

Verify after import:

```sql
SELECT COUNT(*) FROM services;            -- expect 12
SELECT COUNT(*) FROM service_categories;  -- expect 5
SELECT COUNT(*) FROM memberships;         -- expect 3
SELECT COUNT(*) FROM staff;               -- expect 3
SELECT COUNT(*) FROM availability;        -- expect 7
```

## 5. Create `includes/config.php`

1. Copy `includes/config.example.php` to `includes/config.php` on the server
   (do NOT rename the example file — keep it as the template).
2. Fill in:
   - `DB_HOST` — usually `localhost` on shared hosting
   - `DB_NAME`, `DB_USER`, `DB_PASS` — from step 3
   - `SITE_URL` — `https://edurx.icu/ctnails` (no trailing slash)
   - `COOKIE_SECURE` — set to `true` (the live site uses HTTPS)
3. Leave PayHere empty for now (see step 8). Leave SMTP empty unless you
   have SMTP details (email notifications are skipped honestly without them).
4. Never put real credentials in chat, in `config.example.php`, or in git.
   `config.php` is in `.gitignore` and must never be uploaded anywhere else.

## 6. Change the admin password FIRST

1. Open `https://edurx.icu/ctnails/public/admin/login.php`
2. Log in with the seed admin:
   - Email: `admin@ctnails.lk`
   - Password: `admin123`
3. Immediately go to **Admin → Settings → Change Password** and set a
   strong new password. The dashboard shows a red warning until you do.
4. The seed login is documented in `database/seed.sql` and this file only —
   it is NOT shown on the login page.

## 7. Test the live site end to end

1. Home page: `https://edurx.icu/ctnails/public/` — loads, services show.
2. Booking: pick **Classic Gel Manicure → a Saturday → 10:00 → No preference
   → your name + phone → Pay at Salon (Cash) → Confirm**. You must get a
   `CT-YYYYMMDD-XXXX` reference. If it says "not connected to a database",
   step 4 or 5 is wrong — re-check them.
3. My Booking: look the booking up by reference + phone, then cancel it
   (this frees the slot again).
4. Admin: log in, open **Appointments** — the test booking appears;
   approve it, then cancel it.
5. Contact form: send a test message — it must save (Admin → Dashboard
   shows it; it is stored in `contact_messages`).

## 8. PayHere (only after steps 1–7 pass)

1. In the PayHere merchant dashboard: **Settings → Domains & Credentials** —
   copy the **Merchant ID** and **Merchant Secret**.
2. In `includes/config.php` on the server, set:
   - `PAYHERE_MERCHANT_ID` and `PAYHERE_MERCHANT_SECRET`
   - `PAYHERE_SANDBOX` = `true` first — test with a PayHere sandbox card.
3. Test one real sandbox payment: book online, pay the **deposit (20%)**,
   and check **Admin → Payments** — the payment must show as **paid** and
   the appointment as **confirmed**. (A payment is only marked paid after
   PayHere calls `public/payhere/notify.php` and the server verifies it.)
4. Only when the sandbox payment works, set `PAYHERE_SANDBOX` = `false`
   for live payments.
5. Refunds: there is no PayHere merchant refund API — a refund is recorded
   in **Admin → Payments** and the money itself is refunded in the PayHere
   merchant dashboard.

## 9. Still needed from the studio (before launch)

- Real **phone number** and **WhatsApp number** — Admin → Settings
  (currently `+94 77 000 0000` placeholder)
- Real **Instagram URL** and **studio address** — Admin → Settings
  (currently `instagram.com/ctnails` and `Colombo, Sri Lanka`)
- Real **gallery / service photos** — Admin → Gallery (upload JPG/PNG/WebP,
  max 5 MB each; the site currently shows gradient art tiles)
- **Google Maps embed URL** for the contact page — Admin → Settings
  (`salon_map_url`)
- **PayHere Merchant ID + Secret** — step 8 (never in chat)

## If something goes wrong

| Symptom | Check |
|---|---|
| 404 on every page | Folder must be `public_html/ctnails`, not `ct-nails`; `public/index.php` must exist |
| 403 | Folder permissions 0755, file permissions 0644 |
| "not connected to a database" | `includes/config.php` exists with correct DB details; database imported (step 4) |
| Booking saves but slots always look free | `availability` rows missing — re-import `seed.sql` |
| Admin login fails | Check the email/password; after 5 wrong tries login locks for 5 minutes |
| PayHere checkout refuses | Merchant ID + secret are empty in `config.php` — fill them in (step 8) |
| Payment paid but booking still pending | PayHere could not reach `public/payhere/notify.php` — check the site is reachable over HTTPS and `PAYHERE_SANDBOX` matches the PayHere account mode |

## What is NOT in the site zip

- `tests/phase7-sqlite-test.php` — Phase 7 test harness (development only)
- `includes/config.php` — created on the server only, never shipped
