diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..7edac904 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "clockify.tracking.workspaceId": "6464949facab6237e1538c14" +} \ No newline at end of file diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 1215e7c4..afacc81b 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 @@ -141,24 +162,139 @@ $routes->group('', [], function($routes) { }); -//WEB ROUTER ------------------------------------------------------ -//------------------------------------------------------------------ -$routes->get('/', 'Home::index'); -$routes->get('lang/{locale}', 'Language::index'); +$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('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']); + + -//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'); /* @@ -177,5 +313,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/Imposiciones.php b/ci4/app/Controllers/Configuracion/Imposiciones.php index eb621786..c684a39d 100644 --- a/ci4/app/Controllers/Configuracion/Imposiciones.php +++ b/ci4/app/Controllers/Configuracion/Imposiciones.php @@ -1,35 +1,284 @@ -viewData['pageTitle'] = lang('Imposiciones.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Imposiciones.imposicion')]), + 'imposicion' => new Imposicion(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewImposicionList', $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('Imposiciones.imposicion'))]); + $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('Imposiciones.imposicion'))]).'.'; + $message .= anchor( "admin/imposiciones/{$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['imposicion'] = isset($sanitizedData) ? new Imposicion($sanitizedData) : new Imposicion(); + $this->viewData['orientacionList'] = $this->getOrientacionOptions(); + + $this->viewData['formAction'] = route_to('createImposicion'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Imposiciones.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $imposicion = $this->model->find($id); + + if ($imposicion == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Imposiciones.imposicion')), $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); + + + + $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('Imposiciones.imposicion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $imposicion->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $imposicion->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Imposiciones.imposicion'))]).'.'; + $message .= anchor( "admin/imposiciones/{$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['imposicion'] = $imposicion; + $this->viewData['orientacionList'] = $this->getOrientacionOptions(); + + $this->viewData['formAction'] = route_to('updateImposicion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Imposiciones.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; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = ImposicionModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $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 { + 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.', ancho', 'ancho', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->ancho = '- '.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 ?? 'ancho']; + $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 getOrientacionOptions() { + $orientacionOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'H' => 'H', + 'V' => 'V', + ]; + return $orientacionOptions; + } + + } - \ No newline at end of file diff --git a/ci4/app/Controllers/Configuracion/PapelesGenericos.php b/ci4/app/Controllers/Configuracion/PapelesGenericos.php new file mode 100644 index 00000000..52678da8 --- /dev/null +++ b/ci4/app/Controllers/Configuracion/PapelesGenericos.php @@ -0,0 +1,289 @@ +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() + { + + $viewData = [ + '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); + } + + + 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('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("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 : + return $this->redirect2listView('sweet-success', $message); + endif; + else : + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['papelGenerico'] = isset($sanitizedData) ? new PapelGenerico($sanitizedData) : new PapelGenerico(); + + $this->viewData['formAction'] = route_to('createPapelGenerico'); + + $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) + { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $papelGenerico = $this->model->find($id); + + if ($papelGenerico == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $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); + 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; + endif; + if ($noException && $successfulResult) : + $id = $papelGenerico->id ?? $id; + $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 : + return $this->redirect2listView('sweet-success', $message); + endif; + 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['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() + { + 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; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $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(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->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); + } + } +} 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/Configuracion/Papelgenerico.php b/ci4/app/Controllers/Configuracion/Papelgenerico.php deleted file mode 100644 index f8d9d19b..00000000 --- a/ci4/app/Controllers/Configuracion/Papelgenerico.php +++ /dev/null @@ -1,35 +0,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 @@ -57,7 +76,7 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon * * @var array */ - protected $helpers = ['session', 'go_common', 'form', 'text']; + protected $helpers = ['session', 'go_common', 'form', 'text', 'general','jwt']; //JJO /** * Initializer method. @@ -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 efdefb70..2e1d27b4 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -2,8 +2,7 @@ namespace App\Controllers; - -use App\Models\Usuarios\GroupUserModel; +use App\Controllers\Configuracion\Papelesimpresion; class Test extends BaseController { @@ -16,8 +15,8 @@ class Test extends BaseController public function index() { - $model = new GroupUserModel(); - var_dump($model->getUsersWithRol('115b5ad39b853084209caf6824224f6b')); + $papel = new Papelesimpresion(); + var_dump($papel->datatablePG()); } } \ No newline at end of file diff --git a/ci4/app/Entities/Configuracion/Imposicion.php b/ci4/app/Entities/Configuracion/Imposicion.php new file mode 100644 index 00000000..0acdc41c --- /dev/null +++ b/ci4/app/Entities/Configuracion/Imposicion.php @@ -0,0 +1,22 @@ + null, + "ancho" => null, + "alto" => null, + "unidades" => null, + "orientacion" => null, + "maquina" => null, + "etiqueta" => null, + ]; + protected $casts = [ + "ancho" => "int", + "alto" => "int", + "unidades" => "?int", + ]; +} diff --git a/ci4/app/Entities/Configuracion/PapelGenerico.php b/ci4/app/Entities/Configuracion/PapelGenerico.php new file mode 100644 index 00000000..7203bca4 --- /dev/null +++ b/ci4/app/Entities/Configuracion/PapelGenerico.php @@ -0,0 +1,22 @@ + null, + "nombre" => null, + "code" => null, + "code_ot" => null, + "show_in_client" => true, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "show_in_client" => "boolean", + "is_deleted" => "int", + ]; +} 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/Entities/GoBaseEntity.php b/ci4/app/Entities/GoBaseEntity.php new file mode 100644 index 00000000..d28a00be --- /dev/null +++ b/ci4/app/Entities/GoBaseEntity.php @@ -0,0 +1,26 @@ + $value) { + if (isset($this->attributes[$key])) { + $this->attributes[$key] = $value; + } + } + return $this; + } +} \ No newline at end of file diff --git a/ci4/app/Filters/LoginAuthFilter.php b/ci4/app/Filters/LoginAuthFilter.php index 91085c7b..36c9b871 100644 --- a/ci4/app/Filters/LoginAuthFilter.php +++ b/ci4/app/Filters/LoginAuthFilter.php @@ -176,6 +176,8 @@ class LoginAuthFilter implements FilterInterface 'whiteListMethod', '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 new file mode 100644 index 00000000..1570fdba --- /dev/null +++ b/ci4/app/Language/en/PapelGenerico.php @@ -0,0 +1,44 @@ + 'Code', + 'codeOt' => 'Code Ot', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Generic Paper', + 'nombre' => 'Name', + 'papel-generico' => 'Generic Papers', + 'papelGenerico' => 'Generic Paper', + 'papelGenericoList' => 'Generic Papers List', + '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.', + + ], + + 'code_ot' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'nombre' => [ + '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/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/en/TipologiasLibros.php b/ci4/app/Language/en/TipologiasLibros.php new file mode 100644 index 00000000..4369e218 --- /dev/null +++ b/ci4/app/Language/en/TipologiasLibros.php @@ -0,0 +1,32 @@ + 'Code', + 'id' => 'ID', + 'moduleTitle' => 'Tipologias Libros', + 'nombre' => 'Nombre', + 'tipologiaLibros' => 'Tipologia Libros', + 'tipologiaLibrosList' => 'Tipologia Libros List', + 'tipologiasLibros' => 'Tipologias Libros', + 'tipologiaslibros' => 'Tipologias Libros', + 'validation' => [ + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'code' => [ + 'is_unique' => 'The {field} field must contain a unique value', + '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 c309f994..d7fe13c2 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 new file mode 100644 index 00000000..785f5d5d --- /dev/null +++ b/ci4/app/Language/es/PapelGenerico.php @@ -0,0 +1,44 @@ + 'Código', + 'codeOt' => 'Código Ot', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Papel Genérico', + 'nombre' => 'Nombre', + 'papel-generico' => 'Papeles Genéricos', + 'papelGenerico' => 'Papel Genérico', + 'papelGenericoList' => 'Lista Papeles Genéricos', + '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.', + + ], + + 'code_ot' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'nombre' => [ + '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/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/Language/es/TipologiasLibros.php b/ci4/app/Language/es/TipologiasLibros.php new file mode 100644 index 00000000..4369e218 --- /dev/null +++ b/ci4/app/Language/es/TipologiasLibros.php @@ -0,0 +1,32 @@ + 'Code', + 'id' => 'ID', + 'moduleTitle' => 'Tipologias Libros', + 'nombre' => 'Nombre', + 'tipologiaLibros' => 'Tipologia Libros', + 'tipologiaLibrosList' => 'Tipologia Libros List', + 'tipologiasLibros' => 'Tipologias Libros', + 'tipologiaslibros' => 'Tipologias Libros', + 'validation' => [ + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'code' => [ + 'is_unique' => 'The {field} field must contain a unique value', + '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/Models/Collection.php b/ci4/app/Models/Collection.php new file mode 100644 index 00000000..773ae680 --- /dev/null +++ b/ci4/app/Models/Collection.php @@ -0,0 +1,43 @@ +getPostGet('data'))) : + $reqData = $req->getPostGet('data'); + $draw = $reqData['draw']; + elseif (!empty($req->getPostGet('draw'))) : + $draw = $req->getPostGet('draw'); + endif; + + $response = [ + 'draw' => $draw, + 'recordsTotal' => $recordsTotal, + 'recordsFiltered' => $recordsFiltered, + 'data' => $data, + 'token' => csrf_hash(), // in case the CSRF token is regenerated + ]; + + if (!empty($error)) { + $response['error'] = $error; + } + + return $response; + } +} \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/ImposicionModel.php b/ci4/app/Models/Configuracion/ImposicionModel.php new file mode 100644 index 00000000..55175111 --- /dev/null +++ b/ci4/app/Models/Configuracion/ImposicionModel.php @@ -0,0 +1,115 @@ + "t1.id", + 2 => "t1.ancho", + 3 => "t1.alto", + 4 => "t1.unidades", + 5 => "t1.orientacion", + 6 => "t1.maquina", + 7 => "t1.etiqueta", + ]; + + protected $allowedFields = ["ancho", "alto", "unidades", "orientacion", "maquina", "etiqueta"]; + protected $returnType = "App\Entities\Configuracion\Imposicion"; + + public static $labelField = "ancho"; + + protected $validationRules = [ + "alto" => [ + "label" => "Imposiciones.alto", + "rules" => "required|integer", + ], + "ancho" => [ + "label" => "Imposiciones.ancho", + "rules" => "required|integer", + ], + "etiqueta" => [ + "label" => "Imposiciones.etiqueta", + "rules" => "trim|max_length[100]", + ], + "maquina" => [ + "label" => "Imposiciones.maquina", + "rules" => "trim|max_length[100]", + ], + "orientacion" => [ + "label" => "Imposiciones.orientacion", + "rules" => "permit_empty|in_list[H,V]", + ], + "unidades" => [ + "label" => "Imposiciones.unidades", + "rules" => "integer|permit_empty", + ], + ]; + + protected $validationMessages = [ + "alto" => [ + "integer" => "Imposiciones.validation.alto.integer", + "required" => "Imposiciones.validation.alto.required", + ], + "ancho" => [ + "integer" => "Imposiciones.validation.ancho.integer", + "required" => "Imposiciones.validation.ancho.required", + ], + "etiqueta" => [ + "max_length" => "Imposiciones.validation.etiqueta.max_length", + ], + "maquina" => [ + "max_length" => "Imposiciones.validation.maquina.max_length", + ], + "orientacion" => [ + "in_list" => "Imposiciones.validation.orientacion.in_list", + ], + "unidades" => [ + "integer" => "Imposiciones.validation.unidades.integer", + ], + ]; + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.ancho AS ancho, t1.alto AS alto, t1.unidades AS unidades, t1.orientacion AS orientacion, t1.maquina AS maquina, t1.etiqueta AS etiqueta" + ); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orlike("t1.ancho", $search) + ->orLike("t1.alto", $search) + ->orLike("t1.unidades", $search) + ->orLike("t1.orientacion", $search) + ->orLike("t1.maquina", $search) + ->orLike("t1.etiqueta", $search) + ->orlike("t1.id", $search) + ->orLike("t1.ancho", $search) + ->orLike("t1.alto", $search) + ->orLike("t1.unidades", $search) + ->orLike("t1.orientacion", $search) + ->orLike("t1.maquina", $search) + ->orLike("t1.etiqueta", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php new file mode 100644 index 00000000..88a2e6a7 --- /dev/null +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -0,0 +1,93 @@ + "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","deleted_at","is_deleted"]; + protected $returnType = "App\Entities\Configuracion\PapelGenerico"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "code" => [ + "label" => "PapelGenericoes.code", + "rules" => "trim|max_length[5]", + ], + "code_ot" => [ + "label" => "PapelGenericoes.codeOt", + "rules" => "trim|max_length[5]", + ], + "nombre" => [ + "label" => "PapelGenericoes.nombre", + "rules" => "trim|required|max_length[255]", + ], + ]; + + protected $validationMessages = [ + "code" => [ + "max_length" => "PapelGenericoes.validation.code.max_length", + ], + "code_ot" => [ + "max_length" => "PapelGenericoes.validation.code_ot.max_length", + ], + "nombre" => [ + "max_length" => "PapelGenericoes.validation.nombre.max_length", + "required" => "PapelGenericoes.validation.nombre.required", + ], + ]; + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->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 + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); + } +} 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') { ?>