<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */

//service('auth')->routes($routes, ['except' => ['login', 'register']]);
service('auth')->routes($routes);


//WEB ROUTER ------------------------------------------------------
//------------------------------------------------------------------
$routes->get('/', 'Home::index', ['as' => 'home']);
$routes->get('lang/{locale}', 'Language::index');
$routes->get('viewmode/(:alpha)', 'Viewmode::index/$1');

/* URL FOR TESTS */
$routes->get('test', 'Test::index');


$routes->group('activity', ['namespace' => 'App\Controllers\Sistema'], function ($routes) {
    $routes->get('', 'Actividad::index', ['as' => 'activityList']);
    $routes->post('datatable', 'Actividad::datatable', ['as' => 'activityDT']);
});


/*
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// Carga archivos de rutas por dominio
foreach (glob(APPPATH . 'Config/Routes/*Routes.php') as $routeFile) {
    require $routeFile;
}


$routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Users::index', ['as' => 'userList']);
    $routes->get('list', 'Users::index', ['as' => 'userList2']);
    $routes->get('add', 'Users::add', ['as' => 'newUser']);
    $routes->post('add', 'Users::add', ['as' => 'createUser']);
    $routes->get('edit/(:num)', 'Users::edit/$1', ['as' => 'editUser']);
    $routes->post('edit/(:num)', 'Users::edit/$1', ['as' => 'updateUser']);
    $routes->get('delete/(:num)', 'Users::delete/$1', ['as' => 'deleteUser']);
    $routes->post('allmenuitems', 'Users::allItemsSelect', ['as' => 'select2ItemsOfUsers']);
    $routes->post('menuitems', 'Users::menuItems', ['as' => 'menuItemsOfUsers']);
    $routes->post('datatable', 'Users::datatable', ['as' => 'datatableOfUsers']);
    $routes->get('getMenuComerciales', 'Users::getMenuComerciales', ['as' => 'menuItemsComerciales']);
});

$routes->resource('users', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Users', 'except' => 'show,new,create,update']);


$routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifapreimpresion::index', ['as' => 'tarifapreimpresionList']);
    $routes->get('index', 'Tarifapreimpresion::index', ['as' => 'tarifapreimpresionIndex']);
    $routes->get('list', 'Tarifapreimpresion::index', ['as' => 'tarifapreimpresionList2']);
    $routes->get('add', 'Tarifapreimpresion::add', ['as' => 'newTarifapreimpresion']);
    $routes->post('add', 'Tarifapreimpresion::add', ['as' => 'createTarifapreimpresion']);
    $routes->get('edit/(:num)', 'Tarifapreimpresion::edit/$1', ['as' => 'editTarifapreimpresion']);
    $routes->post('edit/(:num)', 'Tarifapreimpresion::edit/$1', ['as' => 'updateTarifapreimpresion']);
    $routes->get('delete/(:num)', 'Tarifapreimpresion::delete/$1', ['as' => 'deleteTarifapreimpresion']);
    $routes->post('allmenuitems', 'Tarifapreimpresion::allItemsSelect', ['as' => 'select2ItemsOfTarifaspreimpresion']);
    $routes->post('menuitems', 'Tarifapreimpresion::menuItems', ['as' => 'menuItemsOfTarifaspreimpresion']);
    $routes->get('gettarifas', 'Tarifapreimpresion::getSelect2');
});


$routes->group('tarifaextra', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifaextra::index', ['as' => 'tarifaextraList']);
    $routes->get('index', 'Tarifaextra::index', ['as' => 'tarifaextraIndex']);
    $routes->get('list', 'Tarifaextra::index', ['as' => 'tarifaextraList2']);
    $routes->get('add', 'Tarifaextra::add', ['as' => 'newTarifaextra']);
    $routes->post('add', 'Tarifaextra::add', ['as' => 'createTarifaextra']);
    $routes->get('edit/(:num)', 'Tarifaextra::edit/$1', ['as' => 'editTarifaextra']);
    $routes->post('edit/(:num)', 'Tarifaextra::edit/$1', ['as' => 'updateTarifaextra']);
    $routes->get('delete/(:num)', 'Tarifaextra::delete/$1', ['as' => 'deleteTarifaextra']);
    $routes->post('allmenuitems', 'Tarifaextra::allItemsSelect', ['as' => 'select2ItemsOfTarifasextra']);
    $routes->post('menuitems', 'Tarifaextra::menuItems', ['as' => 'menuItemsOfTarifasextra']);
    $routes->get('gettarifas', 'Tarifaextra::getSelect2');
});


$routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifasmanipulado::index', ['as' => 'tarifaManipuladoList']);
    $routes->get('add', 'Tarifasmanipulado::add', ['as' => 'newTarifaManipulado']);
    $routes->post('add', 'Tarifasmanipulado::add', ['as' => 'createTarifaManipulado']);
    $routes->post('create', 'Tarifasmanipulado::create', ['as' => 'ajaxCreateTarifaManipulado']);
    $routes->put('(:num)/update', 'Tarifasmanipulado::update/$1', ['as' => 'ajaxUpdateTarifaManipulado']);
    $routes->post('edit/(:num)', 'Tarifasmanipulado::edit/$1', ['as' => 'updateTarifaManipulado']);
    $routes->get('delete/(:num)', 'Tarifasmanipulado::delete/$1', ['as' => 'deleteTarifaManipulado']);
    $routes->post('datatable', 'Tarifasmanipulado::datatable', ['as' => 'dataTableOfTarifasManipulado']);
    $routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']);
    $routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']);
    $routes->get('select', 'Tarifasmanipulado::show_select', ["as" => "showSelectTarifaManipulado"]);
    $routes->get('gettarifas', 'Tarifasmanipulado::getSelect2');
});
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']);


$routes->group('serviciosacabado', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) {
    $routes->get('', 'ServiciosAcabado::index', ['as' => 'serviciosAcabadoList']);
    $routes->get('add', 'ServiciosAcabado::add', ['as' => 'newServicioAcabado']);
    $routes->post('add', 'ServiciosAcabado::add', ['as' => 'createServicioAcabado']);
    $routes->get('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'editServicioAcabado']);
    $routes->post('edit/(:num)', 'ServiciosAcabado::edit/$1', ['as' => 'updateServicioAcabado']);
    $routes->get('datatable', 'ServiciosAcabado::datatable');
    $routes->get('getselectedtarifas', 'ServiciosAcabado::getTarifasSeleccionadas');
    $routes->get('gettarifas', 'ServiciosAcabado::getTarifas');
});
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas\Acabados', 'controller' => 'ServiciosAcabado', 'except' => 'show,new,create,update']);


$routes->group('tarifamanipuladolineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifamanipuladolineas::index', ['as' => 'tarifaManipuladoLineaList']);
    $routes->get('add', 'Tarifamanipuladolineas::add', ['as' => 'newTarifaManipuladoLinea']);
    $routes->post('add', 'Tarifamanipuladolineas::add', ['as' => 'createTarifaManipuladoLinea']);
    $routes->post('create', 'Tarifamanipuladolineas::create', ['as' => 'ajaxCreateTarifaManipuladoLinea']);
    $routes->put('(:num)/update', 'Tarifamanipuladolineas::update/$1', ['as' => 'ajaxUpdateTarifaManipuladoLinea']);
    $routes->post('(:num)/edit', 'Tarifamanipuladolineas::edit/$1', ['as' => 'updateTarifaManipuladoLinea']);
    $routes->post('datatable', 'Tarifamanipuladolineas::datatable', ['as' => 'dataTableOfTarifaManipuladoLineas']);
    $routes->post('datatable_editor', 'Tarifamanipuladolineas::datatable_editor', ['as' => 'editorOfTarifaManipuladoLineas']);
    $routes->post('allmenuitems', 'Tarifamanipuladolineas::allItemsSelect', ['as' => 'select2ItemsOfTarifaManipuladoLineas']);
    $routes->post('menuitems', 'Tarifamanipuladolineas::menuItems', ['as' => 'menuItemsOfTarifaManipuladoLineas']);
});
$routes->resource('tarifamanipuladolineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifamanipuladolineas', 'except' => 'show,new,create,update']);


$routes->group('tipologiaslibros', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Tipologias::index', ['as' => 'tipologiaLibrosList']);
    $routes->get('index', 'Tipologias::index', ['as' => 'tipologiaLibrosIndex']);
    $routes->get('list', 'Tipologias::index', ['as' => 'tipologiaLibrosList2']);
    $routes->get('add', 'Tipologias::add', ['as' => 'newTipologiaLibros']);
    $routes->post('add', 'Tipologias::add', ['as' => 'createTipologiaLibros']);
    $routes->get('edit/(:num)', 'Tipologias::edit/$1', ['as' => 'editTipologiaLibros']);
    $routes->post('edit/(:num)', 'Tipologias::edit/$1', ['as' => 'updateTipologiaLibros']);
    $routes->get('delete/(:num)', 'Tipologias::delete/$1', ['as' => 'deleteTipologiaLibros']);
    $routes->post('allmenuitems', 'Tipologias::allItemsSelect', ['as' => 'select2ItemsOfTipologiasLibros']);
    $routes->post('menuitems', 'Tipologias::menuItems', ['as' => 'menuItemsOfTipologiasLibros']);
});

$routes->group('imposiciones', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Imposiciones::index', ['as' => 'imposicionList']);
    $routes->get('add', 'Imposiciones::add', ['as' => 'newImposicion']);
    $routes->get('add/esquema', 'Imposiciones::add_esquema', ['as' => 'newImposicionEsquema']);
    $routes->get('find/(:num)', 'Imposiciones::find_imposicion/$1', ['as' => 'findImposicion']);
    $routes->get('esquema/find/(:num)', 'Imposiciones::find_imposicion_esquema/$1', ['as' => 'findImposicionEsquema']);
    $routes->post('create', 'Imposiciones::create', ['as' => 'ajaxCreateImposicion']);
    $routes->post('esquema/create', 'Imposiciones::create_imposicion_esquema', ['as' => 'ajaxCreateImposicionEsquema']);
    $routes->post('(:num)', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']);
    $routes->post('esquema/(:num)', 'Imposiciones::update_imposicion_esquema/$1', ['as' => 'ajaxUpdateImposicionEsquema']);
    $routes->delete('(:num)', 'Imposiciones::delete/$1', ['as' => 'deleteImposicion']);
    $routes->delete('esquema/(:num)', 'Imposiciones::delete_imposicion_esquema/$1', ['as' => 'deleteImposicionEsquema']);
    $routes->get('edit/(:num)', 'Imposiciones::edit/$1', ['as' => 'updateImposicionForm']);
    $routes->get('esquema/edit/(:num)', 'Imposiciones::edit_imposicion_esquema/$1', ['as' => 'updateImposicionEsquemaForm']);
    $routes->get('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']);
    $routes->get('esquema/datatable', 'Imposiciones::datatable_imposicion_esquema', ['as' => 'dataTableOfEsquemaImposiciones']);
    $routes->post('allmenuitems', 'Imposiciones::allItemsSelect', ['as' => 'select2ItemsOfImposiciones']);
    $routes->post('menuitems', 'Imposiciones::menuItems', ['as' => 'menuItemsOfImposiciones']);
    $routes->get('select', 'Imposiciones::selectImposicion', ['as' => 'selectImposicion']);
    $routes->get('esquema/select', 'Imposiciones::selectImposicionEsquema', ['as' => 'selectImposicionEsquema']);
});

$routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('add', 'Papelimpresiontipologias::add', ['as' => 'newPapelImpresionTipologia']);
    $routes->post('add', 'Papelimpresiontipologias::add', ['as' => 'createPapelImpresionTipologia']);
    $routes->post('datatable_editor', 'Papelimpresiontipologias::datatable_editor', ['as' => 'editorOfConsumoTintas']);
    $routes->get('edit/(:num)', 'Papelimpresiontipologias::edit/$1', ['as' => 'editPapelImpresionTipologia']);
    $routes->post('edit/(:num)', 'Papelimpresiontipologias::edit/$1', ['as' => 'updatePapelImpresionTipologia']);
    $routes->get('delete/(:num)', 'Papelimpresiontipologias::delete/$1', ['as' => 'deletePapelImpresionTipologia']);
});


$routes->group('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->post('datatable', 'Papelimpresionmargenes::datatable', ['as' => 'dataTableOfPapelImpresionMargen']);
    $routes->post('datatable_editor', 'Papelimpresionmargenes::datatable_editor', ['as' => 'editorOfPapelImpresionMargenes']);
    $routes->get('delete/(:num)', 'Papelimpresionmargenes::delete/$1', ['as' => 'deletePapelImpresionMargen']);
});
$routes->resource('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelimpresionmargenes', 'except' => 'show,new,create,update']);

$routes->group('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Maquinastarifasimpresion::index', ['as' => 'maquinasTarifaImpresionList']);
    $routes->get('add', 'Maquinastarifasimpresion::add', ['as' => 'newMaquinasTarifaImpresion']);
    $routes->post('add', 'Maquinastarifasimpresion::add', ['as' => 'createMaquinasTarifaImpresion']);
    $routes->post('create', 'Maquinastarifasimpresion::create', ['as' => 'ajaxCreateMaquinasTarifaImpresion']);
    $routes->put('(:num)/update', 'Maquinastarifasimpresion::update/$1', ['as' => 'ajaxUpdateMaquinasTarifaImpresion']);
    $routes->post('(:num)/edit', 'Maquinastarifasimpresion::edit/$1', ['as' => 'updateMaquinasTarifaImpresion']);
    $routes->get('delete/(:num)', 'Maquinastarifasimpresion::delete/$1', ['as' => 'deleteMaquinastarifasimpresion']);
    $routes->post('datatable_editor', 'Maquinastarifasimpresion::datatable_editor', ['as' => 'editorOfMaquinasTarifaImpresion']);
    $routes->post('datatable', 'Maquinastarifasimpresion::datatable', ['as' => 'dataTableOfMaquinasTarifasImpresion']);
    $routes->post('allmenuitems', 'Maquinastarifasimpresion::allItemsSelect', ['as' => 'select2ItemsOfMaquinasTarifasImpresion']);
    $routes->post('menuitems', 'Maquinastarifasimpresion::menuItems', ['as' => 'menuItemsOfMaquinasTarifasImpresion']);
});
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);

$routes->group('maquinascalles', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Maquinascalles::index', ['as' => 'maquinasCallesList']);
    $routes->get('delete/(:num)', 'Maquinascalles::delete/$1', ['as' => 'deleteMaquinascalles']);
    $routes->post('datatable_editor', 'Maquinascalles::datatable_editor', ['as' => 'editorOfMaquinascalles']);
    $routes->post('datatable', 'Maquinascalles::datatable', ['as' => 'dataTableOfMaquinascalles']);
});
$routes->resource('maquinascalles', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'maquinascalles', 'except' => 'show,new,create,update']);

$routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->post('datatable', 'Maquinaspapelesimpresion::datatable', ['as' => 'dataTableOfMaquinasPapelesImpresion']);
    $routes->post('datatable_2', 'Maquinaspapelesimpresion::datatable_2', ['as' => 'dataTableOfPapelesImpresionMaquinas']);
    $routes->post('datatable_editor', 'Maquinaspapelesimpresion::datatable_editor', ['as' => 'editorOfMaquinasPapelImpresion']);
    $routes->post('datatable_editor_2', 'Maquinaspapelesimpresion::datatable_editor_2', ['as' => 'editorOfPapelImpresionMaquinas']);
    $routes->post('updateTableOnChange', 'Maquinaspapelesimpresion::updateTableOnChange', ['as' => 'updateMaquinaPapelOnTarifasChange']);
});
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);


$routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) {
    $routes->get('', 'Profile::index', ['as' => 'profileList']);
    $routes->get('index', 'Profile::index', ['as' => 'profileIndex']);
    $routes->get('list', 'Profile::index', ['as' => 'profileList2']);
    $routes->match(['get', 'post'], 'store', 'Profile::store', ['as' => 'profileStore']);
});


$routes->group('comunidades-autonomas', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Comunidadesautonomas::index', ['as' => 'comunidadAutonomaList']);
    $routes->get('add', 'Comunidadesautonomas::add', ['as' => 'newComunidadAutonoma']);
    $routes->post('add', 'Comunidadesautonomas::add', ['as' => 'createComunidadAutonoma']);
    $routes->post('create', 'Comunidadesautonomas::create', ['as' => 'ajaxCreateComunidadAutonoma']);
    $routes->put('(:num)/update', 'Comunidadesautonomas::update/$1', ['as' => 'ajaxUpdateComunidadAutonoma']);
    $routes->post('(:num)/edit', 'Comunidadesautonomas::edit/$1', ['as' => 'updateComunidadAutonoma']);
    $routes->post('datatable', 'Comunidadesautonomas::datatable', ['as' => 'dataTableOfComunidadesAutonomas']);
    $routes->post('allmenuitems', 'Comunidadesautonomas::allItemsSelect', ['as' => 'select2ItemsOfComunidadesAutonomas']);
    $routes->post('menuitems', 'Comunidadesautonomas::menuItems', ['as' => 'menuItemsOfComunidadesAutonomas']);
    $routes->get('menuitems2', 'Comunidadesautonomas::menuItems2', ['as' => 'menuItemsOfComunidadesAutonomas2']);
});
$routes->resource('comunidades-autonomas', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Comunidadesautonomas', 'except' => 'show,new,create,update']);


$routes->group('formas-pago', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'FormasPago::index', ['as' => 'formasPagoList']);
    $routes->match(['get', 'post'], 'add', 'FormasPago::add', ['as' => 'formasPagoAdd']);
    $routes->match(['get', 'post'], 'edit/(:num)', 'FormasPago::edit/$1', ['as' => 'formasPagoEdit']);
    $routes->get('delete/(:num)', 'FormasPago::delete/$1', ['as' => 'formasPagoDelete']);
    $routes->post('datatable', 'FormasPago::datatable', ['as' => 'formasPagoDT']);
    $routes->get('menuitems', 'FormasPago::menuItems', ['as' => 'menuItemsOfFormasDePagos']);
});
$routes->resource('formas-pago', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'FormasPago', 'except' => 'show,new,create,update']);


$routes->group('provincias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
    $routes->get('', 'Provincias::index', ['as' => 'provinciaList']);
    $routes->get('add', 'Provincias::add', ['as' => 'newProvincia']);
    $routes->post('add', 'Provincias::add', ['as' => 'createProvincia']);
    $routes->post('create', 'Provincias::create', ['as' => 'ajaxCreateProvincia']);
    $routes->put('(:num)/update', 'Provincias::update/$1', ['as' => 'ajaxUpdateProvincia']);
    $routes->post('(:num)/edit', 'Provincias::edit/$1', ['as' => 'updateProvincia']);
    $routes->post('datatable', 'Provincias::datatable', ['as' => 'dataTableOfProvincias']);
    $routes->post('allmenuitems', 'Provincias::allItemsSelect', ['as' => 'select2ItemsOfProvincias']);
    $routes->post('menuitems', 'Provincias::menuItems', ['as' => 'menuItemsOfProvincias']);
    $routes->get('menuitems2', 'Provincias::menuItems2', ['as' => 'menuItemsOfProvincias2']);
});
$routes->resource('provincias', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Provincias', 'except' => 'show,new,create,update']);


/* Rutas para configuraciones */
$routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {

    /* Cliente */
    $routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
        $routes->get('', 'Cliente::index', ['as' => 'clienteList']);
        $routes->get('edit/(:num)', 'Cliente::edit/$1', ['as' => 'editarCliente']);
        $routes->match(['get', 'post'], 'add', 'Cliente::add', ['as' => 'clienteAdd']);
        $routes->match(['get', 'post'], 'edit/(:num)', 'Cliente::edit/$1', ['as' => 'clienteEdit']);
        $routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'clienteDelete']);
        $routes->post('datatable', 'Cliente::datatable', ['as' => 'clienteDT']);
        $routes->post('menuitems', 'Cliente::menuItems', ['as' => 'menuItemsOfClientes']);
        $routes->get('getSelect2', 'Cliente::getSelect2', ['as' => 'getListaSelect2']);
    });
});


