<?php

/**
 * Leave Management module routes.
 * @var \CodeIgniter\Router\RouteCollection $routes
 */
$routes->group('leave/types', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Leave\Controllers\LeaveTypeController::index', ['filter' => 'permission:leave_types.view']);
    $routes->get('create', '\Modules\Leave\Controllers\LeaveTypeController::createForm', ['filter' => 'permission:leave_types.create']);
    $routes->post('/', '\Modules\Leave\Controllers\LeaveTypeController::store', ['filter' => 'permission:leave_types.create']);
    $routes->get('(:num)/edit', '\Modules\Leave\Controllers\LeaveTypeController::editForm/$1', ['filter' => 'permission:leave_types.edit']);
    $routes->post('(:num)', '\Modules\Leave\Controllers\LeaveTypeController::update/$1', ['filter' => 'permission:leave_types.edit']);
    $routes->post('(:num)/activate', '\Modules\Leave\Controllers\LeaveTypeController::activate/$1', ['filter' => 'permission:leave_types.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Leave\Controllers\LeaveTypeController::deactivate/$1', ['filter' => 'permission:leave_types.edit']);
    $routes->post('(:num)/delete', '\Modules\Leave\Controllers\LeaveTypeController::destroy/$1', ['filter' => 'permission:leave_types.delete']);
});

$routes->group('leave/balances', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Leave\Controllers\LeaveBalanceController::index', ['filter' => 'permission:leave_balances.view']);
    $routes->post('initialize', '\Modules\Leave\Controllers\LeaveBalanceController::initialize', ['filter' => 'permission:leave_balances.edit']);
    $routes->post('(:num)', '\Modules\Leave\Controllers\LeaveBalanceController::update/$1', ['filter' => 'permission:leave_balances.edit']);
});

$routes->group('leave/requests', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Leave\Controllers\LeaveRequestController::index', ['filter' => 'permission:leave_requests.view']);
    $routes->get('create', '\Modules\Leave\Controllers\LeaveRequestController::createForm', ['filter' => 'permission:leave_requests.create']);
    $routes->post('/', '\Modules\Leave\Controllers\LeaveRequestController::store', ['filter' => 'permission:leave_requests.create']);
    $routes->get('(:num)', '\Modules\Leave\Controllers\LeaveRequestController::show/$1', ['filter' => 'permission:leave_requests.view']);
    $routes->post('(:num)/approve', '\Modules\Leave\Controllers\LeaveRequestController::approve/$1', ['filter' => 'permission:leave_requests.approve']);
    $routes->post('(:num)/reject', '\Modules\Leave\Controllers\LeaveRequestController::reject/$1', ['filter' => 'permission:leave_requests.approve']);
    $routes->post('(:num)/cancel', '\Modules\Leave\Controllers\LeaveRequestController::cancel/$1', ['filter' => 'permission:leave_requests.edit']);
    $routes->post('(:num)/delete', '\Modules\Leave\Controllers\LeaveRequestController::destroy/$1', ['filter' => 'permission:leave_requests.delete']);
});

$routes->group('leave/calendar', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Leave\Controllers\LeaveCalendarController::index', ['filter' => 'permission:leave_calendar.view']);
});

$routes->group('holidays', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Leave\Controllers\HolidayController::index', ['filter' => 'permission:holidays.view']);
    $routes->get('create', '\Modules\Leave\Controllers\HolidayController::createForm', ['filter' => 'permission:holidays.create']);
    $routes->post('/', '\Modules\Leave\Controllers\HolidayController::store', ['filter' => 'permission:holidays.create']);
    $routes->get('(:num)/edit', '\Modules\Leave\Controllers\HolidayController::editForm/$1', ['filter' => 'permission:holidays.edit']);
    $routes->post('(:num)', '\Modules\Leave\Controllers\HolidayController::update/$1', ['filter' => 'permission:holidays.edit']);
    $routes->post('(:num)/delete', '\Modules\Leave\Controllers\HolidayController::destroy/$1', ['filter' => 'permission:holidays.delete']);
});
