From 10a057493fc9972c43239a4d526c184c04292228 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 18 May 2023 20:28:07 +0200 Subject: [PATCH] trabajando en papel generico. Problema al generar el datatable --- ci4/app/Config/Routes.php | 12 + .../Configuracion/Papelgenerico.php | 291 ++++++++++++++++-- .../Controllers/GoBaseResourceController.php | 2 +- ci4/app/Controllers/Test.php | 7 +- .../Configuracion/PapelGenericoEntity.php | 22 ++ ci4/app/Language/en/PapelGenerico.php | 41 +++ ci4/app/Language/en/TipologiasLibros.php | 32 ++ ci4/app/Language/es/PapelGenerico.php | 41 +++ ci4/app/Language/es/TipologiasLibros.php | 32 ++ .../Configuracion/PapelGenericoModel.php | 92 ++++++ .../papel/_papelGenericoFormItems.php | 36 +++ .../papel/viewPapelGenericoForm.php | 26 ++ .../papel/viewPapelGenericoList.php | 173 +++++++++++ .../tipologias/viewTipologiaLibrosForm.php | 6 +- .../tipologias/viewTipologiaLibrosList.php | 6 +- 15 files changed, 782 insertions(+), 37 deletions(-) create mode 100644 ci4/app/Entities/Configuracion/PapelGenericoEntity.php create mode 100644 ci4/app/Language/en/PapelGenerico.php create mode 100644 ci4/app/Language/en/TipologiasLibros.php create mode 100644 ci4/app/Language/es/PapelGenerico.php create mode 100644 ci4/app/Language/es/TipologiasLibros.php create mode 100644 ci4/app/Models/Configuracion/PapelGenericoModel.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelGenericoFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 0db15006..85099761 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -123,6 +123,18 @@ $routes->group('', [], function($routes) { $routes->post('menuitems', 'Tipologias::menuItems', ['as' => 'menuItemsOfTipologiasLibros']); }); + $routes->group('papel-generico', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'PapelGenerico::index', ['as' => 'papelGenericoList']); + $routes->get('add', 'PapelGenerico::add', ['as' => 'newPapelGenerico']); + $routes->post('add', 'PapelGenerico::add', ['as' => 'createPapelGenerico']); + $routes->post('create', 'PapelGenerico::create', ['as' => 'ajaxCreatePapelGenerico']); + $routes->put('(:num)/update', 'PapelGenerico::update/$1', ['as' => 'ajaxUpdatePapelGenerico']); + $routes->post('(:num)/edit', 'PapelGenerico::edit/$1', ['as' => 'updatePapelGenerico']); + $routes->post('datatable', 'PapelGenerico::datatable', ['as' => 'dataTableOfPapelesGenericos']); + $routes->post('allmenuitems', 'PapelGenerico::allItemsSelect', ['as' => 'select2ItemsOfPapelesGenericos']); + $routes->post('menuitems', 'PapelGenerico::menuItems', ['as' => 'menuItemsOfPapelesGenericos']); + }); + $routes->resource('papel-generico', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'PapelGenerico', 'except' => 'show,new,create,update']); }); diff --git a/ci4/app/Controllers/Configuracion/Papelgenerico.php b/ci4/app/Controllers/Configuracion/Papelgenerico.php index f8d9d19b..6cb6c95c 100644 --- a/ci4/app/Controllers/Configuracion/Papelgenerico.php +++ b/ci4/app/Controllers/Configuracion/Papelgenerico.php @@ -1,35 +1,274 @@ -viewData['pageTitle'] = lang('PapelGenerico.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('PapelGenerico.papelGenerico')]), + 'papelGenericoEntity' => new PapelGenericoEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewPapelGenericoList', $viewData); + } + + + public function add() { + + + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.'; + $message .= anchor( "admin/papel-generico/{$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['papelGenericoEntity'] = isset($sanitizedData) ? new PapelGenericoEntity($sanitizedData) : new PapelGenericoEntity(); + + $this->viewData['formAction'] = route_to('createPapelGenerico'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('PapelGenerico.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) { + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $papelGenericoEntity = $this->model->find($id); + + if ($papelGenericoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); +if ($this->request->getPost('show_in_client') == null ) { + $sanitizedData['show_in_client'] = false; + } + + + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $papelGenericoEntity->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $papelGenericoEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.'; + $message .= anchor( "admin/papel-generico/{$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['papelGenericoEntity'] = $papelGenericoEntity; + + $this->viewData['formAction'] = route_to('updatePapelGenerico', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('PapelGenerico.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 = PapelGenericoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function allItemsSelect() { + if ($this->request->isAJAX()) { + $onlyActiveOnes = true; + $reqVal = $this->request->getPost('val') ?? 'id'; + $menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->nombre = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function menuItems() { + if ($this->request->isAJAX()) { + $searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $reqId = goSanitize($this->request->getPost('id'))[0]; + $reqText = goSanitize($this->request->getPost('text'))[0]; + $onlyActiveOnes = false; + $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; + $onlyActiveOnes = false; + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- '.lang('Basic.global.None').' -'; + array_unshift($menu , $nonItem); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + } - \ No newline at end of file diff --git a/ci4/app/Controllers/GoBaseResourceController.php b/ci4/app/Controllers/GoBaseResourceController.php index 538428d4..59d632f0 100644 --- a/ci4/app/Controllers/GoBaseResourceController.php +++ b/ci4/app/Controllers/GoBaseResourceController.php @@ -57,7 +57,7 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon * * @var array */ - protected $helpers = ['session', 'go_common', 'form', 'text']; + protected $helpers = ['session', 'go_common', 'form', 'text', 'general','jwt']; //JJO /** * Initializer method. diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index efdefb70..695ff358 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -2,8 +2,7 @@ namespace App\Controllers; - -use App\Models\Usuarios\GroupUserModel; +use App\Controllers\Configuracion\PapelGenerico; class Test extends BaseController { @@ -16,8 +15,8 @@ class Test extends BaseController public function index() { - $model = new GroupUserModel(); - var_dump($model->getUsersWithRol('115b5ad39b853084209caf6824224f6b')); + $papel = new PapelGenerico(); + var_dump($papel->datatable()); } } \ No newline at end of file diff --git a/ci4/app/Entities/Configuracion/PapelGenericoEntity.php b/ci4/app/Entities/Configuracion/PapelGenericoEntity.php new file mode 100644 index 00000000..4d3534c2 --- /dev/null +++ b/ci4/app/Entities/Configuracion/PapelGenericoEntity.php @@ -0,0 +1,22 @@ + null, + "nombre" => null, + "code" => null, + "code_ot" => null, + "show_in_client" => true, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "show_in_client" => "boolean", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Language/en/PapelGenerico.php b/ci4/app/Language/en/PapelGenerico.php new file mode 100644 index 00000000..71115235 --- /dev/null +++ b/ci4/app/Language/en/PapelGenerico.php @@ -0,0 +1,41 @@ + 'Code', + 'codeOt' => 'Code Ot', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Generic Paper', + 'nombre' => 'Name', + 'papel-generico' => 'Generic Papers', + 'papelGenerico' => 'Generic Paper', + 'papelGenericoList' => 'Generic Papers List', + 'papelesGenericos' => 'Generic Paper', + 'showInClient' => 'Show in Client', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'code' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'code_ot' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/en/TipologiasLibros.php b/ci4/app/Language/en/TipologiasLibros.php new file mode 100644 index 00000000..4369e218 --- /dev/null +++ b/ci4/app/Language/en/TipologiasLibros.php @@ -0,0 +1,32 @@ + 'Code', + 'id' => 'ID', + 'moduleTitle' => 'Tipologias Libros', + 'nombre' => 'Nombre', + 'tipologiaLibros' => 'Tipologia Libros', + 'tipologiaLibrosList' => 'Tipologia Libros List', + 'tipologiasLibros' => 'Tipologias Libros', + 'tipologiaslibros' => 'Tipologias Libros', + 'validation' => [ + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'code' => [ + 'is_unique' => 'The {field} field must contain a unique value', + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/PapelGenerico.php b/ci4/app/Language/es/PapelGenerico.php new file mode 100644 index 00000000..ea621d2a --- /dev/null +++ b/ci4/app/Language/es/PapelGenerico.php @@ -0,0 +1,41 @@ + 'Código', + 'codeOt' => 'Código Ot', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Papel Genérico', + 'nombre' => 'Nombre', + 'papel-generico' => 'Papeles Genéricos', + 'papelGenerico' => 'Papel Genérico', + 'papelGenericoList' => 'Lista Papeles Genéricos', + 'papelesGenericos' => 'Papeles Genéricos', + 'showInClient' => 'Mostrar en cliente', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'code' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'code_ot' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + + ], + + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/TipologiasLibros.php b/ci4/app/Language/es/TipologiasLibros.php new file mode 100644 index 00000000..4369e218 --- /dev/null +++ b/ci4/app/Language/es/TipologiasLibros.php @@ -0,0 +1,32 @@ + 'Code', + 'id' => 'ID', + 'moduleTitle' => 'Tipologias Libros', + 'nombre' => 'Nombre', + 'tipologiaLibros' => 'Tipologia Libros', + 'tipologiaLibrosList' => 'Tipologia Libros List', + 'tipologiasLibros' => 'Tipologias Libros', + 'tipologiaslibros' => 'Tipologias Libros', + 'validation' => [ + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'code' => [ + 'is_unique' => 'The {field} field must contain a unique value', + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php new file mode 100644 index 00000000..a9af532e --- /dev/null +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -0,0 +1,92 @@ + "t1.id", + 2 => "t1.nombre", + 3 => "t1.code", + 4 => "t1.code_ot", + 5 => "t1.show_in_client", + ]; + + protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client"]; + protected $returnType = "App\Entities\Configuracion\PapelGenericoEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "code" => [ + "label" => "PapelGenericoes.code", + "rules" => "trim|max_length[5]", + ], + "code_ot" => [ + "label" => "PapelGenericoes.codeOt", + "rules" => "trim|max_length[5]", + ], + "nombre" => [ + "label" => "PapelGenericoes.nombre", + "rules" => "trim|required|max_length[255]", + ], + ]; + + protected $validationMessages = [ + "code" => [ + "max_length" => "PapelGenericoes.validation.code.max_length", + ], + "code_ot" => [ + "max_length" => "PapelGenericoes.validation.code_ot.max_length", + ], + "nombre" => [ + "max_length" => "PapelGenericoes.validation.nombre.max_length", + "required" => "PapelGenericoes.validation.nombre.required", + ], + ]; + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "") + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code_ot AS code_ot, t1.show_in_client AS show_in_client" + ); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelGenericoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelGenericoFormItems.php new file mode 100644 index 00000000..ecc95b5d --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/_papelGenericoFormItems.php @@ -0,0 +1,36 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php new file mode 100644 index 00000000..6f7364b5 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php @@ -0,0 +1,26 @@ +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/configuracion/papel/viewPapelGenericoList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php new file mode 100644 index 00000000..53f16d45 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoList.php @@ -0,0 +1,173 @@ +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
+ +
+
+

+ 'btn btn-primary float-end']); ?> +
+
+ + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfPapelesgenericos').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfPapelesgenericos').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 10, + lengthChange: true, + "dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other + // "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above + "buttons": [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ], + stateSave: true, + order: [[1, 'asc']], + language: { + url: "/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': 'id' }, + { 'data': 'nombre' }, + { 'data': 'code' }, + { 'data': 'code_ot' }, + { 'data': 'show_in_client' }, + { 'data': actionBtns } + ] + }); + + + theTable.on( 'draw.dt', function () { + const boolCols = [5]; + for (let coln of boolCols) { + theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + cell.innerHTML = cell.innerHTML == '1' ? '' : ''; + }); + } + + }); + +$(document).on('click', '.btn-edit', function(e) { + window.location.href = `/${$(this).attr('data-id')}/edit`; + }); + +$(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/tipologias/viewTipologiaLibrosForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosForm.php index 36cd4768..a9efb916 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosForm.php @@ -1,5 +1,5 @@ -include("Themes/_commonPartialsBs/select2bs5") ?> -extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +include("themes/_commonPartialsBs/select2bs5") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?>
@@ -10,7 +10,7 @@
- + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosList.php index 4059c227..2c922b98 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/tipologias/viewTipologiaLibrosList.php @@ -1,5 +1,5 @@ -include('Themes/_commonPartialsBs/datatables') ?> -extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +include('themes/_commonPartialsBs/datatables') ?> +extend('themes'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> section('content'); ?>
@@ -9,7 +9,7 @@

- +