<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */

$routes->group('', ['filter' => 'cors'], function($routes) {

    // Auth
    $routes->post('auth/login', 'AuthController::login');
    $routes->post('auth/logout', 'AuthController::logout');
    $routes->options('auth/(:any)', 'AuthController::options');
    $routes->options('auth/(:any)', 'AuthController::$1');
    $routes->get('auth/forceDestroySession', 'AuthController::forceDestroySession');

    // Location
    $routes->get('location', 'Location\LocationController::GetAllLocations');
    $routes->options('location/update/(:num)', 'Location\LocationController::options/$1');
    $routes->get('location/(:num)/photos', 'Location\LocationPhotosController::getFotosPorUbicacion/$1');
    $routes->post('location/createLocation', 'Location\LocationController::create');
    $routes->get('location/locationDetails/(:num)', 'Location\LocationController::GetLocationByFK/$1');
    $routes->put('location/update/(:num)', 'Location\LocationController::update/$1');

    // Fotos
    $routes->options('location/(:num)/photos', 'Location\LocationPhotosController::options');
    $routes->post('location/(:num)/photos', 'Location\LocationPhotosController::subirFotosUbicacion/$1');
    $routes->options('location/(:num)/photos/all', 'Location\LocationPhotosController::options');
    $routes->delete('location/(:num)/photos/all', 'Location\LocationPhotosController::deleteAllFotos/$1');
    $routes->options('location/(:num)/photos/single', 'Location\LocationPhotosController::options');
    $routes->delete('location/(:num)/photos/single', 'Location\LocationPhotosController::deleteFoto/$1');

    // Contract
    $routes->options('contract/(:any)', 'ContractInfoController::options');
    $routes->get('contract', 'Contracts\ContractController::GetAllContracts');
    $routes->post('contract/createContract', 'Contracts\ContractController::create');
    $routes->get('contract/contractDetails/(:num)', 'Contracts\ContractController::GetContractByFk/$1');
    $routes->get('contract/contractInfo', 'Contracts\ContractInfoController::GetAllContracts');
    $routes->get('contract/contractDetailsView/(:num)', 'Contracts\ContractInfoController::GetContractByFk/$1');
    $routes->get('contract/contractDetailsByUser/(:num)', 'Contracts\ContractInfoController::GetContractInfoById/$1');
    $routes->get('contract/clauses/(:num)', 'Contracts\ContractController::getContractClauses/$1');
    $routes->post('contract/conclude/(:num)', 'Contracts\ContractController::concludeContract/$1');

    // Emails
    $routes->post('testEmail', 'Contracts\ContractController::testSendEmail');

    // Payments
    $routes->post('payments/registerAbono', 'Payments\PaymentsController::registerAbono');
    $routes->options('payments/registerAbono', 'Payments\PaymentsController::options');
    $routes->get('payments/All/(:num)', 'Payments\PaymentsController::GetAllPayments/$1');

    // Profile
    $routes->options('profile/(:any)', 'UserController::options');
    $routes->get('profile/getUser/(:num)', 'UserController::getUserById/$1');
    $routes->post('profile/uploadPhoto', 'UserController::uploadPhoto');
    $routes->post('profile/updateProfile', 'UserController::updateProfile');
    $routes->post('profile/changePassword', 'UserController::changePassword');

    // Incidence
    $routes->options('incidence/(:any)', 'Incidence\IncidenceController::options');
    $routes->get('incidence', 'Incidence\IncidenceController::GetAllIncidence');
    $routes->post('incidence/create', 'Incidence\IncidenceController::create');
    $routes->put('incidence/(:num)/status', 'Incidence\IncidenceController::updateStatus/$1');

    // Reports
    $routes->get('reports', 'Reports\ReportsController::index');

});