From 17885c29f924e8682d49639b68b1aa4a5eda42b2 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Tue, 2 Jan 2024 10:14:45 +0100 Subject: [PATCH] terminadas plantillas cliente y plantillas cliente lineas --- ci4/app/Config/Routes.php | 19 + .../Clientes/ClientePlantillaPrecios.php | 441 ------------------ .../Clientes/Clienteplantillaprecios.php | 245 ++++++++++ .../Clienteplantillaprecioslineas.php | 198 ++++++++ .../ClientePlantillaPreciosEntity.php | 2 +- .../ClientePlantillaPreciosLineaEntity.php | 4 +- ci4/app/Language/en/ClientePrecios.php | 24 +- ci4/app/Language/es/ClientePrecios.php | 20 + .../ClientePlantillaPreciosLineasModel.php | 78 +++- .../Clientes/ClientePlantillaPreciosModel.php | 32 +- .../_ClienteplantillapreciosFormItems.php | 20 + .../viewClienteplantillapreciosForm.php | 339 ++++++++++++++ .../viewClienteplantillapreciosList.php | 136 ++++++ .../Views/themes/backend/vuexy/main/menu.php | 4 +- .../vuexy/main/menu_digitalizacion.php | 5 + .../backend/vuexy/main/menu_impresion.php | 2 +- .../backend/vuexy/main/menu_maquetacion.php | 5 + 17 files changed, 1123 insertions(+), 451 deletions(-) delete mode 100755 ci4/app/Controllers/Clientes/ClientePlantillaPrecios.php create mode 100755 ci4/app/Controllers/Clientes/Clienteplantillaprecios.php create mode 100755 ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php create mode 100755 ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems.php create mode 100755 ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php create mode 100755 ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosList.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 2d61bc2a..2b04d4a1 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -352,6 +352,25 @@ $routes->group('cliente', ['namespace' => 'App\Controllers\Clientes'], function }); $routes->resource('cliente', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Cliente', 'except' => 'show,new,create,update']); + +$routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { + $routes->get('', 'Clienteplantillaprecios::index', ['as' => 'clienteplantillapreciosList']); + $routes->get('add', 'Clienteplantillaprecios::add', ['as' => 'newClienteplantillaprecios']); + $routes->post('add', 'Clienteplantillaprecios::add', ['as' => 'createClienteplantillaprecios']); + $routes->post('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']); + $routes->get('delete/(:num)', 'Clienteplantillaprecios::delete/$1', ['as' => 'deleteClienteplantillaprecios']); + $routes->post('datatable', 'Clienteplantillaprecios::datatable', ['as' => 'dataTableOfClientesplantillaprecios']); +}); +$routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteplantillaprecios', 'except' => 'show,new,create,update']); + + +$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->resource('clienteplantillaprecioslineas', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'clienteplantillaprecioslineas', 'except' => 'show,new,create,update']); + + $routes->group('formas-pagos', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'Formaspagos::index', ['as' => 'formaDePagoList']); $routes->get('add', 'Formaspagos::add', ['as' => 'newFormaDePago']); diff --git a/ci4/app/Controllers/Clientes/ClientePlantillaPrecios.php b/ci4/app/Controllers/Clientes/ClientePlantillaPrecios.php deleted file mode 100755 index 5d2867a3..00000000 --- a/ci4/app/Controllers/Clientes/ClientePlantillaPrecios.php +++ /dev/null @@ -1,441 +0,0 @@ -viewData['pageTitle'] = lang('Clientes.moduleTitle'); - $this->viewData['usingSweetAlert'] = true; - - // Se indica que este controlador trabaja con soft_delete - $this->soft_delete = true; - // Se indica el flag para los ficheros borrados - $this->delete_flag = 1; - - $this->viewData = ['usingServerSideDataTable' => true]; // JJO - - // Breadcrumbs (IMN) - $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_clientes"), 'route' => "javascript:void(0);", 'active' => false], - ['title' => lang("App.menu_cliente"), 'route' => site_url('clientes/cliente'), 'active' => true] - ]; - - parent::initController($request, $response, $logger); - } - - - public function index() - { - - $viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Clientes.cliente')]), - 'clienteEntity' => new ClienteEntity(), - 'usingServerSideDataTable' => true, - - ]; - - $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - - return view(static::$viewPath . 'viewClienteList', $viewData); - } - - - public function add() - { - // JJO - $session = session(); - - $requestMethod = $this->request->getMethod(); - - if ($requestMethod === 'post') : - - $nullIfEmpty = true; // !(phpversion() >= '8.1'); - - $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); - - // JJO - $sanitizedData['user_created_id'] = $session->id_user; - - $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - - if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - endif; - - $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission - endif; - if ($noException && $successfulResult) : - - $id = $this->model->db->insertID(); - - $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; - - 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['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); - $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null); - $this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($clienteEntity->comercial_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null); - $this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null); - - $this->viewData['formAction'] = site_url('cliente/add'); // route_to('createCliente'); IMN - - $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); - - - return $this->displayForm(__METHOD__); - } // end function add() - - public function edit($requestedId = null) - { - - // JJO - $session = session(); - - 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('Clientes.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('credito_asegurado') == null) { - $sanitizedData['credito_asegurado'] = 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; - } - - // JJO - $sanitizedData['user_updated_id'] = $session->id_user; - - $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - - if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Clientes.cliente'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $clienteEntity->fill($sanitizedData); - - $thenRedirect = false; - endif; - if ($noException && $successfulResult) : - $id = $clienteEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; - - if ($thenRedirect) : - if (!empty($this->indexRoute)) : - return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else: - return $this->redirect2listView('sweet-success', $message); - endif; - else: - $this->session->setFlashData('sweet-success', $message); - endif; - - endif; // $noException && $successfulResult - endif; // ($requestMethod === 'post') - - //var_dump($clienteEntity); dd(); - - $this->viewData['clienteEntity'] = $clienteEntity; - $this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null); - $this->viewData['provinciaList'] = $this->getProvinciaListItems($clienteEntity->provincia_id ?? null); - $this->viewData['paisList'] = $this->getPaisListItems($clienteEntity->pais_id ?? null); - $this->viewData['ccaaList'] = $this->getCcaaListItems($clienteEntity->ccaa_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($clienteEntity->comercial_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($clienteEntity->soporte_id ?? null); - $this->viewData['formaDePagoList'] = $this->getFormaDePagoListItems($clienteEntity->forma_pago_id ?? null); - - $this->viewData['formAction'] = route_to('updateCliente', $id); - - $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3'); - - - 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->direccion) && strlen($item->direccion) > 100) : - $item->direccion = character_limiter($item->direccion, 100); - endif; - if (isset($item->comentarios_tirada_flexible) && strlen($item->comentarios_tirada_flexible) > 100) : - $item->comentarios_tirada_flexible = character_limiter($item->comentarios_tirada_flexible, 100); - endif; - if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) : - $item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100); - endif; - if (isset($item->comentarios) && strlen($item->comentarios) > 100) : - $item->comentarios = character_limiter($item->comentarios, 100); - endif; - endforeach; - - return $this->respond(Collection::datatable( - $resourceData, - $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; - try{ - $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); - $nonItem = new \stdClass; - $nonItem->id = ''; - $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; - array_unshift($menu, $nonItem); - } - catch(Exception $e){ - $menu = []; - } - - $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($selId = null) - { - $paisModel = model('App\Models\Configuracion\PaisModel'); - $onlyActiveOnes = true; - $data = $paisModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes); - - return $data; - } - - protected function getCcaaListItems($selId = null) - { - $ccaaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); - $onlyActiveOnes = true; - $data = $ccaaModel->getAllForMenu('id, nombre', 'nombre', $onlyActiveOnes); - - return $data; - } - - protected function getUserListItems($selId = null) - { - $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])]; - if (!empty($selId)) : - $userModel = model('App\Models\Usuarios\UserModel'); - - $selOption = $userModel->where('id_user', $selId)->findColumn('first_name'); - if (!empty($selOption)) : - $data[$selId] = $selOption[0]; - endif; - endif; - return $data; - } - - - protected function getComunidadAutonomaListItems($selId = null) - { - $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('ComunidadesAutonomas.comunidadAutonoma'))])]; - if (!empty($selId)) : - $comunidadAutonomaModel = model('App\Models\Configuracion\ComunidadAutonomaModel'); - - $selOption = $comunidadAutonomaModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : - $data[$selId] = $selOption[0]; - endif; - endif; - return $data; - } - - - protected function getUserListItems2($selId = null) - { - $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Users.user'))])]; - if (!empty($selId)) : - $userModel = model('App\Models\Configuracion\UserModel'); - - $selOption = $userModel->where('id_user', $selId)->findColumn('last_name'); - if (!empty($selOption)) : - $data[$selId] = $selOption[0]; - endif; - endif; - return $data; - } - - - protected function getFormaDePagoListItems($selId = null) - { - $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])]; - if (!empty($selId)) : - $formaPagoModel = model('App\Models\Configuracion\FormaPagoModel'); - - $selOption = $formaPagoModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : - $data[$selId] = $selOption[0]; - endif; - endif; - return $data; - } - - - protected function getProvinciaListItems($selId = null) - { - $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; - if (!empty($selId)) : - $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); - - $selOption = $provinciaModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : - $data[$selId] = $selOption[0]; - endif; - endif; - return $data; - } - -} diff --git a/ci4/app/Controllers/Clientes/Clienteplantillaprecios.php b/ci4/app/Controllers/Clientes/Clienteplantillaprecios.php new file mode 100755 index 00000000..ee2564e1 --- /dev/null +++ b/ci4/app/Controllers/Clientes/Clienteplantillaprecios.php @@ -0,0 +1,245 @@ +viewData['pageTitle'] = lang('ClientesPrecios.plantillaPrecios_module'); + $this->viewData['usingSweetAlert'] = true; + + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + $this->viewData = ['usingServerSideDataTable' => true]; // JJO + + // Breadcrumbs (IMN) + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_clientes"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_plantillas_tarifas_clientes"), 'route' => site_url('clientes/clienteplantillaprecios'), 'active' => true] + ]; + + parent::initController($request, $response, $logger); + } + + + public function index() + { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClientePrecios.plantillaPrecios_module')]), + 'clientePlantillaPreciosEntity' => new ClientePlantillaPreciosEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath . 'viewClienteplantillapreciosList', $viewData); + } + + + public function add() + { + // JJO + $session = session(); + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_created_id'] = $session->id_user; + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + endif; + + $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission + endif; + if ($noException && $successfulResult) : + + $id = $this->model->db->insertID(); + + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + //return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + return redirect()->to(site_url('/clientes/clientesplantillaprecios/edit/' . $id))->with('message', $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['clienteplantillapreciosEntity'] = isset($sanitizedData) ? new ClientePlantillaPreciosEntity($sanitizedData) : new ClientePlantillaPreciosEntity(); + $this->viewData['formAction'] = route_to('createClienteplantillaprecios'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClientePrecios.plantillaPrecios_name') . ' ' . lang('Basic.global.addNewSuffix'); + + + return $this->displayForm(__METHOD__); + } // end function add() + + public function edit($requestedId = null) + { + + // JJO + $session = session(); + + if ($requestedId == null) : + return $this->redirect2listView(); + endif; + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $clientePlantillaPreciosEntity = $this->model->find($id); + + if ($clientePlantillaPreciosEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Clientes.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); + + // JJO + $sanitizedData['user_updated_id'] = $session->id_user; + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } + else: + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Clientes.cliente'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $clientePlantillaPreciosEntity->fill($sanitizedData); + + $thenRedirect = false; + endif; + if ($noException && $successfulResult) : + $id = $clientePlantillaPreciosEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else: + return $this->redirect2listView('sweet-success', $message); + endif; + else: + $this->session->setFlashData('sweet-success', $message); + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') + + //var_dump($clientePlantillaPreciosEntity); dd(); + + $this->viewData['clienteplantillapreciosEntity'] = $clientePlantillaPreciosEntity; + + $this->viewData['formAction'] = route_to('updateClienteplantillaprecios', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3'); + + + return $this->displayForm(__METHOD__, $id); + } // end function edit(...) + + + public function datatable() + { + 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 = ClientePlantillaPreciosModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0]; + $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); + } + } + + + +} diff --git a/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php b/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php new file mode 100755 index 00000000..6f32762b --- /dev/null +++ b/ci4/app/Controllers/Clientes/Clienteplantillaprecioslineas.php @@ -0,0 +1,198 @@ +viewData['pageTitle'] = lang('ClientesPrecios.plantillaPrecios_module'); + $this->viewData['usingSweetAlert'] = true; + + // Se indica que este controlador trabaja con soft_delete + $this->soft_delete = true; + // Se indica el flag para los ficheros borrados + $this->delete_flag = 1; + + $this->viewData = ['usingServerSideDataTable' => true]; // JJO + + parent::initController($request, $response, $logger); + } + + + + + 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; + $requestedOrder = $reqData['order']['0']['column'] ?? 0; + $requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder; + $requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder; + $requestedOrder4 = $reqData['order']['3']['column'] ?? $requestedOrder; + $requestedOrder5 = $reqData['order']['4']['column'] ?? $requestedOrder; + $order = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 0]; + $order2 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : $requestedOrder]; + $order3 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : $requestedOrder]; + $order4 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder4 : $requestedOrder]; + $order5 = ClientePlantillaPreciosLineasModel::SORTABLE[$requestedOrder4 >= 0 ? $requestedOrder5 : $requestedOrder]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + $dir2 = $reqData['order']['1']['dir'] ?? $dir; + $dir3 = $reqData['order']['2']['dir'] ?? $dir; + $dir4= $reqData['order']['3']['dir'] ?? $dir; + $dir5= $reqData['order']['4']['dir'] ?? $dir; + + $plantilla_id = $reqData['plantilla_id'] ?? 0; + + $resourceData = $this->model->getResource($plantilla_id) + ->orderBy($order, $dir)->orderBy($order2, $dir2)->orderBy($order3, $dir3)->orderBy($order4, $dir4)->orderBy($order5, $dir5) + ->limit($length, $start)->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()) { + + include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); + + + // Build our Editor instance and process the data coming from _POST + $response = Editor::inst( $db, 'cliente_plantilla_precios_lineas' ) + ->fields( + Field::inst( 'plantilla_id' ), + Field::inst( 'tipo' ), + Field::inst( 'tipo_maquina' ), + Field::inst( 'tipo_impresion' ), + Field::inst( 'user_updated_id' ), + Field::inst( 'updated_at' ), + Field::inst( 'tiempo_min' ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('ClientePrecios.validation.required')) + ) + ->validator('Validate::numeric', array( + 'message' => lang('ClientePrecios.validation.decimal')) + ), + + Field::inst( 'tiempo_max' ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('ClientePrecios.validation.required')) + ) + ->validator('Validate::numeric', array( + 'message' => lang('ClientePrecios.validation.decimal')) + ), + + Field::inst( 'precio_hora' ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('ClientePrecios.validation.required')) + ) + ->validator('Validate::numeric', array( + 'message' => lang('ClientePrecios.validation.decimal')) + ), + + Field::inst( 'margen' ) + ->validator( 'Validate::notEmpty',array( + 'message' => lang('ClientePrecios.validation.required')) + ) + ->validator('Validate::numeric', array( + 'message' => lang('ClientePrecios.validation.decimal')) + ), + + ) + ->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) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->on('preEdit', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->debug(true) + ->process($_POST) + ->data(); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $response[$csrfTokenName] = $newTokenHash; + + echo json_encode($response); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + +} diff --git a/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php b/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php index 9221712f..60697dac 100755 --- a/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php +++ b/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php @@ -1,5 +1,5 @@ null, @@ -18,6 +18,7 @@ class ClientePreciosEntity extends \CodeIgniter\Entity\Entity "deleted_at" => null, "created_at" => null, "updated_at" => null, + "user_updated_id" => null ]; protected $casts = [ "plantilla_id" => "int", @@ -25,5 +26,6 @@ class ClientePreciosEntity extends \CodeIgniter\Entity\Entity "tiempo_max" => "float", "margen" => "float", "is_deleted" => "int", + "user_updated_id" => "int" ]; } diff --git a/ci4/app/Language/en/ClientePrecios.php b/ci4/app/Language/en/ClientePrecios.php index a6c941b7..5c14e5b7 100755 --- a/ci4/app/Language/en/ClientePrecios.php +++ b/ci4/app/Language/en/ClientePrecios.php @@ -3,6 +3,9 @@ return [ + 'plantillaPrecios_module' => 'Customer fees templates', + 'plantillaPrecios_name' => 'Customer fees template', + 'plantillaPrecios_list' => 'List Customer fees templates', 'nombre' => 'Name', 'plantilla_id' => 'Template ID', 'tipo' => 'Type', @@ -10,13 +13,32 @@ return [ 'tipo_impresion' => 'Print type', 'tiempo_min' => 'Min. Time', 'tiempo_max' => 'Max. Time', + 'precio_hora' => 'Price per hour', 'margen' => 'Margin', 'cliente_id' => 'Customer', 'user_updated_id' => 'User edition', 'updated_at' => 'Date edition', + + 'interior' => 'Inside', + 'cubierta' => 'Cover', + 'sobrecubierta' => 'Dust jacket', + 'toner' => 'Toner', + 'inkjet' => 'Inkjet', + 'negro' => 'Black', + 'negrohq' => 'Black HQ', + 'color' => 'Colour', + 'colorhq' => 'Colour HQ', + + 'validation' => [ 'max_length' => 'Max. length ', 'required' => 'Field required', - + 'decimal' => 'Decimal number', ], + 'errors' => [ + 'error_tiempo_range' => 'The field Min Time must be lower than the field Max Time', + 'error_tiempo_overlap' => 'The range [Min Time, Max Time] is overlapped with another one for the selected type.', + ] + + } ]; \ No newline at end of file diff --git a/ci4/app/Language/es/ClientePrecios.php b/ci4/app/Language/es/ClientePrecios.php index 69909dd3..f87ace4f 100755 --- a/ci4/app/Language/es/ClientePrecios.php +++ b/ci4/app/Language/es/ClientePrecios.php @@ -3,6 +3,9 @@ return [ + 'plantillaPrecios_module' => 'Plantillas tarifas cliente', + 'plantillaPrecios_name' => 'Plantilla tarifas cliente', + 'plantillaPrecios_list' => 'Lista Plantillas tarifas cliente', 'nombre' => 'Nombre', 'plantilla_id' => 'Plantilla ID', 'tipo' => 'Tipo', @@ -10,13 +13,30 @@ return [ 'tipo_impresion' => 'Tipo de impresión', 'tiempo_min' => 'Tiempo Mín.', 'tiempo_max' => 'Tiempo Máx.', + 'precio_hora' => 'Precio hora', 'margen' => 'Margen', 'cliente_id' => 'Cliente', 'user_updated_id' => 'Usuario edición', 'updated_at' => 'Fecha edición', + + 'interior' => 'Interior', + 'cubierta' => 'Cubierta', + 'sobrecubierta' => 'Sobrecubierta', + 'toner' => 'Tóner', + 'inkjet' => 'Inkjet', + 'negro' => 'Negro', + 'negrohq' => 'Negro HQ', + 'color' => 'Color', + 'colorhq' => 'Color HQ', + 'validation' => [ 'max_length' => 'Max. valor caracteres alcanzado', 'required' => 'Campo obligatorio', + 'decimal' => 'Número decimal', ], + 'errors' => [ + 'error_tiempo_range' => 'El campo Tiempo Mín debe ser menor que el campo Tiempo Máx', + 'error_tiempo_overlap' => 'El rango [Tiempo Min, Tiempo Máx] se solapa con otro con los mismos parámetros.', + ] ]; \ No newline at end of file diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php index 2f1ed657..5f2a7dbe 100755 --- a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php +++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php @@ -4,7 +4,18 @@ namespace App\Models\Clientes; class ClientePlantillaPreciosLineasModel extends \App\Models\GoBaseModel { - protected $table = "cliente_plantilla_precios_linea"; + protected $table = "cliente_plantilla_precios_lineas"; + + const SORTABLE = [ + 0 => "t1.tipo", + 1 => "t1.tipo_maquina", + 2 => "t1.tipo_impresion", + 3 => "t1.tiempo_min", + 4 => "t1.tiempo_max", + 5 => "t1.precio_hora", + 6 => "t1.margen", + + ]; /** * Whether primary key uses auto increment. @@ -26,7 +37,8 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\GoBaseModel "is_deleted", "deleted_at", "created_at", - "updated_at"]; + "updated_at", + "user_updated_id"]; protected $returnType = "App\Entities\Clientes\ClientePlantillaPreciosLineasEntity"; @@ -98,5 +110,65 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\GoBaseModel ], ]; - + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource($plantilla_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id as id, t1.tipo AS tipo, t1.tipo_maquina AS tipo_maquina, t1.tipo_impresion AS tipo_impresion, + t1.tiempo_min AS tiempo_min, t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen, + t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated" + ); + + $builder->join("auth_user t2", "t1.user_updated_id = t2.id_user", "left"); + + $builder->where('t1.is_deleted', 0); + $builder->where('t1.plantilla_id', $plantilla_id); + + + return $builder; + } + + public function checkIntervals($data = [], $id_linea = null, $plantilla_id = null){ + + helper('general'); + + if(floatval($data["tiempo_min"])>= floatval($data["tiempo_max"])){ + return lang('ClientePrecios.errors.error_tiempo_range'); + } + + $rows = $this->db + ->table($this->table) + ->select("id, tiempo_min, tiempo_max") + ->where("is_deleted", 0) + ->where("tipo", $data["tipo"]) + ->where("tipo_maquina", $data["tipo_maquina"]) + ->where("tipo_impresion", $data["tipo_impresion"]) + ->where("plantilla_id", $plantilla_id) + ->get()->getResultObject(); + + + foreach ($rows as $row) { + if (!is_null($id_linea)){ + if($row->id == $id_linea){ + continue; + } + } + if(check_overlap(floatval($data["tiempo_min"]), floatval($data["tiempo_max"]), + $row->tiempo_min, $row->tiempo_max)){ + return lang('ClientePrecios.errors.error_tiempo_overlap'); + } + } + + return ""; + } + } diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php index 869d7c81..a55a8dc7 100755 --- a/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php +++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php @@ -6,6 +6,10 @@ class ClientePlantillaPreciosModel extends \App\Models\GoBaseModel { protected $table = "cliente_plantilla_precios"; + const SORTABLE = [ + 0 => "t1.nombre", + ]; + /** * Whether primary key uses auto increment. * @@ -40,5 +44,31 @@ class ClientePlantillaPreciosModel extends \App\Models\GoBaseModel ], ]; - + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $cliente_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id as id, t1.nombre AS nombre" + ); + + $builder->where('t1.is_deleted', 0); + + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.nombre", $search) + ->groupEnd(); + } + } diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems.php new file mode 100755 index 00000000..5724c4f8 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/_ClienteplantillapreciosFormItems.php @@ -0,0 +1,20 @@ +
+
+
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php new file mode 100755 index 00000000..43e11b59 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php @@ -0,0 +1,339 @@ +include("themes/_commonPartialsBs/datatables") ?> +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> + +section("content") ?> +
+
+
+
+

