From 42a20b93b02d6d9e304cc61c3e3fc23e4dd3f0e2 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 10 Jul 2023 10:05:06 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20clientes=20by=20Ozar=20y=20prime?= =?UTF-8?q?ros=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Config/Routes.php | 16 + ci4/app/Controllers/Clientes/Cliente.php | 346 ++++++++++++++-- .../Configuracion/Comunidadesautonomas.php | 284 +++++++++++++ .../Controllers/Configuracion/Formaspago.php | 241 +++++++++-- ci4/app/Entities/Clientes/ClienteEntity.php | 80 ++++ .../ComunidadesAutonomasEntity.php | 18 + .../Configuracion/FormasPagoEntity.php | 15 + ci4/app/Entities/Configuracion/PaisEntity.php | 22 ++ ci4/app/Language/es/App.php | 3 +- ci4/app/Language/es/Clientes.php | 250 ++++++++++++ ci4/app/Language/es/ComunidadesAutonomas.php | 29 ++ ci4/app/Language/es/FormasPago.php | 27 ++ ci4/app/Language/es/PapelImpresion.php | 2 +- ci4/app/Models/Clientes/ClienteModel.php | 373 ++++++++++++++++++ .../ComunidadesAutonomasModel.php | 97 +++++ .../Models/Configuracion/FormasPagoModel.php | 33 ++ .../vuexy/form/clientes/_clienteFormItems.php | 373 ++++++++++++++++++ .../vuexy/form/clientes/viewClienteForm.php | 27 ++ .../vuexy/form/clientes/viewClienteList.php | 157 ++++++++ .../_comunidadAutonomaFormItems.php | 27 ++ .../viewComunidadAutonomaForm.php | 28 ++ .../viewComunidadAutonomaList.php | 159 ++++++++ .../formas-pago/_formaPagoFormItems.php | 12 + .../formas-pago/viewFormaPagoForm.php | 26 ++ .../formas-pago/viewFormaPagoList.php | 144 +++++++ 25 files changed, 2737 insertions(+), 52 deletions(-) create mode 100644 ci4/app/Controllers/Configuracion/Comunidadesautonomas.php create mode 100644 ci4/app/Entities/Clientes/ClienteEntity.php create mode 100644 ci4/app/Entities/Configuracion/ComunidadesAutonomasEntity.php create mode 100644 ci4/app/Entities/Configuracion/FormasPagoEntity.php create mode 100644 ci4/app/Entities/Configuracion/PaisEntity.php create mode 100644 ci4/app/Language/es/Clientes.php create mode 100644 ci4/app/Language/es/ComunidadesAutonomas.php create mode 100644 ci4/app/Language/es/FormasPago.php create mode 100644 ci4/app/Models/Clientes/ClienteModel.php create mode 100644 ci4/app/Models/Configuracion/ComunidadesAutonomasModel.php create mode 100644 ci4/app/Models/Configuracion/FormasPagoModel.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/clientes/_clienteFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteList.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/_comunidadAutonomaFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaList.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/_formaPagoFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoList.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 79940db8..5384d9ce 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -104,6 +104,22 @@ $routes->group('group', ['namespace' => 'App\Controllers\Configuracion'], functi $routes->post('add', 'Group::add', ['as' => 'createGroup']); }); +$routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { + $routes->get('', 'Cliente::index', ['as' => 'clienteList']); + $routes->get('add', 'Cliente::add', ['as' => 'newCliente']); + $routes->post('add', 'Cliente::add', ['as' => 'createCliente']); + $routes->post('create', 'Cliente::create', ['as' => 'ajaxCreateCliente']); + $routes->put('(:num)/update', 'Cliente::update/$1', ['as' => 'ajaxUpdateCliente']); + $routes->post('edit/(:num)', 'Cliente::edit/$1', ['as' => 'updateCliente']); + $routes->get('delete/(:num)', 'Cliente::delete/$1', ['as' => 'deleteCliente']); + $routes->post('datatable', 'Cliente::datatable', ['as' => 'dataTableOfCliente']); + $routes->post('allmenuitems', 'Cliente::allItemsSelect', ['as' => 'select2ItemsOfCliente']); + $routes->post('menuitems', 'Cliente::menuItems', ['as' => 'menuItemsOfCliente']); +}); +$routes->resource('cliente', ['namespace' => 'App\Clientes\Cliente', 'controller' => 'Cliente', 'except' => 'show,new,create,update']); + + + $routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->get('', 'Tarifapreimpresion::index', ['as' => 'tarifapreimpresionList']); $routes->get('index', 'Tarifapreimpresion::index', ['as' => 'tarifapreimpresionIndex']); diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index 64178a93..6ccddff0 100644 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -1,50 +1,340 @@ -viewData['pageTitle'] = lang('Cliente.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_clientes"), 'route' => "", 'active' => false], + ['title' => lang("App.menu_cliente"), 'route' => site_url('clientes/cliente'), 'active' => true] + ]; + + parent::initController($request, $response, $logger); } + public function index() { - $uri = service('uri'); - $data['page_name'] = "Cliente"; - $data['url'] = base_url() . $uri->getSegment(1) . '/' . $uri->getSegment(2); - echo view(getenv('theme.path').'main/demo_view', $data); - } + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Cliente.cliente')]), + 'clienteEntity' => new ClienteEntity(), + 'usingServerSideDataTable' => true, + ]; - public function delete() - { - $uri = service('uri'); - $data['page_name'] = "Cliente"; - $data['url'] = base_url() . $uri->getSegment(1) . '/' . $uri->getSegment(2); - echo view(getenv('theme.path').'main/demo_view', $data); + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath . 'viewClienteList', $viewData); } + public function add() { - $uri = service('uri'); - $data['page_name'] = "Cliente"; - $data['url'] = base_url() . $uri->getSegment(1) . '/' . $uri->getSegment(2); - echo view(getenv('theme.path').'main/demo_view', $data); + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Cliente.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 + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Cliente.cliente'))]) . '.'; + $message .= anchor("admin/clientes/{$id}/edit", lang('Basic.global.continueEditing') . '?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['clienteEntity'] = isset($sanitizedData) ? new ClienteEntity($sanitizedData) : new ClienteEntity(); + $this->viewData['paisList'] = $this->getPaisListItems(); + $this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); + + $this->viewData['formAction'] = route_to('createCliente'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Cliente.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) + { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $clienteEntity = $this->model->find($id); + + if ($clienteEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Cliente.cliente')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('creditoAsegurado') == null) { + $sanitizedData['creditoAsegurado'] = 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('Cliente.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('Cliente.cliente'))]) . '.'; + $message .= anchor("admin/clientes/{$id}/edit", lang('Basic.global.continueEditing') . '?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['clienteEntity'] = $clienteEntity; + $this->viewData['paisList'] = $this->getPaisListItems(); + $this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); + + $this->viewData['formAction'] = route_to('updateCliente', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Cliente.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + public function datatable() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns'])) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = ClienteModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $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->comentarios) && strlen($item->comentarios) > 100) : + $item->comentarios = character_limiter($item->comentarios, 100); + endif; + if (isset($item->direccion) && strlen($item->direccion) > 100) : + $item->direccion = character_limiter($item->direccion, 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_tirada_flexible) && strlen($item->comentarios_tirada_flexible) > 100) : + $item->comentarios_tirada_flexible = character_limiter($item->comentarios_tirada_flexible, 100); + endif; + endforeach; + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } } - public function edit() + public function allItemsSelect() { - $uri = service('uri'); - $data['page_name'] = "Cliente"; - $data['url'] = base_url() . $uri->getSegment(1) . '/' . $uri->getSegment(2); - echo view(getenv('theme.path').'main/demo_view', $data); + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() + { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getFormaPagoListItems() + { + $formasPagoModel = model('App\Models\Configuracion\FormasPagoModel'); + $onlyActiveOnes = true; + $data = $formasPagoModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes); + + return $data; + } + + + protected function getPaisListItems() + { + $paisModel = model('App\Models\Configuracion\PaisModel'); + $onlyActiveOnes = true; + $data = $paisModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes); + + return $data; } } - \ No newline at end of file diff --git a/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php new file mode 100644 index 00000000..4e8584c6 --- /dev/null +++ b/ci4/app/Controllers/Configuracion/Comunidadesautonomas.php @@ -0,0 +1,284 @@ +viewData['pageTitle'] = lang('ComunidadesAutonomas.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ComunidadesAutonomas.comunidadAutonoma')]), + 'comunidadesAutonomasEntity' => new ComunidadesAutonomasEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewComunidadAutonomaList', $viewData); + } + + + public function add() { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('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 + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]).'.'; + $message .= anchor( "admin/comunidadesautonomas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['comunidadesAutonomasEntity'] = isset($sanitizedData) ? new ComunidadesAutonomasEntity($sanitizedData) : new ComunidadesAutonomasEntity(); + $this->viewData['paisList'] = $this->getPaisListItems(); + + $this->viewData['formAction'] = route_to('createComunidadAutonoma'); + + $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) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $comunidadesAutonomasEntity = $this->model->find($id); + + if ($comunidadesAutonomasEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $comunidadesAutonomasEntity->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $comunidadesAutonomasEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))]).'.'; + $message .= anchor( "admin/comunidadesautonomas/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + $message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['comunidadesAutonomasEntity'] = $comunidadesAutonomasEntity; + $this->viewData['paisList'] = $this->getPaisListItems(); + + $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() { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + if (!isset($reqData['draw']) || !isset($reqData['columns']) ) { + $errstr = 'No data available in response to this specific request.'; + $response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr); + return $response; + } + $start = $reqData['start'] ?? 0; + $length = $reqData['length'] ?? 5; + $search = $reqData['search']['value']; + $requestedOrder = $reqData['order']['0']['column'] ?? 1; + $order = ComunidadesAutonomasModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + protected function getPaisListItems() { + $paisModel = model('App\Models\Configuracion\PaisModel'); + $onlyActiveOnes = true; + $data = $paisModel->getAllForMenu('id, nombre','nombre', $onlyActiveOnes ); + + return $data; + } + +} diff --git a/ci4/app/Controllers/Configuracion/Formaspago.php b/ci4/app/Controllers/Configuracion/Formaspago.php index 26d7f796..a3fc4c8d 100644 --- a/ci4/app/Controllers/Configuracion/Formaspago.php +++ b/ci4/app/Controllers/Configuracion/Formaspago.php @@ -1,35 +1,232 @@ -viewData['pageTitle'] = lang('FormasPagoes.moduleTitle'); + parent::initController($request, $response, $logger); + $this->viewData['usingSweetAlert'] = true; + + if (session('errorMessage')) { + $this->session->setFlashData('sweet-error', session('errorMessage')); + } + if (session('successMessage')) { + $this->session->setFlashData('sweet-success', session('successMessage')); + } + } + + public function index() { + + $this->viewData['usingClientSideDataTable'] = true; + + $this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaPago')]); + parent::index(); + + } + + public function add() { + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - } - public function index() - { - echo 'Formas de pago'; - } + 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 + endif; + if ($noException && $successfulResult) : - public function edit() - { + $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)); - public function add() - { + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + + endif; // ($requestMethod === 'post') + + $this->viewData['formasPagoEntity'] = isset($sanitizedData) ? new FormasPagoEntity($sanitizedData) : new FormasPagoEntity(); + + $this->viewData['formAction'] = route_to('createFormaPago'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('FormasPagoes.formaPago').' '.lang('Basic.global.addNewSuffix'); - } - public function delete() - { + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $formasPagoEntity = $this->model->find($id); + + if ($formasPagoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('FormasPagoes.formaPago')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('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)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + $this->viewData['formasPagoEntity'] = $formasPagoEntity; + + $this->viewData['formAction'] = route_to('updateFormaPago', $id); + + $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() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } } + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + } - \ No newline at end of file diff --git a/ci4/app/Entities/Clientes/ClienteEntity.php b/ci4/app/Entities/Clientes/ClienteEntity.php new file mode 100644 index 00000000..cb520b6d --- /dev/null +++ b/ci4/app/Entities/Clientes/ClienteEntity.php @@ -0,0 +1,80 @@ + null, + "nombre" => null, + "alias" => null, + "direccion" => null, + "ciudad" => null, + "comunidad_autonoma_id" => null, + "provincia" => null, + "cp" => null, + "pais_id" => null, + "telefono" => null, + "email" => null, + "salesman_id" => 1, + "soporte_id" => null, + "forma_pago_id" => null, + "vencimiento" => 15, + "fechaVencimiento" => null, + "margen" => 40.0, + "margen_pod" => null, + "descuento" => 0.0, + "limite_credito" => 0.0, + "limite_credito_user_id" => 1, + "limite_credito_change_at" => null, + "creditoSolunion" => null, + "creditoAsegurado" => false, + "ccc" => null, + "ccc_customer" => null, + "num_cuenta" => null, + "disponible_fe" => false, + "message_tracking" => true, + "message_production_start" => true, + "tirada_flexible" => false, + "descuento_tirada_flexible" => 20.0, + "comentarios_tirada_flexible" => null, + "saturacion" => 100.0, + "tienda_id" => null, + "margen_plantilla_id" => null, + "comentarios_produccion" => null, + "ps_customer_id" => null, + "lineasEnvioFactura" => true, + "comentarios" => null, + "created_at" => null, + "updated_at" => null, + "user_created_id" => 1, + "user_update_id" => 1, + ]; + protected $casts = [ + "comunidad_autonoma_id" => "?int", + "pais_id" => "?int", + "salesman_id" => "int", + "soporte_id" => "?int", + "forma_pago_id" => "?int", + "vencimiento" => "int", + "margen" => "float", + "margen_pod" => "?float", + "descuento" => "float", + "limite_credito" => "float", + "limite_credito_user_id" => "int", + "creditoAsegurado" => "?boolean", + "disponible_fe" => "boolean", + "message_tracking" => "boolean", + "message_production_start" => "boolean", + "tirada_flexible" => "boolean", + "descuento_tirada_flexible" => "float", + "saturacion" => "float", + "tienda_id" => "?int", + "margen_plantilla_id" => "?int", + "ps_customer_id" => "?int", + "lineasEnvioFactura" => "boolean", + "user_created_id" => "int", + "user_update_id" => "int", + ]; +} diff --git a/ci4/app/Entities/Configuracion/ComunidadesAutonomasEntity.php b/ci4/app/Entities/Configuracion/ComunidadesAutonomasEntity.php new file mode 100644 index 00000000..0523e4f5 --- /dev/null +++ b/ci4/app/Entities/Configuracion/ComunidadesAutonomasEntity.php @@ -0,0 +1,18 @@ + null, + "nombre" => null, + "pais_id" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "pais_id" => "int", + ]; +} diff --git a/ci4/app/Entities/Configuracion/FormasPagoEntity.php b/ci4/app/Entities/Configuracion/FormasPagoEntity.php new file mode 100644 index 00000000..d29181c6 --- /dev/null +++ b/ci4/app/Entities/Configuracion/FormasPagoEntity.php @@ -0,0 +1,15 @@ + null, + "nombre" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = []; +} diff --git a/ci4/app/Entities/Configuracion/PaisEntity.php b/ci4/app/Entities/Configuracion/PaisEntity.php new file mode 100644 index 00000000..9460f544 --- /dev/null +++ b/ci4/app/Entities/Configuracion/PaisEntity.php @@ -0,0 +1,22 @@ + null, + "nombre" => null, + "code" => null, + "code3" => null, + "moneda" => null, + "url_erp" => null, + "user_erp" => null, + "key_erp" => null, + "show_erp" => false, + ]; + protected $casts = [ + "show_erp" => "boolean", + ]; +} diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 49fa285a..7dcda7e4 100644 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -646,7 +646,7 @@ return [ "permisos_catalogo" => "Catálogo", - "permisos_clientes" => "Clientes", + "permisos_clientes" => "Cliente", "permisos_tarifacliente" => "Tarifas cliente", "permisos_proveedores" => "Proveedores", @@ -672,6 +672,7 @@ return [ "menu_dashboard" => "Panel de control", "menu_clientes" => "Clientes", + "menu_cliente" => "Cliente", "menu_clientes_nuevo" => "Nuevo", "menu_tarifacliente" => "Tarifas", diff --git a/ci4/app/Language/es/Clientes.php b/ci4/app/Language/es/Clientes.php new file mode 100644 index 00000000..45651367 --- /dev/null +++ b/ci4/app/Language/es/Clientes.php @@ -0,0 +1,250 @@ + 'Alias', + 'ccc' => 'Ccc', + 'cccCustomer' => 'Ccc Customer', + 'ciudad' => 'Ciudad', + 'cliente' => 'Cliente', + 'clienteList' => 'Listado de Clientes', + 'clientes' => 'Clientes', + 'comentarios' => 'Comentarios', + 'comentariosProduccion' => 'Comentarios Producción', + 'comentariosTiradaFlexible' => 'Comentarios Tirada Flexible', + 'comunidadAutonomaId' => 'Comunidad Autónoma', + 'cp' => 'Código Postal', + 'createdAt' => 'Created At', + 'creditoasegurado' => 'Crédito Asegurado', + 'creditosolunion' => 'Crédito Solunion', + 'deletedAt' => 'Deleted At', + 'descuento' => 'Descuento', + 'descuentoTiradaFlexible' => 'Descuento Tirada Flexible', + 'direccion' => 'Dirección', + 'disponibleFe' => 'Disponible Fe', + 'email' => 'Email', + 'fechavencimiento' => 'Fecha Vencimiento', + 'formaPagoId' => 'Forma Pago', + 'id' => 'ID', + 'limiteCredito' => 'Limite Credito', + 'limiteCreditoChangeAt' => 'Limite Credito Change At', + 'limiteCreditoUserId' => 'Limite Credito User ID', + 'lineasenviofactura' => 'Lineasenviofactura', + 'margen' => 'Margen', + 'margenPlantillaId' => 'Margen Plantilla ID', + 'margenPod' => 'Margen Pod', + 'messageProductionStart' => 'Message Production Start', + 'messageTracking' => 'Message Tracking', + 'moduleTitle' => 'Clientes', + 'nombre' => 'Nombre', + 'numCuenta' => 'Número de Cuenta', + 'paisId' => 'País', + 'provincia' => 'Provincia', + 'psCustomerId' => 'Ps Customer ID', + 'salesmanId' => 'Comercial Asignado', + 'saturacion' => 'Saturación', + 'soporteId' => 'Soporte Asignado', + 'telefono' => 'Teléfono', + 'tiendaId' => 'Tienda ID', + 'tiradaFlexible' => 'Tirada Flexible', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdateId' => 'User Update ID', + 'vencimiento' => 'Vencimiento', + 'validation' => [ + 'ccc' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'ccc_customer' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'ciudad' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'comentarios' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'comentarios_produccion' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'comunidad_autonoma' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'comunidad_autonoma_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'cp' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'creditoSolunion' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'direccion' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'fechaVencimiento' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'margen_plantilla_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'margen_pod' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + + ], + + 'num_cuenta' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'pais' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'provincia' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'ps_customer_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'soporte_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'telefono' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'tienda_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + + ], + + 'alias' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'comentarios_tirada_flexible' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'descuento' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'descuento_tirada_flexible' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'email' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'valid_email' => 'El campo {field} debe contener una dirección de correo electrónico válida.', + + ], + + 'limite_credito' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'limite_credito_change_at' => [ + 'required' => 'El campo {field} es obligatorio.', + 'valid_date' => 'The {field} field must contain a valid date.', + + ], + + 'limite_credito_user_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'margen' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'salesman_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'saturacion' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'user_created_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'user_update_id' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'vencimiento' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/ComunidadesAutonomas.php b/ci4/app/Language/es/ComunidadesAutonomas.php new file mode 100644 index 00000000..356b936d --- /dev/null +++ b/ci4/app/Language/es/ComunidadesAutonomas.php @@ -0,0 +1,29 @@ + 'Comunidad Autónoma', + 'comunidadAutonomaList' => 'Listado de Comunidades Autónomas', + 'comunidades-autonomas' => 'Comunidades Autónomas', + 'comunidadesAutonoma' => 'Comunidades Autónoma', + 'comunidadesAutonomaList' => 'Listado de Comunidades Autónomas', + 'comunidadesAutonomas' => 'Comunidades Autónomas', + 'comunidadesautonomas' => 'Comunidades Autónomas', + 'createdAt' => 'Created At', + 'id' => 'ID', + 'moduleTitle' => 'Comunidades Autónomas', + 'nombre' => 'Nombre', + 'pais' => 'País', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'id' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + ], + + ], + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/FormasPago.php b/ci4/app/Language/es/FormasPago.php new file mode 100644 index 00000000..c76dd3ec --- /dev/null +++ b/ci4/app/Language/es/FormasPago.php @@ -0,0 +1,27 @@ + 'Created At', + 'formaPago' => 'Forma Pago', + 'formaPagoList' => 'Listado de Formas Pago', + 'formas-pago' => 'Formas de Pago', + 'formasPago' => 'Formas Pago', + 'formasPagoList' => 'Listado de Formas Pago', + 'formaspago' => 'Formas de Pago', + 'id' => 'ID', + 'moduleTitle' => 'Formas de Pago', + 'nombre' => 'Nombre', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'id' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + ], + + ], + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/PapelImpresion.php b/ci4/app/Language/es/PapelImpresion.php index 766a61e1..55b8c20b 100644 --- a/ci4/app/Language/es/PapelImpresion.php +++ b/ci4/app/Language/es/PapelImpresion.php @@ -84,7 +84,7 @@ return [ ], 'papel_generico_id' => [ - 'integer' => 'The {field} field must contain an integer.', + 'integer' => 'El campo {field} debe contener un número entero.', 'required' => 'El campo {field} es obligatorio.', ], diff --git a/ci4/app/Models/Clientes/ClienteModel.php b/ci4/app/Models/Clientes/ClienteModel.php new file mode 100644 index 00000000..9896f5ee --- /dev/null +++ b/ci4/app/Models/Clientes/ClienteModel.php @@ -0,0 +1,373 @@ + "t1.nombre", + 1 => "t1.alias", + 2 => "t1.email", + 3 => "t1.salesman_id", + 4 => "t1.forma_pago_id", + 5 => "t1.vencimiento", + ]; + + protected $allowedFields = [ + "nombre", + "alias", + "direccion", + "ciudad", + "comunidad_autonoma_id", + "provincia", + "cp", + "pais_id", + "telefono", + "email", + "salesman_id", + "soporte_id", + "forma_pago_id", + "vencimiento", + "fechaVencimiento", + "margen", + "margen_pod", + "descuento", + "limite_credito", + "limite_credito_user_id", + "limite_credito_change_at", + "creditoSolunion", + "creditoAsegurado", + "ccc", + "ccc_customer", + "num_cuenta", + "disponible_fe", + "message_tracking", + "message_production_start", + "tirada_flexible", + "descuento_tirada_flexible", + "comentarios_tirada_flexible", + "saturacion", + "tienda_id", + "margen_plantilla_id", + "comentarios_produccion", + "ps_customer_id", + "lineasEnvioFactura", + "comentarios", + "user_created_id", + "user_update_id", + ]; + protected $returnType = "App\Entities\Clientes\ClienteEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "alias" => [ + "label" => "Cliente.alias", + "rules" => "trim|required|max_length[255]", + ], + "ccc" => [ + "label" => "Cliente.ccc", + "rules" => "trim|max_length[100]", + ], + "ccc_customer" => [ + "label" => "Cliente.cccCustomer", + "rules" => "trim|max_length[100]", + ], + "ciudad" => [ + "label" => "Cliente.ciudad", + "rules" => "trim|max_length[100]", + ], + "comentarios" => [ + "label" => "Cliente.comentarios", + "rules" => "trim|max_length[16313]", + ], + "comentarios_produccion" => [ + "label" => "Cliente.comentariosProduccion", + "rules" => "trim|max_length[16313]", + ], + "comentarios_tirada_flexible" => [ + "label" => "Cliente.comentariosTiradaFlexible", + "rules" => "trim|required|max_length[16313]", + ], + "cp" => [ + "label" => "Cliente.cp", + "rules" => "trim|max_length[10]", + ], + "creditoSolunion" => [ + "label" => "Cliente.creditosolunion", + "rules" => "trim|max_length[100]", + ], + "descuento" => [ + "label" => "Cliente.descuento", + "rules" => "required|decimal", + ], + "descuento_tirada_flexible" => [ + "label" => "Cliente.descuentoTiradaFlexible", + "rules" => "required|decimal", + ], + "direccion" => [ + "label" => "Cliente.direccion", + "rules" => "trim|max_length[300]", + ], + "email" => [ + "label" => "Cliente.email", + "rules" => "trim|max_length[150]|valid_email|permit_empty", + ], + "fechaVencimiento" => [ + "label" => "Cliente.fechavencimiento", + "rules" => "trim|max_length[100]", + ], + "limite_credito" => [ + "label" => "Cliente.limiteCredito", + "rules" => "required|decimal", + ], + "limite_credito_change_at" => [ + "label" => "Cliente.limiteCreditoChangeAt", + "rules" => "required|valid_date", + ], + "limite_credito_user_id" => [ + "label" => "Cliente.limiteCreditoUserId", + "rules" => "required|integer", + ], + "margen" => [ + "label" => "Cliente.margen", + "rules" => "required|decimal", + ], + "margen_plantilla_id" => [ + "label" => "Cliente.margenPlantillaId", + "rules" => "integer|permit_empty", + ], + "margen_pod" => [ + "label" => "Cliente.margenPod", + "rules" => "decimal|permit_empty", + ], + "nombre" => [ + "label" => "Cliente.nombre", + "rules" => "trim|required|max_length[255]", + ], + "num_cuenta" => [ + "label" => "Cliente.numCuenta", + "rules" => "trim|max_length[10]", + ], + "provincia" => [ + "label" => "Cliente.provincia", + "rules" => "trim|max_length[100]", + ], + "ps_customer_id" => [ + "label" => "Cliente.psCustomerId", + "rules" => "integer|permit_empty", + ], + "salesman_id" => [ + "label" => "Cliente.salesmanId", + "rules" => "required|integer", + ], + "saturacion" => [ + "label" => "Cliente.saturacion", + "rules" => "required|decimal", + ], + "soporte_id" => [ + "label" => "Cliente.soporteId", + "rules" => "integer|permit_empty", + ], + "telefono" => [ + "label" => "Cliente.telefono", + "rules" => "trim|max_length[60]", + ], + "tienda_id" => [ + "label" => "Cliente.tiendaId", + "rules" => "integer|permit_empty", + ], + "user_created_id" => [ + "label" => "Cliente.userCreatedId", + "rules" => "required|integer", + ], + "user_update_id" => [ + "label" => "Cliente.userUpdateId", + "rules" => "required|integer", + ], + "vencimiento" => [ + "label" => "Cliente.vencimiento", + "rules" => "required|integer", + ], + ]; + + protected $validationMessages = [ + "alias" => [ + "max_length" => "Cliente.validation.alias.max_length", + "required" => "Cliente.validation.alias.required", + ], + "ccc" => [ + "max_length" => "Cliente.validation.ccc.max_length", + ], + "ccc_customer" => [ + "max_length" => "Cliente.validation.ccc_customer.max_length", + ], + "ciudad" => [ + "max_length" => "Cliente.validation.ciudad.max_length", + ], + "comentarios" => [ + "max_length" => "Cliente.validation.comentarios.max_length", + ], + "comentarios_produccion" => [ + "max_length" => "Cliente.validation.comentarios_produccion.max_length", + ], + "comentarios_tirada_flexible" => [ + "max_length" => "Cliente.validation.comentarios_tirada_flexible.max_length", + "required" => "Cliente.validation.comentarios_tirada_flexible.required", + ], + "cp" => [ + "max_length" => "Cliente.validation.cp.max_length", + ], + "creditoSolunion" => [ + "max_length" => "Cliente.validation.creditoSolunion.max_length", + ], + "descuento" => [ + "decimal" => "Cliente.validation.descuento.decimal", + "required" => "Cliente.validation.descuento.required", + ], + "descuento_tirada_flexible" => [ + "decimal" => "Cliente.validation.descuento_tirada_flexible.decimal", + "required" => "Cliente.validation.descuento_tirada_flexible.required", + ], + "direccion" => [ + "max_length" => "Cliente.validation.direccion.max_length", + ], + "email" => [ + "max_length" => "Cliente.validation.email.max_length", + "valid_email" => "Cliente.validation.email.valid_email", + ], + "fechaVencimiento" => [ + "max_length" => "Cliente.validation.fechaVencimiento.max_length", + ], + "limite_credito" => [ + "decimal" => "Cliente.validation.limite_credito.decimal", + "required" => "Cliente.validation.limite_credito.required", + ], + "limite_credito_change_at" => [ + "required" => "Cliente.validation.limite_credito_change_at.required", + "valid_date" => "Cliente.validation.limite_credito_change_at.valid_date", + ], + "limite_credito_user_id" => [ + "integer" => "Cliente.validation.limite_credito_user_id.integer", + "required" => "Cliente.validation.limite_credito_user_id.required", + ], + "margen" => [ + "decimal" => "Cliente.validation.margen.decimal", + "required" => "Cliente.validation.margen.required", + ], + "margen_plantilla_id" => [ + "integer" => "Cliente.validation.margen_plantilla_id.integer", + ], + "margen_pod" => [ + "decimal" => "Cliente.validation.margen_pod.decimal", + ], + "nombre" => [ + "max_length" => "Cliente.validation.nombre.max_length", + "required" => "Cliente.validation.nombre.required", + ], + "num_cuenta" => [ + "max_length" => "Cliente.validation.num_cuenta.max_length", + ], + "provincia" => [ + "max_length" => "Cliente.validation.provincia.max_length", + ], + "ps_customer_id" => [ + "integer" => "Cliente.validation.ps_customer_id.integer", + ], + "salesman_id" => [ + "integer" => "Cliente.validation.salesman_id.integer", + "required" => "Cliente.validation.salesman_id.required", + ], + "saturacion" => [ + "decimal" => "Cliente.validation.saturacion.decimal", + "required" => "Cliente.validation.saturacion.required", + ], + "soporte_id" => [ + "integer" => "Cliente.validation.soporte_id.integer", + ], + "telefono" => [ + "max_length" => "Cliente.validation.telefono.max_length", + ], + "tienda_id" => [ + "integer" => "Cliente.validation.tienda_id.integer", + ], + "user_created_id" => [ + "integer" => "Cliente.validation.user_created_id.integer", + "required" => "Cliente.validation.user_created_id.required", + ], + "user_update_id" => [ + "integer" => "Cliente.validation.user_update_id.integer", + "required" => "Cliente.validation.user_update_id.required", + ], + "vencimiento" => [ + "integer" => "Cliente.validation.vencimiento.integer", + "required" => "Cliente.validation.vencimiento.required", + ], + ]; + public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS pais, t3.nombre AS forma_pago FROM " . + $this->table . + " t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id LEFT JOIN lg_formas_pago t3 ON t1.forma_pago_id = t3.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . intval($limit); + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . intval($offset); + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre, t1.alias AS alias, t1.direccion AS direccion, t1.ciudad AS ciudad, t1.comunidad_autonoma_id AS comunidad_autonoma_id, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono, t1.email AS email, t1.salesman_id AS salesman_id, t1.soporte_id AS soporte_id, t1.vencimiento AS vencimiento, t1.fechaVencimiento AS fechaVencimiento, t1.margen AS margen, t1.margen_pod AS margen_pod, t1.descuento AS descuento, t1.limite_credito AS limite_credito, t1.limite_credito_user_id AS limite_credito_user_id, t1.limite_credito_change_at AS limite_credito_change_at, t1.creditoSolunion AS creditoSolunion, t1.creditoAsegurado AS creditoAsegurado, t1.ccc AS ccc, t1.ccc_customer AS ccc_customer, t1.num_cuenta AS num_cuenta, t1.disponible_fe AS disponible_fe, t1.message_tracking AS message_tracking, t1.message_production_start AS message_production_start, t1.tirada_flexible AS tirada_flexible, t1.descuento_tirada_flexible AS descuento_tirada_flexible, t1.comentarios_tirada_flexible AS comentarios_tirada_flexible, t1.saturacion AS saturacion, t1.tienda_id AS tienda_id, t1.margen_plantilla_id AS margen_plantilla_id, t1.comentarios_produccion AS comentarios_produccion, t1.ps_customer_id AS ps_customer_id, t1.lineasEnvioFactura AS lineasEnvioFactura, t1.comentarios AS comentarios, t1.created_at AS created_at, t1.updated_at AS updated_at, t1.user_created_id AS user_created_id, t1.user_update_id AS user_update_id, t2.nombre AS pais, t3.nombre AS forma_pago" + ); + $builder->join("lg_paises t2", "t1.pais_id = t2.id", "left"); + $builder->join("lg_formas_pago t3", "t1.forma_pago_id = t3.id", "left"); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.nombre", $search) + ->orLike("t1.alias", $search) + ->orLike("t1.email", $search) + ->orLike("t1.salesman_id", $search) + ->orLike("t1.vencimiento", $search) + ->orLike("t1.fechaVencimiento", $search) + + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Configuracion/ComunidadesAutonomasModel.php b/ci4/app/Models/Configuracion/ComunidadesAutonomasModel.php new file mode 100644 index 00000000..2ac0e435 --- /dev/null +++ b/ci4/app/Models/Configuracion/ComunidadesAutonomasModel.php @@ -0,0 +1,97 @@ + "t1.id", + 2 => "t1.nombre", + 3 => "t1.pais_id", + 4 => "t1.created_at", + 5 => "t1.updated_at", + 6 => "t2.nombre", + ]; + + protected $allowedFields = ["nombre", "pais_id"]; + protected $returnType = "App\Entities\Configuracion\ComunidadesAutonomasEntity"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "nombre" => [ + "label" => "ComunidadesAutonomas.nombre", + "rules" => "trim|required|max_length[100]", + ], + ]; + + protected $validationMessages = [ + "nombre" => [ + "max_length" => "ComunidadesAutonomas.validation.nombre.max_length", + "required" => "ComunidadesAutonomas.validation.nombre.required", + ], + ]; + + public function findAllWithPaises(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS pais FROM " . + $this->table . + " t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . $limit; + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . $offset; + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.nombre AS pais" + ); + $builder->join("lg_paises t2", "t1.pais_id = t2.id", "left"); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.created_at", $search) + ->orLike("t1.updated_at", $search) + ->orLike("t2.id", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.pais_id", $search) + ->orLike("t1.created_at", $search) + ->orLike("t1.updated_at", $search) + ->orLike("t2.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Configuracion/FormasPagoModel.php b/ci4/app/Models/Configuracion/FormasPagoModel.php new file mode 100644 index 00000000..5230e7fd --- /dev/null +++ b/ci4/app/Models/Configuracion/FormasPagoModel.php @@ -0,0 +1,33 @@ + [ + "label" => "FormasPagoes.nombre", + "rules" => "trim|required|max_length[255]", + ], + ]; + + protected $validationMessages = [ + "nombre" => [ + "max_length" => "FormasPagoes.validation.nombre.max_length", + "required" => "FormasPagoes.validation.nombre.required", + ], + ]; +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/_clienteFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/_clienteFormItems.php new file mode 100644 index 00000000..1263ef5d --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/_clienteFormItems.php @@ -0,0 +1,373 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+ +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteForm.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteForm.php new file mode 100644 index 00000000..7dbd0d20 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteForm.php @@ -0,0 +1,27 @@ +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> + +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteList.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteList.php new file mode 100644 index 00000000..af8be974 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/viewClienteList.php @@ -0,0 +1,157 @@ +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> + +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfClientes').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfClientes').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + "dom": 'lfBrtip', + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + stateSave: true, + order: [[1, 'asc']], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr] + } + ], + columns : [ + { 'data': 'nombre' }, + { 'data': 'alias' }, + { 'data': 'email' }, + { 'data': 'salesman_id' }, + { 'data': 'forma_pago' }, + { 'data': 'vencimiento' }, + { 'data': actionBtns } + ] + }); + + +$(document).on('click', '.btn-edit', function(e) { + window.location.href = `/${$(this).attr('data-id')}/edit`; + }); + +$(document).on('click', '.btn-delete', function(e) { + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + $.ajax({ + url: `/${dataId}`, + method: 'DELETE', + }).done((data, textStatus, jqXHR) => { + Toast.fire({ + icon: 'success', + title: data.msg ?? jqXHR.statusText, + }); + + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + Toast.fire({ + icon: 'error', + title: jqXHR.responseJSON.messages.error, + }); + }) + } + }); + }); +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + +endSection() ?> + diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/_comunidadAutonomaFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/_comunidadAutonomaFormItems.php new file mode 100644 index 00000000..353756f2 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/_comunidadAutonomaFormItems.php @@ -0,0 +1,27 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaForm.php new file mode 100644 index 00000000..c0f69af4 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaForm.php @@ -0,0 +1,28 @@ +include("Themes/_commonPartialsBs/select2bs5") ?> +include("Themes/_commonPartialsBs/sweetalert") ?> +extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaList.php new file mode 100644 index 00000000..0c2ab9a8 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/comunidades-autonomas/viewComunidadAutonomaList.php @@ -0,0 +1,159 @@ +include('Themes/_commonPartialsBs/datatables') ?> +include('Themes/_commonPartialsBs/sweetalert') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfComunidadesautonomas').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfComunidadesautonomas').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + + stateSave: true, + order: [[1, 'asc']], + language: { + url: "/assets/dt/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" + }, + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr] + } + ], + columns : [ + { 'data': actionBtns }, + { 'data': 'id' }, + { 'data': 'nombre' }, + { 'data': 'pais' }, + { 'data': 'created_at' }, + { 'data': 'updated_at' }, + { 'data': actionBtns } + ] + }); + + + theTable.on( 'draw.dt', function () { + + const dateCols = [4, 5]; + const shortDateFormat = ''; + const dateTimeFormat = ''; + + for (let coln of dateCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + const datestr = cell.innerHTML; + const dateStrLen = datestr.toString().trim().length; + if (dateStrLen > 0) { + let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values + dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one + const d = new Date(...dateTimeParts); // new Date(datestr); + const md = moment(d); + const usingThisFormat = dateStrLen > 11 ? dateTimeFormat : shortDateFormat; + const formattedDateStr = md.format(usingThisFormat); + cell.innerHTML = formattedDateStr; + } + }); + } + }); + +$(document).on('click', '.btn-edit', function(e) { + window.location.href = `/${$(this).attr('data-id')}/edit`; + }); + +$(document).on('click', '.btn-delete', function(e) { + Swal.fire({ + title: '', + text: '', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }) + .then((result) => { + const dataId = $(this).data('id'); + const row = $(this).closest('tr'); + if (result.value) { + $.ajax({ + url: `/${dataId}`, + method: 'DELETE', + }).done((data, textStatus, jqXHR) => { + Toast.fire({ + icon: 'success', + title: data.msg ?? jqXHR.statusText, + }); + + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + Toast.fire({ + icon: 'error', + title: jqXHR.responseJSON.messages.error, + }); + }) + } + }); + }); + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/_formaPagoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/_formaPagoFormItems.php new file mode 100644 index 00000000..205027a8 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/_formaPagoFormItems.php @@ -0,0 +1,12 @@ +
+
+
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoForm.php new file mode 100644 index 00000000..ed8b112c --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoForm.php @@ -0,0 +1,26 @@ +include("Themes/_commonPartialsBs/select2bs5") ?> +include("Themes/_commonPartialsBs/sweetalert") ?> +extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoList.php new file mode 100644 index 00000000..390dfb26 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/formas-pago/viewFormaPagoList.php @@ -0,0 +1,144 @@ +include('Themes/_commonPartialsBs/datatables') ?> +include('Themes/_commonPartialsBs/sweetalert') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?> + 'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteFormaPago', $item->id)]); ?> + + id ?> + + nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?> + + created_at) ? '' : date('mm/dd/YYYY H:i', strtotime($item->created_at)) ?> + + updated_at) ? '' : date('mm/dd/YYYY H:i', strtotime($item->updated_at)) ?> + + id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?> + 'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteFormaPago', $item->id)]); ?> +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1; + theTable = $('.using-exportable-data-table').DataTable({ + "responsive": true, + "paging": true, + "lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + "pageLength": 10, + "lengthChange": true, + "searching": true, + "ordering": true, + "info": true, + "dom": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + "autoWidth": true, + "scrollX": true, + "stateSave": true, + "language": { + url: "/assets/dt/languages[$currentLocale] ?? config('Basics')->i18n ?>.json" + }, + "columnDefs": [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr2] + } + ] + }); + + + + + $(document).on('click', '.btn-delete', function(e) { + e.preventDefault(); + const dataHref = $(this).data('href'); + Swal.fire({ + title: "", + text: "", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + confirmButtonText: '', + cancelButtonText: '', + cancelButtonColor: '#d33' + }).then((result) => { + if (result.value) { + window.location.href = `${dataHref}`; + } + }); + }); + + +endSection() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> +