$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'dataTableOfClienteprecios']);
    $routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
    $routes->post('changeplantilla', 'ClientePrecios::updatePlantilla', ['as' => 'changePlantillaOfClienteprecios']);
    $routes->get('getplantilla', 'ClientePrecios::getCurrentPlantilla', ['as' => 'getPlantillaOfClienteprecios']);
    $routes->post('update', 'ClientePrecios::updatePlantilla', ['as' => 'updateClienteprecios']);
});
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'ClientePrecios', 'except' => 'show,new,create,update']);


$routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->get('', 'Clienteplantillaprecios::index', ['as' => 'clienteplantillapreciosList']);
    $routes->get('add', 'Clienteplantillaprecios::add', ['as' => 'newClienteplantillaprecios']);
    $routes->post('add', 'Clienteplantillaprecios::add', ['as' => 'createClienteplantillaprecios']);
    $routes->post('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']);
    $routes->get('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']);
    $routes->get('delete/(:num)', 'Clienteplantillaprecios::delete/$1', ['as' => 'deleteClienteplantillaprecios']);
    $routes->post('datatable', 'Clienteplantillaprecios::datatable', ['as' => 'dataTableOfClientesplantillaprecios']);
    $routes->get('menuitems', 'Clienteplantillaprecios::menuItems', ['as' => 'menuItemsOfClienteplantillaprecios']);
    $routes->post('update/(:num)', 'Clienteplantillaprecios::update/$1', ['as' => 'updateClienteplantillaprecios']);
});
$routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteplantillaprecios', 'except' => 'show,new,create']);


$routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->post('datatable', 'Clienteplantillaprecioslineas::datatable', ['as' => 'dataTableOfClientesplantillaprecioslineas']);
    $routes->post('datatable_editor', 'Clienteplantillaprecioslineas::datatable_editor', ['as' => 'editorOfClienteplantillaprecioslineas']);
    $routes->post('getrows', 'Clienteplantillaprecioslineas::getStoredRows', ['as' => 'getStoredRowsOfClienteplantillaprecioslineas']);
});
$routes->resource('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'clienteplantillaprecioslineas', 'except' => 'show,new,create,update']);

$routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->post('datatable', 'Clienteusuarios::datatable', ['as' => 'dataTableOfClienteUsuarios']);
    $routes->post('adduser', 'Clienteusuarios::addUserToClient');
    $routes->get('delete/(:num)', 'Clienteusuarios::removeClienteFromUser/$1');
    $routes->get('getusers', 'Clienteusuarios::getAvailableUsers');
});


$routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->get('', 'Clientedirecciones::index', ['as' => 'clientedireccionesIndex']);
    $routes->get('get/(:num)', 'Clientedirecciones::get/$1', ['as' => 'get']);
    $routes->get('getDireccionPresupuesto/(:num)', 'Clientedirecciones::getDireccionPresupuesto/$1', ['as' => 'getDireccionPresupuesto']);
    $routes->post('add', 'Clientedirecciones::add', ['as' => 'newClientedirecciones']);
    $routes->get('getSelect2', 'Clientedirecciones::getSelect2', ['as' => 'listaClientedirecciones']);
});



