# Job Review System - Enhanced Features

## Overview
This update adds several new features to the job review system to improve workflow and collaboration during meetings.

## New Features

### 1. Job Images
- **Display**: Each job now displays an associated image in the meeting interface
- **Location**: Images appear on the right side of the job header (desktop) or below the job info (mobile)
- **Database**: New `image_url` column added to the `jobs` table
- **Format**: Supports any image URL (JPG, PNG, etc.)

### 2. Enhanced Job Dropdown

#### Ordering Options
- **Default**: Jobs ordered by job number (ascending)
- **Group by Customer**: Option to group jobs by customer name with alphabetical sorting

#### Visual Indicators
- **Reviewed Jobs**: Jobs that have been reviewed (have notes) appear greyed out and italicized
- **Checkmark**: Reviewed jobs show a ✓ symbol
- **Still Clickable**: Reviewed jobs can be re-selected if needed for additional review

### 3. Auto-Progress Feature
- **Automatic Advancement**: When enabled, the system automatically moves to the next job when all participants mark themselves as ready
- **Toggle**: Leaders can enable/disable this feature with a checkbox
- **Default**: Auto-progress is enabled by default
- **Smart Progression**: Skips to the next unreviewed job in the list

### 4. Action Points System

#### Creating Action Points
- **Button**: "Add Action Point" button in the sidebar
- **Assignment**: Assign to any user in the system (not just meeting participants)
- **Context**: Action points can be linked to specific jobs or kept general
- **Due Dates**: Optional due date field
- **Description**: Text field for detailed action description

#### Viewing Action Points
- **Real-time Updates**: Action points list updates automatically
- **Sorting**: Shows incomplete items first, then sorted by due date
- **Job Context**: Displays associated job number if applicable
- **Assignee**: Shows who the action is assigned to
- **Creator**: Tracks who created the action point

#### Managing Action Points
- **Mark Complete**: Button to mark action points as complete
- **Visual Feedback**: Completed items appear greyed out with green indicator
- **Persistent**: Action points remain visible even after completion

## Installation Instructions

### 1. Database Setup
Run the provided SQL script to update your database:

```bash
mysql -u your_username -p your_database < database_updates.sql
```

Or run these SQL commands manually:

```sql
-- Add image_url column to jobs table
ALTER TABLE jobs 
ADD COLUMN IF NOT EXISTS image_url VARCHAR(255) DEFAULT NULL;

-- Create action_points table
CREATE TABLE IF NOT EXISTS action_points (
    id INT AUTO_INCREMENT PRIMARY KEY,
    meeting_id INT NOT NULL,
    job_id INT DEFAULT NULL,
    created_by INT NOT NULL,
    assigned_to INT NOT NULL,
    description TEXT NOT NULL,
    due_date DATE DEFAULT NULL,
    completed BOOLEAN DEFAULT FALSE,
    completed_at DATETIME DEFAULT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (meeting_id) REFERENCES meetings(id) ON DELETE CASCADE,
    FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE SET NULL,
    FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE,
    FOREIGN KEY (assigned_to) REFERENCES users(id) ON DELETE CASCADE
);
```

### 2. File Deployment
Replace the following files on your server:
- `meeting.php` - Main meeting interface (updated)
- `api.php` - Backend API (updated with new endpoints)
- `style.css` - Stylesheet (updated with new styles)
- Keep existing: `config.php`, `login.php`, `dashboard.php`, `logout.php`

### 3. Adding Job Images
Update your jobs with image URLs:

```sql
-- Example: Add images to specific jobs
UPDATE jobs SET image_url = 'https://example.com/images/job1.jpg' WHERE id = 1;
UPDATE jobs SET image_url = 'https://example.com/images/job2.jpg' WHERE id = 2;

-- Or use placeholder images for testing
UPDATE jobs SET image_url = 'https://via.placeholder.com/250x200?text=Job+Image' WHERE image_url IS NULL;
```

## Technical Details

### New API Endpoints
1. `add_action_point` - Creates a new action point
2. `get_action_points` - Retrieves all action points for a meeting
3. `complete_action_point` - Marks an action point as completed

### Database Schema Changes
- **jobs table**: Added `image_url VARCHAR(255)` column
- **action_points table**: New table with full relationship tracking

### Frontend Features
- Real-time polling for meeting state updates (3-second interval)
- Dynamic dropdown rendering based on grouping preference
- Automatic job progression when all participants are ready
- Modal dialog for creating action points
- Visual feedback for reviewed jobs and completed actions

## Usage Guide

### For Meeting Leaders

#### Starting a Meeting
1. Create a new meeting from the dashboard
2. Select "Start Meeting" to allow participants to join
3. Choose a job from the dropdown to begin review

#### Managing Job Selection
- Use the "Group by Customer" checkbox to organize jobs by customer
- Enable/disable "Auto-progress" to control automatic advancement
- Reviewed jobs appear greyed out but remain selectable

#### Creating Action Points
1. Click "Add Action Point" in the sidebar
2. Enter description of the action needed
3. Assign to any user (in meeting or not)
4. Optionally set a due date
5. Submit to create

### For Participants

#### Joining a Meeting
1. Navigate to dashboard and click "Join Meeting"
2. Wait for leader to select a job

#### Reviewing Jobs
1. View job details and image
2. Enter notes in the text area
3. Click "Save Notes" to record your review
4. Click "Mark as Ready" when finished with the job

#### Tracking Action Points
- View all action points in the sidebar
- See your assigned actions highlighted
- Mark actions complete when done

## Browser Compatibility
- Chrome/Edge: Full support
- Firefox: Full support
- Safari: Full support
- Mobile: Responsive design works on all screen sizes

## Troubleshooting

### Images Not Displaying
- Verify the `image_url` column exists in the jobs table
- Check that image URLs are valid and accessible
- Ensure images are served over HTTPS if your site uses HTTPS

### Action Points Not Appearing
- Verify the `action_points` table was created successfully
- Check browser console for JavaScript errors
- Ensure the API endpoints are accessible

### Auto-Progress Not Working
- Verify all participants have marked themselves as ready
- Check that "Auto-progress" checkbox is enabled
- Ensure leader is viewing the meeting interface

## Future Enhancements
Potential features for future development:
- File attachments for action points
- Email notifications for action point assignments
- Export meeting notes and action points to PDF
- Action point filtering by assignee or status
- Job image upload interface
- Bulk job image import

## Support
For issues or questions:
1. Check the browser console for errors
2. Review the database connection settings in config.php
3. Verify all SQL migrations completed successfully
4. Check file permissions on the server

---

**Version**: 2.0
**Last Updated**: February 2026
**Compatible with**: PHP 7.4+, MySQL 5.7+
