# Employees Without Administrative Offenses — API Reference

## Overview

Returns all employees who have **no records** in the `administrative_offenses` table. Uses the same filter parameters as the standard `/employees/get-all` endpoint, plus the exclusion logic.

This endpoint is useful for compliance checks, clearance processing, and reporting scenarios where you need to identify employees with clean disciplinary records.

### Key behavior

- **Exclusion logic**: Only employees with zero rows in `administrative_offenses` (via `WHERE NOT EXISTS`) are included. Any existing offense record — regardless of status, type, or date — excludes the employee.
- **Same filters as get-all**: All query parameters from `GET /v2/employees/get-all` are supported (`name`, `employee_no`, `is_active`, `position_title`, `office`, `section`, etc.).
- **Pagination**: Same `show_all` / `per_page` behavior as the parent endpoint.
- **Response format**: Identical structure to `GET /v2/employees/get-all` — uses `EmployeeResource` for individual items and `EmployeeCollection` for paginated responses.

---

## Endpoint

```
GET /api/v2/employees/without-administrative-offenses
```

All endpoints are prefixed with `/api/v2` and require the standard API authentication (service token / JWT).

---

## Query Parameters

All parameters are optional. Filters are ANDed together.

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | string | LIKE search on `CONCAT(first_name, middle_name, last_name)` |
| `first_name` | string | LIKE search on `first_name` |
| `last_name` | string | LIKE search on `last_name` |
| `middle_name` | string | LIKE search on `middle_name` |
| `employee_no` | string | Exact match on `employee_no` |
| `is_active` | mixed | Exact match on `is_active` |
| `position_title` | string | LIKE search through `positionDetail.position.position_title` |
| `status_of_appointment` | string | LIKE search through `positionDetail.workType.name` |
| `office` | string | Exact match through `positionDetail.itemNumber.originalOffice.name` |
| `section` | string | LIKE search through `positionDetail.section.name` |
| `employment_category` | string | Exact match through `positionDetail.position.employment_category` |
| `date_hired` | string | Exact match through `positionDetail.date_hired` |
| `has_biometric` | boolean | Filters to employees with non-empty `biometric_no` |
| `biometric_no` | string | LIKE search on `biometric_no` |
| `is_attendance_exemption` | boolean | Filter by attendance exemption status |
| `show_all` | boolean | If `true`, returns all results unpaginated. If `false` or omitted, paginates. |
| `per_page` | integer | Items per page when paginated (default: `10`, min: `1`) |

---

## Response (Paginated — `show_all=false`)

**HTTP 200**

```json
{
  "data": [
    {
      "id": 1,
      "employeeId": "2024-001",
      "biometricNo": null,
      "image": null,
      "prefix": null,
      "suffix": null,
      "lastName": "Dela Cruz",
      "firstName": "Juan",
      "middleName": "Santos",
      "nameExtension": null,
      "dateOfBirth": "1990-01-15",
      "placeOfBirth": "Manila",
      "sex": "Male",
      "gender_preference": null,
      "is_filipino_citizen": true,
      "is_dual_citizen": false,
      "civilStatus": "Married",
      "religion": "Roman Catholic",
      "bloodType": "O+",
      "contactNumber": "09171234567",
      "mobileNumber": "09171234567",
      "email": "juan.delacruz@example.com",
      "pagibigIdNo": "1212-1234-5678",
      "philhealthNo": "12-345678901-2",
      "gsisBpNo": null,
      "gsisIdNo": "123456789012",
      "sssNo": "12-3456789-0",
      "tinNo": "123-456-789-000",
      "is_active": true,
      "tag_as_complete_requirements": false,
      "residential_address": { ... },
      "permanent_address": { ... },
      "position_detail": { ... },
      "payroll_detail": { ... },
      "family_child": [ ... ],
      "civil_service_eligibilities": [ ... ],
      "eligibility": [ ... ],
      "work_experience": [ ... ],
      "relatives_in_government": [ ... ],
      "other_information_questions": [ ... ],
      "educational_records": [ ... ],
      "educational_record_histories": [ ... ]
    }
  ],
  "version": "0.1.1",
  "pagination": {
    "current_page": 1,
    "per_page": 10,
    "total": 45,
    "last_page": 5,
    "from": 1,
    "to": 10,
    "next_page_url": "http://.../api/v2/employees/without-administrative-offenses?page=2",
    "prev_page_url": null
  }
}
```

---

## Response (Unpaginated — `show_all=true`)

**HTTP 200**

```json
{
  "data": [
    {
      "id": 1,
      "employeeId": "2024-001",
      "lastName": "Dela Cruz",
      "firstName": "Juan",
      ...
    }
  ],
  "version": "0.1.1"
}
```

No `pagination` key is included when `show_all=true`.

---

## Error Responses

**HTTP 401 — Unauthenticated:**
```json
{
  "message": "Unauthenticated."
}
```

**HTTP 500 — Server Error:**
```json
{
  "message": "Server error",
  "error": "Detailed error message (may include stack trace in debug mode)"
}
```

---

## Examples

### 1. List all employees without offenses, paginated

```bash
curl -H "Authorization: Bearer <token>" \
  "https://api.example.com/api/v2/employees/without-administrative-offenses"
```

### 2. Search by name, exclude those with offenses

```bash
curl -H "Authorization: Bearer <token>" \
  "https://api.example.com/api/v2/employees/without-administrative-offenses?name=Dela%20Cruz"
```

### 3. Get all active employees without offenses (unpaginated)

```bash
curl -H "Authorization: Bearer <token>" \
  "https://api.example.com/api/v2/employees/without-administrative-offenses?is_active=1&show_all=true"
```

### 4. Filter by office and section

```bash
curl -H "Authorization: Bearer <token>" \
  "https://api.example.com/api/v2/employees/without-administrative-offenses?office=HR%20Department&section=Payroll"
```

---

## Related

| Reference | Link |
|-----------|------|
| Parent endpoint (all employees) | `GET /api/v2/employees/get-all` |
| Administrative offense endpoints | `GET /api/v2/employee/{employee_no}/administrative-offenses` |
| Employee resource schema | `EmployeeResource` |