+
+
+ + + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ " + /> + "btn btn-secondary"]) ?> + +
+
+
+
+
+ + + + +
+
+

+ +

+ +
+
+ + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr_lineas = $('#tableOfPlantillasPreciosLineas').find("tr:first th").length - 1; + + const url = window.location.href; + const url_parts = url.split('/'); + if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; + } + else{ + id = -1; + } + + const actionBtns_lineas = function(data) { + return ` + + + + `; + }; + + + const tipo_linea = [ + {label:'', value:'interior'}, + {label:'', value: 'cubierta'}, + {label:'', value: 'sobrecubierta'} + ]; + + const tipo_maquina = [ + {label: '', value:'toner'}, + {label: '', value:'inkjet'}, + ]; + + const tipo_impresion = [ + {label: '', value:'negro'}, + {label: '', value:'negrohq'}, + {label: '', value:'color'}, + {label: '', value:'colorhq'}, + ]; + + var editor = new $.fn.dataTable.Editor( { + ajax: { + url: "", + headers: { + : v, + }, + }, + table : "#tableOfPlantillasPreciosLineas", + idSrc: 'id', + fields: [ { + name: "tipo", + type: "select", + options: tipo_linea + }, { + name: "tipo_maquina", + type: "select", + options: tipo_maquina + }, { + name: "tipo_impresion", + type: "select", + options: tipo_impresion + }, { + name: "tiempo_min" + }, { + name: "tiempo_max" + }, { + name: "precio_hora" + }, { + name: "margen" + }, { + name: "user_updated_id", + type:'hidden', + + }, { + name: "updated_at", + type:'hidden', + + }, { + "name": "plantilla_id", + "type": "hidden" + },{ + "name": "deleted_at", + "type": "hidden" + },{ + "name": "is_deleted", + "type": "hidden" + }, + ] + } ); + + editor.on( 'preSubmit', function ( e, d, type ) { + if ( type === 'create'){ + d.data[0]['plantilla_id'] = id; + } + else if(type === 'edit' ) { + for (v in d.data){ + d.data[v]['plantilla_id'] = id; + } + } + }); + + + editor.on( 'postSubmit', function ( e, json, data, action ) { + + yeniden(json.); + }); + + editor.on( 'submitSuccess', function ( e, json, data, action ) { + + theTable.clearPipeline(); + theTable.draw(); + }); + + + var theTable = $('#tableOfPlantillasPreciosLineas').DataTable( { + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + lengthMenu: [ 10, 25, 50, 100], + order: [[ 0, "asc" ], [ 1, "asc" ], [ 2, "asc" ], [ 3, "asc" ]], + pageLength: 50, + lengthChange: true, + searching: false, + paging: true, + info: false, + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', + ajax : $.fn.dataTable.pipeline( { + url: '', + data: { + plantilla_id: id, + }, + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columns: [ + { 'data': 'tipo' , + 'render': function ( data, type, row, meta ) { + if(data=='interior') + return ''; + else if(data=='cubierta') + return ''; + else if(data=='sobrecubierta') + return ''; + } + }, + { 'data': 'tipo_maquina', + 'render': function ( data, type, row, meta ) { + if(data=='toner') + return ''; + else if(data=='inkjet') + return ''; + } + }, + { 'data': 'tipo_impresion', + 'render': function ( data, type, row, meta ) { + if(data=='negro') + return ''; + else if(data=='negrohq') + return ''; + else if(data=='color') + return ''; + else if(data=='colorhq') + return ''; + } + }, + { 'data': 'tiempo_min' }, + { 'data': 'tiempo_max' }, + { 'data': 'precio_hora' }, + { 'data': 'margen' }, + { 'data': 'user_updated_id', + 'render': function ( data, type, row, meta ) { + return row.user_updated + } + }, + { 'data': 'updated_at' }, + { + data: actionBtns_lineas, + className: 'row-edit dt-center' + } + ], + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr_lineas] + }, + {"orderData": [ 0, 1 ], "targets": 0 }, + + ], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + buttons: [ { + className: 'btn btn-primary me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } + } ] + } ); + + + + // Activate an inline edit on click of a table cell + $('#tableOfPlantillasPreciosLineas').on( 'click', 'tbody span.edit', function (e) { + editor.inline( + theTable.cells(this.parentNode.parentNode, '*').nodes(), + { + cancelHtml: '', + cancelTrigger: 'span.cancel', + submitHtml: '', + submitTrigger: 'span.edit', + submit: 'allIfChanged' + } + ); + } ); + + + // Delete row + $(document).on('click', '.btn-delete', function(e) { + $(".btn-remove").attr('data-id', $(this).attr('data-id')); + }); + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/clientes/clienteplantillaprecioslineas/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); +endSection() ?> + + + +section('css') ?> + + +endSection() ?> + +section('additionalExternalJs') ?> + + + + + + + + +endSection() ?> + diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosList.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosList.php new file mode 100755 index 00000000..25e0a998 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosList.php @@ -0,0 +1,136 @@ +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
+ +
+
+