$routes->group('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifasencuadernacion::index', ['as' => 'tarifaEncuadernacionList']);
    $routes->get('add', 'Tarifasencuadernacion::add', ['as' => 'newTarifaEncuadernacion']);
    $routes->post('add', 'Tarifasencuadernacion::add', ['as' => 'createTarifaEncuadernacion']);
    $routes->post('create', 'Tarifasencuadernacion::create', ['as' => 'ajaxCreateTarifaEncuadernacion']);
    $routes->put('(:num)/update', 'Tarifasencuadernacion::update/$1', ['as' => 'ajaxUpdateTarifaEncuadernacion']);
    $routes->post('edit/(:num)', 'Tarifasencuadernacion::edit/$1', ['as' => 'updateTarifaEncuadernacion']);
    $routes->get('delete/(:num)', 'Tarifasencuadernacion::delete/$1', ['as' => 'deleteTarifaEncuadernacion']);
    $routes->post('datatable', 'Tarifasencuadernacion::datatable', ['as' => 'dataTableOfTarifasEncuadernacion']);
    $routes->post('allmenuitems', 'Tarifasencuadernacion::allItemsSelect', ['as' => 'select2ItemsOfTarifasEncuadernacion']);
    $routes->post('menuitems', 'Tarifasencuadernacion::menuItems', ['as' => 'menuItemsOfTarifasEncuadernacion']);
    $routes->get('gettarifas', 'Tarifasencuadernacion::getSelect2');
});
$routes->resource('tarifasencuadernacion', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasencuadernacion', 'except' => 'show,new,create,update']);


$routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifaencuadernacionlineas::index', ['as' => 'tarifaEncuadernacionLineaList']);
    $routes->get('add', 'Tarifaencuadernacionlineas::add', ['as' => 'newTarifaEncuadernacionLinea']);
    $routes->post('add', 'Tarifaencuadernacionlineas::add', ['as' => 'createTarifaEncuadernacionLinea']);
    $routes->post('create', 'Tarifaencuadernacionlineas::create', ['as' => 'ajaxCreateTarifaEncuadernacionLinea']);
    $routes->put('(:num)/update', 'Tarifaencuadernacionlineas::update/$1', ['as' => 'ajaxUpdateTarifaEncuadernacionLinea']);
    $routes->post('(:num)/edit', 'Tarifaencuadernacionlineas::edit/$1', ['as' => 'updateTarifaEncuadernacionLinea']);
    $routes->post('datatable', 'Tarifaencuadernacionlineas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionLineas']);
    $routes->post('datatable_editor', 'Tarifaencuadernacionlineas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionLineas']);
    $routes->post('allmenuitems', 'Tarifaencuadernacionlineas::allItemsSelect', ['as' => 'select2ItemsOfTarifaEncuadernacionLineas']);
    $routes->post('menuitems', 'Tarifaencuadernacionlineas::menuItems', ['as' => 'menuItemsOfTarifaEncuadernacionLineas']);
});
$routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']);

$routes->group('tarifaencuadernacionlineahorass', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifaencuadernacionlineashoras::index', ['as' => 'tarifaEncuadernacionLineaListHoras']);
    $routes->get('add', 'Tarifaencuadernacionlineashoras::add', ['as' => 'newTarifaEncuadernacionLineaHoras']);
    $routes->post('add', 'Tarifaencuadernacionlineashoras::add', ['as' => 'createTarifaEncuadernacionLineaHoras']);
    $routes->post('create', 'Tarifaencuadernacionlineashoras::create', ['as' => 'ajaxCreateTarifaEncuadernacionLineaHoras']);
    $routes->put('(:num)/update', 'Tarifaencuadernacionlineashoras::update/$1', ['as' => 'ajaxUpdateTarifaEncuadernacionLineaHoras']);
    $routes->post('(:num)/edit', 'Tarifaencuadernacionlineashoras::edit/$1', ['as' => 'updateTarifaEncuadernacionLineaHoras']);
    $routes->post('datatable', 'Tarifaencuadernacionlineashoras::datatable', ['as' => 'dataTableOfTarifaEncuadernacionLineasHoras']);
    $routes->post('datatable_editor', 'Tarifaencuadernacionlineashoras::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionLineasHoras']);
    $routes->post('allmenuitems', 'Tarifaencuadernacionlineashoras::allItemsSelect', ['as' => 'select2ItemsOfTarifaEncuadernacionLineasHoras']);
});
$routes->resource('tarifaencuadernacionlineahorass', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'TarifaencuadernacionlineasHoras', 'except' => 'show,new,create,update']);


$routes->group('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->post('datatable', 'Tarifaencuadernaciontiradas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionTiradas']);
    $routes->post('datatable_editor', 'Tarifaencuadernaciontiradas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionTiradas']);
    $routes->post('menuitems', 'Tarifaencuadernaciontiradas::menuItems', ['as' => 'menuItemsOfTarifaencuadernaciontiradas']);
});
$routes->resource('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernaciontiradas', 'except' => 'show,new,create,update']);


$routes->group('tarifasenvios', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->get('', 'Tarifasenvios::index', ['as' => 'tarifaEnvioList']);
    $routes->get('add', 'Tarifasenvios::add', ['as' => 'newTarifaEnvio']);
    $routes->post('add', 'Tarifasenvios::add', ['as' => 'createTarifaEnvio']);
    $routes->post('create', 'Tarifasenvios::create', ['as' => 'ajaxCreateTarifaEnvio']);
    $routes->put('(:num)/update', 'Tarifasenvios::update/$1', ['as' => 'ajaxUpdateTarifaEnvio']);
    $routes->post('edit/(:num)', 'Tarifasenvios::edit/$1', ['as' => 'updateTarifaEnvio']);
    $routes->post('datatable', 'Tarifasenvios::datatable', ['as' => 'dataTableOfTarifaEnvio']);
    $routes->post('allmenuitems', 'Tarifasenvios::allItemsSelect', ['as' => 'select2ItemsOfTarifaEnvio']);
    $routes->post('menuitems', 'Tarifasenvios::menuItems', ['as' => 'menuItemsOfTarifaEnvio']);
});
$routes->resource('tarifasenvios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvios', 'except' => 'show,new,create,update']);


