> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Braian551/viax/llms.txt
> Use this file to discover all available pages before exploring further.

# Driver Management

> Admin endpoints for managing driver approvals and verification

## Get Pending Drivers

```
GET /admin/pending_drivers.php
```

Retrieve list of drivers pending approval.

### Query Parameters

<ParamField query="admin_id" type="integer" required>
  Administrator ID
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Request success status
</ResponseField>

<ResponseField name="drivers" type="array">
  Array of pending driver profiles
</ResponseField>

### Request Example

```bash cURL theme={null}
curl -X GET "https://76.13.114.194/admin/pending_drivers.php?admin_id=1" \
  -H "Accept: application/json"
```

### Response Example

```json Success theme={null}
{
  "success": true,
  "drivers": [
    {
      "id": 25,
      "nombre_completo": "Juan Carlos Martínez",
      "email": "juan.martinez@example.com",
      "telefono": "+573109876543",
      "fecha_solicitud": "2024-03-10T14:30:00.000Z",
      "licencia": {
        "numero": "12345678",
        "tipo": "C1",
        "fecha_expiracion": "2030-05-15T00:00:00.000Z"
      },
      "vehiculo": {
        "marca": "Yamaha",
        "modelo": "FZ-16",
        "placa": "ABC123",
        "tipo": "moto"
      },
      "aprobado": false
    }
  ]
}
```

***

## Approve Driver

```
POST /admin/aprobar_conductor.php
```

Approve a driver to start accepting trips.

### Request Body

<ParamField body="conductor_id" type="integer" required>
  Driver ID to approve
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Approval success status
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message
</ResponseField>

### Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://76.13.114.194/admin/aprobar_conductor.php \
    -H "Content-Type: application/json" \
    -d '{"conductor_id": 25}'
  ```

  ```dart Dart theme={null}
  Future<void> approveDriver(int conductorId) async {
    final response = await http.post(
      Uri.parse('https://76.13.114.194/admin/aprobar_conductor.php'),
      headers: {'Content-Type': 'application/json'},
      body: jsonEncode({'conductor_id': conductorId}),
    );

    if (response.statusCode == 200) {
      final data = jsonDecode(response.body);
      if (data['success'] != true) {
        throw Exception(data['message']);
      }
    } else {
      throw Exception('Failed to approve driver');
    }
  }
  ```
</CodeGroup>

### Response Example

```json Success theme={null}
{
  "success": true,
  "message": "Conductor aprobado exitosamente"
}
```

***

## Reject Driver

```
POST /admin/rechazar_conductor.php
```

Reject a driver application with a reason.

### Request Body

<ParamField body="conductor_id" type="integer" required>
  Driver ID to reject
</ParamField>

<ParamField body="motivo" type="string" required>
  Rejection reason

  **Common reasons:**

  * `Licencia de conducción vencida`
  * `Documentos del vehículo incompletos`
  * `SOAT vencido`
  * `Tecnomecánica vencida`
  * `Información inconsistente`
  * `Vehículo no cumple requisitos`
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Rejection success status
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message
</ResponseField>

### Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://76.13.114.194/admin/rechazar_conductor.php \
    -H "Content-Type: application/json" \
    -d '{
      "conductor_id": 25,
      "motivo": "Licencia de conducción vencida"
    }'
  ```

  ```dart Dart theme={null}
  Future<void> rejectDriver(int conductorId, String motivo) async {
    await http.post(
      Uri.parse('https://76.13.114.194/admin/rechazar_conductor.php'),
      headers: {'Content-Type': 'application/json'},
      body: jsonEncode({
        'conductor_id': conductorId,
        'motivo': motivo,
      }),
    );
  }
  ```
</CodeGroup>

### Response Example

```json Success theme={null}
{
  "success": true,
  "message": "Conductor rechazado"
}
```

<Note>
  When a driver is rejected, they receive a notification with the rejection reason and can resubmit after addressing the issues.
</Note>

***

## Driver Verification Checklist

Administrators should verify the following before approving a driver:

<Steps>
  <Step title="Personal Information">
    * Full name matches ID
    * Valid phone number
    * Valid email address
  </Step>

  <Step title="Driver's License">
    * License number is valid
    * License type matches vehicle type
    * Not expired (check fecha\_expiracion)
    * Clear photos of both sides
  </Step>

  <Step title="Vehicle Documents">
    * SOAT (insurance) is valid and not expired
    * Tecnomecánica (inspection) is current
    * Tarjeta de propiedad (ownership card) is valid
    * License plate matches documents
  </Step>

  <Step title="Vehicle Information">
    * Make, model, year are correct
    * Vehicle type is appropriate for service
    * Color matches photos
    * Vehicle is in good condition (check photos)
  </Step>

  <Step title="Background Check">
    * No previous violations or complaints
    * Clean driving record (if available)
    * Company affiliation verified (if applicable)
  </Step>
</Steps>

***

## Document Expiration Checks

```dart theme={null}
class DriverVerification {
  bool isLicenseValid(DateTime? expirationDate) {
    if (expirationDate == null) return false;
    return DateTime.now().isBefore(expirationDate);
  }
  
  bool isSOATValid(DateTime? expirationDate) {
    if (expirationDate == null) return false;
    return DateTime.now().isBefore(expirationDate);
  }
  
  bool isTecnomecanicaValid(DateTime? expirationDate) {
    if (expirationDate == null) return false;
    return DateTime.now().isBefore(expirationDate);
  }
  
  List<String> getVerificationIssues(ConductorProfile profile) {
    final issues = <String>[];
    
    if (!isLicenseValid(profile.license?.fechaExpiracion)) {
      issues.add('Licencia de conducción vencida o no proporcionada');
    }
    
    if (!isSOATValid(profile.vehicle?.soatVencimiento)) {
      issues.add('SOAT vencido o no proporcionado');
    }
    
    if (!isTecnomecanicaValid(profile.vehicle?.tecnomecanicaVencimiento)) {
      issues.add('Tecnomecánica vencida o no proporcionada');
    }
    
    if (profile.vehicle?.placa == null || profile.vehicle!.placa.isEmpty) {
      issues.add('Placa del vehículo no proporcionada');
    }
    
    return issues;
  }
  
  bool canApprove(ConductorProfile profile) {
    return getVerificationIssues(profile).isEmpty;
  }
}
```

***

## Bulk Operations

<Note>
  For bulk approval or rejection of drivers, consider implementing a batch processing endpoint in future versions.
</Note>

***

## Error Responses

<ResponseField name="400" type="Bad Request">
  Invalid driver ID or missing rejection reason
</ResponseField>

<ResponseField name="403" type="Forbidden">
  Insufficient admin privileges
</ResponseField>

<ResponseField name="404" type="Not Found">
  Driver not found
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error during approval/rejection
</ResponseField>

## See Also

* [User Management](/api/admin/users) - Manage all users
* [Admin Analytics](/api/admin/analytics) - View platform statistics
* [Driver Profile](/api/drivers/profile) - Driver profile endpoints
