<?php



/**

 * Payroll module routes (Bahrain / Gulf).

 * @var \CodeIgniter\Router\RouteCollection $routes

 */

$routes->group('payroll/settings', ['filter' => 'auth'], static function ($routes) {

    $routes->get('/', '\Modules\Payroll\Controllers\PayrollSettingsController::index', ['filter' => 'permission:payroll_settings.view']);

    $routes->post('/', '\Modules\Payroll\Controllers\PayrollSettingsController::update', ['filter' => 'permission:payroll_settings.edit']);

});



$routes->group('payroll/salary', ['filter' => 'auth'], static function ($routes) {

    $routes->get('/', '\Modules\Payroll\Controllers\SalaryStructureController::index', ['filter' => 'permission:payroll_salary.view']);

    $routes->get('create', '\Modules\Payroll\Controllers\SalaryStructureController::createForm', ['filter' => 'permission:payroll_salary.create']);

    $routes->post('/', '\Modules\Payroll\Controllers\SalaryStructureController::store', ['filter' => 'permission:payroll_salary.create']);

    $routes->get('(:num)/edit', '\Modules\Payroll\Controllers\SalaryStructureController::editForm/$1', ['filter' => 'permission:payroll_salary.edit']);

    $routes->post('(:num)', '\Modules\Payroll\Controllers\SalaryStructureController::update/$1', ['filter' => 'permission:payroll_salary.edit']);

});



$routes->group('payroll/runs', ['filter' => 'auth'], static function ($routes) {

    $routes->get('/', '\Modules\Payroll\Controllers\PayrollRunController::index', ['filter' => 'permission:payroll_runs.view']);

    $routes->get('create', '\Modules\Payroll\Controllers\PayrollRunController::createForm', ['filter' => 'permission:payroll_runs.create']);

    $routes->post('/', '\Modules\Payroll\Controllers\PayrollRunController::store', [

        'filter' => ['permission:payroll_runs.create', 'tpin'],

    ]);

    $routes->get('(:num)', '\Modules\Payroll\Controllers\PayrollRunController::show/$1', ['filter' => 'permission:payroll_runs.view']);

    $routes->post('(:num)/calculate', '\Modules\Payroll\Controllers\PayrollRunController::calculate/$1', [

        'filter' => ['permission:payroll_runs.edit', 'tpin'],

    ]);

    $routes->post('(:num)/approve', '\Modules\Payroll\Controllers\PayrollRunController::approve/$1', [

        'filter' => ['permission:payroll_runs.approve', 'tpin'],

    ]);

    $routes->post('(:num)/paid', '\Modules\Payroll\Controllers\PayrollRunController::markPaid/$1', [

        'filter' => ['permission:payroll_runs.approve', 'tpin'],

    ]);

    $routes->post('(:num)/delete', '\Modules\Payroll\Controllers\PayrollRunController::destroy/$1', [

        'filter' => ['permission:payroll_runs.delete', 'tpin'],

    ]);

    $routes->get('(:num)/wps', '\Modules\Payroll\Controllers\PayrollRunController::exportWps/$1', [

        'filter' => ['permission:payroll_payslips.export', 'tpin'],

    ]);

});



$routes->group('payroll/payslips', ['filter' => 'auth'], static function ($routes) {

    $routes->get('/', '\Modules\Payroll\Controllers\PayslipController::index', ['filter' => 'permission:payroll_payslips.view']);

    $routes->get('(:num)', '\Modules\Payroll\Controllers\PayslipController::show/$1', ['filter' => 'permission:payroll_payslips.view']);

});



$routes->group('payroll/reports', ['filter' => 'auth'], static function ($routes) {

    $routes->get('summary', '\Modules\Payroll\Controllers\PayrollReportController::summary', ['filter' => 'permission:payroll_reports.view']);

    $routes->get('sio', '\Modules\Payroll\Controllers\PayrollReportController::sio', ['filter' => 'permission:payroll_reports.view']);

    $routes->get('eosb', '\Modules\Payroll\Controllers\PayrollReportController::eosb', ['filter' => 'permission:payroll_reports.view']);

});



$routes->group('payroll/settlements', ['filter' => 'auth'], static function ($routes) {

    $routes->get('/', '\Modules\Payroll\Controllers\PayrollSettlementController::index', ['filter' => 'permission:payroll_settlements.view']);

    $routes->get('create', '\Modules\Payroll\Controllers\PayrollSettlementController::createForm', ['filter' => 'permission:payroll_settlements.create']);

    $routes->post('preview', '\Modules\Payroll\Controllers\PayrollSettlementController::preview', ['filter' => 'permission:payroll_settlements.create']);

    $routes->post('/', '\Modules\Payroll\Controllers\PayrollSettlementController::store', [

        'filter' => ['permission:payroll_settlements.create', 'tpin'],

    ]);

    $routes->get('(:num)', '\Modules\Payroll\Controllers\PayrollSettlementController::show/$1', ['filter' => 'permission:payroll_settlements.view']);

    $routes->post('(:num)/approve', '\Modules\Payroll\Controllers\PayrollSettlementController::approve/$1', [

        'filter' => ['permission:payroll_settlements.approve', 'tpin'],

    ]);

    $routes->post('(:num)/paid', '\Modules\Payroll\Controllers\PayrollSettlementController::markPaid/$1', [

        'filter' => ['permission:payroll_settlements.approve', 'tpin'],

    ]);

});