$routes->group('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->post('datatable', 'Tarifasenviosprecios::datatable', ['as' => 'dataTableOfTarifasEnvioPrecios']);
    $routes->post('datatable_editor', 'Tarifasenviosprecios::datatable_editor', ['as' => 'editorOfTarifasEnvioPrecios']);
});
$routes->resource('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenviosprecios', 'except' => 'show,new,create,update']);


$routes->group('tarifasenvioszonas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
    $routes->post('datatable', 'Tarifasenvioszonas::datatable', ['as' => 'dataTableOfTarifasEnvioZonas']);
    $routes->post('datatable_editor', 'Tarifasenvioszonas::datatable_editor', ['as' => 'editorOfTarifasEnvioZonas']);
});
$routes->resource('tarifasenvioszonas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvioszonas', 'except' => 'show,new,create,update']);




$routes->resource('proveedorestipos', ['namespace' => 'App\Controllers\Compras', 'controller' => 'ProveedoresTipos', 'except' => 'show,new,create,update']);

$routes->group('clientecontactos', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->get('', 'Clientecontactos::index', ['as' => 'ClienteContactosList']);
    $routes->get('add', 'Clientecontactos::add', ['as' => 'newClienteContactos']);
    $routes->post('add', 'Clientecontactos::add', ['as' => 'createClienteContactos']);
    $routes->post('create', 'Clientecontactos::create', ['as' => 'ajaxCreateClienteContactos']);
    $routes->put('(:num)/update', 'Clientecontactos::update/$1', ['as' => 'ajaxUpdateClienteContactos']);
    $routes->post('(:num)/edit', 'Clientecontactos::edit/$1', ['as' => 'updateClienteContactos']);
    $routes->post('datatable', 'Clientecontactos::datatable', ['as' => 'dataTableOfClienteContactos']);
    $routes->post('datatable_editor', 'Clientecontactos::datatable_editor', ['as' => 'editorOfClienteContactos']);
    $routes->get('delete/(:num)', 'Clientecontactos::delete/$1', ['as' => 'deleteClienteContactos']);
    $routes->post('allmenuitems', 'Clientecontactos::allItemsSelect', ['as' => 'select2ItemsOfClienteContactos']);
    $routes->post('menuitems', 'Clientecontactos::menuItems', ['as' => 'menuItemsOfClienteContactos']);
});
$routes->resource('ClienteContactos', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'ClienteContactos', 'except' => 'show,new,create,update']);


$routes->group('clientedirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
    $routes->get('delete/(:num)', 'Clientedirecciones::delete/$1', ['as' => 'deleteClientedirecciones']);
    $routes->post('datatable', 'Clientedirecciones::datatable', ['as' => 'dataTableOfClienteDirecciones']);
    $routes->post('datatable_editor', 'Clientedirecciones::datatable_editor', ['as' => 'editorOfClienteDirecciones']);
    $routes->post('menuitems', 'Clientedirecciones::menuItems', ['as' => 'menuItemsOfClienteDirecciones']);
});
$routes->resource('clientedirecciones', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clientedirecciones', 'except' => 'show,new,create,update']);



$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->get('getacabados', 'Presupuestoacabados::getAcabados');
    $routes->post('getvalues', 'Presupuestoacabados::getRowValues');
    $routes->post('menuitems', 'Presupuestoacabados::menuItems', ['as' => 'menuItemsOfPresupuestoAcabados']);
    $routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']);
    $routes->get('cargar', 'Presupuestoacabados::cargar');
    $routes->post('update/(:num)', 'Presupuestoacabados::update/$1');
});


$routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->post('datatable', 'Presupuestoencuadernaciones::datatable', ['as' => 'dataTableOfPresupuestoEncuadernaciones']);
    $routes->post('getvalues', 'Presupuestoencuadernaciones::getRowValues');
    $routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']);
    $routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']);
    $routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updatePresupuestoencuadernaciones']);
    $routes->post('update/(:num)', 'Presupuestoencuadernaciones::update/$1');
});

$routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->post('getvalues', 'Presupuestomanipulados::getRowValues');
    $routes->post('datatable', 'Presupuestomanipulados::datatable', ['as' => 'dataTableOfPresupuestoManipulados']);
    $routes->post('edit/(:num)', 'Presupuestomanipulados::edit/$1', ['as' => 'updatePresupuestomanipulados']);
    $routes->post('update/(:num)', 'Presupuestomanipulados::update/$1');
    $routes->get('serviciosolapas', 'Presupuestomanipulados::getServicioSolapas');
});

$routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->post('getvalues', 'Presupuestopreimpresiones::getRowValues');
    $routes->post('datatable', 'Presupuestopreimpresiones::datatable', ['as' => 'dataTableOfPresupuestoPreimpresiones']);
    $routes->post('edit/(:num)', 'Presupuestopreimpresiones::edit/$1', ['as' => 'updatePresupuestopreimpresiones']);
    $routes->get('cargar', 'Presupuestopreimpresiones::getSelect2');
});

$routes->group('serviciosextra', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->post('datatable', 'Presupuestoserviciosextra::datatable', ['as' => 'dataTableOfPresupuestoServiciosExtra']);
    $routes->post('edit/(:num)', 'Presupuestoserviciosextra::edit/$1', ['as' => 'updatePresupuestoServiciosExtra']);
    $routes->post('getvalues', 'Presupuestoserviciosextra::getRowValues');
});

$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']);
    $routes->post('datatable_2', 'Presupuestodirecciones::datatable_2', ['as' => 'processDataDirecciones']);
});

$routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
    $routes->post('datatable', 'Presupuestotiradasalternativas::datatable', ['as' => 'dataTableOfPresupuestoTiradasAlternativas']);
    $routes->post('datatable_2', 'Presupuestotiradasalternativas::datatable_2', ['as' => 'getTiradaData']);
});

$routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
    $routes->get('list', 'Pedido::todos', ['as' => 'listaPedidos']);
    $routes->get('activos', 'Pedido::activos', ['as' => 'listaPedidosActivos']);
    $routes->get('finalizados', 'Pedido::finalizados', ['as' => 'listaPedidosFinalizados']);
    $routes->get('cancelados', 'Pedido::cancelados', ['as' => 'listaPedidosCancelados']);
    $routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']);
    $routes->get('add', 'Pedido::add', ['as' => 'nuevoPedido']);
    $routes->post('add', 'Pedido::add', ['as' => 'crearPedido']);
    $routes->get('edit/(:any)', 'Pedido::edit/$1', ['as' => 'editarPedido']);
    $routes->post('getlineas', 'Pedido::getLineas', ['as' => 'tablaLineasPedido']);
    $routes->post('cambiarestado', 'Pedido::cambiarEstado', ['as' => 'cambiarEstadoPedido']);
    $routes->post('update/(:any)', 'Pedido::update/$1', ['as' => 'actualizarPedido']);
    $routes->post('insertfactura', 'Pedido::addFactura');
    $routes->get('xml/(:num)', 'Pedido::get_xml_pedido/$1', ['as' => 'getXMLPedido']);
    $routes->post('produccion/(:num)', 'Pedido::to_produccion/$1', ['as' => 'toProduccion']);
    $routes->get('pedidosCliente', 'Pedido::tablaClienteForm');
    $routes->get('getSumCliente/(:num)', 'Pedido::obtenerTotalPedidosCliente/$1');
    $routes->get('validacion', 'Pedido::validacion', ['as' => 'validacionView']);
});
$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);


