# CT NAILS — Deployment Checklist (සිංහලෙන්)

Site එක දාන්න ඕනේ `https://edurx.icu/ctnails/` — live folder එක: `public_html/ctnails`
(**hyphen එක නැහැ**; පරණ `ct-nails` නමෙන් 404 ආවා මේ host එකේ).

පියවර ටික **මේ පිළිවෙළටම** කරන්න. පියවර 5 skip කරන්න එපා — database එක නැතුව
booking එකයි admin එකයි කිසි දෙයක් save කරන්නේ නැහැ.

## 1. Zip එක upload කරන්න

1. `CTNAILS-Final-Complete.zip` එක server එකට upload කරන්න.
2. Unzip කරන්න — folder එක `public_html/ctnails/` වෙන්න ඕනේ, ඒ ඇතුළේ `public/` තියෙන්න ඕනේ
   (`public_html/ctnails/public/index.php` තියෙනවාද කියලා බලන්න).
3. ඊට පස්සේ server එකෙන් zip file එක delete කරන්න.

## 2. Permissions හදන්න

- Folders: `0755`
- Files: `0644`
- `uploads/` folder එක web server එකට ලියන්න පුළුවන් වෙන්න ඕනේ (`0755` ගොඩක්
  shared host වලට ඇති; upload fail වෙනවා නම් `uploads/` සහ ඒ ඇතුළේ තියෙන
  subfolder වලට `0775` දාන්න).

## 3. Database එක හදන්න

1. cPanel → MySQL Databases වලින් database එකක් හදන්න (උදා: `username_ctnails`)
   සහ ඒකට ALL PRIVILEGES තියෙන database user කෙනෙක් හදන්න.
2. Database එකේ නම, username එක, password එක හරියටම ලියාගන්න — පියවර 4ට ඒවා ඕනේ.

## 4. Database එක import කරන්න (මේ පිළිවෙළටම)

cPanel → phpMyAdmin වලින් database එක select කරලා, පහළ file ටික පිළිවෙළට Import කරන්න:

1. `database/schema.sql` — tables 19ක්
2. `database/seed.sql` — memberships, admin, categories, services 12ක්, staff 3ක්,
   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`

Import කරලා ඉවර වුණාම මේකෙන් check කරන්න:

```sql
SELECT COUNT(*) FROM services;            -- 12 වෙන්න ඕනේ
SELECT COUNT(*) FROM service_categories;  -- 5 වෙන්න ඕනේ
SELECT COUNT(*) FROM memberships;         -- 3 වෙන්න ඕනේ
SELECT COUNT(*) FROM staff;               -- 3 වෙන්න ඕනේ
SELECT COUNT(*) FROM availability;        -- 7 වෙන්න ඕනේ
```

## 5. `includes/config.php` හදන්න

1. Server එකේ `includes/config.example.php` එක copy කරලා `includes/config.php`
   කියලා හදන්න (example file එකේ නම මාරු කරන්න එපා — ඒක template එක විදියට තියන්න).
2. මේවා පුරවන්න:
   - `DB_HOST` — shared hosting වල සාමාන්‍යයෙන් `localhost`
   - `DB_NAME`, `DB_USER`, `DB_PASS` — පියවර 3න් ලියාගත්ත ඒවා
   - `SITE_URL` — `https://edurx.icu/ctnails` (අගට slash එකක් දාන්න එපා)
   - `COOKIE_SECURE` — `true` දාන්න (live site එක HTTPS නිසා)
3. PayHere හිස්ව තියන්න දැනට (පියවර 8 බලන්න). SMTP විස්තර තියෙනවා නම් විතරක්
   SMTP පුරවන්න (SMTP නැතුව email notifications යන්නේ නැහැ, ඒත් ඒක හංගන්නේ නැහැ —
   ඒවා skip වෙනවා).
4. ඇත්ත credentials chat එකේවත්, `config.example.php` එකේවත්, git එකේවත්
   දාන්න එපා. `config.php` එක `.gitignore` එකේ තියෙනවා, ඒක වෙන කොහේවත්
   upload කරන්නත් එපා.

## 6. මුලින්ම admin password එක මාරු කරන්න

1. `https://edurx.icu/ctnails/public/admin/login.php` open කරන්න.
2. Seed admin එකෙන් login වෙන්න:
   - Email: `admin@ctnails.lk`
   - Password: `admin123`
3. එකපාරටම **Admin → Settings → Change Password** වලින් ශක්තිමත් අලුත්
   password එකක් දාන්න. මාරු කරනකන් dashboard එකේ රතු warning එකක් පේනවා.
4. Seed login එක ලියලා තියෙන්නේ `database/seed.sql` එකේ සහ මේ file එකේ විතරයි —
   login page එකේ පෙන්නන්නේ නැහැ.

## 7. Live site එක මුල ඉඳන් අගට test කරන්න

