From 1cfa5bd60b84cff8db1f9c19f11fde9889818d15 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Sun, 28 May 2023 12:33:07 +0200 Subject: [PATCH] papel generico terminado. papel impresion a falta de maquinas y tipologias --- ci4/app/Config/Routes.php | 282 ++++++------- .../Configuracion/PapelesGenericos.php | 189 ++++----- .../Configuracion/Papelesimpresion.php | 372 ++++++++++++++++++ .../Controllers/GoBaseResourceController.php | 37 +- ci4/app/Controllers/Test.php | 6 +- ci4/app/Controllers/WorstCase_LT6015.asc | 95 ----- .../Entities/Configuracion/PapelImpresion.php | 50 +++ ci4/app/Filters/LoginAuthFilter.php | 1 + ci4/app/Helpers/go_common_helper.php | 15 + ci4/app/Language/en/App.php | 1 + ci4/app/Language/en/PapelGenerico.php | 3 + ci4/app/Language/en/PapelImpresion.php | 117 ++++++ ci4/app/Language/es/App.php | 1 + ci4/app/Language/es/PapelGenerico.php | 3 + ci4/app/Language/es/PapelImpresion.php | 117 ++++++ .../Configuracion/PapelGenericoModel.php | 29 +- .../Configuracion/PapelImpresionModel.php | 231 +++++++++++ .../_commonPartialsBs/_confirm2delete.php | 22 ++ .../_form_validation_errors.php | 16 + .../themes/_commonPartialsBs/datatables.php | 9 +- .../themes/_commonPartialsBs/select2bs5.php | 22 +- .../themes/_commonPartialsBs/sweetalert.php | 50 ++- .../papel/_papelImpresionFormItems.php | 165 ++++++++ .../papel/viewPapelGenericoForm.php | 160 +++++++- .../papel/viewPapelGenericoList.php | 11 +- .../papel/viewPapelImpresionForm.php | 63 +++ .../papel/viewPapelImpresionList.php | 183 +++++++++ .../Views/themes/backend/vuexy/main/menu.php | 11 +- from mac to app.txt | 22 +- 29 files changed, 1902 insertions(+), 381 deletions(-) create mode 100644 ci4/app/Controllers/Configuracion/Papelesimpresion.php delete mode 100644 ci4/app/Controllers/WorstCase_LT6015.asc create mode 100644 ci4/app/Entities/Configuracion/PapelImpresion.php create mode 100644 ci4/app/Language/en/PapelImpresion.php create mode 100644 ci4/app/Language/es/PapelImpresion.php create mode 100644 ci4/app/Models/Configuracion/PapelImpresionModel.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 4826679c..a4a08d87 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -11,6 +11,27 @@ if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { require SYSTEMPATH . 'Config/Routes.php'; } + +//WEB ROUTER ------------------------------------------------------ +//------------------------------------------------------------------ +$routes->get('/', 'Home::index'); +$routes->get('lang/{locale}', 'Language::index'); + +//API ROUTER ------------------------------------------------------ +//------------------------------------------------------------------ +$routes->get('api/', 'Api::index'); +$routes->get('api/status', 'Api::status'); +$routes->post('api/signIn', 'Api::signIn'); + +//API ROUTER USER ------------------------------------------------------ +//------------------------------------------------------------------ +$routes->get('api/user/', 'Api::user/all'); +$routes->get('api/user/(:segment)', 'Api::user/id/$1'); +$routes->post('api/user/', 'Api::user/add'); +$routes->put('api/user/(:segment)', 'Api::user/edit/$1'); +$routes->delete('api/user/(:segment)', 'Api::user/delete/$1'); + + /* * -------------------------------------------------------------------- * Router Setup @@ -32,144 +53,141 @@ $routes->setAutoRoute(true); // We get a performance increase by specifying the default // route since we don't have to scan directories. -$routes->group('', [], function($routes) { - - $routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'Paises::index', ['as' => 'paisList']); - $routes->get('index', 'Paises::index', ['as' => 'paisIndex']); - $routes->get('add', 'Paises::add', ['as' => 'newPais']); - $routes->post('add', 'Paises::add', ['as' => 'createPais']); - $routes->get('edit/(:num)', 'Paises::edit/$1', ['as' => 'editPais']); - $routes->post('edit/(:num)', 'Paises::edit/$1', ['as' => 'updatePais']); - $routes->get('delete/(:num)', 'Paises::delete/$1', ['as' => 'deletePais']); - $routes->post('allmenuitems', 'Paises::allItemsSelect', ['as' => 'select2ItemsOfPaises']); - $routes->post('menuitems', 'Paises::menuItems', ['as' => 'menuItemsOfPaises']); - }); - - $routes->group('tarifaacabado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { - $routes->get('', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList']); - $routes->get('index', 'Tarifaacabado::index', ['as' => 'tarifaacabadoIndex']); - $routes->get('list', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList2']); - $routes->get('add', 'Tarifaacabado::add', ['as' => 'newTarifaacabado']); - $routes->post('add', 'Tarifaacabado::add', ['as' => 'createTarifaacabado']); - $routes->get('edit/(:num)', 'Tarifaacabado::edit/$1', ['as' => 'editTarifaacabado']); - $routes->post('edit/(:num)', 'Tarifaacabado::edit/$1', ['as' => 'updateTarifaacabado']); - $routes->get('delete/(:num)', 'Tarifaacabado::delete/$1', ['as' => 'deleteTarifaacabado']); - $routes->post('allmenuitems', 'Tarifaacabado::allItemsSelect', ['as' => 'select2ItemsOfTarifasacabado']); - $routes->post('menuitems', 'Tarifaacabado::menuItems', ['as' => 'menuItemsOfTarifasacabado']); - }); - $routes->group('users', ['namespace' => 'App\Controllers\Usuarios'], function ($routes) { - $routes->get('', 'Users::index', ['as' => 'userList']); - $routes->get('index', 'Users::index', ['as' => 'userIndex']); - $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->group('group', ['namespace' => 'App\Controllers\Usuarios'], function ($routes) { - $routes->get('', 'Group::index', ['as' => 'userGroupList']); - $routes->get('index', 'Group::index', ['as' => 'groupIndex']); - $routes->post('edit/(:num)', 'Group::edit/$1', ['as' => 'updateGroup']); - $routes->get('edit/(:num)', 'Group::edit/$1', ['as' => 'editGroup']); - $routes->get('delete/(:num)', 'Group::delete/$1', ['as' => 'deleteGroup']); - $routes->get('add', 'Group::add', ['as' => 'newGroup']); - $routes->post('add', 'Group::add', ['as' => 'createGroup']); - }); +$routes->group('paises', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Paises::index', ['as' => 'paisList']); + $routes->get('index', 'Paises::index', ['as' => 'paisIndex']); + $routes->get('add', 'Paises::add', ['as' => 'newPais']); + $routes->post('add', 'Paises::add', ['as' => 'createPais']); + $routes->get('edit/(:num)', 'Paises::edit/$1', ['as' => 'editPais']); + $routes->post('edit/(:num)', 'Paises::edit/$1', ['as' => 'updatePais']); + $routes->get('delete/(:num)', 'Paises::delete/$1', ['as' => 'deletePais']); + $routes->post('allmenuitems', 'Paises::allItemsSelect', ['as' => 'select2ItemsOfPaises']); + $routes->post('menuitems', 'Paises::menuItems', ['as' => 'menuItemsOfPaises']); +}); - $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->group('tarifamanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { - $routes->get('', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList']); - $routes->get('index', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoIndex']); - $routes->get('list', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList2']); - $routes->get('add', 'Tarifamanipulado::add', ['as' => 'newTarifamanipulado']); - $routes->post('add', 'Tarifamanipulado::add', ['as' => 'createTarifamanipulado']); - $routes->get('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'editTarifamanipulado']); - $routes->post('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'updateTarifamanipulado']); - $routes->get('delete/(:num)', 'Tarifamanipulado::delete/$1', ['as' => 'deleteTarifamanipulado']); - $routes->post('allmenuitems', 'Tarifamanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasmanipulado']); - $routes->post('menuitems', 'Tarifamanipulado::menuItems', ['as' => 'menuItemsOfTarifasmanipulado']); - }); - - - $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('tarifaacabado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + $routes->get('', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList']); + $routes->get('index', 'Tarifaacabado::index', ['as' => 'tarifaacabadoIndex']); + $routes->get('list', 'Tarifaacabado::index', ['as' => 'tarifaacabadoList2']); + $routes->get('add', 'Tarifaacabado::add', ['as' => 'newTarifaacabado']); + $routes->post('add', 'Tarifaacabado::add', ['as' => 'createTarifaacabado']); + $routes->get('edit/(:num)', 'Tarifaacabado::edit/$1', ['as' => 'editTarifaacabado']); + $routes->post('edit/(:num)', 'Tarifaacabado::edit/$1', ['as' => 'updateTarifaacabado']); + $routes->get('delete/(:num)', 'Tarifaacabado::delete/$1', ['as' => 'deleteTarifaacabado']); + $routes->post('allmenuitems', 'Tarifaacabado::allItemsSelect', ['as' => 'select2ItemsOfTarifasacabado']); + $routes->post('menuitems', 'Tarifaacabado::menuItems', ['as' => 'menuItemsOfTarifasacabado']); +}); + +$routes->group('users', ['namespace' => 'App\Controllers\Usuarios'], function ($routes) { + $routes->get('', 'Users::index', ['as' => 'userList']); + $routes->get('index', 'Users::index', ['as' => 'userIndex']); + $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->group('group', ['namespace' => 'App\Controllers\Usuarios'], function ($routes) { + $routes->get('', 'Group::index', ['as' => 'userGroupList']); + $routes->get('index', 'Group::index', ['as' => 'groupIndex']); + $routes->post('edit/(:num)', 'Group::edit/$1', ['as' => 'updateGroup']); + $routes->get('edit/(:num)', 'Group::edit/$1', ['as' => 'editGroup']); + $routes->get('delete/(:num)', 'Group::delete/$1', ['as' => 'deleteGroup']); + $routes->get('add', 'Group::add', ['as' => 'newGroup']); + $routes->post('add', 'Group::add', ['as' => 'createGroup']); +}); + +$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->group('tarifamanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + $routes->get('', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList']); + $routes->get('index', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoIndex']); + $routes->get('list', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList2']); + $routes->get('add', 'Tarifamanipulado::add', ['as' => 'newTarifamanipulado']); + $routes->post('add', 'Tarifamanipulado::add', ['as' => 'createTarifamanipulado']); + $routes->get('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'editTarifamanipulado']); + $routes->post('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'updateTarifamanipulado']); + $routes->get('delete/(:num)', 'Tarifamanipulado::delete/$1', ['as' => 'deleteTarifamanipulado']); + $routes->post('allmenuitems', 'Tarifamanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasmanipulado']); + $routes->post('menuitems', 'Tarifamanipulado::menuItems', ['as' => 'menuItemsOfTarifasmanipulado']); +}); + + +$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->post('add', 'Imposiciones::add', ['as' => 'createImposicion']); + $routes->post('create', 'Imposiciones::create', ['as' => 'ajaxCreateImposicion']); + $routes->put('(:num)/update', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']); + $routes->post('(:num)/edit', 'Imposiciones::edit/$1', ['as' => 'updateImposicion']); + $routes->post('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']); + $routes->post('allmenuitems', 'Imposiciones::allItemsSelect', ['as' => 'select2ItemsOfImposiciones']); + $routes->post('menuitems', 'Imposiciones::menuItems', ['as' => 'menuItemsOfImposiciones']); +}); +$routes->resource('imposiciones', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Imposiciones', 'except' => 'show,new,create,update']); + +$routes->group('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Papelesgenericos::index', ['as' => 'papelGenericoList']); + $routes->delete('', 'Papelesgenericos::index', ['as' => 'papelGenericoList2']); + $routes->get('add', 'Papelesgenericos::add', ['as' => 'newPapelGenerico']); + $routes->post('add', 'Papelesgenericos::add', ['as' => 'createPapelGenerico']); + $routes->post('create', 'Papelesgenericos::create', ['as' => 'ajaxCreatePapelGenerico']); + $routes->put('(:num)/update', 'Papelesgenericos::update/$1', ['as' => 'ajaxUpdatePapelGenerico']); + $routes->post('edit/(:num)', 'Papelesgenericos::edit/$1', ['as' => 'updatePapelGenerico']); + $routes->post('datatable', 'Papelesgenericos::datatable', ['as' => 'dataTableOfPapelesGenericos']); + $routes->post('allmenuitems', 'Papelesgenericos::allItemsSelect', ['as' => 'select2ItemsOfPapelesGenericos']); + $routes->post('menuitems', 'Papelesgenericos::menuItems', ['as' => 'menuItemsOfPapelesGenericos']); +}); +$routes->resource('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesgenericos', 'except' => 'show,new,create,update']); + +$routes->group('papelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'Papelesimpresion::index', ['as' => 'papelImpresionList']); + $routes->get('add', 'Papelesimpresion::add', ['as' => 'newPapelImpresion']); + $routes->post('add', 'Papelesimpresion::add', ['as' => 'createPapelImpresion']); + $routes->post('create', 'Papelesimpresion::create', ['as' => 'ajaxCreatePapelImpresion']); + $routes->put('(:num)/update', 'Papelesimpresion::update/$1', ['as' => 'ajaxUpdatePapelImpresion']); + $routes->post('edit/(:num)', 'Papelesimpresion::edit/$1', ['as' => 'updatePapelImpresion']); + $routes->post('datatable', 'Papelesimpresion::datatable', ['as' => 'dataTableOfPapelesImpresion']); + $routes->post('datatablePG', 'Papelesimpresion::datatablePG', ['as' => 'dataTableOfPapelesImpresionPG']); + $routes->post('allmenuitems', 'Papelesimpresion::allItemsSelect', ['as' => 'select2ItemsOfPapelesImpresion']); + $routes->post('menuitems', 'Papelesimpresion::menuItems', ['as' => 'menuItemsOfPapelesImpresion']); +}); +$routes->resource('papelesimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesimpresion', 'except' => 'show,new,create,update']); - $routes->group('imposiciones', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'Imposiciones::index', ['as' => 'imposicionList']); - $routes->get('add', 'Imposiciones::add', ['as' => 'newImposicion']); - $routes->post('add', 'Imposiciones::add', ['as' => 'createImposicion']); - $routes->post('create', 'Imposiciones::create', ['as' => 'ajaxCreateImposicion']); - $routes->put('(:num)/update', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']); - $routes->post('(:num)/edit', 'Imposiciones::edit/$1', ['as' => 'updateImposicion']); - $routes->post('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']); - $routes->post('allmenuitems', 'Imposiciones::allItemsSelect', ['as' => 'select2ItemsOfImposiciones']); - $routes->post('menuitems', 'Imposiciones::menuItems', ['as' => 'menuItemsOfImposiciones']); - }); - $routes->resource('imposiciones', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Imposiciones', 'except' => 'show,new,create,update']); - - $routes->group('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'Papelesgenericos::index', ['as' => 'papelGenericoList']); - $routes->get('add', 'Papelesgenericos::add', ['as' => 'newPapelGenerico']); - $routes->post('add', 'Papelesgenericos::add', ['as' => 'createPapelGenerico']); - $routes->post('create', 'Papelesgenericos::create', ['as' => 'ajaxCreatePapelGenerico']); - $routes->put('(:num)/update', 'Papelesgenericos::update/$1', ['as' => 'ajaxUpdatePapelGenerico']); - $routes->post('(:num)/edit', 'Papelesgenericos::edit/$1', ['as' => 'updatePapelGenerico']); - $routes->post('datatable', 'Papelesgenericos::datatable', ['as' => 'dataTableOfPapelesGenericos']); - $routes->post('allmenuitems', 'Papelesgenericos::allItemsSelect', ['as' => 'select2ItemsOfPapelesGenericos']); - $routes->post('menuitems', 'Papelesgenericos::menuItems', ['as' => 'menuItemsOfPapelesGenericos']); - }); - $routes->resource('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesgenericos', 'except' => 'show,new,create,update']); - - }); - -//WEB ROUTER ------------------------------------------------------ -//------------------------------------------------------------------ -$routes->get('/', 'Home::index'); -$routes->get('lang/{locale}', 'Language::index'); -//API ROUTER ------------------------------------------------------ -//------------------------------------------------------------------ -$routes->get('api/','Api::index'); -$routes->get('api/status','Api::status'); -$routes->post('api/signIn','Api::signIn'); -//API ROUTER USER ------------------------------------------------------ -//------------------------------------------------------------------ -$routes->get('api/user/','Api::user/all'); -$routes->get('api/user/(:segment)','Api::user/id/$1'); -$routes->post('api/user/','Api::user/add'); -$routes->put('api/user/(:segment)','Api::user/edit/$1'); -$routes->delete('api/user/(:segment)','Api::user/delete/$1'); /* @@ -188,5 +206,3 @@ $routes->delete('api/user/(:segment)','Api::user/delete/$1'); if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; } - - diff --git a/ci4/app/Controllers/Configuracion/PapelesGenericos.php b/ci4/app/Controllers/Configuracion/PapelesGenericos.php index fd6067af..52678da8 100644 --- a/ci4/app/Controllers/Configuracion/PapelesGenericos.php +++ b/ci4/app/Controllers/Configuracion/PapelesGenericos.php @@ -1,4 +1,6 @@ -viewData['pageTitle'] = lang('PapelGenerico.moduleTitle'); $this->viewData['usingSweetAlert'] = true; + + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('PapelGenerico.papelGenerico')]), - 'papelGenerico' => new PapelGenerico(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('PapelGenerico.papelGenerico')]), + 'papelGenerico' => new PapelGenerico(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewPapelGenericoList', $viewData); + return view(static::$viewPath . 'viewPapelGenericoList', $viewData); } - public function add() { - - + public function add() + { + + $requestMethod = $this->request->getMethod(); @@ -61,43 +73,43 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController { $nullIfEmpty = true; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - endif; - - $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else : + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission endif; if ($noException && $successfulResult) : $id = $this->model->db->insertID(); - $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.'; - $message .= anchor( "papeles-genericos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]) . '.'; + $message .= anchor("papelesgenericos/{$id}/edit", lang('Basic.global.continueEditing') . '?'); $message = ucfirst(str_replace("'", "\'", $message)); if ($thenRedirect) : if (!empty($this->indexRoute)) : return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else: + else : return $this->redirect2listView('sweet-success', $message); endif; - else: + else : $this->session->setFlashData('sweet-success', $message); endif; @@ -109,14 +121,14 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = route_to('createPapelGenerico'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('PapelGenerico.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('PapelGenerico.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); return $this->displayForm(__METHOD__); } // end function add() - public function edit($requestedId = null) { - + public function edit($requestedId = null) + { + if ($requestedId == null) : return $this->redirect2listView(); endif; @@ -133,84 +145,84 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); -if ($this->request->getPost('show_in_client') == null ) { - $sanitizedData['show_in_client'] = false; - } + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('show_in_client') == null) { + $sanitizedData['show_in_client'] = false; + } + - $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - - if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $papelGenerico->fill($sanitizedData); - $thenRedirect = true; + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else : + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $papelGenerico->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $papelGenerico->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.'; - $message .= anchor( "papeles-genericos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]) . '.'; + $message .= anchor("papelesgenericos/{$id}/edit", lang('Basic.global.continueEditing') . '?'); $message = ucfirst(str_replace("'", "\'", $message)); if ($thenRedirect) : if (!empty($this->indexRoute)) : return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else: + else : return $this->redirect2listView('sweet-success', $message); endif; - else: + else : $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['papelGenerico'] = $papelGenerico; - $this->viewData['formAction'] = route_to('updatePapelGenerico', $id); + $this->viewData['formAction'] = route_to('updatePapelGenerico', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('PapelGenerico.moduleTitle').' '.lang('Basic.global.edit3'); - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelGenerico.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + $this->viewData['usingServerSideDataTable'] = true; return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - public function datatable() { + + public function datatable() + { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + if (!isset($reqData['draw']) || !isset($reqData['columns'])) { $errstr = 'No data available in response to this specific request.'; - $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); return $response; } - var_dump($reqData); - dd(); $start = $reqData['start'] ?? 0; $length = $reqData['length'] ?? 5; $search = $reqData['search']['value']; - $requestedOrder = $reqData['order']['0']['column'] ?? 0; - $order = PapelGenericoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0]; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = PapelGenericoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; $dir = $reqData['order']['0']['dir'] ?? 'asc'; $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); @@ -225,15 +237,16 @@ if ($this->request->getPost('show_in_client') == null ) { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->nombre = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->nombre = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -247,7 +260,8 @@ if ($this->request->getPost('show_in_client') == null ) { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -258,8 +272,8 @@ if ($this->request->getPost('show_in_client') == null ) { $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->text = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -272,5 +286,4 @@ if ($this->request->getPost('show_in_client') == null ) { return $this->failUnauthorized('Invalid request', 403); } } - } diff --git a/ci4/app/Controllers/Configuracion/Papelesimpresion.php b/ci4/app/Controllers/Configuracion/Papelesimpresion.php new file mode 100644 index 00000000..02e7e920 --- /dev/null +++ b/ci4/app/Controllers/Configuracion/Papelesimpresion.php @@ -0,0 +1,372 @@ +viewData['pageTitle'] = lang('PapelImpresion.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + parent::initController($request, $response, $logger); + } + + + public function index() + { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('PapelImpresion.papelImpresion')]), + 'papelImpresion' => new PapelImpresion(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath . 'viewPapelImpresionList', $viewData); + } + + + public function add() + { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else : + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]) . '.'; + $message .= anchor("papelesimpresion/{$id}/edit", lang('Basic.global.continueEditing') . '?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else : + return $this->redirect2listView('sweet-success', $message); + endif; + else : + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['papelImpresion'] = isset($sanitizedData) ? new PapelImpresion($sanitizedData) : new PapelImpresion(); + $this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($papelImpresion->papel_generico_id ?? null); + + $this->viewData['formAction'] = route_to('createPapelImpresion'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('PapelImpresion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) + { + // JJO + $session = session(); + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $papelImpresion = $this->model->find($id); + + if ($papelImpresion == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelImpresion.papelImpresion')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_update_id'] = $session->id_user; + + + + if ($this->request->getPost('defecto') == null) { + $sanitizedData['defecto'] = false; + } + if ($this->request->getPost('bn') == null) { + $sanitizedData['bn'] = false; + } + if ($this->request->getPost('color') == null) { + $sanitizedData['color'] = false; + } + if ($this->request->getPost('portada') == null) { + $sanitizedData['portada'] = false; + } + if ($this->request->getPost('cubierta') == null) { + $sanitizedData['cubierta'] = false; + } + if ($this->request->getPost('rotativa') == null) { + $sanitizedData['rotativa'] = false; + } + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else : + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $papelImpresion->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $papelImpresion->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]) . '.'; + $message .= anchor("papelesimpresion/{$id}/edit", lang('Basic.global.continueEditing') . '?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else : + return $this->redirect2listView('sweet-success', $message); + endif; + else : + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['papelImpresion'] = $papelImpresion; + $this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($papelImpresion->papel_generico_id ?? null); + + $this->viewData['formAction'] = route_to('updatePapelImpresion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelImpresion.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + + public function datatable() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns'])) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); + return $response; + } + $id_PG = $reqData['id_PG'] ?? -1; + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + if($id_PG<0){ + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + }else{ + $resourceData = $this->model->getResource($search, $id_PG)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource("", $id_PG)->countAllResults(), + $this->model->getResource($search, $id_PG)->countAllResults() + )); + } + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatablePG() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns'])) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); + return $response; + } + $generico_id = $reqData['id'] ?? null; + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = PapelImpresionModel::SORTABLE2[$requestedOrder >= 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search, $generico_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource("", $generico_id)->countAllResults(), + $this->model->getResource($search, $generico_id)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() + { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() + { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getPapelGenericoListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('PapelGenerico.papelGenerico'))])]; + if (!empty($selId)) : + $papelGenericoModel = model('App\Models\Configuracion\PapelGenericoModel'); + + $selOption = $papelGenericoModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } +} diff --git a/ci4/app/Controllers/GoBaseResourceController.php b/ci4/app/Controllers/GoBaseResourceController.php index 59d632f0..363b173a 100644 --- a/ci4/app/Controllers/GoBaseResourceController.php +++ b/ci4/app/Controllers/GoBaseResourceController.php @@ -50,6 +50,25 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon */ protected static $viewPath; + + /** + * JJO: Variable para indicar si el controlador hace soft_delete o no + * + * @var bool + */ + public $soft_delete = false; + /** + * JJO: Variable quién puede ver los registros borrados + * + * 0 -> Not Deleted + * 1 -> Soft Deleted, shows up in lists of deleted items for management users + * 2 -> Soft Deleted, does not show up for any user except admin users + * 3 -> Only shows up for developers. + * @var int + */ + public $delete_flag = 0; + + /** * An array of helpers to be loaded automatically upon * class instantiation. These helpers will be available @@ -197,8 +216,22 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon $objName = lang('Basic.global.record'); } - if (!$this->model->delete($id)) { - return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + if (!$this->soft_delete){ + + if (!$this->model->delete($id)) { + return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + } + } + else{ + $datetime = (new \CodeIgniter\I18n\Time("now")); + $rawResult = $this->model->where('id',$id) + ->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'), + 'is_deleted' => $this->delete_flag]) + ->update(); + if (!$rawResult) { + return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + } + } $message = lang('Basic.global.deleteSuccess', [$objName]); diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 695ff358..2e1d27b4 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -2,7 +2,7 @@ namespace App\Controllers; -use App\Controllers\Configuracion\PapelGenerico; +use App\Controllers\Configuracion\Papelesimpresion; class Test extends BaseController { @@ -15,8 +15,8 @@ class Test extends BaseController public function index() { - $papel = new PapelGenerico(); - var_dump($papel->datatable()); + $papel = new Papelesimpresion(); + var_dump($papel->datatablePG()); } } \ No newline at end of file diff --git a/ci4/app/Controllers/WorstCase_LT6015.asc b/ci4/app/Controllers/WorstCase_LT6015.asc deleted file mode 100644 index ab24f1e7..00000000 --- a/ci4/app/Controllers/WorstCase_LT6015.asc +++ /dev/null @@ -1,95 +0,0 @@ -Version 4 -SHEET 1 2680 680 -WIRE -496 -752 -608 -752 -WIRE -608 -736 -608 -752 -WIRE -496 -736 -496 -752 -WIRE -608 -640 -608 -656 -WIRE -176 -624 -352 -624 -WIRE 0 -624 -96 -624 -WIRE 176 -624 0 -624 -WIRE 352 -624 256 -624 -WIRE -496 -592 -496 -656 -WIRE -432 -592 -496 -592 -WIRE -496 -576 -496 -592 -WIRE 48 -560 48 -576 -WIRE 0 -544 0 -624 -WIRE 16 -544 0 -544 -WIRE 352 -528 352 -624 -WIRE 352 -528 80 -528 -WIRE 368 -528 352 -528 -WIRE 16 -512 0 -512 -WIRE -496 -480 -496 -496 -WIRE -432 -480 -352 -624 -WIRE -432 -480 -496 -480 -WIRE 48 -480 48 -496 -WIRE -608 -464 -608 -480 -WIRE -496 -464 -496 -480 -WIRE -352 -448 -432 -592 -WIRE -336 -448 -352 -448 -WIRE -176 -448 -256 -448 -WIRE 0 -448 0 -512 -WIRE 0 -448 -96 -448 -WIRE 0 -432 0 -448 -WIRE 0 -336 0 -352 -FLAG 0 -336 0 -FLAG 368 -528 Out -FLAG -608 -464 0 -FLAG -608 -640 0 -FLAG -608 -752 Vcc -FLAG -608 -560 Vee -FLAG 48 -576 Vcc -FLAG 48 -480 Vee -FLAG -496 -464 0 -SYMBOL res -192 -432 R270 -WINDOW 0 32 56 VTop 2 -WINDOW 3 0 56 VBottom 2 -SYMATTR InstName R1 -SYMATTR Value {wc(22.5k,tola,1)} -SYMBOL res -16 -448 R0 -SYMATTR InstName R4 -SYMATTR Value {wc(22.5k,tolb,0)} -SYMBOL res 272 -640 R90 -WINDOW 0 0 56 VBottom 2 -WINDOW 3 32 56 VTop 2 -SYMATTR InstName R3 -SYMATTR Value {wc(22.5k,tolb,3)} -SYMBOL res -192 -608 R270 -WINDOW 0 32 56 VTop 2 -WINDOW 3 0 56 VBottom 2 -SYMATTR InstName R2 -SYMATTR Value {wc(22.5k,tola,2)} -SYMBOL Opamps\\LT6015 48 -528 R0 -SYMATTR InstName U2 -SYMBOL voltage -608 -752 R0 -WINDOW 123 0 0 Left 2 -WINDOW 39 0 0 Left 2 -SYMATTR InstName V1 -SYMATTR Value 15 -SYMBOL voltage -608 -576 R0 -WINDOW 123 0 0 Left 2 -WINDOW 39 0 0 Left 2 -SYMATTR InstName V2 -SYMATTR Value -15 -SYMBOL current -496 -736 R0 -SYMATTR InstName I1 -SYMATTR Value PWL(.1m 0 .2m .25) -SYMBOL res -512 -592 R0 -SYMATTR InstName R5 -SYMATTR Value 1 -SYMBOL res -240 -464 R90 -WINDOW 0 0 56 VBottom 2 -WINDOW 3 32 56 VTop 2 -SYMATTR InstName R6 -SYMATTR Value 1 -TEXT -616 -200 Left 2 !.param tola=.01 -TEXT -616 -168 Left 2 !.param tolb=.05 -TEXT 328 -352 Left 2 !.tran .5m -TEXT -96 -168 Left 2 !.step param run 0 16 1 -TEXT -616 -280 Left 2 !.func binary(run,index) floor(run/(2**index))-2*floor(run/(2**(index+1))) -TEXT -616 -240 Left 2 !.func wc(nom,tol,index) if(run==numruns,nom,if(binary(run,index),nom*(1+tol),nom*(1-tol))) -TEXT -96 -200 Left 2 !.param numruns=16 -TEXT 80 -408 Left 2 ;5% Resistor -TEXT 208 -672 Bottom 2 ;5% Resistor -TEXT -136 -672 Bottom 2 ;1% Resistor -TEXT -136 -496 Bottom 2 ;1% Resistor -TEXT 416 -528 Left 2 ;±1mV/mA diff --git a/ci4/app/Entities/Configuracion/PapelImpresion.php b/ci4/app/Entities/Configuracion/PapelImpresion.php new file mode 100644 index 00000000..a68402f0 --- /dev/null +++ b/ci4/app/Entities/Configuracion/PapelImpresion.php @@ -0,0 +1,50 @@ + null, + "papel_generico_id" => null, + "nombre" => null, + "defecto" => false, + "referencia" => null, + "ancho" => null, + "alto" => null, + "mano" => null, + "espesor" => 0.0, + "gramaje" => null, + "precio_tonelada" => null, + "margen" => null, + "peso_por_pliego" => null, + "precio_pliego" => null, + "bn" => true, + "color" => true, + "portada" => false, + "cubierta" => false, + "rotativa" => false, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "papel_generico_id" => "int", + "defecto" => "boolean", + "ancho" => "float", + "alto" => "float", + "mano" => "float", + "espesor" => "float", + "gramaje" => "float", + "precio_tonelada" => "float", + "peso_por_pliego" => "float", + "precio_pliego" => "float", + "bn" => "boolean", + "color" => "boolean", + "portada" => "boolean", + "cubierta" => "boolean", + "rotativa" => "boolean", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index dea70867..4069d72a 100644 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -177,6 +177,7 @@ class LoginAuthFilter implements FilterInterface 'allItemsSelect', 'menuItems', 'datatable', + 'datatablePG', 'collect', 'cast', ]; diff --git a/ci4/app/Helpers/go_common_helper.php b/ci4/app/Helpers/go_common_helper.php index e64429cf..624017df 100644 --- a/ci4/app/Helpers/go_common_helper.php +++ b/ci4/app/Helpers/go_common_helper.php @@ -140,6 +140,21 @@ if (!function_exists('convertToSnakeCase')) { } } +if (!function_exists('convertToCamelCase')) { + function convertToCamelCase($string, $capitalizeFirstCharacter = false) + { + $str = str_replace('-', '', ucwords($string, '-')); + + if (!$capitalizeFirstCharacter) { + $str = lcfirst($str); + } + + $str = str_replace(' ', '', $str); + + return $str; + } +} + if (!function_exists('newUUID')) { function newUUID() { diff --git a/ci4/app/Language/en/App.php b/ci4/app/Language/en/App.php index f4d04f96..7a1ea299 100644 --- a/ci4/app/Language/en/App.php +++ b/ci4/app/Language/en/App.php @@ -682,6 +682,7 @@ return [ "menu_imposiciones" => "Impositions", "menu_maquina" => "Machines", "menu_papelgenerico" => "Generic paper", + "menu_papelimpresion" => "Printing paper", "menu_seriefactura" => "Billing series", "menu_serviciocliente" => "Customer service", "menu_tamanioformatos" => "Format size", diff --git a/ci4/app/Language/en/PapelGenerico.php b/ci4/app/Language/en/PapelGenerico.php index 71115235..1570fdba 100644 --- a/ci4/app/Language/en/PapelGenerico.php +++ b/ci4/app/Language/en/PapelGenerico.php @@ -17,6 +17,9 @@ return [ 'papelesGenericos' => 'Generic Paper', 'showInClient' => 'Show in Client', 'updatedAt' => 'Updated At', + + 'Form_acordion_title' => 'Print papers associated', + 'validation' => [ 'code' => [ 'max_length' => 'The {field} field cannot exceed {param} characters in length.', diff --git a/ci4/app/Language/en/PapelImpresion.php b/ci4/app/Language/en/PapelImpresion.php new file mode 100644 index 00000000..baf1a64f --- /dev/null +++ b/ci4/app/Language/en/PapelImpresion.php @@ -0,0 +1,117 @@ + 'Height', + 'ancho' => 'Width', + 'bn' => 'B/N', + 'color' => 'Colour', + 'createdAt' => 'Created At', + 'cubierta' => 'Cover', + 'defecto' => 'Default', + 'deletedAt' => 'Deleted At', + 'espesor' => 'Thickness', + 'gramaje' => 'Grammage', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'mano' => 'Hand', + 'margen' => 'Margin', + 'moduleTitle' => 'Print papers', + 'nombre' => 'Name', + 'papelGenericoId' => 'Generic paper', + 'papelImpresion' => 'Print paper', + 'papelImpresionList' => 'Print Paper List', + 'papelesImpresion' => 'Print papers', + 'papelesimpresion' => 'Print papers', + 'pesoPorPliego' => 'Weight per sheet', + 'portada' => 'Cover', + 'precioPliego' => 'Sheet price', + 'precioTonelada' => 'Ton price', + 'referencia' => 'Reference', + 'rotativa' => 'Rotary', + 'updatedAt' => 'Updated At', + 'userUpdateId' => 'User Update ID', + 'validation' => [ + 'espesor_update' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'alto' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'ancho' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'espesor' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'gramaje' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'mano' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'margen' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'papel_generico_id' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'The {field} field is required.', + + ], + + 'peso_por_pliego' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_pliego' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'precio_tonelada' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'required' => 'The {field} field is required.', + + ], + + 'referencia' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 215e6bbf..0da4d429 100644 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -682,6 +682,7 @@ return [ "menu_imposiciones" => "Imposiciones", "menu_maquina" => "Maquinas", "menu_papelgenerico" => "Papel generico", + "menu_papelimpresion" => "Papel impresión", "menu_seriefactura" => "Series facturas", "menu_serviciocliente" => "Servicio cliente", "menu_tamanioformatos" => "Tamaño formatos", diff --git a/ci4/app/Language/es/PapelGenerico.php b/ci4/app/Language/es/PapelGenerico.php index ea621d2a..785f5d5d 100644 --- a/ci4/app/Language/es/PapelGenerico.php +++ b/ci4/app/Language/es/PapelGenerico.php @@ -17,6 +17,9 @@ return [ 'papelesGenericos' => 'Papeles Genéricos', 'showInClient' => 'Mostrar en cliente', 'updatedAt' => 'Updated At', + + 'Form_acordion_title' => 'Papeles impresion asociados', + 'validation' => [ 'code' => [ 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', diff --git a/ci4/app/Language/es/PapelImpresion.php b/ci4/app/Language/es/PapelImpresion.php new file mode 100644 index 00000000..de4fc726 --- /dev/null +++ b/ci4/app/Language/es/PapelImpresion.php @@ -0,0 +1,117 @@ + 'Alto', + 'ancho' => 'Ancho', + 'bn' => 'B/N', + 'color' => 'Color', + 'createdAt' => 'Creado en', + 'cubierta' => 'Cubierta', + 'defecto' => 'Por defecto', + 'deletedAt' => 'Borrado en', + 'espesor' => 'Espesor', + 'gramaje' => 'Gramaje', + 'id' => 'ID', + 'isDeleted' => 'Borrado', + 'mano' => 'Mano', + 'margen' => 'Margen', + 'moduleTitle' => 'Papeles Impresion', + 'nombre' => 'Nombre', + 'papelGenericoId' => 'Papel Generico', + 'papelImpresion' => 'Papel Impresion', + 'papelImpresionList' => 'Lista Papel Impresion', + 'papelesImpresion' => 'Papeles Impresion', + 'papelesimpresion' => 'Papeles Impresion', + 'pesoPorPliego' => 'Peso Por Pliego', + 'portada' => 'Portada', + 'precioPliego' => 'Precio Pliego', + 'precioTonelada' => 'Precio Tonelada', + 'referencia' => 'Referencia', + 'rotativa' => 'Rotativa', + 'updatedAt' => 'Actualizado en', + 'userUpdateId' => 'ID usuario actualización', + 'validation' => [ + 'espesor_update' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'alto' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'ancho' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'espesor' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'gramaje' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'mano' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'margen' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'papel_generico_id' => [ + 'integer' => 'The {field} field must contain an integer.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'peso_por_pliego' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_pliego' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'precio_tonelada' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'referencia' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 0dd7bbf0..88a2e6a7 100644 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -13,14 +13,14 @@ class PapelGenericoModel extends \App\Models\GoBaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.id", - 1 => "t1.nombre", - 2 => "t1.code", - 3 => "t1.code_ot", - 4 => "t1.show_in_client", + //0 => "t1.id", + 0 => "t1.nombre", + 1 => "t1.code", + 2 => "t1.code_ot", + 3 => "t1.show_in_client", ]; - protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client"]; + protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client","deleted_at","is_deleted"]; protected $returnType = "App\Entities\Configuracion\PapelGenerico"; protected $useTimestamps = true; @@ -34,29 +34,29 @@ class PapelGenericoModel extends \App\Models\GoBaseModel protected $validationRules = [ "code" => [ - "label" => "PapelGenerico.code", + "label" => "PapelGenericoes.code", "rules" => "trim|max_length[5]", ], "code_ot" => [ - "label" => "PapelGenerico.codeOt", + "label" => "PapelGenericoes.codeOt", "rules" => "trim|max_length[5]", ], "nombre" => [ - "label" => "PapelGenerico.nombre", + "label" => "PapelGenericoes.nombre", "rules" => "trim|required|max_length[255]", ], ]; protected $validationMessages = [ "code" => [ - "max_length" => "PapelGenerico.validation.code.max_length", + "max_length" => "PapelGenericoes.validation.code.max_length", ], "code_ot" => [ - "max_length" => "PapelGenerico.validation.code_ot.max_length", + "max_length" => "PapelGenericoes.validation.code_ot.max_length", ], "nombre" => [ - "max_length" => "PapelGenerico.validation.nombre.max_length", - "required" => "PapelGenerico.validation.nombre.required", + "max_length" => "PapelGenericoes.validation.nombre.max_length", + "required" => "PapelGenericoes.validation.nombre.required", ], ]; @@ -73,7 +73,8 @@ class PapelGenericoModel extends \App\Models\GoBaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code_ot AS code_ot, t1.show_in_client AS show_in_client" - ); + ) + ->where("is_deleted", 0); return empty($search) ? $builder diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php new file mode 100644 index 00000000..377ea3b4 --- /dev/null +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -0,0 +1,231 @@ + "t1.nombre", + 1 => "t1.papel_generico_id", + 2 => "t1.gramaje", + 3 => "t2.nombre", + + /*1 => "t1.id", + 2 => "t1.papel_generico_id", + 3 => "t1.nombre", + 4 => "t1.defecto", + 5 => "t1.referencia", + 6 => "t1.ancho", + 7 => "t1.alto", + 8 => "t1.mano", + 9 => "t1.espesor", + 10 => "t1.gramaje", + 11 => "t1.precio_tonelada", + 12 => "t1.margen", + 13 => "t1.peso_por_pliego", + 14 => "t1.precio_pliego", + 15 => "t1.bn", + 16 => "t1.color", + 17 => "t1.portada", + 18 => "t1.cubierta", + 19 => "t1.rotativa", + 20 => "t2.nombre",*/ + ]; + + const SORTABLE2 = [ + 0 => "t1.defecto", + 1 => "t1.nombre", + 2 => "t1.gramaje", + ]; + + + protected $allowedFields = [ + "papel_generico_id", + "nombre", + "defecto", + "referencia", + "ancho", + "alto", + "mano", + "espesor", + "gramaje", + "precio_tonelada", + "margen", + "peso_por_pliego", + "precio_pliego", + "bn", + "color", + "portada", + "cubierta", + "rotativa", + "deleted_at", + "is_deleted", + "user_update_id", + ]; + protected $returnType = "App\Entities\Configuracion\PapelImpresion"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "alto" => [ + "label" => "PapelImpresions.alto", + "rules" => "required|decimal", + ], + "ancho" => [ + "label" => "PapelImpresions.ancho", + "rules" => "required|decimal", + ], + "espesor" => [ + "label" => "PapelImpresions.espesor", + "rules" => "required|decimal", + ], + "gramaje" => [ + "label" => "PapelImpresions.gramaje", + "rules" => "required|decimal", + ], + "mano" => [ + "label" => "PapelImpresions.mano", + "rules" => "required|decimal", + ], + "margen" => [ + "label" => "PapelImpresions.margen", + "rules" => "required|max_length[31]", + ], + "nombre" => [ + "label" => "PapelImpresions.nombre", + "rules" => "trim|required|max_length[255]", + ], + "peso_por_pliego" => [ + "label" => "PapelImpresions.pesoPorPliego", + "rules" => "required|decimal", + ], + "precio_pliego" => [ + "label" => "PapelImpresions.precioPliego", + "rules" => "required|decimal", + ], + "precio_tonelada" => [ + "label" => "PapelImpresions.precioTonelada", + "rules" => "required|decimal", + ], + "referencia" => [ + "label" => "PapelImpresions.referencia", + "rules" => "trim|required|max_length[13]", + ], + ]; + + protected $validationMessages = [ + "alto" => [ + "decimal" => "PapelImpresions.validation.alto.decimal", + "required" => "PapelImpresions.validation.alto.required", + ], + "ancho" => [ + "decimal" => "PapelImpresions.validation.ancho.decimal", + "required" => "PapelImpresions.validation.ancho.required", + ], + "espesor" => [ + "decimal" => "PapelImpresions.validation.espesor.decimal", + "required" => "PapelImpresions.validation.espesor.required", + ], + "gramaje" => [ + "decimal" => "PapelImpresions.validation.gramaje.decimal", + "required" => "PapelImpresions.validation.gramaje.required", + ], + "mano" => [ + "decimal" => "PapelImpresions.validation.mano.decimal", + "required" => "PapelImpresions.validation.mano.required", + ], + "margen" => [ + "max_length" => "PapelImpresions.validation.margen.max_length", + "required" => "PapelImpresions.validation.margen.required", + ], + "nombre" => [ + "max_length" => "PapelImpresions.validation.nombre.max_length", + "required" => "PapelImpresions.validation.nombre.required", + ], + "peso_por_pliego" => [ + "decimal" => "PapelImpresions.validation.peso_por_pliego.decimal", + "required" => "PapelImpresions.validation.peso_por_pliego.required", + ], + "precio_pliego" => [ + "decimal" => "PapelImpresions.validation.precio_pliego.decimal", + "required" => "PapelImpresions.validation.precio_pliego.required", + ], + "precio_tonelada" => [ + "decimal" => "PapelImpresions.validation.precio_tonelada.decimal", + "required" => "PapelImpresions.validation.precio_tonelada.required", + ], + "referencia" => [ + "max_length" => "PapelImpresions.validation.referencia.max_length", + "required" => "PapelImpresions.validation.referencia.required", + ], + ]; + + public function findAllWithPapelGenerico(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS papel_generico_id FROM " . + $this->table . + " t1 LEFT JOIN lg_papel_generico t2 ON t1.papel_generico_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $generico_id=-1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre, t1.defecto AS defecto, t1.referencia AS referencia, t1.ancho AS ancho, t1.alto AS alto, t1.mano AS mano, t1.espesor AS espesor, t1.gramaje AS gramaje, t1.precio_tonelada AS precio_tonelada, t1.margen AS margen, t1.peso_por_pliego AS peso_por_pliego, t1.precio_pliego AS precio_pliego, t1.bn AS bn, t1.color AS color, t1.portada AS portada, t1.cubierta AS cubierta, t1.rotativa AS rotativa, t2.nombre AS papel_generico_id" + ); + + $builder->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left"); + $builder->where("t1.is_deleted", 0); + if($generico_id>0){ + $builder->where("t1.papel_generico_id", $generico_id); + } + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.nombre", $search) + ->orLike("t1.gramaje", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.gramaje", $search) + ->orLike("t2.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php b/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php index 8983cc18..0bf7e5c0 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_confirm2delete.php @@ -1,3 +1,4 @@ +theme['name'] == 'Bootstrap5') { ?> + + + \ No newline at end of file diff --git a/ci4/app/Views/themes/_commonPartialsBs/_form_validation_errors.php b/ci4/app/Views/themes/_commonPartialsBs/_form_validation_errors.php index e34fc5d7..4984d699 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_form_validation_errors.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_form_validation_errors.php @@ -1,3 +1,4 @@ +theme['name'] == 'Bootstrap5') { ?> @@ -17,3 +18,18 @@ + +
+
+
+ +

