# Volunteer Management System Overview

## Purpose
This system allows the Board Admin (user 999914) to manage volunteer roles and provides volunteers with easy access to their role-specific email accounts and Google Drive folders.

## System Components

### 1. Database Table: `EventVolunteerRoles`
Stores volunteer role information including:
- **Member ID**: The member ID of the person assigned to the role
- **Volunteer Email**: The email address for the volunteer role (e.g., secretary@elparaisogolf.com)
- **Volunteer Password**: Password for the volunteer email account
- **Role Name**: Name of the role (e.g., 'secretary', 'greens')
- **Google Workspace Emails**: Links to Private and Business workspace accounts
- **Status**: Active/Inactive flag

**Location**: `/var/www/html/wordpress6/wordpress/EP/tools-create-volunteer-management-table.sql`

### 2. Volunteer Management Interface
Admin interface accessible only to user 999914 (Board Admin).

**Features**:
- Add/Update volunteer roles
- View all volunteer roles in a table
- Activate/Deactivate volunteer roles
- Delete volunteer roles
- Manage member ID, email, password, and role name

**Location**: `/var/www/html/wordpress6/wordpress/EP/event-volunteer-management.php`

**Access**: Available from the Event Dashboard for user 999914 via the "👥 Volunteer Management" button.

### 3. Event Dashboard Integration
Enhanced dashboard with volunteer-specific features.

**For Board Admin (999914)**:
- **Volunteer Management Button**: Direct access to manage volunteer roles
- **Volunteer Webmail Dropdown**: Quick access to all volunteer email accounts
- **Google Workspace Dropdown**: 
  - Private Workspace Admin (elparaisogolf.co@gmail.com)
  - Business Workspace Admin (elparaisogolfclub@gmail.com)
  - Direct links to volunteer role Google Drive folders

**For Volunteers** (users with assigned volunteer roles):
- **My Volunteer Email Button**: Quick access to their role email account
- **Google Workspace Links**: Access to Private and Business workspaces

**Location**: `/var/www/html/wordpress6/wordpress/EP/event-dashboard.php`

## Current Volunteer Roles

### 1. Secretary Role
- **Member ID**: 8022 (Barry Kirk)
- **Email**: secretary@elparaisogolf.com
- **Password**: @Elparaisogolf2025@
- **Google Drive Folder**: `roles/secretary`
- **Email Forwarding**: Currently forwards to barry@scala4.com

### 2. Greens Role
- **Member ID**: 199 (Alison Evans)
- **Email**: greens@elparaisogolf.com
- **Password**: @Elparaisogolf2025@
- **Google Drive Folder**: `roles/greens`

## Google Workspace Configuration

### Private Workspace
- **Email**: elparaisogolf.co@gmail.com
- **Password**: EPGC19731996#
- **Admin URL**: https://admin.google.com/ac/home?hl=en_GB
- **Access**: User 999914 has full access

### Business Workspace
- **Email**: elparaisogolfclub@gmail.com
- **Password**: @Marketing2026@
- **Admin URL**: https://admin.google.com/ac/home?hl=en_GB
- **Access**: User 999914 has full access and can upload to both workspaces

## Google Drive Setup Instructions