$routes->group('albaranes', ['namespace' => 'App\Controllers\Albaranes'], function ($routes) {
    $routes->post('generarAlbaran', 'Albaran::generateAlbaran', ['as' => 'generarAlbaran']);
    $routes->get('albaranesEnvio', 'Albaran::getAlbaranes');
    $routes->get('datatablesAlbaranLinea', 'Albaran::datatablesLineasAlbaran');
    $routes->post('updateAlbaran', 'Albaran::updateAlbaran');
    $routes->post('borrarAlbaranLinea', 'Albaran::borrarLinea');
    $routes->post('borrarAlbaran', 'Albaran::borrarAlbaran');
    $routes->post('updateAlbaranLinea', 'Albaran::updateAlbaranLinea');
    $routes->post('addIvaAlbaran', 'Albaran::addLineasIva');
    $routes->post('nuevaLineaAlbaran', 'Albaran::addBlankLineaAlbaran');
});
$routes->resource('albaranes', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Albaran', 'except' => 'show,new,create,update']);


$routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], function ($routes) {

    $routes->get('list', 'Facturas::list', ['as' => 'facturasList']);
    $routes->get('datatable', 'Facturas::datatable', ['as' => 'dataTableOfFacturas']);
    $routes->get('add', 'Facturas::add', ['as' => 'newFactura']);
    $routes->post('add', 'Facturas::add', ['as' => 'createFactura']);
    $routes->get('edit/(:any)', 'Facturas::edit/$1', ['as' => 'editarFactura']);
    $routes->get('validar/(:any)', 'Facturas::validar/$1', ['as' => 'validarFactura']);
    $routes->post('update/(:any)', 'Facturas::update/$1', ['as' => 'actualizarFactura']);
    $routes->post('duplicate/(:any)', 'Facturas::duplicate/$1', ['as' => 'duplicarFactura']);
    $routes->post('datatable/(:any)', 'FacturasLineas::datatable/$1', ['as' => 'dataTableOfLineasFacturas']);
    $routes->post('menuPedidosPendientes/(:num)', 'Facturas::menuPedidosPendientes/$1', ['as' => 'menuPedidosPendientesImpresion']);
    $routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']);
    $routes->post('addExcedentes/(:any)', 'Facturas::addExcedentes/$1', ['as' => 'addLineaExcedentes']);
    $routes->get('deleteLinea/(:any)', 'FacturasLineas::deleteLinea/$1', ['as' => 'deleteLineaFactura']);
    $routes->get('delete/(:any)', 'Facturas::delete/$1', ['as' => 'borrarFactura']);
    $routes->post('deleteFacturaLineaPedido', 'Facturas::deleteLineaPedidoImpresion', ['as' => 'deleteLineaPedidoImpresion']);
    $routes->post('editorLineas', 'FacturasLineas::datatable_editor', ['as' => 'editorOfLineasFacturas']);
    $routes->post('updateTotales/(:any)', 'Facturas::updateTotales/$1', ['as' => 'updateFacturaTotales']);
    $routes->post('updateCabecera/(:any)', 'Facturas::updateCabecera/$1', ['as' => 'updateCabecera']);
    $routes->post('datatablePagos/(:any)', 'FacturasPagos::datatable/$1', ['as' => 'dataTableOfPagosFacturas']);
    $routes->post('editorPagos', 'FacturasPagos::datatable_editor', ['as' => 'editorOfPagosFacturas']);
    $routes->post('datatablePedidos', 'Facturas::datatablePedidos', ['as' => 'dataTableOfFacturasPedido']);
    $routes->get('getdatoscliente/(:any)', 'Facturas::getDatosFacturacionClienteForm/$1');
});


$routes->group(
    'printpresupuestos',
    ['namespace' => 'App\Controllers\Pdf'],
    function ($routes) {
        $routes->get('index/(:num)', 'PrintPresupuestos::index/$1', ['as' => 'viewPresupuesto']);
        $routes->get('generar/(:num)', 'PrintPresupuestos::generar/$1', ['as' => 'presupuestoToPdf']);
    }
);

$routes->group(
    'print-albaran',
    ['namespace' => 'App\Controllers\Pdf'],
    function ($routes) {
        $routes->get('index/(:num)', 'PrintAlbaranes::index/$1', ['as' => 'viewAlbaranPDF']);
        $routes->get('generar/(:num)', 'PrintAlbaranes::generar/$1', ['as' => 'albaranToPdf']);
    }
);

$routes->group(
    'print-factura',
    ['namespace' => 'App\Controllers\Pdf'],
    function ($routes) {
        $routes->get('index/(:num)', 'PrintFacturas::index/$1', ['as' => 'viewFacturaPDF']);
        $routes->get('generar/(:num)', 'PrintFacturas::generar/$1', ['as' => 'facturaToPdf']);
    }
);

$routes->group(
    'export-giros',
    ['namespace' => 'App\Controllers\Excel'],
    function ($routes) {
        $routes->get('generar/(:num)', 'PrintGiros::generateExcel/$1', ['as' => 'girosToExcel']);
    }
);

$routes->group(
    'export-lineas',
    ['namespace' => 'App\Controllers\Excel'],
    function ($routes) {
        $routes->get('generar/(:num)', 'PrintLineas::generateExcel/$1', ['as' => 'lineasToExcel']);
    }
);

