# Quick Installation Guide

## 1. Database Setup

### XAMPP (Local)
1. Start Apache + MySQL in XAMPP Control Panel.
2. Open `http://localhost/phpmyadmin/`.
3. Click "New" → Database name: `classic_catering` → Create.
4. Select the database → "Import" tab → upload `database/schema.sql` → Go.
5. "Import" tab again → upload `database/seed.sql` → Go.

### cPanel (Live)
1. cPanel → "MySQL Databases".
2. "Create New Database" → name it `classic_catering` (full name will be `yourname_classic_catering`).
3. "MySQL Users" → "Add New User" → username + password (save these!).
4. "Add User to Database" → select the user + database → ALL PRIVILEGES → Add.
5. Go to "phpMyAdmin" → select your database → "Import" → upload `database/schema.sql` → Go.
6. "Import" again → upload `database/seed.sql` → Go.

## 2. Configure Database Credentials

Edit `config/config.php`:

```php
define('DB_HOST', 'localhost');     // usually 'localhost' on cPanel
define('DB_PORT', '3306');         // default 3306
define('DB_NAME', 'yourname_classic_catering');  // full DB name from cPanel
define('DB_USER', 'yourname_user');              // full DB user from cPanel
define('DB_PASS', 'your-password-here');
define('SITE_URL', 'https://yourdomain.com');    // no trailing slash
define('SESSION_SECRET', 'a-random-32-char-string-here');
```

For XAMPP local, the defaults (`root`, empty password, `classic_catering`) usually work.

## 3. Upload Files

### XAMPP
Copy the entire `classic-catering-php` folder to `C:\xampp\htdocs\` (or wherever your XAMPP htdocs is). Then visit `http://localhost/classic-catering-php/public/`.

### cPanel
For security, upload so that `public/` is your web root:
1. Zip the contents of `classic-catering-php/` (so the structure is `config/`, `app/`, `public/`, `database/` at the top of the ZIP).
2. Upload via cPanel File Manager to a folder ABOVE `public_html` (e.g. `/home/yourname/classic-catering/`).
3. In cPanel → "Domains" or "Subdomains" → set the document root to `/home/yourname/classic-catering/public/`.

Alternative (simpler, less secure): upload everything to `public_html/` and visit `https://yourdomain.com/`. The `.htaccess` will route through `public/index.php`.

## 4. Set Permissions

The `public/uploads/` directory must be writable by the web server.

**cPanel File Manager**:
- Right-click `public/uploads/` → "Permissions" → set to `755` (or `775` if 755 doesn't work).
- Apply recursively to all subdirectories.

**SSH/terminal** (if available):
```bash
chmod -R 755 public/uploads/
```

## 5. Visit Your Site

- **Home page**: `https://yourdomain.com/`
- **Admin login**: `https://yourdomain.com/admin/login`
- **Student login**: `https://yourdomain.com/login`

## 6. Login Credentials

After importing `seed.sql`, these accounts exist in your database:

| Role | Email | Password | URL |
|---|---|---|---|
| **Super Admin** | `admin@classiccatering.com` | `Admin@2026` | `/admin/login` |
| **Student** | `student@demo.com` | `Student@2026` | `/login` |

⚠️ **CHANGE THE ADMIN PASSWORD IMMEDIATELY** after first login:
1. Log in at `/admin/login` with the credentials above.
2. Go to "My Profile" (bottom of sidebar).
3. "Change Password" section → enter current password + new password.
4. Save.

## 7. Configure Your Business Info

After logging in as admin:
1. **Website Settings → Branding** → upload your logo + favicon
2. **Website Settings → General** → business name, tagline, hero text
3. **Website Settings → Contact** → phone, email, address, opening hours, WhatsApp, Google Maps embed
4. **Website Settings → Payment** → bank name, account name, account number, payment instructions
5. **Website Settings → SEO** → SEO title, meta description

## Troubleshooting

### "Database connection failed"
- Check `config/config.php` credentials.
- On cPanel, the DB name and user have a prefix (e.g. `yourname_classic_catering` not just `classic_catering`).
- Verify the DB user has ALL PRIVILEGES on the database.

### "404 - Not Found" on all pages
- Make sure `.htaccess` is uploaded and `mod_rewrite` is enabled (it usually is on cPanel).
- If `mod_rewrite` is disabled, ask your host to enable it.

### "CSRF token mismatch" error
- Clear browser cookies and try again.
- Make sure your `SESSION_SECRET` in `config/config.php` is set to a non-default value.
- Sessions must be working — check that PHP's `session.save_path` is writable.

### "500 Internal Server Error"
- Set `DEBUG_MODE = true` in `config/config.php` to see the actual error.
- Check the PHP error log (cPanel → "Errors" or "MultiPHP Manager" → error_log).

### Styles look broken (no Tailwind)
- The site uses Tailwind via CDN. Make sure you have internet access on the server.
- If you need offline mode, download Tailwind from `https://unpkg.com/tailwindcss@^3` and host it locally in `public/assets/`.

### File uploads fail
- Verify `public/uploads/` is writable (`chmod 755` or `775`).
- Check `php.ini` settings: `upload_max_filesize = 10M`, `post_max_size = 12M`.
- On shared hosting, the `php.ini` overrides may need to be in `public/.htaccess` or a `.user.ini` file.

## Final Verification

After setup, test these flows:
1. **Home page** loads with hero, services, gallery, testimonials. ✓
2. **Contact form** submits successfully. ✓
3. **Register** a new student account → check that you can log in. ✓
4. **Login as admin** → see dashboard with stats. ✓
5. **Admin → Website Settings → Branding** → upload a logo → see it appear in the header. ✓
6. **Admin → Catering Services** → add/edit/delete a service. ✓
7. **Admin → Landing Pages** → create a new landing page → activate it → see home page change. ✓
8. **Login as student** → see dashboard. ✓
9. **Student → Upload Receipt** → upload a payment receipt → admin sees it in Payments. ✓
10. **Admin → Payments** → verify the receipt → student sees the verified status. ✓

If all 10 flows work, your installation is complete. 🎉
