# ONVITE Digital — Super Admin System

## Directory Structure

```
/var/www/html/                        ← web root
├── superadmin/                       ← Super Admin Panel (your private URL)
│   ├── login.php                     ← Super admin login
│   ├── index.php                     ← Dashboard
│   ├── create-project.php            ← Create new wedding site
│   ├── edit-project.php              ← Edit existing project
│   ├── manage-invitees.php           ← Add invitees manually or via Excel
│   ├── import-excel.php              ← Excel import handler
│   ├── download-template.php         ← Download .xlsx template
│   ├── rsvp-report.php               ← Full RSVP report per project
│   ├── projects.php                  ← All projects table
│   ├── sidebar.php / topbar.php      ← Layout partials
│   ├── logout.php
│   └── sa.css                        ← Super admin styles
│
├── includes/
│   ├── db.php                        ← DB connection (edit credentials here)
│   ├── config.php                    ← BASE_DIR, BASE_URL, PROJECTS_DIR
│   ├── sa_auth.php                   ← Auth helper
│   └── template_generator.php        ← Generates index.html from DB data
│
├── projects/                         ← Auto-created wedding sites
│   ├── MichelMaria/                  ← Example project
│   │   ├── index.html                ← Auto-generated wedding page
│   │   ├── get_invitees.php
│   │   ├── respond.php
│   │   ├── css/
│   │   │   ├── main.css
│   │   │   └── admin.css
│   │   ├── img/
│   │   │   ├── bg_1.jpg ... bg_9.jpg
│   │   │   ├── music.mp3
│   │   │   ├── love.png
│   │   │   ├── thumbnail.jpg
│   │   │   ├── icon-date.png
│   │   │   ├── icon-church.png
│   │   │   └── icon-venue.png
│   │   ├── admin/
│   │   │   ├── login.php             ← Per-project admin login
│   │   │   ├── index.php             ← Add invitees + view RSVP
│   │   │   ├── import_excel.php
│   │   │   └── logout.php
│   │   └── user/                     ← (Deprecated — merged into admin)
│
├── vendor/                           ← Composer packages (PhpSpreadsheet)
└── schema.sql                        ← Database schema
```

---

## Setup Steps

### 1. Database
```sql
-- Import the schema
mysql -u root -p < schema.sql

-- Set your own super admin password
UPDATE super_admins SET password = '$2y$12$...' WHERE username='superadmin';
-- Generate hash with PHP: echo password_hash('YourPassword', PASSWORD_BCRYPT);
```

### 2. Config Files
Edit `/includes/db.php`:
```php
define('DB_USER', 'your_mysql_user');
define('DB_PASS', 'your_mysql_password');
define('DB_NAME', 'onvite_superadmin');
```

Edit `/includes/config.php`:
```php
define('BASE_DIR',  '/var/www/html');
define('BASE_URL',  'https://onvite.digital');
```

### 3. Install PHP Dependencies (for Excel)
```bash
cd /var/www/html
composer require phpoffice/phpspreadsheet
```

### 4. Folder Permissions
```bash
chmod -R 755 /var/www/html/projects
chown -R www-data:www-data /var/www/html/projects
```

### 5. Template Icons
Copy your 3 icon images (date, church, venue) to a shared template folder:
- `img/icon-date.png`
- `img/icon-church.png`
- `img/icon-venue.png`

These are auto-copied into each new project's img/ folder.

### 6. Access
- **Super Admin:** `https://onvite.digital/superadmin/login.php`
- **Per-project Admin:** `https://onvite.digital/projects/MichelMaria/admin/login.php`
- **Wedding Site:** `https://onvite.digital/projects/MichelMaria/`
- **Guest RSVP Link:** `https://onvite.digital/projects/MichelMaria/index.html?token=abc123`

---

## Workflow

### Creating a New Wedding
1. Log into `/superadmin/`
2. Click **New Project**
3. Fill in all wedding details, upload photos, music, etc.
4. Click **Create Project** → website is auto-generated
5. Go to **Manage Invitees** → add guests manually or import Excel
6. Share the invitation link: `site.com/projects/GroomBride/?token=XYZ`

### Excel Import Format
| Column A (Token)    | Column B (Name)  |
|---------------------|------------------|
| family_smith        | John Smith       |
| family_smith        | Jane Smith       |
| friends_group1      | Alice Johnson    |

Download the pre-formatted template from the admin panel.

### Per-Project Admin Panel
Each project gets its own `/admin/` folder with:
- Separate password (set when creating the project)
- Same invitee management + RSVP view
- Combined admin + user flow (no separate login needed)

---

## Database Tables
| Table           | Purpose                          |
|-----------------|----------------------------------|
| super_admins    | Super admin accounts             |
| projects        | One row per wedding               |
| project_photos  | Up to 10 background photos       |
| invitations     | Token groups per project         |
| invitees        | Individual guests + RSVP status  |
