<?php

/**
 * Contracts workspace routes.
 * @var \CodeIgniter\Router\RouteCollection $routes
 */

$routes->group('contracts', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Contracts\Controllers\ContractsDashboardController::index', ['filter' => 'permission:contracts.view']);
    $routes->get('active', '\Modules\Contracts\Controllers\ContractLifecycleController::active', ['filter' => 'permission:contracts.view']);
    $routes->get('schedule', '\Modules\Contracts\Controllers\ContractLifecycleController::schedule', ['filter' => 'permission:contracts.view']);
    $routes->get('renewals', '\Modules\Contracts\Controllers\ContractLifecycleController::renewals', ['filter' => 'permission:contracts.view']);
    $routes->get('expiry-alerts', '\Modules\Contracts\Controllers\ContractLifecycleController::expiryAlerts', ['filter' => 'permission:contracts.view']);
});

$routes->group('contracts/customers', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Contracts\Controllers\CustomerController::index', ['filter' => 'permission:companies.view']);
    $routes->get('create', '\Modules\Contracts\Controllers\CustomerController::createForm', ['filter' => 'permission:companies.create']);
    $routes->post('/', '\Modules\Contracts\Controllers\CustomerController::store', ['filter' => 'permission:companies.create']);
    $routes->get('(:num)', '\Modules\Contracts\Controllers\CustomerController::show/$1', ['filter' => 'permission:companies.view']);
    $routes->get('(:num)/edit', '\Modules\Contracts\Controllers\CustomerController::editForm/$1', ['filter' => 'permission:companies.edit']);
    $routes->post('(:num)', '\Modules\Contracts\Controllers\CustomerController::update/$1', ['filter' => 'permission:companies.edit']);
    $routes->post('(:num)/activate', '\Modules\Contracts\Controllers\CustomerController::activate/$1', ['filter' => 'permission:companies.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Contracts\Controllers\CustomerController::deactivate/$1', ['filter' => 'permission:companies.edit']);
    $routes->post('(:num)/delete', '\Modules\Contracts\Controllers\CustomerController::destroy/$1', ['filter' => 'permission:companies.delete']);
});

$routes->group('contracts/sites', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Contracts\Controllers\SiteController::index', ['filter' => 'permission:customer_sites.view']);
    $routes->get('details', '\Modules\Contracts\Controllers\SiteController::details', ['filter' => 'permission:customer_sites.view']);
    $routes->get('contacts', '\Modules\Contracts\Controllers\SiteController::contacts', ['filter' => 'permission:customer_sites.view']);
    $routes->get('history', '\Modules\Contracts\Controllers\SiteController::history', ['filter' => 'permission:customer_sites.view']);
    $routes->get('create', '\Modules\Contracts\Controllers\SiteController::createForm', ['filter' => 'permission:customer_sites.create']);
    $routes->post('/', '\Modules\Contracts\Controllers\SiteController::store', ['filter' => 'permission:customer_sites.create']);
    $routes->get('(:num)', '\Modules\Contracts\Controllers\SiteController::show/$1', ['filter' => 'permission:customer_sites.view']);
    $routes->get('(:num)/edit', '\Modules\Contracts\Controllers\SiteController::editForm/$1', ['filter' => 'permission:customer_sites.edit']);
    $routes->post('(:num)', '\Modules\Contracts\Controllers\SiteController::update/$1', ['filter' => 'permission:customer_sites.edit']);
    $routes->post('(:num)/assign', '\Modules\Contracts\Controllers\SiteController::assignCustomer/$1', ['filter' => 'permission:companies.edit']);
    $routes->post('(:num)/unassign/(:num)', '\Modules\Contracts\Controllers\SiteController::unassignCustomer/$1/$2', ['filter' => 'permission:companies.edit']);
    $routes->post('(:num)/activate', '\Modules\Contracts\Controllers\SiteController::activate/$1', ['filter' => 'permission:customer_sites.edit']);
    $routes->post('(:num)/deactivate', '\Modules\Contracts\Controllers\SiteController::deactivate/$1', ['filter' => 'permission:customer_sites.edit']);
    $routes->post('(:num)/delete', '\Modules\Contracts\Controllers\SiteController::destroy/$1', ['filter' => 'permission:customer_sites.delete']);
});

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