### Step 1: Create Role Directories
1. Log in to Google Drive using the Business Workspace account (elparaisogolfclub@gmail.com)
2. Create a main folder called `roles` (if it doesn't exist)
3. Inside the `roles` folder, create:
   - `roles/secretary` folder
   - `roles/greens` folder

### Step 2: Set Permissions
For each role folder (e.g., `roles/secretary`):

1. **For Secretary Role (Barry Kirk - Member ID 8022)**:
   - Right-click on `roles/secretary` folder
   - Click "Share"
   - Add `secretary@elparaisogolf.com` with "Editor" permissions
   - Add `elparaisogolf.co@gmail.com` (Private workspace) with "Editor" permissions
   - Add `elparaisogolfclub@gmail.com` (Business workspace) with "Editor" permissions
   - User 999914 already has access through Business workspace

2. **For Greens Role (Alison Evans - Member ID 199)**:
   - Right-click on `roles/greens` folder
   - Click "Share"
   - Add `greens@elparaisogolf.com` with "Editor" permissions
   - Add `elparaisogolf.co@gmail.com` (Private workspace) with "Editor" permissions
   - Add `elparaisogolfclub@gmail.com` (Business workspace) with "Editor" permissions
   - User 999914 already has access through Business workspace

### Step 3: Update Database with Folder IDs
After creating the folders, you can optionally update the `EventVolunteerRoles` table with the Google Drive folder IDs and URLs:

```sql
UPDATE EventVolunteerRoles 
SET google_drive_folder_id = 'YOUR_FOLDER_ID_HERE',
    google_drive_folder_url = 'https://drive.google.com/drive/folders/YOUR_FOLDER_ID_HERE'
WHERE role_name = 'secretary';

UPDATE EventVolunteerRoles 
SET google_drive_folder_id = 'YOUR_FOLDER_ID_HERE',
    google_drive_folder_url = 'https://drive.google.com/drive/folders/YOUR_FOLDER_ID_HERE'
WHERE role_name = 'greens';
```

To find the folder ID:
1. Open the folder in Google Drive
2. Look at the URL: `https://drive.google.com/drive/folders/FOLDER_ID_HERE`
3. Copy the FOLDER_ID_HERE part

## Webmail Access

### For Volunteers
Volunteers can access their role email accounts via:
- **Webmail URL**: https://webmail.elparaisogolf.com/
- **Login**: Use their volunteer email (e.g., secretary@elparaisogolf.com)
- **Password**: The password stored in the EventVolunteerRoles table

### For Admin (999914)
Admin can access all volunteer email accounts through the "Volunteer Webmail" dropdown in the Event Dashboard.

## Adding New Volunteers

### Process
1. Log in as user 999914 (Board Admin)
2. Click "👥 Volunteer Management" button
3. Fill in the form:
   - **Member ID**: The member ID of the person taking the role
   - **Volunteer Email**: The email address for the role
   - **Volunteer Password**: Password for the email account
   - **Role Name**: Name of the role (e.g., 'treasurer', 'captain')
   - **Private Workspace Email**: Usually elparaisogolf.co@gmail.com
   - **Business Workspace Email**: Usually elparaisogolfclub@gmail.com
4. Click "Add/Update Volunteer"

### Google Drive Setup for New Roles
1. Create a new folder: `roles/[role_name]` in Google Drive (Business Workspace)
2. Share the folder with:
   - The volunteer email address (Editor permissions)
   - Private workspace email (Editor permissions)
   - Business workspace email (Editor permissions)
3. Optionally update the database with the folder ID and URL

## Email Forwarding

Currently, `secretary@elparaisogolf.com` forwards to `barry@scala4.com`. This allows:
- Read, comment, and edit permissions on directories and files in the Business Google Drive
- When share permissions are provided, the forwarded email account can access shared resources

## Security Considerations

1. **Password Storage**: Passwords are stored in plain text in the database. Consider implementing encryption for production use.
2. **Access Control**: Only user 999914 can manage volunteer roles.
3. **Session Management**: All pages use the standard session check mechanism.
4. **Email Security**: Volunteer email passwords should be changed periodically.

## Future Enhancements

1. **Encrypted Password Storage**: Implement password encryption for volunteer passwords
2. **Google Drive API Integration**: Automatically create and manage Google Drive folders via API
3. **Email Auto-Configuration**: Automatically configure email forwarding and permissions
4. **Role History**: Track role changes over time
5. **Notification System**: Notify volunteers when their role is assigned or changed

## Troubleshooting

### Volunteer Cannot Access Email
1. Verify the email and password in Volunteer Management
2. Check that the role is marked as "Active"
3. Verify webmail server is accessible: https://webmail.elparaisogolf.com/

### Google Drive Access Issues
1. Verify folder exists in Business Workspace
2. Check sharing permissions on the folder
3. Ensure volunteer email has been added with correct permissions
4. Verify user 999914 has access through Business workspace

### Database Table Missing
Run the SQL script to create the table:
```bash
mysql -u root -p el_paraiso < tools-create-volunteer-management-table.sql
```

Or access the Volunteer Management page - it will attempt to create the table automatically if it doesn't exist.

## Support

For issues or questions, contact the system administrator or refer to the code comments in the relevant PHP files.

