# AAF Live CX Intelligence System — Setup Guide
## Version 2.0 | PHP + MySQL | cPanel / XAMPP

---

## Folder Structure
```
cx-system/
├── survey/
│   ├── index.php          ← Customer QR/survey form (multilingual)
│   └── submit.php         ← Survey submission handler
├── admin/
│   ├── login.php          ← Admin login
│   ├── ceo_dashboard.php  ← CEO/COO enterprise dashboard
│   ├── dashboard.php      ← Operational dashboard (branch/touchpoint/product/dept)
│   ├── red_alerts.php     ← Red alert management
│   ├── cases.php          ← Case management & SLA tracking
│   ├── feedback.php       ← All feedback with filters
│   ├── touchpoints.php    ← Touchpoint & QR code management
│   ├── branches.php       ← Branch management
│   ├── routing.php        ← Routing rules
│   ├── reports.php        ← Reports & CSV export
│   ├── settings.php       ← System configuration
│   ├── users.php          ← User management
│   └── logout.php
├── includes/
│   ├── config.php         ← DB config + core helpers (EDIT THIS)
│   ├── auth.php           ← Session & auth
│   └── nav.php            ← Shared sidebar navigation
├── assets/
│   └── style.css          ← Shared admin styles
├── sql/
│   └── schema.sql         ← Full database schema
├── fix_password.php       ← Password reset helper (DELETE AFTER USE)
└── SETUP_GUIDE.md
```

---

## Step 1: Create MySQL Database (cPanel / phpMyAdmin)
1. Log into **cPanel → MySQL Databases**
2. Create database: `aaf_cx`
3. Create user, assign ALL PRIVILEGES
4. Go to **phpMyAdmin → aaf_cx → Import → schema.sql → Go**

---

## Step 2: Configure `includes/config.php`
```php
define('DB_USER', 'your_db_user');     // ← change
define('DB_PASS', 'your_db_password'); // ← change
define('SITE_URL', 'https://yourdomain.com/cx-system'); // ← change
```

---

## Step 3: Upload to Hosting
- Upload entire `cx-system/` folder to `public_html/cx-system/`
- All `.php` files → permissions **644**
- All folders → permissions **755**

---

## Step 4: Fix Password (XAMPP local testing)
Visit: `http://localhost/cx-system/fix_password.php`
Then delete the file.

---

## Step 5: Access the System

| URL | Purpose |
|-----|---------|
| `/admin/login.php` | Admin login |
| `/admin/ceo_dashboard.php` | CEO/COO enterprise view |
| `/admin/dashboard.php` | Operational dashboard |
| `/admin/touchpoints.php` | Manage touchpoints & QR codes |
| `/survey/index.php?t=TOKEN` | Customer feedback form |

**Default login:**
- Email: `admin@asiaasset.lk`
- Password: `Admin@2026`

---

## Step 6: Generate QR Codes
1. Login → **Touchpoints & QR**
2. Click **📱 QR** on any touchpoint
3. Print or screenshot the QR code
4. Place at the relevant desk/counter

## QR URL Format
```
https://yourdomain.com/cx-system/survey/index.php?t=TOUCHPOINT_TOKEN
```

---

## Alert Levels
| Level | Trigger | SLA |
|-------|---------|-----|
| 🟢 Green | Rating 4-5 | 72h |
| 🟡 Amber | Rating = 3 | 24h |
| 🔴 Red | Rating ≤ 2 | 4h |
| 🔴 Critical | Rating = 1 | 2h |

Red + Critical alerts auto-create cases and notify CX Officer.

---

## Security Checklist
- [ ] Change default admin password
- [ ] Enable SSL/HTTPS
- [ ] Delete `fix_password.php` after use
- [ ] Delete `sql/` folder after import
- [ ] Set DB user with limited privileges

---

Developed by **B Force Media (Pvt) Ltd** for Asia Asset Finance PLC
