<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Role-Based Permissions Configuration
    |--------------------------------------------------------------------------
    |
    | Define permission mapping untuk setiap role. 
    | Admin memiliki semua akses, CS dan Technician memiliki akses terbatas.
    |
    */

    'permissions' => [
        'admin' => [
            // Tickets
            'tickets.view' => true,
            'tickets.create' => true,
            'tickets.edit' => true,
            'tickets.delete' => true,
            'tickets.view_all' => true,

            // Clients
            'clients.view' => true,
            'clients.create' => true,
            'clients.edit' => true,
            'clients.delete' => true,

            // Invoices (Full Access)
            'invoices.view' => true,
            'invoices.create' => true,
            'invoices.edit' => true,
            'invoices.delete' => true,
            'invoices.view_payment' => true,
            'invoices.record_payment' => true,

            // Projects
            'projects.view' => true,
            'projects.create' => true,
            'projects.edit' => true,
            'projects.delete' => true,

            // Visits
            'visits.view' => true,
            'visits.create' => true,
            'visits.edit' => true,
            'visits.delete' => true,

            // Work Orders
            'workorders.view' => true,
            'workorders.create' => true,
            'workorders.edit' => true,
            'workorders.delete' => true,

            // Users
            'users.view' => true,
            'users.create' => true,
            'users.edit' => true,
            'users.delete' => true,

            // Settings
            'settings.view' => true,
            'settings.edit' => true,

            // Reports
            'reports.view' => true,
            'reports.financial' => true,
            'reports.sla' => true,
        ],

        'cs' => [
            // Tickets (Full Access)
            'tickets.view' => true,
            'tickets.create' => true,
            'tickets.edit' => true,
            'tickets.delete' => false,
            'tickets.view_all' => true,

            // Clients (View Only)
            'clients.view' => true,
            'clients.create' => false,
            'clients.edit' => false,
            'clients.delete' => false,

            // Invoices (View Only - Limited)
            'invoices.view' => true,           // Can view invoice list & details
            'invoices.create' => false,        // Cannot create
            'invoices.edit' => false,          // Cannot edit
            'invoices.delete' => false,        // Cannot delete
            'invoices.view_payment' => false,  // CANNOT see payment details
            'invoices.record_payment' => false,// CANNOT record payments

            // Projects (View Only)
            'projects.view' => true,
            'projects.create' => false,
            'projects.edit' => false,
            'projects.delete' => false,

            // Visits (Create & View)
            'visits.view' => true,
            'visits.create' => true,
            'visits.edit' => true,
            'visits.delete' => false,

            // Work Orders (View Only)
            'workorders.view' => true,
            'workorders.create' => false,
            'workorders.edit' => false,
            'workorders.delete' => false,

            // Users (Cannot manage)
            'users.view' => false,
            'users.create' => false,
            'users.edit' => false,
            'users.delete' => false,

            // Settings (View Only)
            'settings.view' => true,
            'settings.edit' => false,

            // Reports (Limited)
            'reports.view' => true,
            'reports.financial' => false,     // CANNOT see financial reports
            'reports.sla' => true,
        ],

        'technician' => [
            // Tickets (View Assigned Only)
            'tickets.view' => true,            // Can view assigned tickets
            'tickets.create' => false,         // Cannot create
            'tickets.edit' => true,            // Can update status/notes
            'tickets.delete' => false,         // Cannot delete
            'tickets.view_all' => false,       // CANNOT see all tickets

            // Clients (View Only - Assigned)
            'clients.view' => true,            // Can view assigned client info
            'clients.create' => false,
            'clients.edit' => false,
            'clients.delete' => false,

            // Invoices (BLOCKED)
            'invoices.view' => false,          // CANNOT see invoices
            'invoices.create' => false,
            'invoices.edit' => false,
            'invoices.delete' => false,
            'invoices.view_payment' => false,
            'invoices.record_payment' => false,

            // Projects (View Only - Assigned)
            'projects.view' => true,           // Can view assigned projects
            'projects.create' => false,
            'projects.edit' => false,
            'projects.delete' => false,

            // Visits (View & Update Assigned)
            'visits.view' => true,             // Can view assigned visits
            'visits.create' => false,          // Cannot create
            'visits.edit' => true,             // Can update status/notes
            'visits.delete' => false,

            // Work Orders (View & Update)
            'workorders.view' => true,         // Can view assigned WO
            'workorders.create' => false,
            'workorders.edit' => true,         // Can update status/diagnosis
            'workorders.delete' => false,

            // Users (BLOCKED)
            'users.view' => false,
            'users.create' => false,
            'users.edit' => false,
            'users.delete' => false,

            // Settings (BLOCKED)
            'settings.view' => false,
            'settings.edit' => false,

            // Reports (BLOCKED)
            'reports.view' => false,
            'reports.financial' => false,
            'reports.sla' => false,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Blocked Pages for Roles
    |--------------------------------------------------------------------------
    |
    | Routes yang completely blocked untuk role tertentu
    |
    */

    'blocked_routes' => [
        'technician' => [
            'admin.invoices.*',      // Block semua invoice pages
            'admin.users.*',         // Block semua user management
            'admin.settings.*',      // Block settings
            'admin.reports.*',       // Block reports
        ],

        'cs' => [
            // CS tidak ada route yang completely blocked,
            // tapi ada beberapa yang read-only
        ],
    ],
];