+ 'btn btn-primary float-end']); ?> +
+
+ + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + +section('additionalInlineJs') ?> + + const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1; + const actionBtns2 = function(data) { + return ` + + + + `; + }; + + + $(document).on('click', '.btn-edit', function(e) { + window.location.href = `/clientes/clienteplantillaprecios/edit/${$(this).attr('data-id')}`; + }); + + + // Delete row + $(document).on('click', '.btn-delete', function(e) { + $(".btn-remove").attr('data-id', $(this).attr('data-id')); + }); + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + + $.ajax({ + url: `/clientes/clienteplantillaprecios/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + tablePLantillaPrecios.clearPipeline(); + tablePLantillaPrecios.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }); + } + }); + + + var tablePLantillaPrecios = $('#tableOfClienteplantillaprecios').DataTable( { + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250], + order: [[ 0, "asc" ]], + pageLength: 25, + lengthChange: true, + searching: true, + paging: true, + info: true, + stateSave: true, + dom: "lftp", + ajax : $.fn.dataTable.pipeline( { + url: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columns: [ + { data: 'nombre'}, + { data: actionBtns2, + className: 'row-edit dt-center'} + ], + columnDefs: [ + { + orderable: false, + targets: [lastColNr2] + }, + { + searchable: false, + targets: [lastColNr2] + } + ], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + } + } ); +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu.php b/ci4/app/Views/themes/backend/vuexy/main/menu.php index a586f497..b5184543 100755 --- a/ci4/app/Views/themes/backend/vuexy/main/menu.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu.php @@ -41,8 +41,8 @@ diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu_digitalizacion.php b/ci4/app/Views/themes/backend/vuexy/main/menu_digitalizacion.php index 6863729e..c451b754 100755 --- a/ci4/app/Views/themes/backend/vuexy/main/menu_digitalizacion.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu_digitalizacion.php @@ -45,6 +45,11 @@
">
+ diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php b/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php index 79bb73a3..858ffb0d 100755 --- a/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu_impresion.php @@ -46,7 +46,7 @@ diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu_maquetacion.php b/ci4/app/Views/themes/backend/vuexy/main/menu_maquetacion.php index 2d797e38..958974ec 100755 --- a/ci4/app/Views/themes/backend/vuexy/main/menu_maquetacion.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu_maquetacion.php @@ -45,6 +45,11 @@
">
+