$routes->group(
    'presupuestos',
    ['namespace' => 'App\Controllers\Presupuestos'],
    function ($routes) {
        $routes->get('buscador', 'Buscador::index', ['as' => 'buscadorPresupuestosList']);
        $routes->post('datatable', 'Buscador::datatable', ['as' => 'dataTableOfBuscador']);
    }
);
$routes->resource('buscadorpresupuestos', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Buscador', 'except' => 'show,new,create,update']);


$routes->group(
    'papel-formato',
    ['namespace' => 'App\Controllers\Configuracion'],
    function ($routes) {
        $routes->post('menuitems', 'Papelformato::menuitems', ['as' => 'menuitems']);
        $routes->get('getSelect2', 'Papelformato::getSelect2', ['as' => 'getSelect2']);
    }
);
$routes->resource('papel-formato', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelformato', 'except' => 'show,new,create,update']);



/* Rutas para mensajeria */
$routes->group('mensajes', ['namespace' => 'App\Controllers\Mensajeria'], function ($routes) {

    /* Interna */
    $routes->group('internos', ['namespace' => 'App\Controllers\Mensajeria'], function ($routes) {

        $routes->get('', 'MensajesDirectos::index', ['as' => 'mensajeriaView']);
        $routes->get('chat/(:num)', 'MensajesDirectos::getChatInfo/$1', ['as' => 'getChatInfo']);
        /*$routes->match(['get', 'post'], 'add', 'TarifaAcabados::add', ['as' => 'tarifaAcabadoAdd']);
        $routes->match(['get', 'post'], 'edit/(:num)', 'TarifaAcabados::edit/$1', ['as' => 'tarifaAcabadoEdit']);
        $routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
        $routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);*/
    });
});
$routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($routes) {
    $routes->get('datatable', 'ChatController::datatable_messages', ['as' => 'getDatatableMessages']);
    $routes->get('datatable/presupuesto', 'ChatController::datatable_presupuesto_messages', ['as' => 'getDatatablePresupuestoMessages']);
    $routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']);
    $routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']);

    $routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']);
    $routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']);
});
$routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($routes) {

    $routes->get('direct/(:num)', 'ChatController::get_chat_direct_view/$1', ['as' => 'getChatDirectView']);
    $routes->get('presupuesto/(:num)', 'ChatController::get_chat_presupuesto_view/$1', ['as' => 'getChatPresupuestoView']);
    $routes->get('pedido/(:num)', 'ChatController::get_chat_pedido_view/$1', ['as' => 'getChatPedidoView']);
    $routes->get('factura/(:num)', 'ChatController::get_chat_factura_view/$1', ['as' => 'getChatFacturaView']);

    $routes->get('direct/conversation/(:num)', 'ChatController::get_chat_direct/$1', ['as' => 'getChatDirect']);
    $routes->get('direct/users/select/(:num)', 'ChatController::get_chat_direct_select_users/$1', ['as' => 'getChatDirectSelectUsers']);

    $routes->get('direct/client/users/select/presupuesto/(:num)', 'ChatController::get_presupuesto_client_users/$1/$2', ['as' => 'getPresupuestoClientUsers']);
    $routes->get('direct/client/users/select/pedido/(:num)', 'ChatController::get_pedido_client_users/$1/$2', ['as' => 'getPedidoClientUsers']);
    $routes->get('direct/client/users/select/factura/(:num)', 'ChatController::get_factura_client_users/$1/$2', ['as' => 'getFacturaClientUsers']);
    $routes->get('direct/client/users/select/ot/(:num)', 'ChatController::get_orden_trabajo_client_users/$1/$2', ['as' => 'getOrdenTrabajoClientUsers']);


    $routes->get('direct/users/(:num)', 'ChatController::get_chat_direct_users', ['as' => 'getChatDirectUsers']);
    $routes->post('direct/users/(:num)', 'ChatController::store_chat_direct_users/$1', ['as' => 'storeChatDirectUsers']);
    $routes->get('direct/messages/(:num)', 'ChatController::get_chat_direct_messages/$1', ['as' => 'getChatDirectMessages']);
    $routes->post('direct/messages/(:num)', 'ChatController::store_chat_direct_message/$1', ['as' => 'storeChatDirectMessages']);
    $routes->post('direct/messages/unread/(:num)', 'ChatController::update_chat_direct_message_unread/$1', ['as' => 'updateChatDirectMessageUnread']);


    $routes->post('department', 'ChatController::store_chat_department', ['as' => 'storeChatDepartment']);
    $routes->delete('department/(:num)', 'ChatController::delete_chat_department/$1', ['as' => 'deleteChatDepartment']);
    $routes->post('department/update/(:num)', 'ChatController::update_chat_department/$1', ['as' => 'updateChatDepartment']);
    $routes->get('departments/(:alpha)/(:num)', 'ChatController::get_chat_departments/$1/$2', ['as' => 'getChatDepartments']);
    $routes->get('departments/select', 'ChatController::get_chat_department_select', ['as' => 'getChatDepartmentSelect']);
    $routes->get('department/presupuesto/(:num)/(:num)', 'ChatController::get_chat_presupuesto/$1/$2', ['as' => 'getChatPresupuesto']);
    $routes->get('department/pedido/(:num)/(:num)', 'ChatController::get_chat_pedido/$1/$2', ['as' => 'getChatPedido']);
    $routes->get('department/factura/(:num)/(:num)', 'ChatController::get_chat_factura/$1/$2', ['as' => 'getChatFactura']);
    $routes->get('department/ot/(:num)/(:num)', 'ChatController::get_chat_orden_trabajo/$1/$2', ['as' => 'getChatOrdenTrabajo']);
    $routes->get('department/users/presupuesto/(:num)/(:num)', 'ChatController::get_chat_department_presupuesto_users/$1/$2', ['as' => 'getPresupuestoChatDepartmentUsers']);
    $routes->get('department/users/ot/(:num)/(:num)', 'ChatController::get_chat_department_orden_trabajo_users/$1/$2', ['as' => 'getOrdenTrabajoChatDepartmentUsers']);

    $routes->get('department/datatable', 'ChatController::chat_department_datatable', ['as' => 'chatDepartmentDatatable']);
    $routes->get('department/edit/(:num)', 'ChatController::chat_department_edit/$1', ['as' => 'chatDepartmentEditView']);
    $routes->get('department/users/datatable/(:num)', 'ChatController::chat_department_user_datatable/$1', ['as' => 'chatDepartmentUsersDatatable']);
    $routes->get('department/users/pedido/(:num)/(:num)', 'ChatController::get_chat_department_pedido_users/$1/$2', ['as' => 'getPedidoChatDepartmentUsers']);
    $routes->get('department/users/factura/(:num)/(:num)', 'ChatController::get_chat_department_factura_users/$1/$2', ['as' => 'getFacturaChatDepartmentUsers']);
    $routes->get('department/users/select/add/(:num)', 'ChatController::select_users_not_in_chat_department/$1', ['as' => 'selectUsersNotInChatDepartment']);
    $routes->post('department/user', 'ChatController::subscribe_to_chat_deparment/$1', ['as' => 'subscribeToChatDepartment']);
    $routes->post('department/subscribe/admin/user', 'ChatController::subscribe_admin_to_department', ['as' => 'subscribeAdminToChatDepartment']);
    $routes->delete('department/user/(:num)', 'ChatController::delete_user_from_department/$1', ['as' => 'deleteUserFromDepartment']);
    $routes->delete('department/admin/user/(:num)/(:num)', 'ChatController::delete_user_admin_from_department/$1/$2', ['as' => 'deleteUserAdminFromDepartment']);


    $routes->get('(:num)', 'ChatController::get_chat/$1', ['as' => 'getChat']);
    $routes->post('message/error/presupuesto', 'ChatController::store_chat_error_message', ['as' => 'storeChatErrorMessage']);
    $routes->post('message/(:alpha)', 'ChatController::store_message/$1', ['as' => 'storeChatMessage']);
    $routes->post('message/internal', 'ChatController::store_chat_message_single', ['as' => 'storeChatMessageSingle']);
    $routes->get('contacts', 'ChatController::get_chat_internal_contacts', ['as' => 'getChatInternalContacts']);
    $routes->get('contacts/(:num)', 'ChatController::get_chat_internal_contact/$1', ['as' => 'getChatInternalContact']);
    $routes->get('contact/(:num)/messages', 'ChatController::get_chat_internal_messages/$1', ['as' => 'getChatInternalMessages']);
    $routes->get('notifications', 'ChatController::get_chat_cliente/$1', ['as' => 'getChatCliente']);
    $routes->get('users/internal', 'ChatController::get_chat_users_internal', ['as' => 'getChatUsersInternal']);
    $routes->get('users/all', 'ChatController::get_chat_users_all', ['as' => 'getChatUsersAll']);

    $routes->post('hebra/(:alpha)', 'ChatController::store_hebra/$1', ['as' => 'storeHebra']);
    $routes->post('hebra/(:num)', 'ChatController::update_hebra/$1', ['as' => 'updateHebra']);
    $routes->get('hebra/(:alpha)/(:num)', "ChatController::get_hebra/$1/$2", ["as" => "getHebra"]);

    $routes->get('users/message/notifications-unviewed/(:num)', 'ChatController::get_notifications_not_viewed_from_message/$1');
});


$routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($routes) {
    $routes->get('datatable', 'ChatController::datatable_messages', ['as' => 'getDatatableMessages']);
    $routes->get('datatable/presupuesto', 'ChatController::datatable_presupuesto_messages', ['as' => 'getDatatablePresupuestoMessages']);
    $routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']);
    $routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']);

    $routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']);
    $routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']);
});


$routes->group('soporte', ['namespace' => 'App\Controllers\Soporte'], function ($routes) {
    $routes->get('', 'Ticketcontroller::index', ['as' => 'TicketIndex']);
    $routes->get('add', 'Ticketcontroller::add', ['as' => 'NewTicket']);
    $routes->post('add', 'Ticketcontroller::add', ['as' => 'createTicket']);
    $routes->get('edit/(:num)', 'Ticketcontroller::edit/$1', ['as' => 'editTicket']);
    $routes->post('edit/(:num)', 'Ticketcontroller::edit/$1', ['as' => 'updateTicket']);
    $routes->post('ticketlist', 'Ticketcontroller::datatable');
    $routes->get('image/(:segment)', 'Ticketcontroller::image/$1');
});



$routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
    $routes->group('ordentrabajo', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
        $routes->get('', 'Ordentrabajo::index', ['as' => 'viewOrdenTrabajoIndex']);
        $routes->get('edit/(:num)', 'Ordentrabajo::edit/$1', ['as' => 'viewOrdenTrabajoEdit']);
        $routes->delete('reset/tareas/(:num)', 'Ordentrabajo::reset_tareas/$1');
        $routes->delete('tareas/(:num)', 'Ordentrabajo::delete_tarea/$1');
        $routes->get('summary/(:num)', 'Ordentrabajo::get_orden_trabajo_summary/$1', ['as' => 'getOrdenTrabajoSumary']);
        $routes->get('datatable', 'Ordentrabajo::datatable');
        $routes->get('datatable_pendientes', 'Ordentrabajo::datatable_pendientes');
        $routes->get('datatable_ferro_pendiente', 'Ordentrabajo::datatable_ferro_pendiente');
        $routes->get('datatable_ferro_ok', 'Ordentrabajo::datatable_ferro_ok');
        $routes->get('tareas/datatable/(:num)', 'Ordentrabajo::tareas_datatable/$1', ['as' => 'datatableTareasOrdenTrabajo']);
        /**======================
         *    UPDATES
         *========================**/
        $routes->post("update/tarea", 'Ordentrabajo::update_orden_trabajo_tarea');
        $routes->post("update/date", 'Ordentrabajo::update_orden_trabajo_date');
        $routes->post("update/pedido/date", 'Ordentrabajo::update_orden_trabajo_pedido_date');
        $routes->post("update/pedido", 'Ordentrabajo::update_orden_trabajo_pedido');
        $routes->post("update/user", 'Ordentrabajo::update_orden_trabajo_user');
        $routes->post("update", 'Ordentrabajo::update_orden_trabajo');
        $routes->post("upload/portada", 'Ordentrabajo::upload_orden_trabajo_portada');
        $routes->delete("portada/(:num)", 'Ordentrabajo::delete_orden_trabajo_portada/$1');
        $routes->get("color/(:num)", 'Ordentrabajo::get_orden_trabajo_color_status/$1');

        /**======================
         *    FILES
         *========================**/
        $routes->post('get_files', 'Ordentrabajo::get_files');
        $routes->post('upload_files', 'Ordentrabajo::upload_files');
        $routes->get('barcode/(:num)', 'Ordentrabajo::imprimir_codigo_safekat/$1',['as' => "getOrdenTrabajoBarCode"]);
        /**======================
         *    PDF
         *========================**/
        $routes->get('pdf/(:num)', 'Ordentrabajo::get_pdf/$1');
        $routes->get('portada/(:num)', 'Ordentrabajo::get_portada_img/$1');
        $routes->group('planning', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
            $routes->get('select/maquina/rotativa', 'Ordentrabajo::select_maquina_planning_rot');
            $routes->get('select/papel/rotativa', 'Ordentrabajo::select_papel_planning_rot');
            $routes->get('select/maquina/plana', 'Ordentrabajo::select_maquina_planning_plana');
            $routes->get('select/maquina/padre/plana', 'Ordentrabajo::select_maquina_padre_planning_plana');
            $routes->get('select/papel/plana', 'Ordentrabajo::select_papel_planning_plana');
            $routes->get('rotativa', 'Ordentrabajo::index_planning_rotativa');
            $routes->get('papel/datatable', 'Ordentrabajo::papel_gramaje_datatable');
            $routes->get('papel/plana/datatable', 'Ordentrabajo::papel_pliego_datatable');
            $routes->get('rotativa/datatable', 'Ordentrabajo::planning_rotativa_datatable');
            $routes->get('plana/datatable', 'Ordentrabajo::planning_plana_datatable');
            $routes->post('tarea/toggle/corte/(:num)', 'Ordentrabajo::tarea_toggle_corte/$1');
        });

        $routes->group('maquinista', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
            $routes->get('maquinas/view', 'Ordentrabajo::maquinista_maquinas_view', ['as' => 'viewProduccionMaquinistaMaquinas']);
            $routes->get('colas/view', 'Ordentrabajo::maquinista_colas_view', ['as' => 'viewProduccionMaquinistaColas']);
        });
    });
});
$routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], function ($routes) {

    $routes->get('print/label/test', 'LogisticaController::print_test_label');
    $routes->get('panel', 'LogisticaController::panel', ['as' => 'LogisticaPanel']);
    $routes->get('envios', 'LogisticaController::gestionEnvios', ['as' => 'gestionEnvios']);
    $routes->get('buscar/(:any)', 'LogisticaController::searchPedidoOrISBN/$1', ['as' => 'buscarPedidoOrISBN']);
    $routes->get('datatableEnvios', 'LogisticaController::datatable_envios');
    $routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1');
    $routes->get('envio/(:num)', 'LogisticaController::editEnvio/$1');
    $routes->get('selectAddLinea', 'LogisticaController::selectAddEnvioLinea');
    $routes->get('addLineaEnvio', 'LogisticaController::addEnvioLinea');
    $routes->post('updateCajaLinea', 'LogisticaController::setCajaLinea');
    $routes->post('deleteLineasEnvio', 'LogisticaController::deleteLineas');
    $routes->post('updateLineaEnvio', 'LogisticaController::updateLineaEnvio');
    $routes->post('updateComentariosEnvio', 'LogisticaController::saveComments');
    $routes->post('updateCajasEnvio', 'LogisticaController::updateCajasEnvio');
    $routes->post('updateCodigoSeguimiento', 'LogisticaController::updateCodigoSeguimiento');
    $routes->post('updateProveedorEnvio', 'LogisticaController::updateProveedorEnvio');
    $routes->post('finalizarEnvio', 'LogisticaController::finalizarEnvio');
});

/*
 * --------------------------------------------------------------------
 * Translation
 * --------------------------------------------------------------------
 */
$routes->group('translate', ['namespace' => 'App\Controllers'], function ($routes) {
    $routes->post('getTranslation', 'Language::getTranslation', ['as' => 'getKeys']);
});
$routes->resource('translate', ['namespace' => 'App\Controllers', 'controller' => 'Language', 'except' => '']);


/*
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
    require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
