From d25ff9666c480f7f26bf8fcc5f5578e97b189593 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Wed, 26 Jul 2023 22:36:57 +0200 Subject: [PATCH] Creado mecanismo de generacion de alertas tipo Boostrap (defecto) y ToastR. Aplicado a los controladores existentes --- ci4/app/Controllers/Clientes/Cliente.php | 307 +++++++-------- .../Controllers/Clientes/Clientecontactos.php | 184 ++++----- .../Clientes/Clientedistribuidores.php | 219 +++++------ .../Configuracion/Comunidadesautonomas.php | 174 ++++----- .../Controllers/Configuracion/Formaspago.php | 150 ++++---- .../Controllers/Configuracion/Formaspagos.php | 159 ++++---- ci4/app/Controllers/Configuracion/Group.php | 184 +++++---- .../Configuracion/Imposiciones.php | 180 ++++----- .../Controllers/Configuracion/Maquinas.php | 220 +++++------ .../Configuracion/Maquinasdefecto.php | 206 +++++----- .../Maquinastarifasimpresion.php | 358 +++++++++--------- ci4/app/Controllers/Configuracion/Paises.php | 165 ++++---- .../Configuracion/Papelesgenericos.php | 10 +- .../Configuracion/Papelesimpresion.php | 10 +- .../Papelimpresiontipologias.php | 10 +- .../Controllers/Configuracion/Provincias.php | 174 ++++----- .../Controllers/Configuracion/Tipologias.php | 144 ++++--- .../Controllers/GoBaseResourceController.php | 12 + ci4/app/Controllers/Tarifas/Tarifaacabado.php | 17 +- .../Tarifas/Tarifaacabadolineas.php | 349 ++++++++--------- .../Tarifas/Tarifaencuadernacionlineas.php | 332 ++++++++-------- .../Tarifas/Tarifamanipuladolineas.php | 332 ++++++++-------- .../Tarifas/Tarifapreimpresion.php | 149 ++++---- .../Tarifas/Tarifasencuadernacion.php | 148 ++++---- .../Controllers/Tarifas/Tarifasmanipulado.php | 144 +++---- ci4/app/Language/es/Basic.php | 2 +- .../themes/_commonPartialsBs/sweetalert.php | 69 ++-- .../backend/vuexy/main/defaultlayout.php | 1 - 28 files changed, 2214 insertions(+), 2195 deletions(-) diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index 642ac371..f72247b5 100644 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Clientes.moduleTitle'); $this->viewData['usingSweetAlert'] = true; @@ -57,23 +58,25 @@ class Cliente extends \App\Controllers\GoBaseResourceController { } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Clientes.cliente')]), - 'clienteEntity' => new ClienteEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Clientes.cliente')]), + 'clienteEntity' => new ClienteEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewClienteList', $viewData); + return view(static::$viewPath . 'viewClienteList', $viewData); } - public function add() { + public function add() + { $requestMethod = $this->request->getMethod(); @@ -83,39 +86,37 @@ class Cliente 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('Clientes.cliente'))]); - $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', [lang('Basic.global.record')]); + $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('Clientes.cliente'))]).'.'; - $message .= anchor( "admin/cliente/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -128,23 +129,24 @@ class Cliente extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['clienteEntity'] = isset($sanitizedData) ? new ClienteEntity($sanitizedData) : new ClienteEntity(); - $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); - $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null); - $this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($clienteEntity->comercial_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null); - $this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null); + $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null); + $this->viewData['userList'] = $this->getUserListItems($clienteEntity->comercial_id ?? null); + $this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null); + $this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null); $this->viewData['formAction'] = route_to('createCliente'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Clientes.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Clientes.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; @@ -161,98 +163,94 @@ class Cliente 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('credito_asegurado') == null ) { - $sanitizedData['credito_asegurado'] = false; - } -if ($this->request->getPost('disponible_fe') == null ) { - $sanitizedData['disponible_fe'] = false; - } -if ($this->request->getPost('message_tracking') == null ) { - $sanitizedData['message_tracking'] = false; - } -if ($this->request->getPost('message_production_start') == null ) { - $sanitizedData['message_production_start'] = false; - } -if ($this->request->getPost('tirada_flexible') == null ) { - $sanitizedData['tirada_flexible'] = false; - } -if ($this->request->getPost('lineasEnvioFactura') == null ) { - $sanitizedData['lineasEnvioFactura'] = false; - } + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('credito_asegurado') == null) { + $sanitizedData['credito_asegurado'] = false; + } + if ($this->request->getPost('disponible_fe') == null) { + $sanitizedData['disponible_fe'] = false; + } + if ($this->request->getPost('message_tracking') == null) { + $sanitizedData['message_tracking'] = false; + } + if ($this->request->getPost('message_production_start') == null) { + $sanitizedData['message_production_start'] = false; + } + if ($this->request->getPost('tirada_flexible') == null) { + $sanitizedData['tirada_flexible'] = false; + } + if ($this->request->getPost('lineasEnvioFactura') == null) { + $sanitizedData['lineasEnvioFactura'] = 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('Clientes.cliente'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $clienteEntity->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('Clientes.cliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $clienteEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $clienteEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Clientes.cliente'))]).'.'; - $message .= anchor( "admin/cliente/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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') //var_dump($clienteEntity); dd(); $this->viewData['clienteEntity'] = $clienteEntity; - $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); - $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null); - $this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($clienteEntity->comercial_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null); - $this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null); + $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null); + $this->viewData['userList'] = $this->getUserListItems($clienteEntity->comercial_id ?? null); + $this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null); + $this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null); + + $this->viewData['formAction'] = route_to('updateCliente', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateCliente', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Clientes.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -263,17 +261,20 @@ if ($this->request->getPost('lineasEnvioFactura') == null ) { $dir = $reqData['order']['0']['dir'] ?? 'asc'; $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); - foreach ($resourceData as $item) : -if (isset($item->direccion) && strlen($item->direccion) > 100) : - $item->direccion = character_limiter($item->direccion, 100); -endif;if (isset($item->comentarios_tirada_flexible) && strlen($item->comentarios_tirada_flexible) > 100) : - $item->comentarios_tirada_flexible = character_limiter($item->comentarios_tirada_flexible, 100); -endif;if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) : - $item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100); -endif;if (isset($item->comentarios) && strlen($item->comentarios) > 100) : - $item->comentarios = character_limiter($item->comentarios, 100); -endif; - endforeach; + foreach ($resourceData as $item) : + if (isset($item->direccion) && strlen($item->direccion) > 100) : + $item->direccion = character_limiter($item->direccion, 100); + endif; + if (isset($item->comentarios_tirada_flexible) && strlen($item->comentarios_tirada_flexible) > 100) : + $item->comentarios_tirada_flexible = character_limiter($item->comentarios_tirada_flexible, 100); + endif; + if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) : + $item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100); + endif; + if (isset($item->comentarios) && strlen($item->comentarios) > 100) : + $item->comentarios = character_limiter($item->comentarios, 100); + endif; + endforeach; return $this->respond(Collection::datatable( $resourceData, @@ -285,15 +286,16 @@ endif; } } - 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(); @@ -307,7 +309,8 @@ endif; } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -318,8 +321,8 @@ endif; $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(); @@ -334,87 +337,93 @@ endif; } - protected function getPaisListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; + protected function getPaisListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; if (!empty($selId)) : - $paisModel = model('App\Models\Configuracion\PaisModel'); + $paisModel = model('App\Models\Configuracion\PaisModel'); $selOption = $paisModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getUserListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])]; + protected function getUserListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])]; if (!empty($selId)) : - $userModel = model('App\Models\Usuarios\UserModel'); + $userModel = model('App\Models\Usuarios\UserModel'); $selOption = $userModel->where('id_user', $selId)->findColumn('first_name'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getComunidadAutonomaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; + protected function getComunidadAutonomaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; if (!empty($selId)) : - $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); + $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); $selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getUserListItems2($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])]; + protected function getUserListItems2($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])]; if (!empty($selId)) : - $userModel = model('App\Models\Configuracion\UserModel'); + $userModel = model('App\Models\Configuracion\UserModel'); $selOption = $userModel->where('id_user', $selId)->findColumn('last_name'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getFormaDePagoListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])]; + protected function getFormaDePagoListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])]; if (!empty($selId)) : - $formaPagoModel = model('App\Models\Configuracion\FormaPagoModel'); + $formaPagoModel = model('App\Models\Configuracion\FormaPagoModel'); $selOption = $formaPagoModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getProvinciaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; + protected function getProvinciaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; if (!empty($selId)) : - $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); + $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); $selOption = $provinciaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } } diff --git a/ci4/app/Controllers/Clientes/Clientecontactos.php b/ci4/app/Controllers/Clientes/Clientecontactos.php index 3eedbe45..9080bfad 100644 --- a/ci4/app/Controllers/Clientes/Clientecontactos.php +++ b/ci4/app/Controllers/Clientes/Clientecontactos.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('ClienteContactos.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteContactos.contactoDeCliente')]), - 'clienteContactoEntity' => new ClienteContactoEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteContactos.contactoDeCliente')]), + 'clienteContactoEntity' => new ClienteContactoEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewContactoDeClienteList', $viewData); + return view(static::$viewPath . 'viewContactoDeClienteList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -63,39 +65,37 @@ class Clientecontactos 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('ClienteContactos.contactoDeCliente'))]); - $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', [lang('Basic.global.record')]); + $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('ClienteContactos.contactoDeCliente'))]).'.'; - $message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -108,18 +108,19 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['clienteContactoEntity'] = isset($sanitizedData) ? new ClienteContactoEntity($sanitizedData) : new ClienteContactoEntity(); - $this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null); + $this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null); $this->viewData['formAction'] = route_to('createContactoDeCliente'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClienteContactos.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; @@ -136,73 +137,69 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $clienteContactoEntity->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('ClienteContactos.contactoDeCliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $clienteContactoEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $clienteContactoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]).'.'; - $message .= anchor( "admin/cliente-contactos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['clienteContactoEntity'] = $clienteContactoEntity; - $this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null); + $this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null); + + $this->viewData['formAction'] = route_to('updateContactoDeCliente', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateContactoDeCliente', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteContactos.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -213,11 +210,11 @@ class Clientecontactos extends \App\Controllers\GoBaseResourceController { $dir = $reqData['order']['0']['dir'] ?? 'asc'; $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); - foreach ($resourceData as $item) : -if (isset($item->apellidos) && strlen($item->apellidos) > 100) : - $item->apellidos = character_limiter($item->apellidos, 100); -endif; - endforeach; + foreach ($resourceData as $item) : + if (isset($item->apellidos) && strlen($item->apellidos) > 100) : + $item->apellidos = character_limiter($item->apellidos, 100); + endif; + endforeach; return $this->respond(Collection::datatable( $resourceData, @@ -229,15 +226,16 @@ endif; } } - 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(); @@ -251,7 +249,8 @@ endif; } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -262,8 +261,8 @@ endif; $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(); @@ -278,17 +277,18 @@ endif; } - protected function getClienteListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])]; + protected function getClienteListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])]; if (!empty($selId)) : - $clienteModel = model('App\Models\Clientes\ClienteModel'); + $clienteModel = model('App\Models\Clientes\ClienteModel'); $selOption = $clienteModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } } diff --git a/ci4/app/Controllers/Clientes/Clientedistribuidores.php b/ci4/app/Controllers/Clientes/Clientedistribuidores.php index 09af41c8..c73e0d8e 100644 --- a/ci4/app/Controllers/Clientes/Clientedistribuidores.php +++ b/ci4/app/Controllers/Clientes/Clientedistribuidores.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('ClienteDistribuidores.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteDistribuidores.distribuidorDeCliente')]), - 'clienteDistribuidorEntity' => new ClienteDistribuidorEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteDistribuidores.distribuidorDeCliente')]), + 'clienteDistribuidorEntity' => new ClienteDistribuidorEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewDistribuidorDeClienteList', $viewData); + return view(static::$viewPath . 'viewDistribuidorDeClienteList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -67,39 +69,37 @@ class Clientedistribuidores 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('ClienteDistribuidores.distribuidorDeCliente'))]); - $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', [lang('Basic.global.record')]); + $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('ClienteDistribuidores.distribuidorDeCliente'))]).'.'; - $message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -112,20 +112,21 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['clienteDistribuidorEntity'] = isset($sanitizedData) ? new ClienteDistribuidorEntity($sanitizedData) : new ClienteDistribuidorEntity(); - $this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null); - $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null); - $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null); + $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null); $this->viewData['formAction'] = route_to('createDistribuidorDeCliente'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClienteDistribuidores.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; @@ -142,75 +143,71 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $clienteDistribuidorEntity->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('ClienteDistribuidores.distribuidorDeCliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $clienteDistribuidorEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $clienteDistribuidorEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ClienteDistribuidores.distribuidorDeCliente'))]).'.'; - $message .= anchor( "admin/cliente-distribuidores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['clienteDistribuidorEntity'] = $clienteDistribuidorEntity; - $this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null); - $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null); - $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($clienteDistribuidorEntity->pais_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteDistribuidorEntity->provincia_id ?? null); + $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteDistribuidorEntity->comunidad_autonoma_id ?? null); + + $this->viewData['formAction'] = route_to('updateDistribuidorDeCliente', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ClienteDistribuidores.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateDistribuidorDeCliente', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ClienteDistribuidores.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -221,13 +218,14 @@ class Clientedistribuidores extends \App\Controllers\GoBaseResourceController { $dir = $reqData['order']['0']['dir'] ?? 'asc'; $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); - foreach ($resourceData as $item) : -if (isset($item->direccion) && strlen($item->direccion) > 100) : - $item->direccion = character_limiter($item->direccion, 100); -endif;if (isset($item->horarios_entrega) && strlen($item->horarios_entrega) > 100) : - $item->horarios_entrega = character_limiter($item->horarios_entrega, 100); -endif; - endforeach; + foreach ($resourceData as $item) : + if (isset($item->direccion) && strlen($item->direccion) > 100) : + $item->direccion = character_limiter($item->direccion, 100); + endif; + if (isset($item->horarios_entrega) && strlen($item->horarios_entrega) > 100) : + $item->horarios_entrega = character_limiter($item->horarios_entrega, 100); + endif; + endforeach; return $this->respond(Collection::datatable( $resourceData, @@ -239,15 +237,16 @@ endif; } } - 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(); @@ -261,7 +260,8 @@ endif; } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -272,8 +272,8 @@ endif; $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(); @@ -288,45 +288,48 @@ endif; } - protected function getComunidadAutonomaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; + protected function getComunidadAutonomaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; if (!empty($selId)) : - $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); + $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); $selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getPaisListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; + protected function getPaisListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; if (!empty($selId)) : - $paisModel = model('App\Models\Configuracion\PaisModel'); + $paisModel = model('App\Models\Configuracion\PaisModel'); $selOption = $paisModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getProvinciaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; + protected function getProvinciaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; if (!empty($selId)) : - $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); + $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); $selOption = $provinciaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } } diff --git a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php index 624b0744..92e4d741 100644 --- a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php +++ b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('ComunidadesAutonomas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ComunidadesAutonomas.comunidadAutonoma')]), - 'comunidadAutonomaEntity' => new ComunidadAutonomaEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ComunidadesAutonomas.comunidadAutonoma')]), + 'comunidadAutonomaEntity' => new ComunidadAutonomaEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewComunidadAutonomaList', $viewData); + return view(static::$viewPath . 'viewComunidadAutonomaList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -63,39 +65,37 @@ class Comunidadesautonomas 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('ComunidadesAutonomas.comunidadAutonoma'))]); - $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', [lang('Basic.global.record')]); + $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('ComunidadesAutonomas.comunidadAutonoma'))]).'.'; - $message .= anchor( "admin/comunidades-autonomas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -108,18 +108,19 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['comunidadAutonomaEntity'] = isset($sanitizedData) ? new ComunidadAutonomaEntity($sanitizedData) : new ComunidadAutonomaEntity(); - $this->viewData['paisList'] = $this->getPaisListItems($comunidadAutonomaEntity->pais_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($comunidadAutonomaEntity->pais_id ?? null); $this->viewData['formAction'] = route_to('createComunidadAutonoma'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ComunidadesAutonomas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ComunidadesAutonomas.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; @@ -136,73 +137,69 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $comunidadAutonomaEntity->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('ComunidadesAutonomas.comunidadAutonoma'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $comunidadAutonomaEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $comunidadAutonomaEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]).'.'; - $message .= anchor( "admin/comunidades-autonomas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['comunidadAutonomaEntity'] = $comunidadAutonomaEntity; - $this->viewData['paisList'] = $this->getPaisListItems($comunidadAutonomaEntity->pais_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($comunidadAutonomaEntity->pais_id ?? null); + + $this->viewData['formAction'] = route_to('updateComunidadAutonoma', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ComunidadesAutonomas.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateComunidadAutonoma', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ComunidadesAutonomas.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -224,15 +221,16 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController { } } - 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(); @@ -246,7 +244,8 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -257,8 +256,8 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController { $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(); @@ -273,17 +272,18 @@ class Comunidadesautonomas extends \App\Controllers\GoBaseResourceController { } - protected function getPaisListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; + protected function getPaisListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; if (!empty($selId)) : - $paisModel = model('App\Models\Configuracion\PaisModel'); + $paisModel = model('App\Models\Configuracion\PaisModel'); $selOption = $paisModel->where('id', $selId)->findColumn('id'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } } diff --git a/ci4/app/Controllers/Configuracion/Formaspago.php b/ci4/app/Controllers/Configuracion/Formaspago.php index a3fc4c8d..8c6e7091 100644 --- a/ci4/app/Controllers/Configuracion/Formaspago.php +++ b/ci4/app/Controllers/Configuracion/Formaspago.php @@ -1,11 +1,12 @@ -viewData['pageTitle'] = lang('FormasPagoes.moduleTitle'); parent::initController($request, $response, $logger); - $this->viewData['usingSweetAlert'] = true; + $this->viewData['usingSweetAlert'] = true; - if (session('errorMessage')) { + if (session('errorMessage')) { $this->session->setFlashData('sweet-error', session('errorMessage')); - } - if (session('successMessage')) { + } + if (session('successMessage')) { $this->session->setFlashData('sweet-success', session('successMessage')); - } + } } - public function index() { - + public function index() + { + $this->viewData['usingClientSideDataTable'] = true; - - $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaPago')]); + + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaPago')]); parent::index(); } - public function add() { - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -52,34 +55,32 @@ class Formaspago extends \App\Controllers\GoBaseController { $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('FormasPagoes.formaPago'))]); - $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', [lang('Basic.global.record')]); + $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('FormasPagoes.formaPago'))]).'.'; - $message .= anchor(route_to('editFormaPago', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -99,14 +100,15 @@ class Formaspago extends \App\Controllers\GoBaseController { $this->viewData['formAction'] = route_to('createFormaPago'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('FormasPagoes.formaPago').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.formaPago') . ' ' . 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; @@ -123,38 +125,35 @@ class Formaspago extends \App\Controllers\GoBaseController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPagoes.formaPago'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $formasPagoEntity->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('FormasPagoes.formaPago'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $formasPagoEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $formasPagoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('FormasPagoes.formaPago'))]).'.'; - $message .= anchor(route_to('editFormaPago', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -165,7 +164,7 @@ class Formaspago extends \App\Controllers\GoBaseController { else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') @@ -173,23 +172,23 @@ class Formaspago extends \App\Controllers\GoBaseController { $this->viewData['formAction'] = route_to('updateFormaPago', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('FormasPagoes.formaPago').' '.lang('Basic.global.edit3'); - - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.formaPago') . ' ' . lang('Basic.global.edit3'); + + return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - - 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(); @@ -202,8 +201,9 @@ class Formaspago extends \App\Controllers\GoBaseController { return $this->failUnauthorized('Invalid request', 403); } } - - public function menuItems() { + + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -214,8 +214,8 @@ class Formaspago extends \App\Controllers\GoBaseController { $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(); @@ -228,5 +228,5 @@ class Formaspago extends \App\Controllers\GoBaseController { return $this->failUnauthorized('Invalid request', 403); } } - + } diff --git a/ci4/app/Controllers/Configuracion/Formaspagos.php b/ci4/app/Controllers/Configuracion/Formaspagos.php index 259760d8..aae07b4a 100644 --- a/ci4/app/Controllers/Configuracion/Formaspagos.php +++ b/ci4/app/Controllers/Configuracion/Formaspagos.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('FormasPagoes.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaDePago')]), - 'formaPagoEntity' => new FormaPagoEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaDePago')]), + 'formaPagoEntity' => new FormaPagoEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewFormaDePagoList', $viewData); + return view(static::$viewPath . 'viewFormaDePagoList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -61,39 +63,37 @@ class Formaspagos 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('FormasPagoes.formaDePago'))]); - $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', [lang('Basic.global.record')]); + $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('FormasPagoes.formaDePago'))]).'.'; - $message .= anchor( "admin/formas-pagos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -109,14 +109,15 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = route_to('createFormaDePago'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('FormasPagoes.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.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,72 +134,68 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPagoes.formaDePago'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $formaPagoEntity->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('FormasPagoes.formaDePago'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $formaPagoEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $formaPagoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('FormasPagoes.formaDePago'))]).'.'; - $message .= anchor( "admin/formas-pagos/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['formaPagoEntity'] = $formaPagoEntity; - $this->viewData['formAction'] = route_to('updateFormaDePago', $id); + $this->viewData['formAction'] = route_to('updateFormaDePago', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.edit3'); + - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('FormasPagoes.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -220,15 +217,16 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController { } } - 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(); @@ -242,7 +240,8 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -253,8 +252,8 @@ class Formaspagos extends \App\Controllers\GoBaseResourceController { $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(); diff --git a/ci4/app/Controllers/Configuracion/Group.php b/ci4/app/Controllers/Configuracion/Group.php index a3513231..e7cf5645 100644 --- a/ci4/app/Controllers/Configuracion/Group.php +++ b/ci4/app/Controllers/Configuracion/Group.php @@ -6,13 +6,13 @@ use App\Controllers\GoBaseResourceController; use App\Models\Usuarios\UserGroupModel; use App\Models\Usuarios\GroupUserModel; -class Group extends \App\Controllers\GoBaseController +class Group extends \App\Controllers\GoBaseController { use \CodeIgniter\API\ResponseTrait; protected static $primaryModelName = 'App\Models\Usuarios\UserGroupModel'; protected $modelName = UserGroupModel::class; - + protected static $singularObjectNameCc = 'userGroup'; protected static $singularObjectName = 'Group'; protected static $pluralObjectName = 'Groups'; @@ -24,22 +24,23 @@ class Group extends \App\Controllers\GoBaseController private $group_user_model; - public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) { + public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) + { $this->viewData['pageTitle'] = lang('Group.moduleTitle'); - self::$viewPath = getenv('theme.path').'form/group/'; + self::$viewPath = getenv('theme.path') . 'form/group/'; parent::initController($request, $response, $logger); - + } public function index() { $this->viewData['usingClientSideDataTable'] = true; - $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Groups.group')]); + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Groups.group')]); // IMN $this->group_user_model = new GroupUserModel(); $this->viewData['model'] = $this->group_user_model; - + parent::index(); } @@ -55,38 +56,36 @@ class Group extends \App\Controllers\GoBaseController $postData = $this->request->getPost(); - $title = $postData['title']; $dashboard = $postData['dashboard']; unset($postData['title']); unset($postData['dashboard']); unset($postData['id_group']); unset($postData['save']); - + $controller = null; $rules_access = null; - foreach ($postData as $key=>$value){ - $exp = explode('_',$key); + foreach ($postData as $key => $value) { + $exp = explode('_', $key); $controller[] = $exp[0]; } - - if($controller != null){ - foreach (array_unique($controller) as $item){ + + if ($controller != null) { + foreach (array_unique($controller) as $item) { $rules_access[$item] = []; - - foreach ($postData as $key=>$value){ - $exp = explode('_',$key); - if($exp[0] == $item){ - array_push($rules_access[$item],str_replace($exp[0].'_','',$key)) ; + + foreach ($postData as $key => $value) { + $exp = explode('_', $key); + if ($exp[0] == $item) { + array_push($rules_access[$item], str_replace($exp[0] . '_', '', $key)); } } } } - - $temp_data['rules'] = json_encode($rules_access??'{}'); + $temp_data['rules'] = json_encode($rules_access ?? '{}'); $temp_data['token'] = md5(uniqid(rand(), true));; $temp_data['title'] = $title; $temp_data['dashboard'] = $dashboard; @@ -97,31 +96,29 @@ class Group extends \App\Controllers\GoBaseController 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('Group.userGroup'))]); - $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', [lang('Basic.global.record')]); + $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('Group.userGroup'))]).'.'; - $message .= anchor( "admin/user-groups/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -134,21 +131,22 @@ class Group extends \App\Controllers\GoBaseController endif; // ($requestMethod === 'post') $this->viewData['group'] = isset($sanitizedData) ? new UserGroupModel($sanitizedData) : new UserGroupModel(); - + $this->viewData['formAction'] = route_to('createGroup'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Group.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Group.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + return $this->displayForm(__METHOD__); } - - public function edit($requestedId = null) { + + public function edit($requestedId = null) + { helper('general'); $session = session(); - + if ($requestedId == null) : return $this->redirect2listView(); endif; @@ -165,7 +163,7 @@ class Group extends \App\Controllers\GoBaseController if ($requestMethod === 'post') : $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); $id_group = $groupEntity->id_group; @@ -180,62 +178,59 @@ class Group extends \App\Controllers\GoBaseController $controller = null; $rules_access = null; - foreach ($postData as $key=>$value){ - $exp = explode('_',$key); + foreach ($postData as $key => $value) { + $exp = explode('_', $key); $controller[] = $exp[0]; } - - if($controller != null){ - foreach (array_unique($controller) as $item){ + + if ($controller != null) { + foreach (array_unique($controller) as $item) { $rules_access[$item] = []; - - foreach ($postData as $key=>$value){ - $exp = explode('_',$key); - if($exp[0] == $item){ - array_push($rules_access[$item],str_replace($exp[0].'_','',$key)) ; + + foreach ($postData as $key => $value) { + $exp = explode('_', $key); + if ($exp[0] == $item) { + array_push($rules_access[$item], str_replace($exp[0] . '_', '', $key)); } } } } - + $temp_data['id_group'] = $id_group; - $temp_data['rules'] = json_encode($rules_access??'{}'); + $temp_data['rules'] = json_encode($rules_access ?? '{}'); $temp_data['token'] = $token; $temp_data['title'] = $title; $temp_data['dashboard'] = $dashboard; $sanitizedData = $this->sanitized($temp_data, $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('Group.userGroup'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $groupEntity->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('Group.userGroup'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $groupEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $groupEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Group.userGroup'))]).'.'; - $message .= anchor(route_to('editGroup', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; - if($session->get('group') == $this->request->getPost('token')){ + if ($session->get('group') == $this->request->getPost('token')) { $session->set('rules', $temp_data['rules']); } if ($thenRedirect) : @@ -247,7 +242,7 @@ class Group extends \App\Controllers\GoBaseController else: $this->viewData['successMessage'] = $message; endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') @@ -255,23 +250,23 @@ class Group extends \App\Controllers\GoBaseController $this->viewData['formAction'] = route_to('updateGroup', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Group.userGroup').' '.lang('Basic.global.edit3'); - - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Group.userGroup') . ' ' . lang('Basic.global.edit3'); + + return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - - 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(); @@ -284,8 +279,9 @@ class Group extends \App\Controllers\GoBaseController return $this->failUnauthorized('Invalid request', 403); } } - - public function menuItems() { + + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -296,8 +292,8 @@ class Group extends \App\Controllers\GoBaseController $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(); diff --git a/ci4/app/Controllers/Configuracion/Imposiciones.php b/ci4/app/Controllers/Configuracion/Imposiciones.php index c684a39d..99df05e4 100644 --- a/ci4/app/Controllers/Configuracion/Imposiciones.php +++ b/ci4/app/Controllers/Configuracion/Imposiciones.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Imposiciones.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Imposiciones.imposicion')]), - 'imposicion' => new Imposicion(), - 'usingServerSideDataTable' => true, - - ]; + '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); + return view(static::$viewPath . 'viewImposicionList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -61,39 +63,37 @@ class Imposiciones 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('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 + 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', [lang('Basic.global.record')]); + $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)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -106,18 +106,19 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['imposicion'] = isset($sanitizedData) ? new Imposicion($sanitizedData) : new Imposicion(); - $this->viewData['orientacionList'] = $this->getOrientacionOptions(); + $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'); - + $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) { - + public function edit($requestedId = null) + { + if ($requestedId == null) : return $this->redirect2listView(); endif; @@ -134,73 +135,69 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->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; + 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)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['orientacionList'] = $this->getOrientacionOptions(); + + $this->viewData['formAction'] = route_to('updateImposicion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $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() { + 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; } $start = $reqData['start'] ?? 0; @@ -222,15 +219,16 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', ancho', 'ancho', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', ancho', 'ancho', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->ancho = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->ancho = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -244,7 +242,8 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -255,8 +254,8 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController { $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(); @@ -271,14 +270,15 @@ class Imposiciones extends \App\Controllers\GoBaseResourceController { } - protected function getOrientacionOptions() { - $orientacionOptions = [ - '' => lang('Basic.global.pleaseSelect'), - 'H' => 'H', - 'V' => 'V', - ]; - return $orientacionOptions; - } + protected function getOrientacionOptions() + { + $orientacionOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'H' => 'H', + 'V' => 'V', + ]; + return $orientacionOptions; + } } diff --git a/ci4/app/Controllers/Configuracion/Maquinas.php b/ci4/app/Controllers/Configuracion/Maquinas.php index 91e9c361..df472836 100644 --- a/ci4/app/Controllers/Configuracion/Maquinas.php +++ b/ci4/app/Controllers/Configuracion/Maquinas.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Maquinas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; @@ -48,24 +49,26 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Maquinas.maquina')]), - 'maquina' => new Maquina(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Maquinas.maquina')]), + 'maquina' => new Maquina(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewMaquinaList', $viewData); + return view(static::$viewPath . 'viewMaquinaList', $viewData); } - public function add() { - + public function add() + { + // JJO $session = session(); @@ -76,42 +79,40 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { $nullIfEmpty = true; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - $sanitizedData['user_created_id'] = $session->id_user; - + $sanitizedData['user_created_id'] = $session->id_user; + $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('Maquinas.maquina'))]); - $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', [lang('Basic.global.record')]); + $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('Maquinas.maquina'))]).'.'; - $message .= anchor( "maquinas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - return redirect()->to(site_url('configuracion/maquinas/edit/'.$id))->with('sweet-success', $message); + return redirect()->to(site_url('configuracion/maquinas/edit/' . $id))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -124,18 +125,19 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['maquina'] = isset($sanitizedData) ? new Maquina($sanitizedData) : new Maquina(); - $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquina->padre_id ?? null); - $this->viewData['tipoList'] = $this->getTipoOptions(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquina->padre_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); $this->viewData['formAction'] = route_to('createMaquina'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Maquinas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Maquinas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + return $this->displayForm(__METHOD__); } // end function add() - public function edit($requestedId = null) { + public function edit($requestedId = null) + { // JJO $session = session(); @@ -156,61 +158,57 @@ class Maquinas 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('is_padre') == null ) { - $sanitizedData['is_padre'] = false; - } - if ($this->request->getPost('is_rotativa') == null ) { - $sanitizedData['is_rotativa'] = false; - } - if ($this->request->getPost('is_tinta') == null ) { - $sanitizedData['is_tinta'] = false; - } - + if ($this->request->getPost('is_padre') == null) { + $sanitizedData['is_padre'] = false; + } + if ($this->request->getPost('is_rotativa') == null) { + $sanitizedData['is_rotativa'] = false; + } + if ($this->request->getPost('is_tinta') == null) { + $sanitizedData['is_tinta'] = false; + } + // JJO - $sanitizedData['user_updated_id'] = $session->id_user; + $sanitizedData['user_updated_id'] = $session->id_user; $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - if ($this->canValidate()) : + + if ($this->canValidate()) : //JJO: comprobar alto y ancho impresion < alto y ancho - if($sanitizedData['alto'] < $sanitizedData['alto_impresion']){ + if ($sanitizedData['alto'] < $sanitizedData['alto_impresion']) { $successfulResult = false; $this->viewData['errorMessage'] = lang('Maquinas.validation.alto_menor_alto_impresion');; - $this->session->setFlashdata('formErrors', $this->model->errors()); - } - else if ($sanitizedData['ancho'] < $sanitizedData['ancho_impresion']){ + $this->session->setFlashdata('formErrors', $this->model->errors()); + } else if ($sanitizedData['ancho'] < $sanitizedData['ancho_impresion']) { $successfulResult = false; $this->viewData['errorMessage'] = lang('Maquinas.validation.ancho_menor_ancho_impresion');; - $this->session->setFlashdata('formErrors', $this->model->errors()); - } - else{ - try { + $this->session->setFlashdata('formErrors', $this->model->errors()); + } else { + 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('Maquinas.maquina'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $maquina->fill($sanitizedData); - $thenRedirect = false; + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Maquinas.maquina'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $maquina->fill($sanitizedData); + + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $maquina->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Maquinas.maquina'))]).'.'; - $message .= anchor( "maquinas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -221,30 +219,30 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['maquina'] = $maquina; - $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquina->padre_id ?? null); - $this->viewData['tipoList'] = $this->getTipoOptions(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquina->padre_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); $this->viewData['formAction'] = route_to('updateMaquina', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Maquinas.moduleTitle').' '.lang('Basic.global.edit3'); - - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Maquinas.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + 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; } $start = $reqData['start'] ?? 0; @@ -255,11 +253,11 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { $dir = $reqData['order']['0']['dir'] ?? 'asc'; $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); - foreach ($resourceData as $item) : + foreach ($resourceData as $item) : if (isset($item->observaciones) && strlen($item->observaciones) > 100) : $item->observaciones = character_limiter($item->observaciones, 100); endif; - endforeach; + endforeach; return $this->respond(Collection::datatable( $resourceData, @@ -271,15 +269,16 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { } } - 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(); @@ -293,7 +292,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -304,8 +304,8 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { $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(); @@ -320,29 +320,31 @@ class Maquinas extends \App\Controllers\GoBaseResourceController { } - protected function getMaquinaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; + protected function getMaquinaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; if (!empty($selId)) : - $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); + $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getTipoOptions() { - $tipoOptions = [ - '' => lang('Basic.global.pleaseSelect'), - 'impresion' => 'impresion', - 'manipulado' => 'manipulado', - 'acabado' => 'acabado', - ]; - return $tipoOptions; - } + protected function getTipoOptions() + { + $tipoOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'impresion' => 'impresion', + 'manipulado' => 'manipulado', + 'acabado' => 'acabado', + ]; + return $tipoOptions; + } } diff --git a/ci4/app/Controllers/Configuracion/Maquinasdefecto.php b/ci4/app/Controllers/Configuracion/Maquinasdefecto.php index 427dbfbc..9c49fc6a 100644 --- a/ci4/app/Controllers/Configuracion/Maquinasdefecto.php +++ b/ci4/app/Controllers/Configuracion/Maquinasdefecto.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('MaquinasPorDefecto.moduleTitle'); $this->viewData['usingSweetAlert'] = true; @@ -42,24 +43,26 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('MaquinasPorDefecto.maquinaPorDefecto')]), - 'maquinasDefectoEntity' => new MaquinasDefectoEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('MaquinasPorDefecto.maquinaPorDefecto')]), + 'maquinasDefectoEntity' => new MaquinasDefectoEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewMaquinaPorDefectoList', $viewData); + return view(static::$viewPath . 'viewMaquinaPorDefectoList', $viewData); } - public function add() { - + public function add() + { + // JJO $session = session(); @@ -70,46 +73,43 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { $nullIfEmpty = true; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO $sanitizedData['user_created_id'] = $session->id_user; - + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()) : // JJO: se añade que se checkeen los intervalos de ancho y tirada. // En caso de error se devuelve un mensaje. - try { + try { $error = $this->model->checkIntervals($sanitizedData); - if(empty($error)){ - $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); - } - else{ + if (empty($error)) { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } else { $successfulResult = false; $this->viewData['errorMessage'] = $error; - $this->session->setFlashdata('formErrors', $this->model->errors()); + $this->session->setFlashdata('formErrors', $this->model->errors()); } - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]); - $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 + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); + $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('MaquinasPorDefecto.maquinaPorDefecto'))]).'.'; - $message .= anchor( "configuracion/maquinasdefecto/edit/{$id}" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -126,19 +126,20 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['maquinasDefectoEntity'] = isset($sanitizedData) ? new MaquinasDefectoEntity($sanitizedData) : new MaquinasDefectoEntity(); - $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasDefectoEntity->maquina_id ?? null); - $this->viewData['tipoList'] = $this->getTipoOptions(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasDefectoEntity->maquina_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); $this->viewData['formAction'] = route_to('createMaquinaPorDefecto'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('MaquinasPorDefecto.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('MaquinasPorDefecto.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + return $this->displayForm(__METHOD__); } // end function add() - public function edit($requestedId = null) { - + public function edit($requestedId = null) + { + // JJO $session = session(); @@ -158,49 +159,46 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); - + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO $sanitizedData['user_updated_id'] = $session->id_user; - + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()) : // JJO: se añade que se checkeen los intervalos de ancho y tirada. // En caso de error se devuelve un mensaje. try { $error = $this->model->checkIntervals($sanitizedData, $id); - if(empty($error)){ - $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); - } - else{ + if (empty($error)) { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } else { $successfulResult = false; $this->viewData['errorMessage'] = $error; - $this->session->setFlashdata('formErrors', $this->model->errors()); + $this->session->setFlashdata('formErrors', $this->model->errors()); } - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $maquinasDefectoEntity->fill($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); - $thenRedirect = true; + endif; + + $maquinasDefectoEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $maquinasDefectoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('MaquinasPorDefecto.maquinaPorDefecto'))]).'.'; - $message .= anchor( "maquinasdefecto/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -211,30 +209,30 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['maquinasDefectoEntity'] = $maquinasDefectoEntity; - $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasDefectoEntity->maquina_id ?? null); - $this->viewData['tipoList'] = $this->getTipoOptions(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasDefectoEntity->maquina_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); $this->viewData['formAction'] = route_to('updateMaquinaPorDefecto', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('MaquinasPorDefecto.moduleTitle').' '.lang('Basic.global.edit3'); - - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('MaquinasPorDefecto.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + 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; } $start = $reqData['start'] ?? 0; @@ -259,15 +257,16 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', tipo', 'tipo', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', tipo', 'tipo', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->tipo = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->tipo = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -281,7 +280,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -292,8 +292,8 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { $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(); @@ -308,32 +308,34 @@ class Maquinasdefecto extends \App\Controllers\GoBaseResourceController { } - protected function getMaquinaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; + protected function getMaquinaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; if (!empty($selId)) : - $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); + $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getTipoOptions() { - $tipoOptions = [ - '' => lang('Basic.global.pleaseSelect'), - 'bn' => 'bn', - 'bnhq' => 'bnhq', - 'color' => 'color', - 'portada' => 'portada', - 'cubierta' => 'cubierta', - 'rotativa' => 'rotativa', - ]; - return $tipoOptions; - } + protected function getTipoOptions() + { + $tipoOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'bn' => 'bn', + 'bnhq' => 'bnhq', + 'color' => 'color', + 'portada' => 'portada', + 'cubierta' => 'cubierta', + 'rotativa' => 'rotativa', + ]; + return $tipoOptions; + } //sanitiezdata diff --git a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php index 0b04e2a6..a6096779 100644 --- a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php +++ b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('MaquinasTarifasImpresions.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')]), - 'maquinasTarifasImpresion' => new MaquinasTarifasImpresion(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')]), + 'maquinasTarifasImpresion' => new MaquinasTarifasImpresion(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewMaquinasTarifaImpresionList', $viewData); + return view(static::$viewPath . 'viewMaquinasTarifaImpresionList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -74,35 +76,33 @@ class Maquinastarifasimpresion 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('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]); - $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', [lang('Basic.global.record')]); + $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('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]).'.'; - $message .= anchor( "maquinastarifasimpresion/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -119,19 +119,20 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController endif; // ($requestMethod === 'post') $this->viewData['maquinasTarifasImpresion'] = isset($sanitizedData) ? new MaquinasTarifasImpresion($sanitizedData) : new MaquinasTarifasImpresion(); - $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasTarifasImpresion->maquina_id ?? null); - $this->viewData['tipoList'] = $this->getTipoOptions(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasTarifasImpresion->maquina_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); $this->viewData['formAction'] = route_to('createMaquinasTarifaImpresion'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('MaquinasTarifasImpresions.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('MaquinasTarifasImpresions.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; @@ -148,43 +149,39 @@ class Maquinastarifasimpresion 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('predeterminado') == null ) { - $sanitizedData['predeterminado'] = false; - } + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('predeterminado') == null) { + $sanitizedData['predeterminado'] = 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('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $maquinasTarifasImpresion->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('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $maquinasTarifasImpresion->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $maquinasTarifasImpresion->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion'))]).'.'; - $message .= anchor( "maquinastarifasimpresion/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -195,110 +192,110 @@ if ($this->request->getPost('predeterminado') == null ) { else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['maquinasTarifasImpresion'] = $maquinasTarifasImpresion; - $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasTarifasImpresion->maquina_id ?? null); - $this->viewData['tipoList'] = $this->getTipoOptions(); + $this->viewData['maquinaList'] = $this->getMaquinaListItems($maquinasTarifasImpresion->maquina_id ?? null); + $this->viewData['tipoList'] = $this->getTipoOptions(); + + $this->viewData['formAction'] = route_to('updateMaquinasTarifaImpresion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('MaquinasTarifasImpresions.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateMaquinasTarifaImpresion', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('MaquinasTarifasImpresions.moduleTitle').' '.lang('Basic.global.edit3'); - - return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - public function datatable_editor() { + + public function datatable_editor() + { if ($this->request->isAJAX()) { include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); // Build our Editor instance and process the data coming from _POST - $response = Editor::inst( $db, 'lg_maquinas_tarifas_impresion' ) - ->fields( - Field::inst( 'uso' ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('MaquinasTarifasImpresions.validation.uso.required') ) - ), - Field::inst( 'tipo' ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') ) - ), - Field::inst( 'precio' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') ) - ), - Field::inst( 'maquina_id' ), - Field::inst( 'user_created_id' ), - Field::inst( 'created_at' ), - Field::inst( 'user_updated_id' ), - Field::inst( 'updated_at' ), - Field::inst( 'is_deleted' ), - Field::inst( 'deleted_at' ), - - ) - ->validator( function($editor, $action, $data){ - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ - foreach ($data['data'] as $pkey => $values ){ - // Si no se quiere borrar... - if($data['data'][$pkey]['is_deleted'] != 1) - { - // Cubierta y sobrecubierta sólo pueden ser en color - if($values['uso'] != 'interior' && $values['tipo'] != 'color'){ - return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color'); - } + $response = Editor::inst($db, 'lg_maquinas_tarifas_impresion') + ->fields( + Field::inst('uso') + ->validator('Validate::notEmpty', array( + 'message' => lang('MaquinasTarifasImpresions.validation.uso.required')) + ), + Field::inst('tipo') + ->validator('Validate::notEmpty', array( + 'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) + ), + Field::inst('precio') + ->validator('Validate::numeric', array( + 'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')) + ), + Field::inst('maquina_id'), + Field::inst('user_created_id'), + Field::inst('created_at'), + Field::inst('user_updated_id'), + Field::inst('updated_at'), + Field::inst('is_deleted'), + Field::inst('deleted_at'), - $builder = $this->model->select('*') - ->where(array( - 'maquina_id'=> $values['maquina_id'], - 'tipo'=> $values['tipo'], - 'uso'=> $values['uso'], - 'is_deleted'=> 0)); + ) + ->validator(function ($editor, $action, $data) { + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { + foreach ($data['data'] as $pkey => $values) { + // Si no se quiere borrar... + if ($data['data'][$pkey]['is_deleted'] != 1) { + // Cubierta y sobrecubierta sólo pueden ser en color + if ($values['uso'] != 'interior' && $values['tipo'] != 'color') { + return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color'); + } - // No se pueden duplicar valores al crear o al editar - if ($builder->countAllResults() >= 1){ - if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey) - || $action === Editor::ACTION_CREATE){ - - return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo'); + $builder = $this->model->select('*') + ->where(array( + 'maquina_id' => $values['maquina_id'], + 'tipo' => $values['tipo'], + 'uso' => $values['uso'], + 'is_deleted' => 0)); + + // No se pueden duplicar valores al crear o al editar + if ($builder->countAllResults() >= 1) { + if (($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey) + || $action === Editor::ACTION_CREATE) { + + return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo'); + } } } } } - } - }) - ->on( 'preCreate', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_created_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'created_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->on( 'preEdit', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_updated_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'updated_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->debug(true) - ->process( $_POST ) - ->data(); + }) + ->on('preCreate', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_created_id') + ->setValue($session->id_user); + $editor + ->field('created_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->on('preEdit', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->debug(true) + ->process($_POST) + ->data(); + - /*// if unique key is set in DB if(isset($response['error'])){ if(str_contains($response['error'], "tirada_min_tirada_max") && @@ -307,10 +304,10 @@ if ($this->request->getPost('predeterminado') == null ) { } }*/ $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - + $csrfTokenName = csrf_token(); + $response[$csrfTokenName] = $newTokenHash; - + echo json_encode($response); } else { @@ -318,12 +315,13 @@ if ($this->request->getPost('predeterminado') == null ) { } } - 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; } $start = $reqData['start'] ?? 0; @@ -347,15 +345,16 @@ if ($this->request->getPost('predeterminado') == null ) { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', maquina_id', 'maquina_id', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', maquina_id', 'maquina_id', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->maquina_id = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->maquina_id = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -369,7 +368,8 @@ if ($this->request->getPost('predeterminado') == 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]; @@ -380,8 +380,8 @@ if ($this->request->getPost('predeterminado') == 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(); @@ -396,30 +396,32 @@ if ($this->request->getPost('predeterminado') == null ) { } - protected function getMaquinaListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; + protected function getMaquinaListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; if (!empty($selId)) : - $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); + $maquinaModel = model('App\Models\Configuracion\MaquinaModel'); $selOption = $maquinaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } - protected function getTipoOptions() { - $tipoOptions = [ - '' => lang('Basic.global.pleaseSelect'), - 'negro' => 'negro', - 'color' => 'color', - 'negrohq' => 'negrohq', - 'bicolor' => 'bicolor', - ]; - return $tipoOptions; - } + protected function getTipoOptions() + { + $tipoOptions = [ + '' => lang('Basic.global.pleaseSelect'), + 'negro' => 'negro', + 'color' => 'color', + 'negrohq' => 'negrohq', + 'bicolor' => 'bicolor', + ]; + return $tipoOptions; + } } diff --git a/ci4/app/Controllers/Configuracion/Paises.php b/ci4/app/Controllers/Configuracion/Paises.php index af70b4e1..c31ced9e 100644 --- a/ci4/app/Controllers/Configuracion/Paises.php +++ b/ci4/app/Controllers/Configuracion/Paises.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Paises.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Paises.pais')]), - 'paisEntity' => new PaisEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Paises.pais')]), + 'paisEntity' => new PaisEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewPaisList', $viewData); + return view(static::$viewPath . 'viewPaisList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -61,39 +63,37 @@ class Paises 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('Paises.pais'))]); - $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', [lang('Basic.global.record')]); + $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('Paises.pais'))]).'.'; - $message .= anchor( "admin/paises/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -109,14 +109,15 @@ class Paises extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = route_to('createPais'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Paises.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Paises.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,75 +134,71 @@ class Paises 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_erp') == null ) { - $sanitizedData['show_erp'] = false; - } + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('show_erp') == null) { + $sanitizedData['show_erp'] = 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('Paises.pais'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $paisEntity->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('Paises.pais'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $paisEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $paisEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Paises.pais'))]).'.'; - $message .= anchor( "admin/paises/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['paisEntity'] = $paisEntity; - $this->viewData['formAction'] = route_to('updatePais', $id); + $this->viewData['formAction'] = route_to('updatePais', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Paises.moduleTitle') . ' ' . lang('Basic.global.edit3'); + - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Paises.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -223,15 +220,16 @@ if ($this->request->getPost('show_erp') == 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(); @@ -245,7 +243,8 @@ if ($this->request->getPost('show_erp') == 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]; @@ -256,8 +255,8 @@ if ($this->request->getPost('show_erp') == 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(); diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index 407abe29..e19cdf0b 100644 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -95,7 +95,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController $this->dealWithException($e); } else : - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; @@ -105,9 +105,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController $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)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -185,9 +183,7 @@ class Papelesgenericos extends \App\Controllers\GoBaseResourceController 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)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : diff --git a/ci4/app/Controllers/Configuracion/Papelesimpresion.php b/ci4/app/Controllers/Configuracion/Papelesimpresion.php index 05143b21..49a439c7 100644 --- a/ci4/app/Controllers/Configuracion/Papelesimpresion.php +++ b/ci4/app/Controllers/Configuracion/Papelesimpresion.php @@ -118,7 +118,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController $this->dealWithException($e); } else : - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelImpresion.papelImpresion'))]); + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; @@ -128,9 +128,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController $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)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -232,9 +230,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController 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)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : diff --git a/ci4/app/Controllers/Configuracion/Papelimpresiontipologias.php b/ci4/app/Controllers/Configuracion/Papelimpresiontipologias.php index b9163562..9e253f68 100644 --- a/ci4/app/Controllers/Configuracion/Papelimpresiontipologias.php +++ b/ci4/app/Controllers/Configuracion/Papelimpresiontipologias.php @@ -78,7 +78,7 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController $this->dealWithException($e); } else: - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]); + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; @@ -88,9 +88,7 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController $id = $this->model->db->insertID(); - $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.'; - $message .= anchor( "papelimpresiontipologias/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -177,9 +175,7 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController if ($noException && $successfulResult) : $id = $papelImpresionTipologia->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.'; - $message .= anchor( "papelimpresiontipologias/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : diff --git a/ci4/app/Controllers/Configuracion/Provincias.php b/ci4/app/Controllers/Configuracion/Provincias.php index 0344c0b1..0ccb0db1 100644 --- a/ci4/app/Controllers/Configuracion/Provincias.php +++ b/ci4/app/Controllers/Configuracion/Provincias.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Provincias.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Provincias.provincia')]), - 'provinciaEntity' => new ProvinciaEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Provincias.provincia')]), + 'provinciaEntity' => new ProvinciaEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewProvinciaList', $viewData); + return view(static::$viewPath . 'viewProvinciaList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -63,39 +65,37 @@ class Provincias 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('Provincias.provincia'))]); - $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', [lang('Basic.global.record')]); + $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('Provincias.provincia'))]).'.'; - $message .= anchor( "admin/provincias/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; @@ -108,18 +108,19 @@ class Provincias extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['provinciaEntity'] = isset($sanitizedData) ? new ProvinciaEntity($sanitizedData) : new ProvinciaEntity(); - $this->viewData['paisList'] = $this->getPaisListItems($provinciaEntity->pais_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($provinciaEntity->pais_id ?? null); $this->viewData['formAction'] = route_to('createProvincia'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Provincias.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Provincias.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; @@ -136,73 +137,69 @@ class Provincias extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Provincias.provincia'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $provinciaEntity->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('Provincias.provincia'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $provinciaEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $provinciaEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Provincias.provincia'))]).'.'; - $message .= anchor( "admin/provincias/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + 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['provinciaEntity'] = $provinciaEntity; - $this->viewData['paisList'] = $this->getPaisListItems($provinciaEntity->pais_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems($provinciaEntity->pais_id ?? null); + + $this->viewData['formAction'] = route_to('updateProvincia', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Provincias.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateProvincia', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Provincias.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -224,15 +221,16 @@ class Provincias extends \App\Controllers\GoBaseResourceController { } } - 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(); @@ -246,7 +244,8 @@ class Provincias extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -257,8 +256,8 @@ class Provincias extends \App\Controllers\GoBaseResourceController { $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(); @@ -273,17 +272,18 @@ class Provincias extends \App\Controllers\GoBaseResourceController { } - protected function getPaisListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; + protected function getPaisListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Paises.pais'))])]; if (!empty($selId)) : - $paisModel = model('App\Models\Configuracion\PaisModel'); + $paisModel = model('App\Models\Configuracion\PaisModel'); $selOption = $paisModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } } diff --git a/ci4/app/Controllers/Configuracion/Tipologias.php b/ci4/app/Controllers/Configuracion/Tipologias.php index d3ae3812..706cd089 100644 --- a/ci4/app/Controllers/Configuracion/Tipologias.php +++ b/ci4/app/Controllers/Configuracion/Tipologias.php @@ -1,11 +1,12 @@ -viewData['pageTitle'] = lang('TipologiasLibros.moduleTitle'); parent::initController($request, $response, $logger); - + } - public function index() { - + public function index() + { + $this->viewData['usingClientSideDataTable'] = true; - - $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('TipologiasLibros.tipologiaLibros')]); + + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('TipologiasLibros.tipologiaLibros')]); parent::index(); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -46,34 +48,32 @@ class Tipologias extends \App\Controllers\GoBaseController { $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('TipologiasLibros.tipologiaLibros'))]); - $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', [lang('Basic.global.record')]); + $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('TipologiasLibros.tipologiaLibros'))]).'.'; - $message .= anchor(route_to('editTipologiaLibros', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -93,14 +93,15 @@ class Tipologias extends \App\Controllers\GoBaseController { $this->viewData['formAction'] = route_to('createTipologiaLibros'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TipologiasLibros.tipologiaLibros').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TipologiasLibros.tipologiaLibros') . ' ' . 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; @@ -117,39 +118,35 @@ class Tipologias extends \App\Controllers\GoBaseController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TipologiasLibros.tipologiaLibros'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $tipologiasEntity->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('TipologiasLibros.tipologiaLibros'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tipologiasEntity->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $tipologiasEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TipologiasLibros.tipologiaLibros'))]).'.'; - $message .= anchor(route_to('editTipologiaLibros', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -160,7 +157,7 @@ class Tipologias extends \App\Controllers\GoBaseController { else: $this->viewData['successMessage'] = $message; endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') @@ -168,23 +165,23 @@ class Tipologias extends \App\Controllers\GoBaseController { $this->viewData['formAction'] = route_to('updateTipologiaLibros', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TipologiasLibros.tipologiaLibros').' '.lang('Basic.global.edit3'); - - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TipologiasLibros.tipologiaLibros') . ' ' . lang('Basic.global.edit3'); + + return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - - 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(); @@ -197,8 +194,9 @@ class Tipologias extends \App\Controllers\GoBaseController { return $this->failUnauthorized('Invalid request', 403); } } - - public function menuItems() { + + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -209,8 +207,8 @@ class Tipologias extends \App\Controllers\GoBaseController { $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(); @@ -223,5 +221,5 @@ class Tipologias extends \App\Controllers\GoBaseController { return $this->failUnauthorized('Invalid request', 403); } } - + } diff --git a/ci4/app/Controllers/GoBaseResourceController.php b/ci4/app/Controllers/GoBaseResourceController.php index 7310be40..86433d87 100644 --- a/ci4/app/Controllers/GoBaseResourceController.php +++ b/ci4/app/Controllers/GoBaseResourceController.php @@ -68,6 +68,15 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon */ public $delete_flag = 0; + /** + * IMN: Variable para seleccionar el tipo de mensajeria que usa una clase + * + * 'alerts' -> Boostrap 5 default alerts + * 'toastr' -> Javascript ToastR library + * @var string + */ + public $alertStyle = 'alerts'; + /** * An array of helpers to be loaded automatically upon @@ -116,6 +125,9 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon $this->viewData['viewPath'] = static::$viewPath; $this->viewData['currentLocale'] = $this->request->getLocale(); + + /* IMN */ + $this->viewData['alertStyle'] = $this->alertStyle; } /** diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabado.php b/ci4/app/Controllers/Tarifas/Tarifaacabado.php index 2b56abff..cc80c24d 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabado.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabado.php @@ -98,7 +98,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController $this->dealWithException($e); } else: - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]); + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; @@ -108,9 +108,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController $id = $this->model->db->insertID(); - $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]) . '.'; - $message .= anchor("tarifasacabado/{$id}/edit", lang('Basic.global.continueEditing') . '?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -120,9 +118,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController return $this->redirect2listView('sweet-success', $message); endif; else: - //JJO - $this->viewData['successMessage'] = $message; - //$this->session->setFlashData('sweet-success', $message); + $this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult @@ -194,9 +190,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController if ($noException && $successfulResult) : $id = $tarifaacabadoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaacabado.tarifaacabado'))]) . '.'; - //$message .= anchor("tarifasacabado/{$id}/edit", lang('Basic.global.continueEditing') . '?'); - //$message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -205,8 +199,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController return $this->redirect2listView('sweet-success', $message); endif; else: - //JJO - $this->viewData['successMessage'] = $message; + $this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php index 9e965574..e185ccca 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('TarifaAcabadoLineas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaAcabadoLineas.tarifaAcabadoLinea')]), - 'tarifaAcabadoLinea' => new TarifaAcabadoLinea(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaAcabadoLineas.tarifaAcabadoLinea')]), + 'tarifaAcabadoLinea' => new TarifaAcabadoLinea(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewTarifaAcabadoLineaList', $viewData); + return view(static::$viewPath . 'viewTarifaAcabadoLineaList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -76,35 +78,33 @@ class Tarifaacabadolineas 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('TarifaAcabadoLineas.tarifaAcabadoLinea'))]); - $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', [lang('Basic.global.record')]); + $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('TarifaAcabadoLineas.tarifaAcabadoLinea'))]).'.'; - $message .= anchor( "tarifa-acabado-lineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -121,18 +121,19 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { endif; // ($requestMethod === 'post') $this->viewData['tarifaAcabadoLinea'] = isset($sanitizedData) ? new TarifaAcabadoLinea($sanitizedData) : new TarifaAcabadoLinea(); - $this->viewData['tarifaAcabadoList'] = $this->getTarifaAcabadoListItems($tarifaAcabadoLinea->tarifa_acabado_id ?? null); + $this->viewData['tarifaAcabadoList'] = $this->getTarifaAcabadoListItems($tarifaAcabadoLinea->tarifa_acabado_id ?? null); $this->viewData['formAction'] = route_to('createTarifaAcabadoLinea'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaAcabadoLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifaAcabadoLineas.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; @@ -149,40 +150,36 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $tarifaAcabadoLinea->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('TarifaAcabadoLineas.tarifaAcabadoLinea'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaAcabadoLinea->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $tarifaAcabadoLinea->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaAcabadoLineas.tarifaAcabadoLinea'))]).'.'; - $message .= anchor( "tarifa-acabado-lineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -193,29 +190,29 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['tarifaAcabadoLinea'] = $tarifaAcabadoLinea; - $this->viewData['tarifaAcabadoList'] = $this->getTarifaAcabadoListItems($tarifaAcabadoLinea->tarifa_acabado_id ?? null); + $this->viewData['tarifaAcabadoList'] = $this->getTarifaAcabadoListItems($tarifaAcabadoLinea->tarifa_acabado_id ?? null); + + $this->viewData['formAction'] = route_to('updateTarifaAcabadoLinea', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifaAcabadoLineas.moduleTitle') . ' ' . lang('Basic.global.edit3'); - $this->viewData['formAction'] = route_to('updateTarifaAcabadoLinea', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaAcabadoLineas.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } @@ -226,10 +223,10 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { $order = TarifaAcabadoLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0]; $dir = $reqData['order']['0']['dir'] ?? 'asc'; - + $id_TA = $reqData['id_tarifaacabado'] ?? -1; - + $resourceData = $this->model->getResource("", $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( @@ -242,98 +239,99 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { } } - public function datatable_editor() { + public function datatable_editor() + { if ($this->request->isAJAX()) { include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); // Build our Editor instance and process the data coming from _POST - $response = Editor::inst( $db, 'tarifa_acabado_lineas' ) - ->fields( - Field::inst( 'paginas_min' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') ) - ), - Field::inst( 'paginas_max' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') ) - ), - Field::inst( 'precio_min' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') ) - ), - Field::inst( 'precio_max' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') ) - ), - Field::inst( 'margen' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required') ) - ), - Field::inst( 'tarifa_acabado_id' ), - Field::inst( 'user_created_id' ), - Field::inst( 'created_at' ), - Field::inst( 'user_updated_id' ), - Field::inst( 'updated_at' ), - Field::inst( 'is_deleted' ), - Field::inst( 'deleted_at' ), - - ) - ->validator( function($editor, $action, $data){ - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ - foreach ($data['data'] as $pkey => $values ){ - // Si no se quiere borrar... - if($data['data'][$pkey]['is_deleted'] != 1){ + $response = Editor::inst($db, 'tarifa_acabado_lineas') + ->fields( + Field::inst('paginas_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + ), + Field::inst('paginas_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + ), + Field::inst('precio_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ), + Field::inst('precio_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) + ), + Field::inst('margen') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ), + Field::inst('tarifa_acabado_id'), + Field::inst('user_created_id'), + Field::inst('created_at'), + Field::inst('user_updated_id'), + Field::inst('updated_at'), + Field::inst('is_deleted'), + Field::inst('deleted_at'), - $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; - $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; - $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']); - // No se pueden duplicar valores al crear o al editar - if (!empty($response)){ - return $response; + ) + ->validator(function ($editor, $action, $data) { + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { + foreach ($data['data'] as $pkey => $values) { + // Si no se quiere borrar... + if ($data['data'][$pkey]['is_deleted'] != 1) { + + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)) { + return $response; + } } - } + } } - } - }) - ->on( 'preCreate', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_created_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'created_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->on( 'preEdit', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_updated_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'updated_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->debug(true) - ->process( $_POST ) - ->data(); + }) + ->on('preCreate', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_created_id') + ->setValue($session->id_user); + $editor + ->field('created_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->on('preEdit', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->debug(true) + ->process($_POST) + ->data(); // if unique key is set in DB /*if(isset($response['error'])){ @@ -343,10 +341,10 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { } }*/ $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - + $csrfTokenName = csrf_token(); + $response[$csrfTokenName] = $newTokenHash; - + echo json_encode($response); } else { @@ -354,15 +352,16 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', tarifa_acabado_id', 'tarifa_acabado_id', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', tarifa_acabado_id', 'tarifa_acabado_id', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->tarifa_acabado_id = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->tarifa_acabado_id = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -376,7 +375,8 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -387,8 +387,8 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { $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(); @@ -403,17 +403,18 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController { } - protected function getTarifaAcabadoListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Tarifaacabado.tarifaAcabado'))])]; + protected function getTarifaAcabadoListItems($selId = null) + { + $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Tarifaacabado.tarifaAcabado'))])]; if (!empty($selId)) : - $tarifaacabadoModel = model('App\Models\tarifas\TarifaacabadoModel'); + $tarifaacabadoModel = model('App\Models\tarifas\TarifaacabadoModel'); $selOption = $tarifaacabadoModel->where('id', $selId)->findColumn('id'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; endif; - return $data; - } + return $data; + } } diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php index 178dbf92..d4360bbe 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('TarifaEncuadernacionLineas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')]), - 'tarifaEncuadernacionLinea' => new TarifaEncuadernacionLinea(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')]), + 'tarifaEncuadernacionLinea' => new TarifaEncuadernacionLinea(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewTarifaEncuadernacionLineaList', $viewData); + return view(static::$viewPath . 'viewTarifaEncuadernacionLineaList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -73,35 +75,33 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $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('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]); - $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', [lang('Basic.global.record')]); + $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('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]).'.'; - $message .= anchor( "tarifaencuadernacionlineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -121,14 +121,15 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $this->viewData['formAction'] = route_to('createTarifaEncuadernacionLinea'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaEncuadernacionLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifaEncuadernacionLineas.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; @@ -145,40 +146,36 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $tarifaEncuadernacionLinea->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('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaEncuadernacionLinea->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $tarifaEncuadernacionLinea->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea'))]).'.'; - $message .= anchor( "tarifaencuadernacionlineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -189,119 +186,119 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['tarifaEncuadernacionLinea'] = $tarifaEncuadernacionLinea; - $this->viewData['formAction'] = route_to('updateTarifaEncuadernacionLinea', $id); + $this->viewData['formAction'] = route_to('updateTarifaEncuadernacionLinea', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifaEncuadernacionLineas.moduleTitle') . ' ' . lang('Basic.global.edit3'); + - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaEncuadernacionLineas.moduleTitle').' '.lang('Basic.global.edit3'); - - return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - public function datatable_editor() { + + public function datatable_editor() + { if ($this->request->isAJAX()) { include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); // Build our Editor instance and process the data coming from _POST - $response = Editor::inst( $db, 'tarifa_encuadernacion_lineas' ) - ->fields( - Field::inst( 'paginas_min' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') ) - ), - Field::inst( 'paginas_max' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') ) - ), - Field::inst( 'precio_min' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') ) - ), - Field::inst( 'precio_max' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') ) - ), - Field::inst( 'margen' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required') ) - ), - Field::inst( 'tarifa_encuadernacion_id' ), - Field::inst( 'user_created_id' ), - Field::inst( 'created_at' ), - Field::inst( 'user_updated_id' ), - Field::inst( 'updated_at' ), - Field::inst( 'is_deleted' ), - Field::inst( 'deleted_at' ), - - ) - ->validator( function($editor, $action, $data){ - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ - foreach ($data['data'] as $pkey => $values ){ - // Si no se quiere borrar... - if($data['data'][$pkey]['is_deleted'] != 1) - { - $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; - $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; - $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_encuadernacion_id']); - // No se pueden duplicar valores al crear o al editar - if (!empty($response)){ - return $response; + $response = Editor::inst($db, 'tarifa_encuadernacion_lineas') + ->fields( + Field::inst('paginas_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + ), + Field::inst('paginas_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + ), + Field::inst('precio_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ), + Field::inst('precio_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) + ), + Field::inst('margen') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ), + Field::inst('tarifa_encuadernacion_id'), + Field::inst('user_created_id'), + Field::inst('created_at'), + Field::inst('user_updated_id'), + Field::inst('updated_at'), + Field::inst('is_deleted'), + Field::inst('deleted_at'), + + ) + ->validator(function ($editor, $action, $data) { + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { + foreach ($data['data'] as $pkey => $values) { + // Si no se quiere borrar... + if ($data['data'][$pkey]['is_deleted'] != 1) { + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_encuadernacion_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)) { + return $response; + } } } } - } - }) - ->on( 'preCreate', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_created_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'created_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->on( 'preEdit', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_updated_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'updated_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->debug(true) - ->process( $_POST ) - ->data(); + }) + ->on('preCreate', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_created_id') + ->setValue($session->id_user); + $editor + ->field('created_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->on('preEdit', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->debug(true) + ->process($_POST) + ->data(); $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - + $csrfTokenName = csrf_token(); + $response[$csrfTokenName] = $newTokenHash; - + echo json_encode($response); } else { @@ -309,12 +306,13 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll } } - 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; } $start = $reqData['start'] ?? 0; @@ -325,7 +323,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $dir = $reqData['order']['0']['dir'] ?? 'asc'; $id_TM = $reqData['id_tarifaencuadernacion'] ?? -1; - + $resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( @@ -338,15 +336,16 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', tarifa_encuadernacion_id', 'tarifa_encuadernacion_id', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', tarifa_encuadernacion_id', 'tarifa_encuadernacion_id', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->tarifa_encuadernacion_id = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->tarifa_encuadernacion_id = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -360,7 +359,8 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -371,8 +371,8 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $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(); diff --git a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php index a663c868..a9542460 100644 --- a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('TarifaManipuladoLineas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaManipuladoLineas.tarifamanipuladoLinea')]), - 'tarifaManipuladoLinea' => new TarifaManipuladoLinea(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaManipuladoLineas.tarifamanipuladoLinea')]), + 'tarifaManipuladoLinea' => new TarifaManipuladoLinea(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewTarifaManipuladoLineaList', $viewData); + return view(static::$viewPath . 'viewTarifaManipuladoLineaList', $viewData); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -73,35 +75,33 @@ class Tarifamanipuladolineas 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('TarifaManipuladoLineas.tarifamanipuladoLinea'))]); - $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', [lang('Basic.global.record')]); + $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('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.'; - $message .= anchor( "tarifamanipuladolineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -121,14 +121,15 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = route_to('createTarifaManipuladoLinea'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaManipuladoLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('TarifaManipuladoLineas.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; @@ -145,40 +146,36 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $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)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $tarifaManipuladoLinea->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('TarifaManipuladoLineas.tarifamanipuladoLinea'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $tarifaManipuladoLinea->fill($sanitizedData); + + $thenRedirect = true; endif; if ($noException && $successfulResult) : $id = $tarifaManipuladoLinea->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.'; - $message .= anchor( "tarifamanipuladolineas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -189,119 +186,119 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { else: $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['tarifaManipuladoLinea'] = $tarifaManipuladoLinea; - $this->viewData['formAction'] = route_to('updateTarifaManipuladoLinea', $id); + $this->viewData['formAction'] = route_to('updateTarifaManipuladoLinea', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('TarifaManipuladoLineas.moduleTitle') . ' ' . lang('Basic.global.edit3'); + - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaManipuladoLineas.moduleTitle').' '.lang('Basic.global.edit3'); - - return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - public function datatable_editor() { + + public function datatable_editor() + { if ($this->request->isAJAX()) { include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); // Build our Editor instance and process the data coming from _POST - $response = Editor::inst( $db, 'tarifa_manipulado_lineas' ) - ->fields( - Field::inst( 'paginas_min' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required') ) - ), - Field::inst( 'paginas_max' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required') ) - ), - Field::inst( 'precio_min' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') ) - ), - Field::inst( 'precio_max' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') ) - ), - Field::inst( 'margen' ) - ->validator( 'Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') ) - ) - ->validator( 'Validate::notEmpty',array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required') ) - ), - Field::inst( 'tarifa_manipulado_id' ), - Field::inst( 'user_created_id' ), - Field::inst( 'created_at' ), - Field::inst( 'user_updated_id' ), - Field::inst( 'updated_at' ), - Field::inst( 'is_deleted' ), - Field::inst( 'deleted_at' ), - - ) - ->validator( function($editor, $action, $data){ - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){ - foreach ($data['data'] as $pkey => $values ){ - // Si no se quiere borrar... - if($data['data'][$pkey]['is_deleted'] != 1) - { - $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; - $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; - $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_manipulado_id']); - // No se pueden duplicar valores al crear o al editar - if (!empty($response)){ - return $response; + $response = Editor::inst($db, 'tarifa_manipulado_lineas') + ->fields( + Field::inst('paginas_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + ), + Field::inst('paginas_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + ), + Field::inst('precio_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ), + Field::inst('precio_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) + ), + Field::inst('margen') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ), + Field::inst('tarifa_manipulado_id'), + Field::inst('user_created_id'), + Field::inst('created_at'), + Field::inst('user_updated_id'), + Field::inst('updated_at'), + Field::inst('is_deleted'), + Field::inst('deleted_at'), + + ) + ->validator(function ($editor, $action, $data) { + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { + foreach ($data['data'] as $pkey => $values) { + // Si no se quiere borrar... + if ($data['data'][$pkey]['is_deleted'] != 1) { + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_manipulado_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)) { + return $response; + } } } } - } - }) - ->on( 'preCreate', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_created_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'created_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->on( 'preEdit', function ( $editor, &$values ) { - $session = session(); - $datetime = (new \CodeIgniter\I18n\Time("now")); - $editor - ->field( 'user_updated_id' ) - ->setValue( $session->id_user ); - $editor - ->field( 'updated_at' ) - ->setValue( $datetime->format('Y-m-d H:i:s') ); - } ) - ->debug(true) - ->process( $_POST ) - ->data(); + }) + ->on('preCreate', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_created_id') + ->setValue($session->id_user); + $editor + ->field('created_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->on('preEdit', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->debug(true) + ->process($_POST) + ->data(); $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - + $csrfTokenName = csrf_token(); + $response[$csrfTokenName] = $newTokenHash; - + echo json_encode($response); } else { @@ -309,12 +306,13 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { } } - 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; } $start = $reqData['start'] ?? 0; @@ -325,7 +323,7 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { $dir = $reqData['order']['0']['dir'] ?? 'asc'; $id_TM = $reqData['id_tarifamanipulado'] ?? -1; - + $resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( @@ -338,15 +336,16 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { } } - public function allItemsSelect() { + public function allItemsSelect() + { if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal.', tarifa_manipulado_id', 'tarifa_manipulado_id', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', tarifa_manipulado_id', 'tarifa_manipulado_id', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->tarifa_manipulado_id = '- '.lang('Basic.global.None').' -'; - array_unshift($menu , $nonItem); + $nonItem->tarifa_manipulado_id = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -360,7 +359,8 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -371,8 +371,8 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { $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(); diff --git a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php index 6a0f0742..b7f74a3c 100644 --- a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php +++ b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php @@ -1,11 +1,12 @@ -viewData['pageTitle'] = lang('Tarifapreimpresion.moduleTitle'); // Se indica que este controlador trabaja con soft_delete $this->soft_delete = true; @@ -34,21 +35,22 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { ]; parent::initController($request, $response, $logger); - + } - public function index() { - + public function index() + { + $this->viewData['usingClientSideDataTable'] = true; - - $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]); + + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifapreimpresion.tarifapreimpresion')]); parent::index(); } - public function add() { - - + public function add() + { + $requestMethod = $this->request->getMethod(); @@ -57,34 +59,32 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { $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('Tarifapreimpresion.tarifapreimpresion'))]); - $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', [lang('Basic.global.record')]); + $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('Tarifapreimpresion.tarifapreimpresion'))]).'.'; - $message .= anchor(route_to('editTarifapreimpresion', $id), lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -93,7 +93,7 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { return $this->redirect2listView('successMessage', $message); endif; else: - $this->viewData['successMessage'] = $message; + $this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult @@ -104,14 +104,15 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { $this->viewData['formAction'] = route_to('createTarifapreimpresion'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifapreimpresion.tarifapreimpresion').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifapreimpresion.tarifapreimpresion') . ' ' . lang('Basic.global.addNewSuffix'); + return $this->displayForm(__METHOD__); } // end function add() - public function edit($requestedId = null) { - + public function edit($requestedId = null) + { + // JJO $session = session(); @@ -131,39 +132,37 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { if ($requestMethod === 'post') : $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - if(isset($this->model->user_updated_id)){ - $sanitizedData['user_updated_id'] = $session->id_user; + if (isset($this->model->user_updated_id)) { + $sanitizedData['user_updated_id'] = $session->id_user; } - + $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('Tarifapreimpresion.tarifapreimpresion'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $tarifapreimpresionEntity->fill($sanitizedData); + 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('Tarifapreimpresion.tarifapreimpresion'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); - $thenRedirect = false; + endif; + + $tarifapreimpresionEntity->fill($sanitizedData); + + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $tarifapreimpresionEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifapreimpresion.tarifapreimpresion'))]).'.'; - //$message .= anchor(route_to('editTarifapreimpresion', $id), lang('Basic.global.continueEditing').'?'); - //$message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -172,10 +171,9 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { return $this->redirect2listView('successMessage', $message); endif; else: - //JJO - $this->viewData['successMessage'] = $message; + $this->session->setFlashData('sweet-success', $message); endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') @@ -183,23 +181,23 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { $this->viewData['formAction'] = route_to('updateTarifapreimpresion', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifapreimpresion.tarifapreimpresion').' '.lang('Basic.global.edit3'); - - + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifapreimpresion.tarifapreimpresion') . ' ' . lang('Basic.global.edit3'); + + return $this->displayForm(__METHOD__, $id); } // end function edit(...) - - - 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(); @@ -212,8 +210,9 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { return $this->failUnauthorized('Invalid request', 403); } } - - public function menuItems() { + + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -224,8 +223,8 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { $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(); @@ -238,5 +237,5 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController { return $this->failUnauthorized('Invalid request', 403); } } - + } diff --git a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php index b39ad5c3..cbe48801 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php +++ b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Tarifaencuadernacion.moduleTitle'); $this->viewData['usingSweetAlert'] = true; @@ -48,24 +49,26 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaencuadernacion.tarifaencuadernacion')]), - 'tarifaEncuadernacionEntity' => new TarifaEncuadernacionEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifaencuadernacion.tarifaencuadernacion')]), + 'tarifaEncuadernacionEntity' => new TarifaEncuadernacionEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewTarifaEncuadernacionList', $viewData); + return view(static::$viewPath . 'viewTarifaEncuadernacionList', $viewData); } - public function add() { - + public function add() + { + // JJO $session = session(); @@ -76,51 +79,47 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { $nullIfEmpty = true; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - if(isset($this->model->user_updated_id)){ - $sanitizedData['user_created_id'] = $session->id_user; + if (isset($this->model->user_updated_id)) { + $sanitizedData['user_created_id'] = $session->id_user; } $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('Tarifaencuadernacion.tarifaencuadernacion'))]); - $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', [lang('Basic.global.record')]); + $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('Tarifaencuadernacion.tarifaencuadernacion'))]).'.'; - //$message .= anchor( "tarifaencuadernacion/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - //$message = ucfirst(str_replace("'", "\'", $message)); + + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(site_url('tarifas/tarifasencuadernacion/edit/'.$id))->with('sweet-success', $message); - //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + return redirect()->to(site_url('tarifas/tarifasencuadernacion/edit/' . $id))->with('sweet-success', $message); + //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; else: - //JJO - $this->viewData['successMessage'] = $message; - //$this->session->setFlashData('sweet-success', $message); + $this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult @@ -131,17 +130,18 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add');//route_to('createTarifaEncuadernacion'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifaencuadernacion.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + return $this->displayForm(__METHOD__); } // end function add() - public function edit($requestedId = null) { + public function edit($requestedId = null) + { // JJO $session = session(); - + if ($requestedId == null) : return $this->redirect2listView(); endif; @@ -149,7 +149,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { $tarifaEncuadernacionEntity = $this->model->find($id); if ($tarifaEncuadernacionEntity == false) : - $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion')), $id]); + $message = lang('Basic.global.notFoundWithIdErr', [lang('Basic.global.record'), $id]); return $this->redirect2listView('sweet-error', $message); endif; @@ -158,16 +158,16 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); - + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - if(isset($this->model->user_updated_id)){ - $sanitizedData['user_updated_id'] = $session->id_user; + if (isset($this->model->user_updated_id)) { + $sanitizedData['user_updated_id'] = $session->id_user; } - + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($this->canValidate()) : @@ -178,23 +178,21 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { $this->dealWithException($e); } else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]); + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); - + endif; - + $tarifaEncuadernacionEntity->fill($sanitizedData); $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $tarifaEncuadernacionEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifaencuadernacion.tarifaencuadernacion'))]).'.'; - //$message .= anchor( "tarifa ulado/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - //$message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if (!empty($this->indexRoute)) : return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); @@ -202,28 +200,28 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { else: $this->viewData['successMessage'] = $message; endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['tarifaEncuadernacionEntity'] = $tarifaEncuadernacionEntity; - $this->viewData['formAction'] = route_to('updateTarifaEncuadernacion', $id); + $this->viewData['formAction'] = route_to('updateTarifaEncuadernacion', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.edit3'); + - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifaencuadernacion.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -245,15 +243,16 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { } } - 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(); @@ -267,7 +266,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -278,8 +278,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { $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(); diff --git a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php index a5d5b9b2..cce5593f 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php +++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php @@ -1,4 +1,4 @@ -viewData['pageTitle'] = lang('Tarifamanipulado.moduleTitle'); $this->viewData['usingSweetAlert'] = true; @@ -48,24 +49,26 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { } - public function index() { - + public function index() + { + $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifamanipulado.tarifamanipulado')]), - 'tarifaManipuladoEntity' => new TarifaManipuladoEntity(), - 'usingServerSideDataTable' => true, - - ]; + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifamanipulado.tarifamanipulado')]), + 'tarifaManipuladoEntity' => new TarifaManipuladoEntity(), + 'usingServerSideDataTable' => true, + + ]; $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - return view(static::$viewPath.'viewTarifaManipuladoList', $viewData); + return view(static::$viewPath . 'viewTarifaManipuladoList', $viewData); } - public function add() { - + public function add() + { + // JJO $session = session(); @@ -76,51 +79,47 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { $nullIfEmpty = true; // !(phpversion() >= '8.1'); $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - if(isset($this->model->user_updated_id)){ - $sanitizedData['user_created_id'] = $session->id_user; + if (isset($this->model->user_updated_id)) { + $sanitizedData['user_created_id'] = $session->id_user; } $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('Tarifamanipulado.tarifamanipulado'))]); - $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', [lang('Basic.global.record')]); + $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('Tarifamanipulado.tarifamanipulado'))]).'.'; - $message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : - return redirect()->to(site_url('tarifas/tarifasmanipulado/edit/'.$id))->with('sweet-success', $message); - //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + return redirect()->to(site_url('tarifas/tarifasmanipulado/edit/' . $id))->with('sweet-success', $message); + //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); endif; else: - //JJO - $this->viewData['successMessage'] = $message; - //$this->session->setFlashData('sweet-success', $message); + $this->session->setFlashData('sweet-success', $message); endif; endif; // $noException && $successfulResult @@ -131,17 +130,18 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add');//route_to('createTarifaManipulado'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.addNewSuffix'); - + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + return $this->displayForm(__METHOD__); } // end function add() - public function edit($requestedId = null) { + public function edit($requestedId = null) + { // JJO $session = session(); - + if ($requestedId == null) : return $this->redirect2listView(); endif; @@ -158,16 +158,16 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { if ($requestMethod === 'post') : $nullIfEmpty = true; // !(phpversion() >= '8.1'); - + $postData = $this->request->getPost(); - + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); // JJO - if(isset($this->model->user_updated_id)){ - $sanitizedData['user_updated_id'] = $session->id_user; + if (isset($this->model->user_updated_id)) { + $sanitizedData['user_updated_id'] = $session->id_user; } - + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($this->canValidate()) : @@ -180,21 +180,19 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { else: $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); - + endif; - + $tarifaManipuladoEntity->fill($sanitizedData); $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $tarifaManipuladoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.'; - //$message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - //$message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if (!empty($this->indexRoute)) : return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); else: return $this->redirect2listView('sweet-success', $message); @@ -202,28 +200,28 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { else: $this->viewData['successMessage'] = $message; endif; - + endif; // $noException && $successfulResult endif; // ($requestMethod === 'post') $this->viewData['tarifaManipuladoEntity'] = $tarifaManipuladoEntity; - $this->viewData['formAction'] = route_to('updateTarifaManipulado', $id); + $this->viewData['formAction'] = route_to('updateTarifaManipulado', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.edit3'); + - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.edit3'); - - 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; } $start = $reqData['start'] ?? 0; @@ -245,15 +243,16 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { } } - 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(); @@ -267,7 +266,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { } } - public function menuItems() { + public function menuItems() + { if ($this->request->isAJAX()) { $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; $reqId = goSanitize($this->request->getPost('id'))[0]; @@ -278,8 +278,8 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController { $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(); diff --git a/ci4/app/Language/es/Basic.php b/ci4/app/Language/es/Basic.php index aac5351d..1dcfd513 100644 --- a/ci4/app/Language/es/Basic.php +++ b/ci4/app/Language/es/Basic.php @@ -63,7 +63,7 @@ return [ 'pleaseSelect' => 'Por favor seleccione...', 'pleaseSelectA' => 'Por favor seleccione un {0}... ', 'pleaseSelectOne' => 'Por favor seleccione un...', - 'record' => 'el registro', + 'record' => 'registro', 'saveSuccess' => 'El {0} se ha guardado satisfactoriamente', 'saveSuccess1' => 'El {0} ', 'saveSuccess2' => ' se ha guardado satisfactoriamente', diff --git a/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php b/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php index 738ec929..c6486011 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php +++ b/ci4/app/Views/themes/_commonPartialsBs/sweetalert.php @@ -10,32 +10,49 @@ section('additionalInlineJs') ?> - toastr.options = { - "closeButton": false, - "debug": false, - "newestOnTop": false, - "progressBar": false, - "positionClass": "toast-top-right", - "preventDuplicates": false, - "onclick": null, - "showDuration": "300", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": "fadeIn", - "hideMethod": "fadeOut" - }; +toastr.options = { +"closeButton": false, +"debug": false, +"newestOnTop": false, +"progressBar": false, +"positionClass": "toast-top-right", +"preventDuplicates": false, +"onclick": null, +"showDuration": "300", +"hideDuration": "1000", +"timeOut": "5000", +"extendedTimeOut": "1000", +"showEasing": "swing", +"hideEasing": "linear", +"showMethod": "fadeIn", +"hideMethod": "fadeOut" +}; - - toastr.success(``); - - - toastr.success(``); - - - toastr.success(``); - + + toastr.success(``); + + popSuccessAlert(``); + + + + toastr.warning(``); + + popWarningAlert(``); + + + + toastr.error(``); + + popErrorgAlert(``); + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php index 8f4932fc..7a225272 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php +++ b/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php @@ -134,7 +134,6 @@ if (!empty($token) && $tfa == false) { aria-expanded="false" > - 5