diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index a665e363..6e377cbc 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -418,6 +418,7 @@ $routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Cl $routes->group('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { $routes->post('datatable', 'Clienteplantillaprecioslineas::datatable', ['as' => 'dataTableOfClientesplantillaprecioslineas']); $routes->post('datatable_editor', 'Clienteplantillaprecioslineas::datatable_editor', ['as' => 'editorOfClienteplantillaprecioslineas']); + $routes->post('getrows', 'Clienteplantillaprecioslineas::getStoredRows', ['as' => 'getStoredRowsOfClienteplantillaprecioslineas']); }); $routes->resource('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'clienteplantillaprecioslineas', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php b/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php index 4e933a3a..d0b4d98a 100755 --- a/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php +++ b/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php @@ -120,6 +120,26 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl } } + + public function getStoredRows() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + $plantilla_id = $reqData['plantilla_id'] ?? 0; + + $resourceData = $this->model->getResource([], $plantilla_id); + $resourceData = $resourceData->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource([], $plantilla_id)->countAllResults(), + $this->model->getResource([], $plantilla_id)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + public function datatable_editor() { if ($this->request->isAJAX()) { @@ -178,26 +198,6 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl ), ) - ->validator(function ($editor, $action, $data) { - if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { - foreach ($data['data'] as $pkey => $values) { - // Si no se quiere borrar... - if ($data['data'][$pkey]['is_deleted'] != 1) { - $process_data['tiempo_min'] = $data['data'][$pkey]['tiempo_min']; - $process_data['tiempo_max'] = $data['data'][$pkey]['tiempo_max']; - $process_data['tipo'] = $data['data'][$pkey]['tipo']; - $process_data['tipo_maquina'] = $data['data'][$pkey]['tipo_maquina']; - $process_data['tipo_impresion'] = $data['data'][$pkey]['tipo_impresion']; - - $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['plantilla_id']); - // No se pueden duplicar valores al crear o al editar - if (!empty($response)) { - return $response; - } - } - } - } - }) ->on('preCreate', function ($editor, &$values) { $datetime = (new \CodeIgniter\I18n\Time("now")); $editor diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php index 4a948f0e..9e1b6852 100755 --- a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php +++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php @@ -160,7 +160,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel else { $builder->groupStart(); foreach ($search as $col_search) { - if ($col_search[1] > 0 && $col_search[0] < 4) + if ($col_search[0] > 0 && $col_search[0] < 4) $builder->where(self::SORTABLE[$col_search[0]], $col_search[2]); else $builder->like(self::SORTABLE[$col_search[0]], $col_search[2]); diff --git a/httpdocs/assets/js/safekat/components/modalYesNo.js b/httpdocs/assets/js/safekat/components/modalYesNo.js index 2a88cc59..d9531dcc 100644 --- a/httpdocs/assets/js/safekat/components/modalYesNo.js +++ b/httpdocs/assets/js/safekat/components/modalYesNo.js @@ -7,8 +7,10 @@ class ModalYesNo { this.btnCancelId = alias !== "" ? `btnCancelModal-${alias}` : 'btnCancelModal'; this.btnConfirmId = alias !== "" ? `btnYesModal-${alias}` : 'btnYesModal'; + this.callback = () => {}; + this.modalHtml = ` -