1. Home page එක: `https://edurx.icu/ctnails/public/` — load වෙනවා, services පේනවා.
2. Booking: **Classic Gel Manicure → සෙනසුරාදා දවසක් → 10:00 → No preference
   → ඔයාගේ නම + phone → Pay at Salon (Cash) → Confirm** තෝරන්න. `CT-YYYYMMDD-XXXX`
   reference එකක් ලැබෙන්නම ඕනේ. "not connected to a database" කියලා ආවොත්
   පියවර 4 හරි 5 හරි වැරදියි — ආයෙත් check කරන්න.
3. My Booking: reference එකයි phone එකයි දීලා booking එක හොයලා, cancel කරන්න
   (එතකොට ඒ slot එක ආයෙත් free වෙනවා).
4. Admin: login වෙලා **Appointments** open කරන්න — test booking එක පේන්න ඕනේ;
   ඒක approve කරලා, ඊට පස්සේ cancel කරන්න.
5. Contact form: test message එකක් යවන්න — ඒක save වෙන්න ඕනේ (Admin → Dashboard
   එකේ පේනවා; `contact_messages` table එකේ save වෙනවා).

## 8. PayHere (පියවර 1–7 හරියට වැඩ කළාට පස්සේ විතරක්)

1. PayHere merchant dashboard එකේ: **Settings → Domains & Credentials** —
   **Merchant ID** එකයි **Merchant Secret** එකයි copy කරගන්න.
2. Server එකේ `includes/config.php` එකේ මේවා දාන්න:
   - `PAYHERE_MERCHANT_ID` සහ `PAYHERE_MERCHANT_SECRET`
   - `PAYHERE_SANDBOX` = `true` මුලින්ම දාන්න — PayHere sandbox card එකකින් test කරන්න.
3. එක sandbox payment එකක් test කරන්න: online book කරලා **deposit (20%)**
   එක pay කරන්න, **Admin → Payments** බලන්න — payment එක **paid** කියලාත්
   appointment එක **confirmed** කියලාත් පේන්න ඕනේ. (Payment එක paid කියලා
   mark වෙන්නේ PayHere `public/payhere/notify.php` එකට call කරලා server එක
   verify කළාට පස්සේ විතරයි.)
4. Sandbox payment එක වැඩ කළාට පස්සේ විතරක්, live payments වලට
   `PAYHERE_SANDBOX` = `false` දාන්න.
5. Refunds: PayHere merchant refund API එකක් නැහැ — refund එක **Admin → Payments**
   එකේ record වෙනවා, සල්ලි ආපහු දෙන්න ඕනේ PayHere merchant dashboard එකෙන්.

## 9. Launch කරන්න කලින් studio එකෙන් තාම ඕනේ දේවල්

- ඇත්ත **phone number** එකයි **WhatsApp number** එකයි — Admin → Settings
  (දැන් තියෙන්නේ `+94 77 000 0000` placeholder එක)
- ඇත්ත **Instagram URL** එකයි **studio address** එකයි — Admin → Settings
  (දැන් තියෙන්නේ `instagram.com/ctnails` සහ `Colombo, Sri Lanka`)
- ඇත්ත **gallery / service photos** — Admin → Gallery (JPG/PNG/WebP upload කරන්න,
  එකක් max 5 MB; දැන් site එකේ පේන්නේ gradient art tiles)
- Contact page එකට **Google Maps embed URL** එක — Admin → Settings
  (`salon_map_url`)
- **PayHere Merchant ID + Secret** — පියවර 8 (chat එකේ කවදාවත් දාන්න එපා)

## මොකක් හරි වැරදුණොත්

| පේන ලක්ෂණය | Check කරන්න |
|---|---|
| හැම page එකම 404 | Folder එක `public_html/ctnails` වෙන්න ඕනේ, `ct-nails` නෙවෙයි; `public/index.php` තියෙන්න ඕනේ |
| 403 | Folder permissions 0755, file permissions 0644 |
| "not connected to a database" | `includes/config.php` තියෙනවාද, DB විස්තර හරිද බලන්න; database import කරලාද බලන්න (පියවර 4) |
| Booking save වෙනවා, ඒත් slots හැමවෙලේම free වගේ පේනවා | `availability` rows නැහැ — `seed.sql` ආයෙත් import කරන්න |
| Admin login fail වෙනවා | Email/password හරිද බලන්න; 5 වතාවක් වැරදුණොත් login විනාඩි 5කට lock වෙනවා |
| PayHere checkout refuse වෙනවා | `config.php` එකේ Merchant ID + secret හිස්ව තියෙනවා — පුරවන්න (පියවර 8) |
| Payment paid, ඒත් booking තාම pending | PayHereට `public/payhere/notify.php` එකට එන්න බැරි වෙලා — site එක HTTPS වලින් reachable ද, `PAYHERE_SANDBOX` එක PayHere account එකේ mode එකට ගැලපෙනවද බලන්න |

## Site zip එකේ නැති දේවල්

- `tests/phase7-sqlite-test.php` — Phase 7 test harness (development එකට විතරක්)
- `includes/config.php` — server එකේ විතරක් හදන්නේ, zip එකේ එන්නේ නැහැ
