# Equipment Maintenance System - Controllers & Workflows

## 1. Role-Based Routing
The application strictly enforces access control based on user `Roles`. Upon login, the user is redirected to their specific dashboard.
- `Clerk`: `/clerk/dashboard`
- `Director`: `/director/dashboard` (Approver logic)
- `IT Admin`: `/it-admin/dashboard`
- `Technician`: `/technician/dashboard`
- `Super Admin`: `/super-admin/dashboard`

## 2. Key Controllers

### `TicketController`
The central controller managing the ticket lifecycle.
- **`store()`**: Generates the case number (`Ticket::generateCaseNo()`), identifies the first step of the workflow from `ApprovalSequence`, and sets the initial status (e.g., `Pending_Director`).
- **`dashboard()`**: Dynamically returns different Inertia views based on the authenticated user's capabilities (e.g., `manage-users` vs `process-tickets`).
- **History Methods**: Handles fetching completed/resolved tickets for different roles (e.g., `itAdminHistory()`, `directorHistory()`).
- **Analytics Methods**: Handles logic for `technicianPerformance()` and `equipmentMaintenance()` views, pulling aggregated data.

### `SuperAdminWorkflowController`
Provides the Super Admin with a God-mode view of the entire workflow. 
- Responsible for overriding the workflow, reverting accidental approvals, or manually moving a ticket between states.

### `AssetController` & `EmployeeController`
Handle CRUD operations for inventory and staff.

## 3. The Workflow System
Tickets traverse through a state machine dictated by the `status` column.

### Standard Workflow (Repair Example)
1. **Creation**: Clerk creates a ticket -> `Pending_Director`.
2. **Approval 1 (Director)**: Director logs in, views their dashboard, clicks "Approve". `TicketApproval` is recorded. Status shifts to -> `Pending_IT_Admin`.
3. **IT Admin Review**: IT Admin assigns a `Technician`. Status -> `Technician_Inspecting`.
4. **Technician Inspection**: Technician enters estimated costs. IT Admin requests Minute Sheet -> `Pending_IT_Admin_Minute_Sheet`.
5. **Minute Sheet Flow**: IT Admin processes -> `Pending_IT_Director` -> `Approved_IT_Director` -> `Pending_Secretary` -> `In_Progress`.
6. **Resolution**: Technician completes work. IT Admin verifies. Status -> `Resolved`.

### Signatures Logic
Digital stamps and dates are dynamically checked using string matching against the `status` column inside `SignaturesBox.vue`. When a ticket progresses past a specific role's checkpoint in the sequence, their signature timestamp is locked in.
