# ═══════════════════════════════════════════════════════════════
# PHASE 6: VIOLATIONS, PENALTIES & COMPLAINTS MODULE
# Module directory: /modules/violations/
# ═══════════════════════════════════════════════════════════════
# READ THE MASTER PROMPT FIRST.

## YOUR TABLES
violation_categories, violation_types, violations, violation_evidence,
violation_witnesses, violation_investigations, violation_investigation_notes,
violation_escalation_rules, penalties, penalty_appeals, penalty_appeal_decisions,
penalty_payments, complaint_categories, complaint_priorities, complaints,
complaint_followups, complaint_attachments, complaint_resolutions

## PAGES TO BUILD

### 1. Violations Listing (`GET /violations`)
- DataTable with vw_violation_summary data
- Filters: Status, Category, Severity, Date Range

### 2. Report Violation (`GET /violations/create`, `POST /violations`)
- Member lookup, violation type (cascading: category → type), incident date/time/location
- Description, evidence upload (multi-file), witness information
- Auto-calculate occurrence_number (DB trigger does this)

### 3. View Violation (`GET /violations/{id}`)
- Full details with status timeline
- Evidence gallery, witness list
- Investigation section: assign investigator, record findings
- Decision section: penalty assignment
- Appeal section
- Related violations (if repeat offense)

### 4. Investigation Management
- Open investigation, record notes
- Member notification & response tracking
- Final recommendation

### 5. Penalties (`GET /penalties`)
- DataTable: Penalty#, Member, Type, Fine, Suspension Days, Status
- Create penalty from violation decision
- Fine tracking (paid/unpaid)
- Suspension management

### 6. Penalty Appeals
- Submit appeal form
- Hearing scheduling
- Decision recording
- Override/modify original penalty

### 7. Violation Types Management
- CRUD for violation_categories, violation_types
- Escalation rules per type

### 8. Complaints Listing (`GET /complaints`)
- DataTable with vw_complaint_dashboard data
- SLA status indicators (on track / at risk / breached)
- Filters: Status, Category, Priority, SLA Status

### 9. Submit Complaint (`POST /complaints`)
- Member lookup (or walk-in), category, priority, subject, description
- Attachments, channel selection
- SLA deadline auto-calculated (DB trigger does this)

### 10. Manage Complaint (`GET /complaints/{id}`)
- Full details with follow-up timeline
- Assign to staff/department
- Add follow-ups (notes, actions, status changes)
- Escalation management
- Resolution recording
- Satisfaction rating (after resolution)

### 11. Complaint Categories & Priorities
- CRUD management

## BUSINESS LOGIC
- Violation occurrence tracking for repeat offenders
- Escalation rules trigger harsher penalties for repeat offenses
- Penalty of type suspension auto-changes member status (DB trigger)
- Penalty of type termination auto-terminates member (DB trigger)
- Complaint SLA monitoring
- SLA breach auto-flagging (DB trigger on update)

## DASHBOARD WIDGETS
1. **Open Violations** — Count by severity
2. **SLA Status** — Complaints at risk/breached
3. **Pending Appeals** — Count

## PERMISSIONS
violations.view, violations.create, violations.decide,
penalties.manage, complaints.view, complaints.manage