Please correct the errors below:

+
    + +
  • + +
+
+
+
+ diff --git a/ci4/app/Views/themes/_commonPartialsBs/datatables.php b/ci4/app/Views/themes/_commonPartialsBs/datatables.php index f36b6b6d..8596891c 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/datatables.php +++ b/ci4/app/Views/themes/_commonPartialsBs/datatables.php @@ -1,18 +1,17 @@ section('css') ?> - + endSection() ?> - section('footerAdditions') ?> include('themes/_commonPartialsBs/_confirm2delete') ?> endSection() ?> - + section('additionalExternalJs') ?> - + endSection() ?> @@ -160,7 +159,7 @@ "scrollX": true, "stateSave": true, "language": { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + url: "//cdn.datatables.net/plug-ins/1.10.25/i18n/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" }, "columnDefs": [ { diff --git a/ci4/app/Views/themes/_commonPartialsBs/select2bs5.php b/ci4/app/Views/themes/_commonPartialsBs/select2bs5.php index 00be171b..c5afb660 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/select2bs5.php +++ b/ci4/app/Views/themes/_commonPartialsBs/select2bs5.php @@ -1,27 +1,19 @@ section('css') ?> - + + endSection() ?> section('additionalExternalJs') ?> - + endSection() ?> section('additionalInlineJs') ?> - - const select2 = $('.select2'); - - // Select2 - // -------------------------------------------------------------------- - if (select2.length) { - select2.each(function () { - var $this = $(this); - $this.wrap('
').select2({ - placeholder: 'Select value', - dropdownParent: $this.parent() - }); + + $('.select2bs').select2({ + theme: "bootstrap-5", + allowClear: false, }); - } endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php b/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php index c522221b..f85d90f7 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php +++ b/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php @@ -1,26 +1,66 @@ section('css') ?> - + + + + endSection() ?> section('additionalExternalJs') ?> - + endSection() ?> section('additionalInlineJs') ?> -var Toast = Swal.mixin({ + const Toast = Swal.mixin({ toast: true, - position: 'top-end', + position: 'top-right', + iconColor: 'white', + customClass: { + popup: 'colored-toast' + }, showConfirmButton: false, timer: 6000, timerProgressBar: true, - onOpen: (toast) => { + didOpen: (toast) => { toast.addEventListener('mouseenter', Swal.stopTimer) toast.addEventListener('mouseleave', Swal.resumeTimer) } diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php new file mode 100644 index 00000000..c88cce57 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelImpresionFormItems.php @@ -0,0 +1,165 @@ +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ + + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php index 6f7364b5..0ee48784 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php @@ -1,26 +1,158 @@ +include('themes/_commonPartialsBs/datatables') ?> include("themes/_commonPartialsBs/select2bs5") ?> include("themes/_commonPartialsBs/sweetalert") ?> -extend('themes/backend/vuexy/main/defaultlayout') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?>
-
+
-

+

-
- - getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> - -
- +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
-
-
+ + +
+
+

+ +

+ +
+
+ + + + + + + + + + + + + + +
+
+
+
+
+ +
+
endSection() ?> + +section('additionalInlineJs') ?> + + // JJO + const url = window.location.href; + const url_parts = url.split('/'); + if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; + } + else + id = -1; + const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ +
+ `; + }; + theTable = $('#tableOfPapelesimpresion').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + //"dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + + stateSave: true, + order: [[1, 'asc']], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + data: { + id_PG: id, + }, + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr] //JJO añadidas bool cols + } + ], + columns : [ + { 'data': 'defecto' }, + { 'data': 'nombre' }, + { 'data': 'gramaje' }, + { 'data': actionBtns } + ] + }); + + + theTable.on( 'draw.dt', function () { + const boolCols = [0]; + for (let coln of boolCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + + }); + +$(document).on('click', '.btn-edit', function(e) { + //window.location.href = `/${$(this).attr('data-id')}/edit`; + window.location.href = `/configuracion/papelesimpresion/edit/${$(this).attr('data-id')}`; + }); + + + +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php index bcc0ace5..b129d218 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php @@ -106,7 +106,8 @@ }); $(document).on('click', '.btn-edit', function(e) { - window.location.href = `/${$(this).attr('data-id')}/edit`; + //window.location.href = `/edit/${$(this).attr('data-id')}`; + window.location.href = `/configuracion/papelesgenericos/edit/${$(this).attr('data-id')}`; }); $(document).on('click', '.btn-delete', function(e) { @@ -122,11 +123,13 @@ $(document).on('click', '.btn-delete', function(e) { }) .then((result) => { const dataId = $(this).data('id'); - const row = $(this).closest('tr'); + const row = $(this).closest('tr'); if (result.value) { $.ajax({ - url: `/${dataId}`, - method: 'DELETE', + //url: `/${dataId}`, + //method: 'DELETE', + url: `/configuracion/papelesgenericos/delete/${dataId}`, + method: 'GET', }).done((data, textStatus, jqXHR) => { Toast.fire({ icon: 'success', diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php new file mode 100644 index 00000000..e21b318f --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php @@ -0,0 +1,63 @@ +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> + + +section("additionalInlineJs") ?> + + + $('#papelGenericoId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php new file mode 100644 index 00000000..d9f4f8b7 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php @@ -0,0 +1,183 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
+ +
+
+

+ 'btn btn-primary float-end']); ?> +
+
+ + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfPapelesimpresion').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + "dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + stateSave: true, + order: [[1, 'asc']], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [3, 4, 5, 6, 7, lastColNr] //JJO añadidas bool cols + } + ], + columns : [ + { 'data': 'nombre' }, + { 'data': 'papel_generico_id' }, + { 'data': 'gramaje' }, + { 'data': 'bn' }, + { 'data': 'color' }, + { 'data': 'portada' }, + { 'data': 'cubierta' }, + { 'data': 'rotativa' }, + { 'data': actionBtns } + ] + }); + + + theTable.on( 'draw.dt', function () { + const boolCols = [3, 4, 5, 6, 7]; + for (let coln of boolCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + + }); + +$(document).on('click', '.btn-edit', function(e) { + //window.location.href = `/${$(this).attr('data-id')}/edit`; + window.location.href = `/configuracion/papelesimpresion/edit/${$(this).attr('data-id')}`; + }); + +$(document).on('click', '.btn-delete', function(e) { + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + $.ajax({ + //url: `/${dataId}`, + //method: 'DELETE', + url: `/configuracion/papelesimpresion/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + Toast.fire({ + icon: 'success', + title: data.msg ?? jqXHR.statusText, + }); + + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + Toast.fire({ + icon: 'error', + title: jqXHR.responseJSON.messages.error, + }); + }) + } + }); + }); + + + + +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu.php b/ci4/app/Views/themes/backend/vuexy/main/menu.php index a4621406..b147f0e1 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/menu.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu.php @@ -57,7 +57,7 @@ @@ -130,6 +130,15 @@ + 0): ?> + 0): ?> + + + 0): ?> 0): ?>