<?php
declare(strict_types=1);

const MAINTENANCE_STAGE_ORDER = [
    'Complaint Logged',
    'Maintenance Review',
    'Work Order Raised',
    'RFQ Sent',
    'Quote Submitted',
    'Quote Vetted',
    'Job Order Approved',
    'Workshop In Progress',
    'Inspection',
    'Internal Control',
    'Closed',
    'Requisition Raised',
    'Requisition Approved',
    'Requisition Rejected',
    'Payment Made',
    'Payment Not Made'
];

const MAINTENANCE_STAGE_TRANSITIONS = [
    'Complaint Logged' => ['Maintenance Review', 'Suspended', 'Cancelled'],
    'Maintenance Review' => ['Work Order Raised', 'Suspended', 'Cancelled'],
    'Work Order Raised' => ['Workshop In Progress', 'RFQ Sent', 'Quote Submitted', 'Suspended', 'Cancelled'],
    'RFQ Sent' => ['Quote Submitted', 'Suspended', 'Cancelled'],
    'Quote Submitted' => ['Quote Vetted', 'Job Order Approved', 'Suspended', 'Cancelled'],
    'Quote Vetted' => ['Job Order Approved', 'Suspended', 'Cancelled'],
    'Job Order Approved' => ['Workshop In Progress', 'Suspended', 'Cancelled'],
    'Workshop In Progress' => ['Inspection', 'Suspended'],
    'Inspection' => ['Internal Control', 'Workshop In Progress'],
    'Internal Control' => ['Closed'],
    'Closed' => ['Closed', 'Requisition Raised', 'Workshop In Progress'],
    'Requisition Raised' => ['Requisition Approved', 'Requisition Rejected', 'Workshop In Progress'],
    'Requisition Approved' => ['Payment Made', 'Payment Not Made', 'Workshop In Progress'],
    'Requisition Rejected' => ['Workshop In Progress'],
    'Payment Made' => ['Payment Made', 'Workshop In Progress'],
    'Payment Not Made' => ['Payment Not Made', 'Workshop In Progress'],
    'Suspended' => ['Workshop In Progress', 'Cancelled'],
    'Cancelled' => ['Cancelled']
];

const MAINTENANCE_STAGE_ROLE_MATRIX = [
    'Complaint Logged' => ['Fleet Operations', 'Maintenance Lead', 'Admin'],
    'Maintenance Review' => ['Fleet Operations', 'Maintenance Lead'],
    'Work Order Raised' => ['Maintenance Lead'],
    'RFQ Sent' => ['Procurement & Finance', 'Maintenance Lead'],
    'Quote Submitted' => ['Procurement & Finance', 'Maintenance Lead', 'Quality & Oversight'],
    'Quote Vetted' => ['Procurement & Finance'],
    'Job Order Approved' => ['Procurement & Finance', 'Quality & Oversight'],
    'Workshop In Progress' => ['Vendor', 'Workshop', 'Maintenance Lead'],
    'Inspection' => ['Quality & Oversight', 'Fleet Operations'],
    'Internal Control' => ['Quality & Oversight'],
    'Closed' => ['Fleet Operations', 'Procurement & Finance', 'Admin'],
    'Requisition Raised' => ['Procurement & Finance', 'Quality & Oversight'],
    'Requisition Approved' => ['Procurement & Finance', 'Quality & Oversight'],
    'Requisition Rejected' => ['Procurement & Finance', 'Quality & Oversight'],
    'Payment Made' => ['Procurement & Finance', 'Quality & Oversight'],
    'Payment Not Made' => ['Procurement & Finance', 'Quality & Oversight'],
    'Suspended' => ['Maintenance Lead', 'Procurement & Finance'],
    'Cancelled' => ['Quality & Oversight', 'Procurement & Finance']
];

// Stage name constants — single source of truth to eliminate magic strings
const STAGE_COMPLAINT_LOGGED = 'Complaint Logged';
const STAGE_MAINTENANCE_REVIEW = 'Maintenance Review';
const STAGE_WORK_ORDER_RAISED = 'Work Order Raised';
const STAGE_RFQ_SENT = 'RFQ Sent';
const STAGE_QUOTE_SUBMITTED = 'Quote Submitted';
const STAGE_QUOTE_VETTED = 'Quote Vetted';
const STAGE_JOB_ORDER_APPROVED = 'Job Order Approved';
const STAGE_WORKSHOP_IN_PROGRESS = 'Workshop In Progress';
const STAGE_INSPECTION = 'Inspection';
const STAGE_INTERNAL_CONTROL = 'Internal Control';
const STAGE_CLOSED = 'Closed';
const STAGE_REQUISITION_RAISED = 'Requisition Raised';
const STAGE_REQUISITION_APPROVED = 'Requisition Approved';
const STAGE_REQUISITION_REJECTED = 'Requisition Rejected';
const STAGE_PAYMENT_MADE = 'Payment Made';
const STAGE_PAYMENT_NOT_MADE = 'Payment Not Made';
const STAGE_SUSPENDED = 'Suspended';
const STAGE_CANCELLED = 'Cancelled';

// Common status constants
const STATUS_PENDING = 'Pending';
const STATUS_IN_PROGRESS = 'In Progress';
const STATUS_APPROVED = 'Approved';
const STATUS_REJECTED = 'Rejected';
const STATUS_COMPLETED = 'Completed';
const STATUS_CLOSED = 'Closed';
