# Plan: Separate Vehicle Lists by Collector Access

## Objective
Filter vehicle dropdown lists based on collector access permissions:
- If collector has `dozar_only` access → Show only Dozar vehicles
- If collector has `tripper_loading_only` or `tripper_unloading_only` access → Show only Tripper vehicles
- Admin users see all vehicles

## Current Situation
- Vehicles table has `vehicle_type` column with values: "Dozar" or "Tripper"
- Current queries fetch ALL vehicles regardless of type
- No filtering based on user collector access

## Files to Modify

### 1. `dozar/add.php` (Lines 33-37)
**Current:**
```php
$vehicles = [];
$stmt = $pdo->query("SELECT * FROM vehicles WHERE is_active = 1 ORDER BY vehicle_number");
```

**Change to:**
```php
$vehicles = [];
$vehicleFilter = "";
if ($user['role'] === 'collector' && $user['collector_access'] === 'dozar_only') {
    $vehicleFilter = " AND vehicle_type = 'Dozar'";
}
$stmt = $pdo->query("SELECT * FROM vehicles WHERE is_active = 1" . $vehicleFilter . " ORDER BY vehicle_number");
```

### 2. `tripper/add_loading.php` (Lines 33-37)
**Current:**
```php
$vehicles = [];
$stmt = $pdo->query("SELECT * FROM vehicles WHERE is_active = 1 ORDER BY vehicle_number");
```

**Change to:**
```php
$vehicles = [];
$vehicleFilter = "";
if ($user['role'] === 'collector' && ($user['collector_access'] === 'tripper_loading_only' || $user['collector_access'] === 'tripper_unloading_only')) {
    $vehicleFilter = " AND vehicle_type = 'Tripper'";
}
$stmt = $pdo->query("SELECT * FROM vehicles WHERE is_active = 1" . $vehicleFilter . " ORDER BY vehicle_number");
```

### 3. `tripper/add_unloading.php`
Same modification as tripper/add_loading.php

### 4. `dozar/edit.php`
Same modification as dozar/add.php

### 5. `tripper/edit.php`
Same modification as tripper/add_loading.php

## Implementation Steps

1. **Modify dozar/add.php** - Add vehicle type filter based on collector access
2. **Modify dozar/edit.php** - Add vehicle type filter based on collector access  
3. **Modify tripper/add_loading.php** - Add vehicle type filter based on collector access
4. **Modify tripper/add_unloading.php** - Add vehicle type filter based on collector access
5. **Modify tripper/edit.php** - Add vehicle type filter based on collector access
6. **Test** - Verify filtering works correctly for each collector type

## User Role Mapping

| User Role | Collector Access | Show Vehicles |
|-----------|------------------|---------------|
| admin | - | All vehicles |
| collector | dozar_only | Dozar only |
| collector | tripper_loading_only | Tripper only |
| collector | tripper_unloading_only | Tripper only |
| collector | all_modules | All vehicles |
| viewer | - | All vehicles (read-only) |
