From 3e27d3fc17693068b78694fb6fda466ec98b3851 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Fri, 4 Aug 2023 18:17:05 +0200 Subject: [PATCH 01/13] =?UTF-8?q?A=C3=B1adido=20los=20archivos=20necesario?= =?UTF-8?q?s=20para=20proveedores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Controllers/Compras/Proveedores.php | 320 ++++++++++++++++++ .../Controllers/Compras/ProveedoresTipos.php | 271 +++++++++++++++ ci4/app/Entities/Compras/ProveedorEntity.php | 32 ++ .../Entities/Compras/ProveedorTipoEntity.php | 18 + ci4/app/Models/Compras/ProveedorModel.php | 203 +++++++++++ ci4/app/Models/Compras/ProveedorTipoModel.php | 75 ++++ .../proveedores/_proveedorFormItems.php | 117 +++++++ .../proveedores/_proveedorTipoFormItems.php | 12 + .../compras/proveedores/viewProveedorForm.php | 93 +++++ .../compras/proveedores/viewProveedorList.php | 183 ++++++++++ .../proveedores/viewProveedorTipoForm.php | 26 ++ .../proveedores/viewProveedorTipoList.php | 185 ++++++++++ 12 files changed, 1535 insertions(+) create mode 100644 ci4/app/Controllers/Compras/Proveedores.php create mode 100644 ci4/app/Controllers/Compras/ProveedoresTipos.php create mode 100644 ci4/app/Entities/Compras/ProveedorEntity.php create mode 100644 ci4/app/Entities/Compras/ProveedorTipoEntity.php create mode 100644 ci4/app/Models/Compras/ProveedorModel.php create mode 100644 ci4/app/Models/Compras/ProveedorTipoModel.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorTipoFormItems.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorTipoForm.php create mode 100644 ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorTipoList.php diff --git a/ci4/app/Controllers/Compras/Proveedores.php b/ci4/app/Controllers/Compras/Proveedores.php new file mode 100644 index 00000000..714cc810 --- /dev/null +++ b/ci4/app/Controllers/Compras/Proveedores.php @@ -0,0 +1,320 @@ +viewData['pageTitle'] = lang('LgProveedores.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('LgProveedores.proveedor')]), + 'proveedorEntity' => new ProveedorEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewProveedorList', $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('LgProveedores.proveedor'))]); + $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('LgProveedores.proveedor'))]).'.'; + $message .= anchor( "admin/proveedores/{$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['proveedorEntity'] = isset($sanitizedData) ? new ProveedorEntity($sanitizedData) : new ProveedorEntity(); + $this->viewData['proveedorTipoList'] = $this->getProveedorTipoListItems($proveedorEntity->tipo_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($proveedorEntity->provincia_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems(); + + $this->viewData['formAction'] = route_to('createProveedor'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('LgProveedores.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); + $proveedorEntity = $this->model->find($id); + + if ($proveedorEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('LgProveedores.proveedor')), $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('LgProveedores.proveedor'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $proveedorEntity->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $proveedorEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('LgProveedores.proveedor'))]).'.'; + $message .= anchor( "admin/proveedores/{$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['proveedorEntity'] = $proveedorEntity; + $this->viewData['proveedorTipoList'] = $this->getProveedorTipoListItems($proveedorEntity->tipo_id ?? null); + $this->viewData['provinciaList'] = $this->getProvinciaListItems($proveedorEntity->provincia_id ?? null); + $this->viewData['paisList'] = $this->getPaisListItems(); + + $this->viewData['formAction'] = route_to('updateProveedor', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('LgProveedores.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 = ProveedorModel::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 getProveedorTipoListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo'))])]; + if (!empty($selId)) : + $proveedorTipoModel = model('App\Models\compras\ProveedorTipoModel'); + + $selOption = $proveedorTipoModel->where('id', $selId)->findColumn('nombre'); + if (!empty($selOption)) : + $data[$selId] = $selOption[0]; + endif; + endif; + return $data; + } + + + protected function getPaisListItems() { + $paisModel = model('App\Models\Configuracion\PaisModel'); + $onlyActiveOnes = true; + $data = $paisModel->getAllForMenu('id, nombre','nombre', $onlyActiveOnes ); + + return $data; + } + + + protected function getProvinciaListItems($selId = null) { + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; + if (!empty($selId)) : + $provinciaModel = model('App\Models\compras\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/Compras/ProveedoresTipos.php b/ci4/app/Controllers/Compras/ProveedoresTipos.php new file mode 100644 index 00000000..fbcbf10c --- /dev/null +++ b/ci4/app/Controllers/Compras/ProveedoresTipos.php @@ -0,0 +1,271 @@ +viewData['pageTitle'] = lang('LgProveedoresTipos.moduleTitle'); + $this->viewData['usingSweetAlert'] = true; + parent::initController($request, $response, $logger); + } + + + public function index() { + + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('LgProveedoresTipos.proveedorTipo')]), + 'proveedorTipoEntity' => new ProveedorTipoEntity(), + 'usingServerSideDataTable' => true, + + ]; + + $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class + + return view(static::$viewPath.'viewProveedorTipoList', $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('LgProveedoresTipos.proveedorTipo'))]); + $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('LgProveedoresTipos.proveedorTipo'))]).'.'; + $message .= anchor( "admin/proveedorestipos/{$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['proveedorTipoEntity'] = isset($sanitizedData) ? new ProveedorTipoEntity($sanitizedData) : new ProveedorTipoEntity(); + + $this->viewData['formAction'] = route_to('createProveedorTipo'); + + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('LgProveedoresTipos.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); + $proveedorTipoEntity = $this->model->find($id); + + if ($proveedorTipoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo')), $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('LgProveedoresTipos.proveedorTipo'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $proveedorTipoEntity->fill($sanitizedData); + + $thenRedirect = true; + endif; + if ($noException && $successfulResult) : + $id = $proveedorTipoEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo'))]).'.'; + $message .= anchor( "admin/proveedorestipos/{$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['proveedorTipoEntity'] = $proveedorTipoEntity; + + $this->viewData['formAction'] = route_to('updateProveedorTipo', $id); + + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('LgProveedoresTipos.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 = ProveedorTipoModel::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); + } + } + +} diff --git a/ci4/app/Entities/Compras/ProveedorEntity.php b/ci4/app/Entities/Compras/ProveedorEntity.php new file mode 100644 index 00000000..a276ae45 --- /dev/null +++ b/ci4/app/Entities/Compras/ProveedorEntity.php @@ -0,0 +1,32 @@ + null, + "nombre" => null, + "tipo_id" => null, + "razon_social" => null, + "cif" => null, + "direccion" => null, + "cp" => null, + "ciudad" => null, + "provincia_id" => null, + "pais_id" => 1, + "persona_contacto" => null, + "email" => null, + "telefono" => null, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "tipo_id" => "?int", + "provincia_id" => "int", + "pais_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Compras/ProveedorTipoEntity.php b/ci4/app/Entities/Compras/ProveedorTipoEntity.php new file mode 100644 index 00000000..8def2632 --- /dev/null +++ b/ci4/app/Entities/Compras/ProveedorTipoEntity.php @@ -0,0 +1,18 @@ + null, + "nombre" => null, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php new file mode 100644 index 00000000..a6e3f263 --- /dev/null +++ b/ci4/app/Models/Compras/ProveedorModel.php @@ -0,0 +1,203 @@ + "t1.id", + 2 => "t1.nombre", + 3 => "t1.tipo_id", + 4 => "t1.razon_social", + 5 => "t1.cif", + 6 => "t1.direccion", + 7 => "t1.cp", + 8 => "t1.ciudad", + 9 => "t1.provincia_id", + 10 => "t1.pais_id", + 11 => "t1.persona_contacto", + 12 => "t1.email", + 13 => "t1.telefono", + 14 => "t2.nombre", + 15 => "t3.nombre", + 16 => "t4.nombre", + ]; + + protected $allowedFields = [ + "nombre", + "tipo_id", + "razon_social", + "cif", + "direccion", + "cp", + "ciudad", + "provincia_id", + "pais_id", + "persona_contacto", + "email", + "telefono", + ]; + protected $returnType = "App\Entities\compras\ProveedorEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "cif" => [ + "label" => "LgProveedores.cif", + "rules" => "trim|max_length[15]", + ], + "ciudad" => [ + "label" => "LgProveedores.ciudad", + "rules" => "trim|max_length[255]", + ], + "cp" => [ + "label" => "LgProveedores.cp", + "rules" => "trim|max_length[10]", + ], + "direccion" => [ + "label" => "LgProveedores.direccion", + "rules" => "trim|max_length[255]", + ], + "email" => [ + "label" => "LgProveedores.email", + "rules" => "trim|max_length[255]|valid_email|permit_empty", + ], + "nombre" => [ + "label" => "LgProveedores.nombre", + "rules" => "trim|required|max_length[255]", + ], + "persona_contacto" => [ + "label" => "LgProveedores.personaContacto", + "rules" => "trim|max_length[255]", + ], + "razon_social" => [ + "label" => "LgProveedores.razonSocial", + "rules" => "trim|max_length[255]", + ], + "telefono" => [ + "label" => "LgProveedores.telefono", + "rules" => "trim|max_length[60]", + ], + ]; + + protected $validationMessages = [ + "cif" => [ + "max_length" => "LgProveedores.validation.cif.max_length", + ], + "ciudad" => [ + "max_length" => "LgProveedores.validation.ciudad.max_length", + ], + "cp" => [ + "max_length" => "LgProveedores.validation.cp.max_length", + ], + "direccion" => [ + "max_length" => "LgProveedores.validation.direccion.max_length", + ], + "email" => [ + "max_length" => "LgProveedores.validation.email.max_length", + "valid_email" => "LgProveedores.validation.email.valid_email", + ], + "nombre" => [ + "max_length" => "LgProveedores.validation.nombre.max_length", + "required" => "LgProveedores.validation.nombre.required", + ], + "persona_contacto" => [ + "max_length" => "LgProveedores.validation.persona_contacto.max_length", + ], + "razon_social" => [ + "max_length" => "LgProveedores.validation.razon_social.max_length", + ], + "telefono" => [ + "max_length" => "LgProveedores.validation.telefono.max_length", + ], + ]; + public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.nombre AS tipo, t3.nombre AS provincia, t4.nombre AS pais FROM " . + $this->table . + " t1 LEFT JOIN lg_proveedores_tipos t2 ON t1.tipo_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_paises t4 ON t1.pais_id = t4.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.razon_social AS razon_social, t1.cif AS cif, t1.direccion AS direccion, t1.cp AS cp, t1.ciudad AS ciudad, t1.persona_contacto AS persona_contacto, t1.email AS email, t1.telefono AS telefono, t2.nombre AS tipo, t3.nombre AS provincia, t4.nombre AS pais" + ); + $builder->join("lg_proveedores_tipos t2", "t1.tipo_id = t2.id", "left"); + $builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left"); + $builder->join("lg_paises t4", "t1.pais_id = t4.id", "left"); + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.razon_social", $search) + ->orLike("t1.cif", $search) + ->orLike("t1.direccion", $search) + ->orLike("t1.cp", $search) + ->orLike("t1.ciudad", $search) + ->orLike("t1.persona_contacto", $search) + ->orLike("t1.email", $search) + ->orLike("t1.telefono", $search) + ->orLike("t2.id", $search) + ->orLike("t3.id", $search) + ->orLike("t4.id", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.tipo_id", $search) + ->orLike("t1.razon_social", $search) + ->orLike("t1.cif", $search) + ->orLike("t1.direccion", $search) + ->orLike("t1.cp", $search) + ->orLike("t1.ciudad", $search) + ->orLike("t1.provincia_id", $search) + ->orLike("t1.pais_id", $search) + ->orLike("t1.persona_contacto", $search) + ->orLike("t1.email", $search) + ->orLike("t1.telefono", $search) + ->orLike("t2.nombre", $search) + ->orLike("t3.nombre", $search) + ->orLike("t4.nombre", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Models/Compras/ProveedorTipoModel.php b/ci4/app/Models/Compras/ProveedorTipoModel.php new file mode 100644 index 00000000..c0c40191 --- /dev/null +++ b/ci4/app/Models/Compras/ProveedorTipoModel.php @@ -0,0 +1,75 @@ + "t1.id", + 2 => "t1.nombre", + 3 => "t1.created_at", + 4 => "t1.updated_at", + ]; + + protected $allowedFields = ["nombre"]; + protected $returnType = "App\Entities\compras\ProveedorTipoEntity"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "nombre"; + + protected $validationRules = [ + "nombre" => [ + "label" => "LgProveedoresTipos.nombre", + "rules" => "trim|required|max_length[255]", + ], + ]; + + protected $validationMessages = [ + "nombre" => [ + "max_length" => "LgProveedoresTipos.validation.nombre.max_length", + "required" => "LgProveedoresTipos.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.created_at AS created_at, t1.updated_at AS updated_at"); + + 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("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.created_at", $search) + ->orLike("t1.updated_at", $search) + ->groupEnd(); + } +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorFormItems.php new file mode 100644 index 00000000..b7ae5eef --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorFormItems.php @@ -0,0 +1,117 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorTipoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorTipoFormItems.php new file mode 100644 index 00000000..90d8389b --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/_proveedorTipoFormItems.php @@ -0,0 +1,12 @@ +
+
+
+ + +
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php new file mode 100644 index 00000000..aa555fd9 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php @@ -0,0 +1,93 @@ +include("Themes/_commonPartialsBs/select2bs5") ?> +include("Themes/_commonPartialsBs/sweetalert") ?> +extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +section("content") ?> +
+
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ +
+
+
+
+endSection() ?> + + +section("additionalInlineJs") ?> + + + $('#tipoId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + $('#provinciaId').select2({ + theme: 'bootstrap-5', + allowClear: false, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + id: 'id', + text: 'nombre', + searchTerm: params.term, + : v + }; + }, + delay: 60, + processResults: function (response) { + + yeniden(response.); + + return { + results: response.menu + }; + }, + + cache: true + } + }); + + +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php new file mode 100644 index 00000000..ecb013a8 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php @@ -0,0 +1,183 @@ +include('Themes/_commonPartialsBs/select2bs5') ?> +include('Themes/_commonPartialsBs/datatables') ?> +include('Themes/_commonPartialsBs/sweetalert') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfProveedores').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfProveedores').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": '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' + } + ], + 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': 'tipo' }, + { 'data': 'razon_social' }, + { 'data': 'cif' }, + { 'data': 'direccion' }, + { 'data': 'cp' }, + { 'data': 'ciudad' }, + { 'data': 'provincia' }, + { 'data': 'pais' }, + { 'data': 'persona_contacto' }, + { 'data': 'email' }, + { 'data': 'telefono' }, + { '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/compras/proveedores/viewProveedorTipoForm.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorTipoForm.php new file mode 100644 index 00000000..0382ff7a --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorTipoForm.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/compras/proveedores/viewProveedorTipoList.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorTipoList.php new file mode 100644 index 00000000..a3e15710 --- /dev/null +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorTipoList.php @@ -0,0 +1,185 @@ +include('Themes/_commonPartialsBs/datatables') ?> +include('Themes/_commonPartialsBs/sweetalert') ?> +extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +section('content'); ?> +
+
+ +
+
+

+
+
+ + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +endSection() ?> + + +section('additionalInlineJs') ?> + + const lastColNr = $('#tableOfProveedorestipos').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; + theTable = $('#tableOfProveedorestipos').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": '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' + } + ], + 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': 'created_at' }, + { 'data': 'updated_at' }, + { 'data': actionBtns } + ] + }); + + + theTable.on( 'draw.dt', function () { + + const dateCols = [3, 4]; + 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() ?> + + +section('css') ?> + +endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + + + + +endSection() ?> + From 121b270dd01561ecfa6aa75461572496b748b249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 5 Aug 2023 12:51:29 +0200 Subject: [PATCH 02/13] Falta testear funcionamiento completo. Edit no funciona --- ci4/app/Config/Routes.php | 19 ++ ci4/app/Controllers/Compras/Proveedores.php | 61 +++--- .../Controllers/Compras/ProveedoresTipos.php | 6 +- ci4/app/Entities/Compras/ProveedorEntity.php | 2 +- .../Entities/Compras/ProveedorTipoEntity.php | 2 +- ci4/app/Language/en/Proveedores.php | 85 ++++++++ ci4/app/Language/es/Proveedores.php | 84 ++++++++ ci4/app/Models/Compras/ProveedorModel.php | 70 +++--- ci4/app/Models/Compras/ProveedorTipoModel.php | 4 +- .../proveedores/_proveedorFormItems.php | 50 ++--- .../compras/proveedores/viewProveedorForm.php | 26 ++- .../compras/proveedores/viewProveedorList.php | 201 +++++++----------- .../acabado/_tarifaAcabadoFormItems.php | 6 +- .../Views/themes/backend/vuexy/main/menu.php | 6 +- .../backend/vuexy/main/menu_impresion.php | 4 +- 15 files changed, 390 insertions(+), 236 deletions(-) create mode 100644 ci4/app/Language/en/Proveedores.php create mode 100644 ci4/app/Language/es/Proveedores.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 5f34cb4b..f15b815d 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -378,6 +378,25 @@ $routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Ta }); $routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']); + +$routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], function ($routes) { + $routes->get('', 'Proveedores::index', ['as' => 'proveedorList']); + $routes->get('add', 'Proveedores::add', ['as' => 'newProveedor']); + $routes->post('add', 'Proveedores::add', ['as' => 'createProveedor']); + $routes->post('create', 'Proveedores::create', ['as' => 'ajaxCreateProveedor']); + $routes->put('(:num)/update', 'Proveedores::update/$1', ['as' => 'ajaxUpdateProveedor']); + $routes->post('(:num)/edit', 'Proveedores::edit/$1', ['as' => 'updateProveedor']); + $routes->post('datatable', 'Proveedores::datatable', ['as' => 'dataTableOfProveedores']); + $routes->post('allmenuitems', 'Proveedores::allItemsSelect', ['as' => 'select2ItemsOfProveedores']); + $routes->post('menuitems', 'Proveedores::menuItems', ['as' => 'menuItemsOfProveedores']); +}); +$routes->resource('proveedores', ['namespace' => 'App\Controllers\Compras', 'controller' => 'Proveedores', 'except' => 'show,new,create,update']); + +$routes->group('proveedorestipos', ['namespace' => 'App\Controllers\Compras'], function ($routes) { + $routes->post('menuitems', 'ProveedoresTipos::menuItems', ['as' => 'menuItemsOfProveedoresTipos']); + }); + $routes->resource('proveedorestipos', ['namespace' => 'App\Controllers\Compras', 'controller' => 'ProveedoresTipos', 'except' => 'show,new,create,update']); + /* * -------------------------------------------------------------------- * Additional Routing diff --git a/ci4/app/Controllers/Compras/Proveedores.php b/ci4/app/Controllers/Compras/Proveedores.php index 714cc810..6950f26f 100644 --- a/ci4/app/Controllers/Compras/Proveedores.php +++ b/ci4/app/Controllers/Compras/Proveedores.php @@ -1,19 +1,12 @@ -viewData['pageTitle'] = lang('LgProveedores.moduleTitle'); + $this->viewData['pageTitle'] = lang('Proveedores.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]; + + + // Breadcrumbs (IMN) + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_proveedores"), 'route' => site_url('compras/proveedores'), 'active' => true] + ]; + parent::initController($request, $response, $logger); } @@ -44,7 +52,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $viewData = [ 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('LgProveedores.proveedor')]), + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Proveedores.proveedor')]), 'proveedorEntity' => new ProveedorEntity(), 'usingServerSideDataTable' => true, @@ -83,7 +91,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $this->dealWithException($e); } else: - $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('LgProveedores.proveedor'))]); + $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Proveedores.proveedor'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; @@ -93,7 +101,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $id = $this->model->db->insertID(); - $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('LgProveedores.proveedor'))]).'.'; + $message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Proveedores.proveedor'))]).'.'; $message .= anchor( "admin/proveedores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); $message = ucfirst(str_replace("'", "\'", $message)); @@ -118,7 +126,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = route_to('createProveedor'); - $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('LgProveedores.moduleTitle').' '.lang('Basic.global.addNewSuffix'); + $this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Proveedores.moduleTitle').' '.lang('Basic.global.addNewSuffix'); return $this->displayForm(__METHOD__); @@ -133,7 +141,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $proveedorEntity = $this->model->find($id); if ($proveedorEntity == false) : - $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('LgProveedores.proveedor')), $id]); + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Proveedores.proveedor')), $id]); return $this->redirect2listView('sweet-error', $message); endif; @@ -162,20 +170,21 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $this->dealWithException($e); } else: - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('LgProveedores.proveedor'))]); + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Proveedores.proveedor'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; $proveedorEntity->fill($sanitizedData); - $thenRedirect = true; + $thenRedirect = false; endif; if ($noException && $successfulResult) : $id = $proveedorEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('LgProveedores.proveedor'))]).'.'; - $message .= anchor( "admin/proveedores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; + //$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Proveedores.proveedor'))]).'.'; + //$message .= anchor( "admin/proveedores/{$id}/edit" , lang('Basic.global.continueEditing').'?'); + //$message = ucfirst(str_replace("'", "\'", $message)); if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -197,7 +206,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $this->viewData['formAction'] = route_to('updateProveedor', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('LgProveedores.moduleTitle').' '.lang('Basic.global.edit3'); + $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Proveedores.moduleTitle').' '.lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); @@ -217,7 +226,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $length = $reqData['length'] ?? 5; $search = $reqData['search']['value']; $requestedOrder = $reqData['order']['0']['column'] ?? 1; - $order = ProveedorModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; + $order = ProveedorModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0]; $dir = $reqData['order']['0']['dir'] ?? 'asc'; $resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); @@ -282,9 +291,9 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { protected function getProveedorTipoListItems($selId = null) { - $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('LgProveedoresTipos.proveedorTipo'))])]; + $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Proveedores.tipoId'))])]; if (!empty($selId)) : - $proveedorTipoModel = model('App\Models\compras\ProveedorTipoModel'); + $proveedorTipoModel = model('App\Models\Compras\ProveedorTipoModel'); $selOption = $proveedorTipoModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : @@ -307,7 +316,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { protected function getProvinciaListItems($selId = null) { $data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Provincias.provincia'))])]; if (!empty($selId)) : - $provinciaModel = model('App\Models\compras\ProvinciaModel'); + $provinciaModel = model('App\Models\Configuracion\ProvinciaModel'); $selOption = $provinciaModel->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : diff --git a/ci4/app/Controllers/Compras/ProveedoresTipos.php b/ci4/app/Controllers/Compras/ProveedoresTipos.php index fbcbf10c..45b0cc1b 100644 --- a/ci4/app/Controllers/Compras/ProveedoresTipos.php +++ b/ci4/app/Controllers/Compras/ProveedoresTipos.php @@ -1,13 +1,13 @@ - 'CIF', + 'ciudad' => 'City', + 'cp' => 'Postal code', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'direccion' => 'Address', + 'email' => 'Email', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Suppliers', + 'nombre' => 'Name', + 'paisId' => 'Country', + 'personaContacto' => 'Contact Person', + 'propiedades' => 'Properties', + 'proveedor' => 'Supplier', + 'proveedorList' => 'Suppliers List', + 'proveedores' => 'Suppliers', + 'provinciaId' => 'Region', + 'razonSocial' => 'Business Name', + 'telefono' => 'Phone', + 'tipoId' => 'Type', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'cif' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'ciudad' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'cp' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'direccion' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'persona_contacto' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'razon_social' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'telefono' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + + ], + + 'email' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'valid_email' => 'The {field} field must contain a valid email address.', + + ], + + 'nombre' => [ + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', + + ], + + 'tipo' => [ + 'required' => 'The {field} field is required.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/Proveedores.php b/ci4/app/Language/es/Proveedores.php new file mode 100644 index 00000000..d6928648 --- /dev/null +++ b/ci4/app/Language/es/Proveedores.php @@ -0,0 +1,84 @@ + 'CIF', + 'ciudad' => 'Ciudad', + 'cp' => 'Código Postal', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'direccion' => 'Direccion', + 'email' => 'Email', + 'id' => 'ID', + 'isDeleted' => 'Is Deleted', + 'moduleTitle' => 'Proveedores', + 'nombre' => 'Nombre', + 'paisId' => 'País', + 'personaContacto' => 'Persona Contacto', + 'propiedades' => 'Propiedades', + 'proveedor' => 'Proveedor', + 'proveedorList' => 'Lista de Proveedores', + 'proveedores' => 'Proveedores', + 'provinciaId' => 'Provincia', + 'razonSocial' => 'Razón Social', + 'telefono' => 'Teléfono', + 'tipoId' => 'Tipo', + 'updatedAt' => 'Updated At', + 'validation' => [ + 'cif' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'ciudad' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'cp' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'direccion' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'persona_contacto' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'razon_social' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'telefono' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + + ], + + 'email' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + 'valid_email' => 'El campo {field} debe contener una dirección de correo válida.', + + ], + + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres en longitud.', + 'required' => 'El campo {field} es obligatorio.', + + ], + 'tipo' => [ + 'required' => 'El campo {field} es obligatorio.', + + ], + + + ], + + +]; \ No newline at end of file diff --git a/ci4/app/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php index a6e3f263..b5d5896a 100644 --- a/ci4/app/Models/Compras/ProveedorModel.php +++ b/ci4/app/Models/Compras/ProveedorModel.php @@ -1,5 +1,5 @@ "t1.id", - 2 => "t1.nombre", - 3 => "t1.tipo_id", - 4 => "t1.razon_social", - 5 => "t1.cif", - 6 => "t1.direccion", - 7 => "t1.cp", - 8 => "t1.ciudad", - 9 => "t1.provincia_id", - 10 => "t1.pais_id", - 11 => "t1.persona_contacto", - 12 => "t1.email", - 13 => "t1.telefono", - 14 => "t2.nombre", - 15 => "t3.nombre", - 16 => "t4.nombre", + 0 => "t1.nombre", + 1 => "t2.nombre", + ]; protected $allowedFields = [ @@ -45,7 +32,7 @@ class ProveedorModel extends \App\Models\GoBaseModel "email", "telefono", ]; - protected $returnType = "App\Entities\compras\ProveedorEntity"; + protected $returnType = "App\Entities\Compras\ProveedorEntity"; protected $useTimestamps = true; protected $useSoftDeletes = false; @@ -58,72 +45,79 @@ class ProveedorModel extends \App\Models\GoBaseModel protected $validationRules = [ "cif" => [ - "label" => "LgProveedores.cif", + "label" => "Proveedores.cif", "rules" => "trim|max_length[15]", ], + "tipo_id" => [ + "label" => "Proveedores.tipoId", + "rules" => "required", + ], "ciudad" => [ - "label" => "LgProveedores.ciudad", + "label" => "Proveedores.ciudad", "rules" => "trim|max_length[255]", ], "cp" => [ - "label" => "LgProveedores.cp", + "label" => "Proveedores.cp", "rules" => "trim|max_length[10]", ], "direccion" => [ - "label" => "LgProveedores.direccion", + "label" => "Proveedores.direccion", "rules" => "trim|max_length[255]", ], "email" => [ - "label" => "LgProveedores.email", + "label" => "Proveedores.email", "rules" => "trim|max_length[255]|valid_email|permit_empty", ], "nombre" => [ - "label" => "LgProveedores.nombre", + "label" => "Proveedores.nombre", "rules" => "trim|required|max_length[255]", ], "persona_contacto" => [ - "label" => "LgProveedores.personaContacto", + "label" => "Proveedores.personaContacto", "rules" => "trim|max_length[255]", ], "razon_social" => [ - "label" => "LgProveedores.razonSocial", + "label" => "Proveedores.razonSocial", "rules" => "trim|max_length[255]", ], "telefono" => [ - "label" => "LgProveedores.telefono", + "label" => "Proveedores.telefono", "rules" => "trim|max_length[60]", ], ]; protected $validationMessages = [ "cif" => [ - "max_length" => "LgProveedores.validation.cif.max_length", + "max_length" => "Proveedores.validation.cif.max_length", ], "ciudad" => [ - "max_length" => "LgProveedores.validation.ciudad.max_length", + "max_length" => "Proveedores.validation.ciudad.max_length", ], "cp" => [ - "max_length" => "LgProveedores.validation.cp.max_length", + "max_length" => "Proveedores.validation.cp.max_length", ], "direccion" => [ - "max_length" => "LgProveedores.validation.direccion.max_length", + "max_length" => "Proveedores.validation.direccion.max_length", ], "email" => [ - "max_length" => "LgProveedores.validation.email.max_length", - "valid_email" => "LgProveedores.validation.email.valid_email", + "max_length" => "Proveedores.validation.email.max_length", + "valid_email" => "Proveedores.validation.email.valid_email", ], "nombre" => [ - "max_length" => "LgProveedores.validation.nombre.max_length", - "required" => "LgProveedores.validation.nombre.required", + "max_length" => "Proveedores.validation.nombre.max_length", + "required" => "Proveedores.validation.nombre.required", + ], + "tipo_id" => [ + "required" => "Proveedores.validation.tipo.required", ], "persona_contacto" => [ - "max_length" => "LgProveedores.validation.persona_contacto.max_length", + "max_length" => "Proveedores.validation.persona_contacto.max_length", ], "razon_social" => [ - "max_length" => "LgProveedores.validation.razon_social.max_length", + "max_length" => "Proveedores.validation.razon_social.max_length", ], "telefono" => [ - "max_length" => "LgProveedores.validation.telefono.max_length", + "max_length" => "Proveedores.validation.telefono.max_length", ], ]; public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) diff --git a/ci4/app/Models/Compras/ProveedorTipoModel.php b/ci4/app/Models/Compras/ProveedorTipoModel.php index c0c40191..d2ffb31a 100644 --- a/ci4/app/Models/Compras/ProveedorTipoModel.php +++ b/ci4/app/Models/Compras/ProveedorTipoModel.php @@ -1,5 +1,5 @@
- +
- +
- +
- +
- +
- $v) : ?> @@ -70,23 +70,23 @@
- +
- +
- $v) : ?> @@ -100,16 +100,16 @@
- +
- +
diff --git a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php index aa555fd9..a96c6207 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorForm.php @@ -1,6 +1,6 @@ -include("Themes/_commonPartialsBs/select2bs5") ?> -include("Themes/_commonPartialsBs/sweetalert") ?> -extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?> +include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?>
@@ -11,15 +11,21 @@
- + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
- -
+ +
+ " + /> + "btn btn-secondary float-start"]) ?> +
+ +
@@ -30,7 +36,6 @@ $('#tipoId').select2({ - theme: 'bootstrap-5', allowClear: false, ajax: { url: '', @@ -60,7 +65,6 @@ }); $('#provinciaId').select2({ - theme: 'bootstrap-5', allowClear: false, ajax: { url: '', diff --git a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php index ecb013a8..54040ed1 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/compras/proveedores/viewProveedorList.php @@ -1,45 +1,34 @@ -include('Themes/_commonPartialsBs/select2bs5') ?> -include('Themes/_commonPartialsBs/datatables') ?> -include('Themes/_commonPartialsBs/sweetalert') ?> -extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/backend/vuexy/main/defaultlayout') ?> section('content'); ?>
-

+

+ 'btn btn-primary float-end']); ?>
- + - - - - - - - - - - - - - - + + - +
@@ -50,26 +39,26 @@ section('additionalInlineJs') ?> - const lastColNr = $('#tableOfProveedores').find("tr:first th").length - 1; - const actionBtns = function(data) { - return ` -
- - -
- `; - }; - theTable = $('#tableOfProveedores').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": '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 + const lastColNr = $('#tableOfProveedores').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` + +
+ + +
+ `; + }; + theTable = $('#tableOfProveedores').DataTable({ + processing: true, + serverSide: true, + autoWidth: true, + responsive: true, + scrollX: true, + lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], + pageLength: 25, + lengthChange: true, + "dom": 'lfBrtip', "buttons": [ 'copy', 'csv', 'excel', 'print', { extend: 'pdfHtml5', @@ -77,89 +66,59 @@ 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': actionBtns }, - { 'data': 'id' }, - { 'data': 'nombre' }, - { 'data': 'tipo' }, - { 'data': 'razon_social' }, - { 'data': 'cif' }, - { 'data': 'direccion' }, - { 'data': 'cp' }, - { 'data': 'ciudad' }, - { 'data': 'provincia' }, - { 'data': 'pais' }, - { 'data': 'persona_contacto' }, - { 'data': 'email' }, - { 'data': 'telefono' }, - { '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, - }); - }) + stateSave: true, + order: [[0, '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': 'tipo' }, + { 'data': actionBtns } + ] }); - - + + $(document).on('click', '.btn-edit', function(e) { + window.location.href = `/compras/proveedores/edit/${$(this).attr('data-id')}`; + }); + + $(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: `/compras/proveedores/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() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php index c4b1eecb..f6508319 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php @@ -4,7 +4,7 @@ -
@@ -12,7 +12,7 @@ -
@@ -20,7 +20,7 @@ - diff --git a/ci4/app/Views/themes/backend/vuexy/main/menu.php b/ci4/app/Views/themes/backend/vuexy/main/menu.php index 5d9bd0d0..50a80092 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/menu.php +++ b/ci4/app/Views/themes/backend/vuexy/main/menu.php @@ -388,10 +388,10 @@ /** * MENU PROVEEDORES */ - if (count(getArrayItem($menus, 'name', 'Proveedor')) > 0): ?> - + if (count(getArrayItem($menus, 'name', 'Proveedores')) > 0): ?> + From 2e820fb12b40ff6fb8bb6e520289d6204a0f24ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 5 Aug 2023 17:51:32 +0200 Subject: [PATCH 03/13] Terminado modulo proveedores --- ci4/app/Config/Routes.php | 2 +- ci4/app/Controllers/Compras/Proveedores.php | 2 +- ci4/app/Models/Compras/ProveedorModel.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index f15b815d..dc4faebe 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -385,7 +385,7 @@ $routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], functi $routes->post('add', 'Proveedores::add', ['as' => 'createProveedor']); $routes->post('create', 'Proveedores::create', ['as' => 'ajaxCreateProveedor']); $routes->put('(:num)/update', 'Proveedores::update/$1', ['as' => 'ajaxUpdateProveedor']); - $routes->post('(:num)/edit', 'Proveedores::edit/$1', ['as' => 'updateProveedor']); + $routes->post('edit/(:num)', 'Proveedores::edit/$1', ['as' => 'updateProveedor']); $routes->post('datatable', 'Proveedores::datatable', ['as' => 'dataTableOfProveedores']); $routes->post('allmenuitems', 'Proveedores::allItemsSelect', ['as' => 'select2ItemsOfProveedores']); $routes->post('menuitems', 'Proveedores::menuItems', ['as' => 'menuItemsOfProveedores']); diff --git a/ci4/app/Controllers/Compras/Proveedores.php b/ci4/app/Controllers/Compras/Proveedores.php index 6950f26f..6c524d49 100644 --- a/ci4/app/Controllers/Compras/Proveedores.php +++ b/ci4/app/Controllers/Compras/Proveedores.php @@ -204,7 +204,7 @@ class Proveedores extends \App\Controllers\GoBaseResourceController { $this->viewData['provinciaList'] = $this->getProvinciaListItems($proveedorEntity->provincia_id ?? null); $this->viewData['paisList'] = $this->getPaisListItems(); - $this->viewData['formAction'] = route_to('updateProveedor', $id); + $this->viewData['formAction'] = route_to('updateProveedor', $id); $this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Proveedores.moduleTitle').' '.lang('Basic.global.edit3'); diff --git a/ci4/app/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php index b5d5896a..0d21344f 100644 --- a/ci4/app/Models/Compras/ProveedorModel.php +++ b/ci4/app/Models/Compras/ProveedorModel.php @@ -31,6 +31,8 @@ class ProveedorModel extends \App\Models\GoBaseModel "persona_contacto", "email", "telefono", + "is_deleted", + "deleted_at" ]; protected $returnType = "App\Entities\Compras\ProveedorEntity"; @@ -159,6 +161,9 @@ class ProveedorModel extends \App\Models\GoBaseModel $builder->join("lg_provincias t3", "t1.provincia_id = t3.id", "left"); $builder->join("lg_paises t4", "t1.pais_id = t4.id", "left"); + //JJO + $builder->where("t1.is_deleted", 0); + return empty($search) ? $builder : $builder From 7a4891af632b4f659a8a0cb75d34923608022a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 9 Aug 2023 09:58:11 +0200 Subject: [PATCH 04/13] trabajando tabla tiradas! --- .../Tarifas/Tarifaencuadernacionlineas.php | 10 +- .../Tarifas/Tarifaencuadernaciontiradas.php | 161 ++++++++++++++++++ .../Entities/Tarifas/TarifaAcabadoLinea.php | 4 +- .../Tarifas/TarifaEncuadernacionLinea.php | 4 +- .../Tarifas/TarifaEncuadernacionTirada.php | 29 ++++ .../Tarifas/TarifaManipuladoLinea.php | 8 +- ci4/app/Language/en/TarifaAcabadoLineas.php | 12 +- .../en/TarifaEncuadernacionTiradas.php | 28 +++ .../Language/en/TarifaManipuladoLineas.php | 12 +- ci4/app/Language/es/TarifaAcabadoLineas.php | 12 +- .../es/TarifaEncuadernacionTiradas.php | 28 +++ .../Language/es/TarifaManipuladoLineas.php | 12 +- .../Tarifas/TarifaAcabadoLineaModel.php | 46 ++--- .../TarifaEncuadernacionLineaModel.php | 56 +++--- .../TarifaEncuadernacionTiradaModel.php | 134 +++++++++++++++ .../Tarifas/TarifaManipuladoLineaModel.php | 50 +++--- .../tarifas/acabado/viewTarifaAcabadoForm.php | 4 +- .../_tarifaEncuadernacionFormItems.php | 6 +- .../viewTarifaEncuadernacionForm.php | 42 ++++- .../manipulado/_tarifaManipuladoFormItems.php | 6 +- .../manipulado/viewTarifaManipuladoForm.php | 4 +- 21 files changed, 542 insertions(+), 126 deletions(-) create mode 100644 ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php create mode 100644 ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php create mode 100644 ci4/app/Language/en/TarifaEncuadernacionTiradas.php create mode 100644 ci4/app/Language/es/TarifaEncuadernacionTiradas.php create mode 100644 ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php index f978bfe6..439a4176 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -245,7 +245,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll ->validator('Validate::notEmpty', array( 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) ), - Field::inst('tarifa_encuadernacion_id'), + Field::inst('tirada_encuadernacion_id'), Field::inst('user_created_id'), Field::inst('created_at'), Field::inst('user_updated_id'), @@ -261,7 +261,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll if ($data['data'][$pkey]['is_deleted'] != 1) { $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; - $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_encuadernacion_id']); + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tirada_encuadernacion_id']); // No se pueden duplicar valores al crear o al editar if (!empty($response)) { return $response; @@ -341,10 +341,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll if ($this->request->isAJAX()) { $onlyActiveOnes = true; $reqVal = $this->request->getPost('val') ?? 'id'; - $menu = $this->model->getAllForMenu($reqVal . ', tarifa_encuadernacion_id', 'tarifa_encuadernacion_id', $onlyActiveOnes, false); + $menu = $this->model->getAllForMenu($reqVal . ', tirada_encuadernacion_id', 'tirada_encuadernacion_id', $onlyActiveOnes, false); $nonItem = new \stdClass; $nonItem->id = ''; - $nonItem->tarifa_encuadernacion_id = '- ' . lang('Basic.global.None') . ' -'; + $nonItem->tirada_encuadernacion_id = '- ' . lang('Basic.global.None') . ' -'; array_unshift($menu, $nonItem); $newTokenHash = csrf_hash(); @@ -366,7 +366,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $reqId = goSanitize($this->request->getPost('id'))[0]; $reqText = goSanitize($this->request->getPost('text'))[0]; $onlyActiveOnes = false; - $columns2select = [$reqId ?? 'id', $reqText ?? 'tarifa_encuadernacion_id']; + $columns2select = [$reqId ?? 'id', $reqText ?? 'tirada_encuadernacion_id']; $onlyActiveOnes = false; $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); $nonItem = new \stdClass; diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php new file mode 100644 index 00000000..4706536f --- /dev/null +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -0,0 +1,161 @@ +request->isAJAX()) { + + include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php"); + + // Build our Editor instance and process the data coming from _POST + $response = Editor::inst($db, 'tarifa_encuadernacion_tiradas') + ->fields( + Field::inst('paginas_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + ), + Field::inst('paginas_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + ), + Field::inst('precio_min') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ), + Field::inst('precio_max') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) + ), + Field::inst('margen') + ->validator('Validate::numeric', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + ) + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ), + Field::inst('tirada_encuadernacion_id'), + Field::inst('user_created_id'), + Field::inst('created_at'), + Field::inst('user_updated_id'), + Field::inst('updated_at'), + Field::inst('is_deleted'), + Field::inst('deleted_at'), + + ) + ->validator(function ($editor, $action, $data) { + if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { + foreach ($data['data'] as $pkey => $values) { + // Si no se quiere borrar... + if ($data['data'][$pkey]['is_deleted'] != 1) { + $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; + $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tirada_encuadernacion_id']); + // No se pueden duplicar valores al crear o al editar + if (!empty($response)) { + return $response; + } + } + } + } + }) + ->on('preCreate', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_created_id') + ->setValue($session->id_user); + $editor + ->field('created_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->on('preEdit', function ($editor, &$values) { + $session = session(); + $datetime = (new \CodeIgniter\I18n\Time("now")); + $editor + ->field('user_updated_id') + ->setValue($session->id_user); + $editor + ->field('updated_at') + ->setValue($datetime->format('Y-m-d H:i:s')); + }) + ->debug(true) + ->process($_POST) + ->data(); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + + $response[$csrfTokenName] = $newTokenHash; + + echo json_encode($response); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + 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'] ?? 0; + $order = TarifaEncuadernacionLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0]; + $dir = $reqData['order']['0']['dir'] ?? 'asc'; + + $id_TM = $reqData['id_tarifaencuadernacion'] ?? -1; + + $resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + + return $this->respond(Collection::datatable( + $resourceData, + $this->model->getResource()->countAllResults(), + $this->model->getResource($search, $id_TM)->countAllResults() + )); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } +} + diff --git a/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php b/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php index 832fa317..0fcf0556 100644 --- a/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaAcabadoLinea.php @@ -8,8 +8,8 @@ class TarifaAcabadoLinea extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "tarifa_acabado_id" => 0, - "paginas_min" => 0, - "paginas_max" => 0, + "tirada_min" => 0, + "tirada_max" => 0, "precio_min" => 0, "precio_max" => 0, "margen" => 0, diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php index 58041841..cef07060 100644 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php @@ -7,7 +7,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity { protected $attributes = [ "id" => null, - "tarifa_encuadernacion_id" => 0, + "tirada_encuadernacion_id" => 0, "paginas_min" => 0, "paginas_max" => 0, "precio_min" => 0, @@ -20,7 +20,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity "updated_at" => null, ]; protected $casts = [ - "tarifa_encuadernacion_id" => "int", + "tirada_encuadernacion_id" => "int", "paginas_min" => "float", "paginas_max" => "float", "precio_min" => "float", diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php new file mode 100644 index 00000000..b432686f --- /dev/null +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php @@ -0,0 +1,29 @@ + null, + "tarifa_encuadernacion_id" => 0, + "tirada_min" => 0, + "tirada_max" => 0, + "proveedor_id" => 0, + "user_created_id" => 0, + "user_updated_id" => 0, + "is_deleted" => 0, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "tarifa_encuadernacion_id" => "int", + "tirada_min" => "float", + "tirada_max" => "float", + "proveedor_id" => "int", + "user_created_id" => "int", + "user_updated_id" => "int", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php b/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php index 63b503c2..f358343d 100644 --- a/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php @@ -8,8 +8,8 @@ class TarifaManipuladoLinea extends \CodeIgniter\Entity\Entity protected $attributes = [ "id" => null, "tarifa_manipulado_id" => 0, - "paginas_min" => 0, - "paginas_max" => 0, + "tirada_min" => 0, + "tirada_max" => 0, "precio_min" => 0, "precio_max" => 0, "margen" => 0, @@ -21,8 +21,8 @@ class TarifaManipuladoLinea extends \CodeIgniter\Entity\Entity ]; protected $casts = [ "tarifa_manipulado_id" => "int", - "paginas_min" => "float", - "paginas_max" => "float", + "tirada_min" => "float", + "tirada_max" => "float", "precio_min" => "float", "precio_max" => "float", "margen" => "float", diff --git a/ci4/app/Language/en/TarifaAcabadoLineas.php b/ci4/app/Language/en/TarifaAcabadoLineas.php index db580bec..35361c39 100644 --- a/ci4/app/Language/en/TarifaAcabadoLineas.php +++ b/ci4/app/Language/en/TarifaAcabadoLineas.php @@ -9,12 +9,12 @@ return [ 'precioMax' => 'Max Price', 'precioMin' => 'Min Price', 'precioUnidad' => 'Price Unit', - 'paginasMax' => 'Max Pages', - 'paginasMin' => 'Min Pages', + 'tiradaMax' => 'Max Printing', + 'tiradaMin' => 'Min Printing', 'margen' => 'Margin', 'validation' => [ - 'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.', - 'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages', + 'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.', + 'error_tirada_range' => 'The field Min Printing must be lower than the field Max Printing', 'precio_max' => [ 'decimal' => 'The field must contain a decimal number.', 'required' => 'The field is required.', @@ -27,13 +27,13 @@ return [ ], - 'paginas_max' => [ + 'tirada_max' => [ 'integer' => 'The field must contain an integer.', 'required' => 'The field is required.', ], - 'paginas_min' => [ + 'tirada_min' => [ 'integer' => 'The field must contain an integer.', 'required' => 'The field is required.', diff --git a/ci4/app/Language/en/TarifaEncuadernacionTiradas.php b/ci4/app/Language/en/TarifaEncuadernacionTiradas.php new file mode 100644 index 00000000..68bf7ef6 --- /dev/null +++ b/ci4/app/Language/en/TarifaEncuadernacionTiradas.php @@ -0,0 +1,28 @@ + 'ID', + 'moduleTitle' => 'Printings Binding rates', + 'deleteLine' => 'the selected register', + 'proveedor' => 'Supplier', + 'seleccion' => 'Selection', + 'tiradaMax' => 'Max Printing', + 'tiradaMin' => 'Min Printing', + 'validation' => [ + 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', + 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', + 'tirada_max' => [ + 'integer' => 'The {field} field must contain a integer number.', + 'required' => 'The {field} field is required.', + + ], + + 'paginas_min' => [ + 'integer' => 'The {field} field must contain a integer number.', + 'required' => 'The {field} field is required.', + + ] + ], +]; \ No newline at end of file diff --git a/ci4/app/Language/en/TarifaManipuladoLineas.php b/ci4/app/Language/en/TarifaManipuladoLineas.php index 5da798c9..732add80 100644 --- a/ci4/app/Language/en/TarifaManipuladoLineas.php +++ b/ci4/app/Language/en/TarifaManipuladoLineas.php @@ -9,12 +9,12 @@ return [ 'precioMax' => 'Max Price', 'precioMin' => 'Min Price', 'precioUnidad' => 'Price Unit', - 'paginasMax' => 'Max Pages', - 'paginasMin' => 'Min Pages', + 'tiradaMax' => 'Max Printing', + 'tiradaMin' => 'Min Printing', 'margen' => 'Margin', 'validation' => [ - 'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.', - 'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages', + 'error_tirada_overlap' => 'The range [Min Printing, Max Printing] is overlapped with another one for the selected type.', + 'error_tirada_range' => 'The field Min Printing must be lower than the field Max Printing', 'precio_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', @@ -27,13 +27,13 @@ return [ ], - 'paginas_max' => [ + 'tirada_max' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', ], - 'paginas_min' => [ + 'tirada_min' => [ 'decimal' => 'The {field} field must contain a decimal number.', 'required' => 'The {field} field is required.', diff --git a/ci4/app/Language/es/TarifaAcabadoLineas.php b/ci4/app/Language/es/TarifaAcabadoLineas.php index 00f4c41a..6a671ac7 100644 --- a/ci4/app/Language/es/TarifaAcabadoLineas.php +++ b/ci4/app/Language/es/TarifaAcabadoLineas.php @@ -9,12 +9,12 @@ return [ 'precioMax' => 'Precio Max', 'precioMin' => 'Precio Min', 'precioUnidad' => 'Precio Unidad', - 'paginasMax' => 'Páginas Max', - 'paginasMin' => 'Páginas Min', + 'tiradaMax' => 'Tirada Max', + 'tiradaMin' => 'Tirada Min', 'margen' => 'Margen', 'validation' => [ - 'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.', - 'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max', + 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', + 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'precio_max' => [ 'decimal' => 'El campo debe contener un número decimal.', 'required' => 'El campo es obligatorio.', @@ -27,13 +27,13 @@ return [ ], - 'paginas_max' => [ + 'tirada_max' => [ 'integer' => 'El campo debe contener un número entero.', 'required' => 'El campo es obligatorio.', ], - 'paginas_min' => [ + 'tirada_min' => [ 'integer' => 'El campo debe contener un número entero.', 'required' => 'El campo es obligatorio.', diff --git a/ci4/app/Language/es/TarifaEncuadernacionTiradas.php b/ci4/app/Language/es/TarifaEncuadernacionTiradas.php new file mode 100644 index 00000000..068b065f --- /dev/null +++ b/ci4/app/Language/es/TarifaEncuadernacionTiradas.php @@ -0,0 +1,28 @@ + 'ID', + 'moduleTitle' => 'Tiradas Tarifa Encuadernación', + 'deleteLine' => 'el registro seleccionado', + 'proveedor' => 'Proveedor', + 'seleccion' => 'Selección', + 'tiradaMax' => 'Tirada Max', + 'tiradaMin' => 'Tirada Min', + 'validation' => [ + 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', + 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', + 'tirada_max' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', + + ], + + 'paginas_min' => [ + '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/TarifaManipuladoLineas.php b/ci4/app/Language/es/TarifaManipuladoLineas.php index 4d8ce4c6..93ac435b 100644 --- a/ci4/app/Language/es/TarifaManipuladoLineas.php +++ b/ci4/app/Language/es/TarifaManipuladoLineas.php @@ -9,12 +9,12 @@ return [ 'precioMax' => 'Precio Max', 'precioMin' => 'Precio Min', 'precioUnidad' => 'Precio Unidad', - 'paginasMax' => 'Páginas Max', - 'paginasMin' => 'Páginas Min', + 'tiradaMax' => 'Tirada Max', + 'tiradaMin' => 'Tirada Min', 'margen' => 'Margen', 'validation' => [ - 'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.', - 'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max', + 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', + 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'precio_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'The {field} field is required.', @@ -27,13 +27,13 @@ return [ ], - 'paginas_max' => [ + 'tirada_max' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'The {field} field is required.', ], - 'paginas_min' => [ + 'tirada_min' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', 'required' => 'The {field} field is required.', diff --git a/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php b/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php index 48130463..dcde951e 100644 --- a/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaAcabadoLineaModel.php @@ -13,16 +13,16 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.paginas_min", - 1 => "t1.paginas_max", + 0 => "t1.tirada_min", + 1 => "t1.tirada_max", 2 => "t1.precio_min", 3 => "t1.precio_max", 4 => "t1.margen", ]; protected $allowedFields = [ - "paginas_min", - "paginas_max", + "tirada_min", + "tirada_max", "precio_min", "precio_max", "margen", @@ -53,11 +53,11 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel "label" => "TarifaAcabadoLineas.precioMin", "rules" => "required|decimal", ], - "paginas_max" => [ + "tirada_max" => [ "label" => "TarifaAcabadoLineas.tiradaMax", "rules" => "required|integer", ], - "paginas_min" => [ + "tirada_min" => [ "label" => "TarifaAcabadoLineas.tiradaMin", "rules" => "required|integer", ], @@ -80,13 +80,13 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel "decimal" => "TarifaAcabadoLineas.validation.precio_min.decimal", "required" => "TarifaAcabadoLineas.validation.precio_min.required", ], - "paginas_max" => [ - "integer" => "TarifaAcabadoLineas.validation.paginas_max.integer", - "required" => "TarifaAcabadoLineas.validation.paginas_max.required", + "tirada_max" => [ + "integer" => "TarifaAcabadoLineas.validation.tirada_max.integer", + "required" => "TarifaAcabadoLineas.validation.tirada_max.required", ], - "paginas_min" => [ - "integer" => "TarifaAcabadoLineas.validation.paginas_min.integer", - "required" => "TarifaAcabadoLineas.validation.paginas_min.required", + "tirada_min" => [ + "integer" => "TarifaAcabadoLineas.validation.tirada_min.integer", + "required" => "TarifaAcabadoLineas.validation.tirada_min.required", ], "margen" => [ "integer" => "TarifaAcabadoLineas.validation.margen.integer", @@ -131,7 +131,7 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_acabado" + "t1.id AS id, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_acabado" ); //JJO @@ -145,12 +145,12 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel ? $builder : $builder ->groupStart() - ->like("t1.paginas_min", $search) - ->orLike("t1.paginas_max", $search) + ->like("t1.tirada_min", $search) + ->orLike("t1.tirada_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) - ->orLike("t1.paginas_min", $search) - ->orLike("t1.paginas_max", $search) + ->orLike("t1.tirada_min", $search) + ->orLike("t1.tirada_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) ->groupEnd(); @@ -172,13 +172,13 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel helper('general'); - if(floatval($data["paginas_min"])>= floatval($data["paginas_max"])){ - return lang('TarifaAcabadoLineas.validation.error_paginas_range'); + if(floatval($data["tirada_min"])>= floatval($data["tirada_max"])){ + return lang('TarifaAcabadoLineas.validation.error_tirada_range'); } $rows = $this->db ->table($this->table) - ->select("id, paginas_min, paginas_max") + ->select("id, tirada_min, tirada_max") ->where("is_deleted", 0) ->where("tarifa_acabado_id", $id_tarifa_acabado) ->get()->getResultObject(); @@ -190,9 +190,9 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel continue; } } - if(check_overlap(floatval($data["paginas_min"]), floatval($data["paginas_max"]), - $row->paginas_min, $row->paginas_max)){ - return lang('TarifaAcabadoLineas.validation.error_paginas_overlap'); + if(check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), + $row->tirada_min, $row->tirada_max)){ + return lang('TarifaAcabadoLineas.validation.error_tirada_overlap'); } } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php index aa5b9519..d714b390 100644 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php @@ -20,7 +20,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel ]; protected $allowedFields = [ - "tarifa_encuadernacion_id", + "tirada_encuadernacion_id", "paginas_min", "paginas_max", "precio_min", @@ -29,7 +29,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel "is_deleted", ]; - protected $returnType = "App\Entities\Tarifas\TarifaManipuladoLinea"; + protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionLinea"; protected $useTimestamps = true; protected $useSoftDeletes = false; @@ -38,51 +38,51 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel protected $updatedField = "updated_at"; - public static $labelField = "tarifa_encuadernacion_id"; + public static $labelField = "tirada_encuadernacion_id"; protected $validationRules = [ "precio_max" => [ - "label" => "TarifaManipuladoLineas.precioMax", + "label" => "TarifaEncuadernacionLineas.precioMax", "rules" => "required|decimal", ], "precio_min" => [ - "label" => "TarifaManipuladoLineas.precioMin", + "label" => "TarifaEncuadernacionLineas.precioMin", "rules" => "required|decimal", ], "paginas_max" => [ - "label" => "TarifaManipuladoLineas.paginasMax", + "label" => "TarifaEncuadernacionLineas.paginasMax", "rules" => "required|decimal", ], "paginas_min" => [ - "label" => "TarifaManipuladoLineas.paginasMin", + "label" => "TarifaEncuadernacionLineas.paginasMin", "rules" => "required|decimal", ], "margen" => [ - "label" => "TarifaManipuladoLineas.margen", + "label" => "TarifaEncuadernacionLineas.margen", "rules" => "required|decimal", ], ]; protected $validationMessages = [ "precio_max" => [ - "decimal" => "TarifaManipuladoLineas.validation.precio_max.decimal", - "required" => "TarifaManipuladoLineas.validation.precio_max.required", + "decimal" => "TarifaEncuadernacionLineas.validation.precio_max.decimal", + "required" => "TarifaEncuadernacionLineas.validation.precio_max.required", ], "precio_min" => [ - "decimal" => "TarifaManipuladoLineas.validation.precio_min.decimal", - "required" => "TarifaManipuladoLineas.validation.precio_min.required", + "decimal" => "TarifaEncuadernacionLineas.validation.precio_min.decimal", + "required" => "TarifaEncuadernacionLineas.validation.precio_min.required", ], "paginas_max" => [ - "decimal" => "TarifaManipuladoLineas.validation.paginas_max.decimal", - "required" => "TarifaManipuladoLineas.validation.paginas_max.required", + "decimal" => "TarifaEncuadernacionLineas.validation.paginas_max.decimal", + "required" => "TarifaEncuadernacionLineas.validation.paginas_max.required", ], "paginas_min" => [ - "decimal" => "TarifaManipuladoLineas.validation.paginas_min.decimal", - "required" => "TarifaManipuladoLineas.validation.paginas_min.required", + "decimal" => "TarifaEncuadernacionLineas.validation.paginas_min.decimal", + "required" => "TarifaEncuadernacionLineas.validation.paginas_min.required", ], "margen" => [ - "decimal" => "TarifaManipuladoLineas.validation.margen.decimal", - "required" => "TarifaManipuladoLineas.validation.margen.required", + "decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal", + "required" => "TarifaEncuadernacionLineas.validation.margen.required", ], ]; @@ -93,18 +93,18 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel * * @return \CodeIgniter\Database\BaseBuilder */ - public function getResource(string $search = "", $tarifa_encuadernacion_id = -1) + public function getResource(string $search = "", $tirada_encuadernacion_id = -1) { $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion" + "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion" ); //JJO - $builder->where('tarifa_encuadernacion_id', $tarifa_encuadernacion_id); + $builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id); $builder->where("t1.is_deleted", 0); - $builder->join("tarifa_encuadernacion t2", "t1.tarifa_encuadernacion_id = t2.id", "left"); + $builder->join("tarifa_encuadernacion_tiradas t2", "t1.tirada_encuadernacion_id = t2.id", "left"); return empty($search) @@ -112,13 +112,13 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel : $builder ->groupStart() ->like("t1.id", $search) - ->orLike("t1.tarifa_encuadernacion_id", $search) + ->orLike("t1.tirada_encuadernacion_id", $search) ->orLike("t1.paginas_min", $search) ->orLike("t1.paginas_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) ->orLike("t1.id", $search) - ->orLike("t1.tarifa_encuadernacion_id", $search) + ->orLike("t1.tirada_encuadernacion_id", $search) ->orLike("t1.paginas_min", $search) ->orLike("t1.paginas_max", $search) ->orLike("t1.precio_min", $search) @@ -126,19 +126,19 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel ->groupEnd(); } - public function checkIntervals($data = [], $id_linea = null, $id_tarifa_encuadernacion = null){ + public function checkIntervals($data = [], $id_linea = null, $tirada_encuadernacion_id = null){ helper('general'); if(floatval($data["paginas_min"])>= floatval($data["paginas_max"])){ - return lang('TarifaManipuladoLineas.validation.error_paginas_range'); + return lang('TarifaEncuadernacionLineas.validation.error_paginas_range'); } $rows = $this->db ->table($this->table) ->select("id, paginas_min, paginas_max") ->where("is_deleted", 0) - ->where("tarifa_encuadernacion_id", $id_tarifa_encuadernacion) + ->where("tirada_encuadernacion_id", $tirada_encuadernacion_id) ->get()->getResultObject(); @@ -150,7 +150,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel } if(check_overlap(floatval($data["paginas_min"]), floatval($data["paginas_max"]), $row->paginas_min, $row->paginas_max)){ - return lang('TarifaManipuladoLineas.validation.error_paginas_overlap'); + return lang('TarifaEncuadernacionLineas.validation.error_paginas_overlap'); } } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php new file mode 100644 index 00000000..c16cd026 --- /dev/null +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php @@ -0,0 +1,134 @@ + "t3.nombre", + 2 => "t1.tirada_min", + 3 => "t1.tirada_max", + + ]; + + protected $allowedFields = [ + "tarifa_encuadernacion_id", + "tirada_min", + "tirada_max", + "proveedor_id", + "user_created_id", + "user_updated_id", + "is_deleted", + "deleted_at", + + ]; + protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionTirada"; + + protected $useTimestamps = true; + protected $useSoftDeletes = false; + + protected $createdField = "created_at"; + + protected $updatedField = "updated_at"; + + public static $labelField = "tarifa_encuadernacion_id"; + + protected $validationRules = [ + "tirada_max" => [ + "label" => "TarifaEncuadernacionTiradas.tiradaMax", + "rules" => "required|integer", + ], + "tirada_min" => [ + "label" => "TarifaEncuadernacionTiradas.tiradaMin", + "rules" => "required|integer", + ] + ]; + + protected $validationMessages = [ + "tirada_max" => [ + "integer" => "TarifaEncuadernacionTiradas.validation.tirada_max.integer", + "required" => "TarifaEncuadernacionTiradas.validation.tirada_max.required", + ], + "tirada_min" => [ + "integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer", + "required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required", + ] + ]; + + /** + * Get resource data. + * + * @param string $search + * + * @return \CodeIgniter\Database\BaseBuilder + */ + public function getResource(string $search = "", $tarifa_encuadernacion_id = -1) + { + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, t1.tirada_min AS tirada_min, + t1.tirada_max AS tirada_max, t3.nombre AS proveedor, t2.id AS tarifa_encuadernacion" + ); + //JJO + $builder->where('tarifa_encuadernacion_id', $tarifa_encuadernacion_id); + $builder->where("t1.is_deleted", 0); + + $builder->join("tarifa_encuadernacion t2", "t1.tarifa_encuadernacion_id = t2.id", "left"); + $builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left"); + + + return empty($search) + ? $builder + : $builder + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.tirada_min", $search) + ->orLike("t1.tirada_max", $search) + ->orLike("t3.nombre", $search) + ->orLike("t1.id", $search) + ->orLike("t1.tirada_min", $search) + ->orLike("t1.tirada_max", $search) + ->orLike("t3.nombre", $search) + ->groupEnd(); + } + + public function checkIntervals($data = [], $id_linea = null, $tarifa_encuadernacion_id = null){ + + helper('general'); + + if(floatval($data["tirada_min"])>= floatval($data["tirada_max"])){ + return lang('TarifaEncuadernacionTiradas.validation.error_tirada_range'); + } + + $rows = $this->db + ->table($this->table) + ->select("id, tirada_min, tirada_max") + ->where("is_deleted", 0) + ->where("tarifa_encuadernacion_id", $tarifa_encuadernacion_id) + ->get()->getResultObject(); + + + foreach ($rows as $row) { + if (!is_null($id_linea)){ + if($row->id == $id_linea){ + continue; + } + } + if(check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), + $row->tirada_min, $row->tirada_max)){ + return lang('TarifaEncuadernacionTiradas.validation.error_tirada_overlap'); + } + } + + return ""; + } +} diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php index 77fbcc6f..6b795f9f 100644 --- a/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php @@ -13,16 +13,16 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.paginas_min", - 1 => "t1.paginas_max", + 0 => "t1.tirada_min", + 1 => "t1.tirada_max", 2 => "t1.precio_min", 3 => "t1.precio_max", ]; protected $allowedFields = [ "tarifa_manipulado_id", - "paginas_min", - "paginas_max", + "tirada_min", + "tirada_max", "precio_min", "precio_max", "user_created_id", @@ -49,12 +49,12 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel "label" => "TarifaManipuladoLineas.precioMin", "rules" => "required|decimal", ], - "paginas_max" => [ - "label" => "TarifaManipuladoLineas.paginasMax", + "tirada_max" => [ + "label" => "TarifaManipuladoLineas.tiradaMax", "rules" => "required|decimal", ], - "paginas_min" => [ - "label" => "TarifaManipuladoLineas.paginasMin", + "tirada_min" => [ + "label" => "TarifaManipuladoLineas.tiradaMin", "rules" => "required|decimal", ], "margen" => [ @@ -72,13 +72,13 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel "decimal" => "TarifaManipuladoLineas.validation.precio_min.decimal", "required" => "TarifaManipuladoLineas.validation.precio_min.required", ], - "paginas_max" => [ - "decimal" => "TarifaManipuladoLineas.validation.paginas_max.decimal", - "required" => "TarifaManipuladoLineas.validation.paginas_max.required", + "tirada_max" => [ + "decimal" => "TarifaManipuladoLineas.validation.tirada_max.decimal", + "required" => "TarifaManipuladoLineas.validation.tirada_max.required", ], - "paginas_min" => [ - "decimal" => "TarifaManipuladoLineas.validation.paginas_min.decimal", - "required" => "TarifaManipuladoLineas.validation.paginas_min.required", + "tirada_min" => [ + "decimal" => "TarifaManipuladoLineas.validation.tirada_min.decimal", + "required" => "TarifaManipuladoLineas.validation.tirada_min.required", ], "margen" => [ "decimal" => "TarifaManipuladoLineas.validation.margen.decimal", @@ -98,7 +98,7 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.paginas_min AS paginas_min, t1.paginas_max AS paginas_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_manipulado" + "t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.margen AS margen, t2.id AS tarifa_manipulado" ); //JJO $builder->where('tarifa_manipulado_id', $tarifa_manipulado_id); @@ -113,14 +113,14 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel ->groupStart() ->like("t1.id", $search) ->orLike("t1.tarifa_manipulado_id", $search) - ->orLike("t1.paginas_min", $search) - ->orLike("t1.paginas_max", $search) + ->orLike("t1.tirada_min", $search) + ->orLike("t1.tirada_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) ->orLike("t1.id", $search) ->orLike("t1.tarifa_manipulado_id", $search) - ->orLike("t1.paginas_min", $search) - ->orLike("t1.paginas_max", $search) + ->orLike("t1.tirada_min", $search) + ->orLike("t1.tirada_max", $search) ->orLike("t1.precio_min", $search) ->orLike("t1.precio_max", $search) ->groupEnd(); @@ -130,13 +130,13 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel helper('general'); - if(floatval($data["paginas_min"])>= floatval($data["paginas_max"])){ - return lang('TarifaManipuladoLineas.validation.error_paginas_range'); + if(floatval($data["tirada_min"])>= floatval($data["tirada_max"])){ + return lang('TarifaManipuladoLineas.validation.error_tirada_range'); } $rows = $this->db ->table($this->table) - ->select("id, paginas_min, paginas_max") + ->select("id, tirada_min, tirada_max") ->where("is_deleted", 0) ->where("tarifa_manipulado_id", $id_tarifa_manipulado) ->get()->getResultObject(); @@ -148,9 +148,9 @@ class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel continue; } } - if(check_overlap(floatval($data["paginas_min"]), floatval($data["paginas_max"]), - $row->paginas_min, $row->paginas_max)){ - return lang('TarifaManipuladoLineas.validation.error_paginas_overlap'); + if(check_overlap(floatval($data["tirada_min"]), floatval($data["tirada_max"]), + $row->tirada_min, $row->tirada_max)){ + return lang('TarifaManipuladoLineas.validation.error_tirada_overlap'); } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index 4806b013..5683ecd8 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -44,9 +44,9 @@ - + - + diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php index d654d2d9..87bb6eb4 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php @@ -4,21 +4,21 @@ - +
- +
- +
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 617ed7e3..1d65d028 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -28,6 +28,42 @@ + + +
+ + + + + + + + + + + +
+ + + + + +
- +
- +
diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index fb54d6db..1a12da80 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -47,9 +47,9 @@ - + - + From 0c3485681c698f917ae2c3dca0e76935f759735c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 9 Aug 2023 14:07:30 +0200 Subject: [PATCH 05/13] haciendo select en tabla tiradas encuadernacion --- ci4/app/Config/Routes.php | 5 + .../Tarifas/Tarifaencuadernacionlineas.php | 6 +- .../Tarifas/Tarifaencuadernaciontiradas.php | 15 +- .../TarifaEncuadernacionTiradaModel.php | 2 +- .../papel/viewPapelImpresionForm.php | 6 +- .../viewTarifaEncuadernacionForm.php | 380 ++++++++++++++---- 6 files changed, 321 insertions(+), 93 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index dc4faebe..b30da853 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -378,6 +378,11 @@ $routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Ta }); $routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']); +$routes->group('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + $routes->post('datatable', 'Tarifaencuadernaciontiradas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionTiradas']); + $routes->post('datatable_editor', 'Tarifaencuadernaciontiradas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionTiradas']); +}); +$routes->resource('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernaciontiradas', 'except' => 'show,new,create,update']); $routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], function ($routes) { $routes->get('', 'Proveedores::index', ['as' => 'proveedorList']); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php index 439a4176..da5d9e93 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -322,14 +322,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $order = TarifaEncuadernacionLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0]; $dir = $reqData['order']['0']['dir'] ?? 'asc'; - $id_TM = $reqData['id_tarifaencuadernacion'] ?? -1; + $id_TE = $reqData['tirada_id'] ?? -1; - $resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + $resourceData = $this->model->getResource("", $id_TE)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( $resourceData, $this->model->getResource()->countAllResults(), - $this->model->getResource($search, $id_TM)->countAllResults() + $this->model->getResource("", $id_TE)->countAllResults() )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index 4706536f..4d5a0f6e 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -23,7 +23,9 @@ use class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceController { - public function datatable_editor() + protected static $controllerSlug = 'tarifaencuadernaciontiradas'; + + public function datatable_editor() { if ($this->request->isAJAX()) { @@ -131,6 +133,7 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl 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.'; @@ -141,17 +144,19 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl $length = $reqData['length'] ?? 5; $search = $reqData['search']['value']; $requestedOrder = $reqData['order']['0']['column'] ?? 0; - $order = TarifaEncuadernacionLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0]; + $order = TarifaEncuadernacionTiradaModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1]; $dir = $reqData['order']['0']['dir'] ?? 'asc'; $id_TM = $reqData['id_tarifaencuadernacion'] ?? -1; - $resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + $model = new TarifaEncuadernacionTiradaModel(); + + $resourceData = $model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); return $this->respond(Collection::datatable( $resourceData, - $this->model->getResource()->countAllResults(), - $this->model->getResource($search, $id_TM)->countAllResults() + $model->getResource()->countAllResults(), + $model->getResource($search, $id_TM)->countAllResults() )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php index c16cd026..59b0b621 100644 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php @@ -1,7 +1,7 @@ section('css') ?> - "> - -*/ ?> - - + diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 1d65d028..7658efc9 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -1,6 +1,7 @@ include("themes/_commonPartialsBs/datatables") ?> include("themes/_commonPartialsBs/select2bs5") ?> include("themes/_commonPartialsBs/sweetalert") ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?> @@ -29,84 +30,78 @@ - -
- - - - - - - - - - - -
- - - - +
+
+ + + + + + + + + + + + + +
+
+
+ + - - - + endSection() ?> + + + section("additionalInlineJs") ?> - - const lastColNr = $('#tableOfTarifaencuadernacionlineas').find("tr:first th").length - 1; const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } @@ -114,16 +109,30 @@ id = -1; } + const actionBtns = function(data) { return ` - - - - `; + + + + `; }; + var selected_tirada_id = -1; + +endSection() ?> - editor = new $.fn.dataTable.Editor( { + + + + + + +section("additionalInlineJs") ?> + + const lastColNr = $('#tableOfTarifaencuadernacionlineas').find("tr:first th").length - 1; + + var editor = new $.fn.dataTable.Editor( { ajax: { url: "", headers: { @@ -155,6 +164,7 @@ ] } ); + editor.on( 'preSubmit', function ( e, d, type ) { if ( type === 'create'){ d.data[0]['tirada_encuadernacion_id'] = id; @@ -172,14 +182,14 @@ yeniden(json.); }); + editor.on( 'submitSuccess', function ( e, json, data, action ) { theTable.clearPipeline(); theTable.draw(); }); - - var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( { + var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( { serverSide: true, processing: true, autoWidth: true, @@ -195,7 +205,7 @@ ajax : $.fn.dataTable.pipeline( { url: '', data: { - id_tarifaencuadernacion: id, + tirada_id: selected_tirada_id, }, method: 'POST', headers: {'X-Requested-With': 'XMLHttpRequest'}, @@ -230,21 +240,20 @@ editor: editor, formOptions: { submitTrigger: -1, - submitHtml: '' + submitHtml: '' } } ] } ); - // Activate an inline edit on click of a table cell $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.edit', function (e) { editor.inline( theTable.cells(this.parentNode.parentNode, '*').nodes(), { - cancelHtml: '', + cancelHtml: '', cancelTrigger: 'span.cancel', - submitHtml: '', + submitHtml: '', submitTrigger: 'span.edit', submit: 'allIfChanged' } @@ -253,6 +262,36 @@ // 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: `/configuracion/papelimpresiontipologias/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) + })*/ + console.log(this.parentNode); + /*editor + .create( false ) + .edit( this.parentNode, false) + .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) + .set( 'is_deleted', 1 ) + .submit();*/ + } + }); + + /* $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) { Swal.fire({ @@ -278,10 +317,192 @@ } }); - }); + });*/ + + endSection() ?> + + + +section("additionalInlineJs") ?> + + const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1; + + var editor2 = new $.fn.dataTable.Editor( { + ajax: { + url: "", + headers: { + : v, + }, + }, + table : "#tableOfTarifaencuadernaciontiradas", + idSrc: 'id', + fields: [ { + name: "proveedor" + }, { + name: "tirada_min" + }, { + name: "tirada_max" + }, { + "name": "tarifa_encuadernacion_id", + "type": "hidden" + },{ + "name": "deleted_at", + "type": "hidden" + },{ + "name": "is_deleted", + "type": "hidden" + }, + ] + } ); + + + editor2.on( 'preSubmit', function ( e, d, type ) { + if ( type === 'create'){ + d.data[0]['tarifa_encuadernacion_id'] = id; + } + else if(type === 'edit' ) { + for (v in d.data){ + d.data[v]['tarifa_encuadernacion_id'] = id; + } + } + }); + + + editor2.on( 'postSubmit', function ( e, json, data, action ) { + + yeniden(json.); + }); + + + editor2.on( 'submitSuccess', function ( e, json, data, action ) { + + theTable.clearPipeline(); + theTable.draw(); + }); + + var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( { + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + lengthMenu: [ 5, 10, 25], + order: [ 0, "asc" ], + pageLength: 10, + 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: { + id_tarifaencuadernacion: id, + }, + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columns: [ + { + className: 'dt-body-center' + }, + { 'data': 'proveedor' }, + { 'data': 'tirada_min' }, + { 'data': 'tirada_max' }, + { + data: actionBtns, + className: 'row-edit dt-center' + } + ], + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr2] + }, + { + orderable: false, + className: 'select-checkbox', + targets: 0 + } + //], + + // {"orderData": [ 0, 1 ], "targets": 0 }, + + ], + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + buttons: [ { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor2, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } + } ], + select: { + style: 'single', + selector: 'td:first-child' + } + } ); + + + // Activate an inline edit on click of a table cell + $('#tableOfTarifaencuadernaciontiradas').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 + + /* + $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', 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) { + editor + .create( false ) + .edit( this.parentNode, false) + .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) + .set( 'is_deleted', 1 ) + .submit(); + + } + }); + });*/ + + +endSection() ?> + + + section('css') ?> + endSection() ?> @@ -289,6 +510,7 @@ section('additionalExternalJs') ?> + From 3b84839fc0b1f909d0bd12a9f904867ddccedb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 11 Aug 2023 09:52:12 +0200 Subject: [PATCH 06/13] trabajando tabla tiradas para el editor --- ci4/app/Config/Routes.php | 1 + .../Tarifas/Tarifaencuadernaciontiradas.php | 64 +++++++++++-------- ci4/app/Models/Compras/ProveedorModel.php | 11 ++++ ci4/app/Models/Compras/ProveedorTipoModel.php | 11 ++++ .../TarifaEncuadernacionTiradaModel.php | 6 +- .../viewTarifaEncuadernacionForm.php | 37 +++++------ 6 files changed, 78 insertions(+), 52 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index b30da853..3c6ebf21 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -381,6 +381,7 @@ $routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controller $routes->group('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->post('datatable', 'Tarifaencuadernaciontiradas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionTiradas']); $routes->post('datatable_editor', 'Tarifaencuadernaciontiradas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionTiradas']); + $routes->post('menuitems', 'Tarifaencuadernaciontiradas::menuItems', ['as' => 'menuItemsOfTarifaencuadernaciontiradas']); }); $routes->resource('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernaciontiradas', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index 4d5a0f6e..ab32c9ab 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -8,6 +8,8 @@ use App\Models\Collection; use App\Entities\Tarifas\TarifaEncuadernacionTirada; use App\Models\Tarifas\TarifaEncuadernacionTiradaModel; +use App\Models\Compras\ProveedorModel; +use App\Models\Compras\ProveedorTipoModel; use DataTables\Editor, @@ -34,42 +36,28 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl // Build our Editor instance and process the data coming from _POST $response = Editor::inst($db, 'tarifa_encuadernacion_tiradas') ->fields( - Field::inst('paginas_min') + Field::inst('tirada_min') ->validator('Validate::numeric', array( 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) ) ->validator('Validate::notEmpty', array( 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) ), - Field::inst('paginas_max') + Field::inst('tirada_max') ->validator('Validate::numeric', array( 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) ) ->validator('Validate::notEmpty', array( 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) ), - Field::inst('precio_min') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) - ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) - ), - Field::inst('precio_max') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) - ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) - ), - Field::inst('margen') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) - ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) - ), - Field::inst('tirada_encuadernacion_id'), + Field::inst('proveedor') + ->options( Options::inst() + ->table( 'lg_proveedores' ) + ->value( 'id' ) + ->label( 'nombre' ) + ), + Field::inst('tarifa_encuadernacion_id'), + Field::inst('proveedor_id'), Field::inst('user_created_id'), Field::inst('created_at'), Field::inst('user_updated_id'), @@ -78,7 +66,7 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl Field::inst('deleted_at'), ) - ->validator(function ($editor, $action, $data) { + /*->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... @@ -93,7 +81,7 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl } } } - }) + })*/ ->on('preCreate', function ($editor, &$values) { $session = session(); $datetime = (new \CodeIgniter\I18n\Time("now")); @@ -162,5 +150,29 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl return $this->failUnauthorized('Invalid request', 403); } } + + + public function menuItems() + { + if ($this->request->isAJAX()) { + + $provTipoModel = new ProveedorTipoModel(); + $provModel = new ProveedorModel(); + + $tipoId = $provTipoModel->getTipoId("Encuadernacion"); + $provList = $provModel->getProvList($tipoId); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'data' => $provList, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + } diff --git a/ci4/app/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php index 0d21344f..bb77ee7f 100644 --- a/ci4/app/Models/Compras/ProveedorModel.php +++ b/ci4/app/Models/Compras/ProveedorModel.php @@ -199,4 +199,15 @@ class ProveedorModel extends \App\Models\GoBaseModel ->orLike("t4.nombre", $search) ->groupEnd(); } + + public function getProvList(int $tipoId = -1){ + + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.id AS proveedor_id, t1.nombre AS proveedor") + ->where("tipo_id", $tipoId); + + return $builder->getResult('array'); + } } diff --git a/ci4/app/Models/Compras/ProveedorTipoModel.php b/ci4/app/Models/Compras/ProveedorTipoModel.php index d2ffb31a..1c8c9a99 100644 --- a/ci4/app/Models/Compras/ProveedorTipoModel.php +++ b/ci4/app/Models/Compras/ProveedorTipoModel.php @@ -72,4 +72,15 @@ class ProveedorTipoModel extends \App\Models\GoBaseModel ->orLike("t1.updated_at", $search) ->groupEnd(); } + + + public function getTipoId(string $tipo = ""){ + + $builder = $this->db + ->table($this->table . " t1") + ->select("t1.id AS id") + ->where("t1.nombre", $tipo); + + return $builder->get()->getResultObject(); + } } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php index 59b0b621..3b7174a9 100644 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php @@ -76,7 +76,7 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\GoBaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, t1.tirada_min AS tirada_min, - t1.tirada_max AS tirada_max, t3.nombre AS proveedor, t2.id AS tarifa_encuadernacion" + t1.tirada_max AS tirada_max, t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion" ); //JJO $builder->where('tarifa_encuadernacion_id', $tarifa_encuadernacion_id); @@ -90,11 +90,9 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\GoBaseModel ? $builder : $builder ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.tirada_min", $search) + ->Like("t1.tirada_min", $search) ->orLike("t1.tirada_max", $search) ->orLike("t3.nombre", $search) - ->orLike("t1.id", $search) ->orLike("t1.tirada_min", $search) ->orLike("t1.tirada_max", $search) ->orLike("t3.nombre", $search) diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 7658efc9..a86aec52 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -46,7 +46,6 @@ - @@ -339,7 +338,8 @@ table : "#tableOfTarifaencuadernaciontiradas", idSrc: 'id', fields: [ { - name: "proveedor" + name: "proveedor", + "type": "select" }, { name: "tirada_min" }, { @@ -348,6 +348,9 @@ "name": "tarifa_encuadernacion_id", "type": "hidden" },{ + name: "proveedor_id", + "type": "hidden" + }, { "name": "deleted_at", "type": "hidden" },{ @@ -382,6 +385,7 @@ theTable.draw(); }); + var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( { serverSide: true, processing: true, @@ -393,6 +397,7 @@ lengthChange: true, searching: false, paging: true, + select: true, info: false, dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', ajax : $.fn.dataTable.pipeline( { @@ -405,9 +410,6 @@ async: true, }), columns: [ - { - className: 'dt-body-center' - }, { 'data': 'proveedor' }, { 'data': 'tirada_min' }, { 'data': 'tirada_max' }, @@ -421,15 +423,8 @@ orderable: false, searchable: false, targets: [lastColNr2] - }, - { - orderable: false, - className: 'select-checkbox', - targets: 0 - } - //], - - // {"orderData": [ 0, 1 ], "targets": 0 }, + }, + {"orderData": [ 0, 1 ], "targets": 1 }, ], language: { @@ -443,18 +438,14 @@ submitTrigger: -1, submitHtml: '' } - } ], - select: { - style: 'single', - selector: 'td:first-child' - } + } ] } ); // Activate an inline edit on click of a table cell $('#tableOfTarifaencuadernaciontiradas').on( 'click', 'tbody span.edit', function (e) { - editor.inline( - theTable.cells(this.parentNode.parentNode, '*').nodes(), + editor2.inline( + theTable2.cells(this.parentNode.parentNode, '*').nodes(), { cancelHtml: '', cancelTrigger: 'span.cancel', @@ -502,8 +493,10 @@ section('css') ?> + + endSection() ?> @@ -516,6 +509,6 @@ - + endSection() ?> From c2ef6cce611966058e0b6f371972ba2ef081df56 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Fri, 11 Aug 2023 18:01:10 +0200 Subject: [PATCH 07/13] Cambiado Swal y referencia propia del CSS --- .../papel/viewPapelImpresionForm.php | 32 +++---------------- .../papel/viewPapelImpresionList.php | 3 +- .../tarifas/acabado/viewTarifaAcabadoList.php | 2 +- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php index 0694fcee..8f63c14e 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php @@ -231,16 +231,9 @@ ] } ); - editor.on( 'initCreate', function () { if ($('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3){ - Swal.fire({ - title: '', - icon: 'info', - confirmButtonColor: '#3085d6', - confirmButtonText: '', - - }); + popErrorAlert(); } } ); @@ -495,11 +488,7 @@ yeniden(json.); if(json.error){ document.getElementById("check_" + json.data.papel_impresion_id).checked = false; - Swal.fire({ - icon: 'error', - title: '', - text: json.error, - }); + popErrorAlert(json.error); } }); @@ -511,8 +500,7 @@ .submit(); } ); - - // Para los calculos del precio + // Calculos del precio $("#ancho").on('input', function () { updateValue(); }); @@ -546,22 +534,14 @@ $('#precioPliego').val(value2); } - endSection() ?> + section('css') ?> - - "> - -*/ ?> - - + - - endSection() ?> - section('additionalExternalJs') ?> @@ -570,8 +550,6 @@ - - endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php index 4ae5971d..6eeece15 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionList.php @@ -66,8 +66,7 @@ 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 + "dom": 'lfBrtip', "buttons": [ 'copy', 'csv', 'excel', 'print', { extend: 'pdfHtml5', diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php index 8f9a689f..bb18b419 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php @@ -115,7 +115,7 @@ theTable.row($(row)).invalidate().draw(); popSuccessAlert(data.msg ?? jqXHR.statusText); }).fail((jqXHR, textStatus, errorThrown) => { - popErrorAlert(jqXHR.responseJSON.messages.error) + popErrorAlert(jqXHR.responseJSON.messages.error); }) } }); From 4a3c054e1bb66f8f415d27d46180fdee3ca6db1e Mon Sep 17 00:00:00 2001 From: imnavajas Date: Mon, 14 Aug 2023 14:52:02 +0200 Subject: [PATCH 08/13] =?UTF-8?q?Cambiados=20CSS=20genericos=20y=20a=C3=B1?= =?UTF-8?q?adido=20uno=20especifico=20para=20sobrescribir=20datatables=20p?= =?UTF-8?q?or=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/themes/backend/vuexy/login/header.php | 2 +- .../backend/vuexy/main/activities_layout.php | 2 +- ci4/app/Views/themes/backend/vuexy/main/all.php | 2 +- .../themes/backend/vuexy/main/defaultlayout.php | 4 +++- .../Views/themes/backend/vuexy/main/demo_view.php | 2 +- .../vuexy/main/general_settings_layout.php | 2 +- .../Views/themes/backend/vuexy/main/header.php | 2 +- .../backend/vuexy/main/presupuestos_layout.php | 2 +- .../themes/vuexy/css/{demo.css => safekat.css} | 2 +- httpdocs/themes/vuexy/css/sk-datatables.css | 15 +++++++++++++++ 10 files changed, 26 insertions(+), 9 deletions(-) rename httpdocs/themes/vuexy/css/{demo.css => safekat.css} (99%) create mode 100644 httpdocs/themes/vuexy/css/sk-datatables.css diff --git a/ci4/app/Views/themes/backend/vuexy/login/header.php b/ci4/app/Views/themes/backend/vuexy/login/header.php index fec3e52d..7b8eb5f5 100644 --- a/ci4/app/Views/themes/backend/vuexy/login/header.php +++ b/ci4/app/Views/themes/backend/vuexy/login/header.php @@ -73,7 +73,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php b/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php index fb37147c..f1925adf 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php +++ b/ci4/app/Views/themes/backend/vuexy/main/activities_layout.php @@ -77,7 +77,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/ci4/app/Views/themes/backend/vuexy/main/all.php b/ci4/app/Views/themes/backend/vuexy/main/all.php index c7127724..bdc0b785 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/all.php +++ b/ci4/app/Views/themes/backend/vuexy/main/all.php @@ -77,7 +77,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php index 7a225272..bd145fa5 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php +++ b/ci4/app/Views/themes/backend/vuexy/main/defaultlayout.php @@ -77,7 +77,7 @@ if (!empty($token) && $tfa == false) { - + @@ -86,6 +86,8 @@ if (!empty($token) && $tfa == false) { renderSection('css') ?> + + diff --git a/ci4/app/Views/themes/backend/vuexy/main/demo_view.php b/ci4/app/Views/themes/backend/vuexy/main/demo_view.php index 5c96ceb5..5efa5c48 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/demo_view.php +++ b/ci4/app/Views/themes/backend/vuexy/main/demo_view.php @@ -76,7 +76,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php b/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php index 67d418c0..c2ae8a35 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php +++ b/ci4/app/Views/themes/backend/vuexy/main/general_settings_layout.php @@ -77,7 +77,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/ci4/app/Views/themes/backend/vuexy/main/header.php b/ci4/app/Views/themes/backend/vuexy/main/header.php index ff069297..5edbb201 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/header.php +++ b/ci4/app/Views/themes/backend/vuexy/main/header.php @@ -79,7 +79,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/ci4/app/Views/themes/backend/vuexy/main/presupuestos_layout.php b/ci4/app/Views/themes/backend/vuexy/main/presupuestos_layout.php index ae5a4b4d..bbefab79 100644 --- a/ci4/app/Views/themes/backend/vuexy/main/presupuestos_layout.php +++ b/ci4/app/Views/themes/backend/vuexy/main/presupuestos_layout.php @@ -77,7 +77,7 @@ if (!empty($token) && $tfa == false) { - + diff --git a/httpdocs/themes/vuexy/css/demo.css b/httpdocs/themes/vuexy/css/safekat.css similarity index 99% rename from httpdocs/themes/vuexy/css/demo.css rename to httpdocs/themes/vuexy/css/safekat.css index 277097b9..4914d797 100644 --- a/httpdocs/themes/vuexy/css/demo.css +++ b/httpdocs/themes/vuexy/css/safekat.css @@ -1,5 +1,5 @@ /* -* demo.css +* safekat.css * File include item demo only specific css only ******************************************************************************/ diff --git a/httpdocs/themes/vuexy/css/sk-datatables.css b/httpdocs/themes/vuexy/css/sk-datatables.css new file mode 100644 index 00000000..6f1342e2 --- /dev/null +++ b/httpdocs/themes/vuexy/css/sk-datatables.css @@ -0,0 +1,15 @@ + +/* Overwrite datatables styles */ + +table.dataTable.table-striped > tbody > tr.odd.selected > * { + box-shadow: inset 0 0 0 9999px rgba(13, 110, 253, 0.5); +} + +table.dataTable > tbody > tr.selected > * { + box-shadow: inset 0 0 0 9999px rgba(13, 110, 253, 0.5); + color: white; +} + +table.dataTable.table-hover > tbody > tr.selected:hover > * { + box-shadow: inset 0 0 0 9999px rgba(13, 110, 253, 0.65); +} \ No newline at end of file From d8afcf9c321afaba2175e72b3b765d8bde0444fa Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 16 Aug 2023 19:44:00 +0200 Subject: [PATCH 09/13] Trabajando --- ci4/app/Config/Routes.php | 4 +- .../Tarifas/Tarifaencuadernaciontiradas.php | 34 +++- .../Tarifas/Tarifasencuadernacion.php | 12 ++ .../en/TarifaEncuadernacionLineas.php | 1 + .../es/TarifaEncuadernacionLineas.php | 1 + ci4/app/Models/Compras/ProveedorModel.php | 4 +- ci4/app/Models/Compras/ProveedorTipoModel.php | 6 +- .../themes/_commonPartialsBs/_alertBoxes.php | 10 +- .../viewTarifaEncuadernacionForm.php | 173 +++++++++++------- 9 files changed, 158 insertions(+), 87 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 3c6ebf21..52415fbe 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -378,13 +378,15 @@ $routes->group('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Ta }); $routes->resource('tarifaencuadernacionlineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernacionlineas', 'except' => 'show,new,create,update']); + $routes->group('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { $routes->post('datatable', 'Tarifaencuadernaciontiradas::datatable', ['as' => 'dataTableOfTarifaEncuadernacionTiradas']); $routes->post('datatable_editor', 'Tarifaencuadernaciontiradas::datatable_editor', ['as' => 'editorOfTarifaEncuadernacionTiradas']); $routes->post('menuitems', 'Tarifaencuadernaciontiradas::menuItems', ['as' => 'menuItemsOfTarifaencuadernaciontiradas']); -}); +}); $routes->resource('tarifaencuadernaciontiradas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaencuadernaciontiradas', 'except' => 'show,new,create,update']); + $routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], function ($routes) { $routes->get('', 'Proveedores::index', ['as' => 'proveedorList']); $routes->get('add', 'Proveedores::add', ['as' => 'newProveedor']); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index ab32c9ab..67ff3c07 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -27,6 +27,26 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl { protected static $controllerSlug = 'tarifaencuadernaciontiradas'; + protected $modelName = TarifaEncuadernacionTiradaModel::class; + protected $format = 'json'; + + protected static $singularObjectName = 'Tarifa Encuadernacion Tirada'; + protected static $singularObjectNameCc = 'tarifaEncuadernacionTirada'; + protected static $pluralObjectName = 'Tarifa Encuadernacion Tiradas'; + protected static $pluralObjectNameCc = 'tarifaEncuadernacionTiradas'; + + public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) + { + // 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_editor() { if ($this->request->isAJAX()) { @@ -50,14 +70,11 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl ->validator('Validate::notEmpty', array( 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) ), - Field::inst('proveedor') - ->options( Options::inst() - ->table( 'lg_proveedores' ) - ->value( 'id' ) - ->label( 'nombre' ) - ), + Field::inst('proveedor_id') + ->validator('Validate::notEmpty', array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + ), Field::inst('tarifa_encuadernacion_id'), - Field::inst('proveedor_id'), Field::inst('user_created_id'), Field::inst('created_at'), Field::inst('user_updated_id'), @@ -161,9 +178,10 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl $tipoId = $provTipoModel->getTipoId("Encuadernacion"); $provList = $provModel->getProvList($tipoId); - + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); + $data = [ 'data' => $provList, $csrfTokenName => $newTokenHash diff --git a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php index 12c6c168..f9fc8713 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php +++ b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php @@ -8,6 +8,9 @@ use App\Models\Collection; use App\Entities\Tarifas\TarifaEncuadernacionEntity; use App\Models\Tarifas\TarifaEncuadernacionModel; +use App\Models\Compras\ProveedorModel; +use App\Models\Compras\ProveedorTipoModel; + class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController { @@ -210,6 +213,8 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.edit3'); + //JJO + $this->viewData['proveedores'] = $this->getProveedores(); return $this->displayForm(__METHOD__, $id); } // end function edit(...) @@ -293,4 +298,11 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController } } + private function getProveedores(){ + $provTipoModel = new ProveedorTipoModel(); + $provModel = new ProveedorModel(); + + $tipoId = $provTipoModel->getTipoId("Encuadernacion"); + return $provModel->getProvList($tipoId); + } } diff --git a/ci4/app/Language/en/TarifaEncuadernacionLineas.php b/ci4/app/Language/en/TarifaEncuadernacionLineas.php index d3528a85..97f92970 100644 --- a/ci4/app/Language/en/TarifaEncuadernacionLineas.php +++ b/ci4/app/Language/en/TarifaEncuadernacionLineas.php @@ -13,6 +13,7 @@ return [ 'paginasMin' => 'Min Pages', 'margen' => 'Margin', 'validation' => [ + 'error_seleccion_tiradas' => 'A line from the Printings table must be selected before creating a new record.', 'error_paginas_overlap' => 'The range [Min Pages, Max Pages] is overlapped with another one for the selected type.', 'error_paginas_range' => 'The field Min Pages must be lower than the field Max Pages', 'precio_max' => [ diff --git a/ci4/app/Language/es/TarifaEncuadernacionLineas.php b/ci4/app/Language/es/TarifaEncuadernacionLineas.php index eb7f5f84..69f95d65 100644 --- a/ci4/app/Language/es/TarifaEncuadernacionLineas.php +++ b/ci4/app/Language/es/TarifaEncuadernacionLineas.php @@ -13,6 +13,7 @@ return [ 'paginasMin' => 'Páginas Min', 'margen' => 'Margen', 'validation' => [ + 'error_seleccion_tiradas' => 'Debe seleccionar una línea de la tabla tiradas antes de crear un registro nuevo.', 'error_paginas_overlap' => 'El rango [Páginas Min, Páginas Max] se solapa con otro existente para el tipo seleccionado.', 'error_paginas_range' => 'El campo Páginas Min debe ser menor que el campo Páginas Max', 'precio_max' => [ diff --git a/ci4/app/Models/Compras/ProveedorModel.php b/ci4/app/Models/Compras/ProveedorModel.php index bb77ee7f..2366636d 100644 --- a/ci4/app/Models/Compras/ProveedorModel.php +++ b/ci4/app/Models/Compras/ProveedorModel.php @@ -205,9 +205,9 @@ class ProveedorModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS proveedor_id, t1.nombre AS proveedor") + "t1.id AS value, t1.nombre AS label") ->where("tipo_id", $tipoId); - return $builder->getResult('array'); + return $builder->get()->getResultObject(); } } diff --git a/ci4/app/Models/Compras/ProveedorTipoModel.php b/ci4/app/Models/Compras/ProveedorTipoModel.php index 1c8c9a99..747e5973 100644 --- a/ci4/app/Models/Compras/ProveedorTipoModel.php +++ b/ci4/app/Models/Compras/ProveedorTipoModel.php @@ -81,6 +81,10 @@ class ProveedorTipoModel extends \App\Models\GoBaseModel ->select("t1.id AS id") ->where("t1.nombre", $tipo); - return $builder->get()->getResultObject(); + $rows = $builder->get()->getResultObject(); + if(sizeof($rows)>0) + return intval($rows[0]->id); + else + return -1; } } diff --git a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php index d3b7e52f..ab60abcd 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php @@ -24,9 +24,7 @@ if (session()->has('error')) { section('additionalInlineJs') ?> -function popAlert(message, alertType){ - var alertClass = "alert-" + alertType; - var alertIcon = alertType == "success" ? "ti-check" : "ti-" + alertType; +function popAlert(message, alertClass, alertIcon){ var htmlString = ` - + @@ -117,6 +117,10 @@ `; }; + $(document).on('click', '.btn-delete', function(e) { + $(".btn-remove").attr('data-id', $(this).attr('data-id')); + }); + var selected_tirada_id = -1; endSection() ?> @@ -166,11 +170,11 @@ editor.on( 'preSubmit', function ( e, d, type ) { if ( type === 'create'){ - d.data[0]['tirada_encuadernacion_id'] = id; + d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; } else if(type === 'edit' ) { for (v in d.data){ - d.data[v]['tirada_encuadernacion_id'] = id; + d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id; } } }); @@ -188,6 +192,7 @@ theTable.draw(); }); + var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( { serverSide: true, processing: true, @@ -203,8 +208,8 @@ dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', ajax : $.fn.dataTable.pipeline( { url: '', - data: { - tirada_id: selected_tirada_id, + data: function ( d ) { + d.tirada_id = selected_tirada_id; }, method: 'POST', headers: {'X-Requested-With': 'XMLHttpRequest'}, @@ -240,7 +245,21 @@ formOptions: { submitTrigger: -1, submitHtml: '' - } + + }, + action: function ( e, dt, node, config ) { + if(selected_tirada_id == -1){ + popErrorAlert(""); + } + else{ + formOptions= { + submitTrigger: -1, + submitHtml: '' + + }; + editor.inlineCreate(config.position, formOptions); + } + }, } ] } ); @@ -261,34 +280,29 @@ // 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: `/configuracion/papelimpresiontipologias/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) - })*/ - console.log(this.parentNode); - /*editor - .create( false ) - .edit( this.parentNode, false) - .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) - .set( 'is_deleted', 1 ) - .submit();*/ - } - }); + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + /*$.ajax({ + url: `/configuracion/papelimpresiontipologias/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) + })*/ + /*editor + .create( false ) + .edit( this.parentNode, false) + .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) + .set( 'is_deleted', 1 ) + .submit();*/ + } + }); /* $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', function (e) { @@ -326,8 +340,11 @@ section("additionalInlineJs") ?> + // Definicion de la ultima columna de la tabla const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1; + + // Datatables Editor var editor2 = new $.fn.dataTable.Editor( { ajax: { url: "", @@ -338,7 +355,7 @@ table : "#tableOfTarifaencuadernaciontiradas", idSrc: 'id', fields: [ { - name: "proveedor", + name: "proveedor_id", "type": "select" }, { name: "tirada_min" @@ -348,7 +365,7 @@ "name": "tarifa_encuadernacion_id", "type": "hidden" },{ - name: "proveedor_id", + name: "proveedor", "type": "hidden" }, { "name": "deleted_at", @@ -361,6 +378,11 @@ } ); + // Generación de la lista de proveedores (id, nombre) para encuadernación + const suppliersList = ; + editor2.field( 'proveedor_id' ).update( suppliersList ); + + editor2.on( 'preSubmit', function ( e, d, type ) { if ( type === 'create'){ d.data[0]['tarifa_encuadernacion_id'] = id; @@ -381,11 +403,12 @@ editor2.on( 'submitSuccess', function ( e, json, data, action ) { - theTable.clearPipeline(); - theTable.draw(); + theTable2.clearPipeline(); + theTable2.draw(); }); - + + // Tabla de tiradas var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( { serverSide: true, processing: true, @@ -410,7 +433,12 @@ async: true, }), columns: [ - { 'data': 'proveedor' }, + { 'data': 'proveedor_id', + render: function(data, type, row, meta) { + var value = suppliersList.find(element => element.value === data); + return value['label']; + }, + }, { 'data': 'tirada_min' }, { 'data': 'tirada_max' }, { @@ -441,6 +469,25 @@ } ] } ); + + // Obtener la id de la fila seleccionada o ponerla a -1 cuando no haya ninguna seleccionada + var selected_tirada_id = -1; + theTable2.on( 'select', function ( e, dt, type, indexes ) { + if ( type === 'row' ) { + selected_tirada_id = parseInt(theTable2.rows( indexes ).data().pluck( 'id' )[0]); + theTable.clearPipeline(); + theTable.draw(); + } + } ); + + theTable2.on( 'deselect', function ( e, dt, type, indexes ) { + if ( theTable2.rows( '.selected' ).count() == 0 ) { + selected_tirada_id = -1; + theTable.clearPipeline(); + theTable.draw(); + } + } ); + // Activate an inline edit on click of a table cell $('#tableOfTarifaencuadernaciontiradas').on( 'click', 'tbody span.edit', function (e) { @@ -458,36 +505,24 @@ // Delete row + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + $.ajax({ + url: `/tarifas/tarifaencuadernaciontiradas/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable2.clearPipeline(); + theTable2.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) + } + }); - /* - $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', 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) { - editor - .create( false ) - .edit( this.parentNode, false) - .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) - .set( 'is_deleted', 1 ) - .submit(); - - } - }); - });*/ - - endSection() ?> From ce070dfcf7060e140db37c950e117610617f8db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 17 Aug 2023 13:15:01 +0200 Subject: [PATCH 10/13] =?UTF-8?q?Faltan=20test=20sobre=20tarifas=20encuade?= =?UTF-8?q?rnaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tarifas/Tarifaencuadernaciontiradas.php | 23 ++++++++++--------- .../en/TarifaEncuadernacionTiradas.php | 14 +++++------ .../es/TarifaEncuadernacionTiradas.php | 14 +++++------ .../TarifaEncuadernacionTiradaModel.php | 7 +++--- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index 67ff3c07..200cc139 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -58,22 +58,22 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl ->fields( Field::inst('tirada_min') ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')) ) ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')) ), Field::inst('tirada_max') ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.decimal')) ) ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required')) ), Field::inst('proveedor_id') ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) - ), + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required')) + ), Field::inst('tarifa_encuadernacion_id'), Field::inst('user_created_id'), Field::inst('created_at'), @@ -83,14 +83,15 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl Field::inst('deleted_at'), ) - /*->validator(function ($editor, $action, $data) { + ->validator(function ($editor, $action, $data) { if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) { foreach ($data['data'] as $pkey => $values) { // Si no se quiere borrar... if ($data['data'][$pkey]['is_deleted'] != 1) { - $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; - $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; - $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tirada_encuadernacion_id']); + $process_data['tirada_min'] = $data['data'][$pkey]['tirada_min']; + $process_data['tirada_max'] = $data['data'][$pkey]['tirada_max']; + $process_data['proveedor_id'] = $data['data'][$pkey]['proveedor_id']; + $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_encuadernacion_id']); // No se pueden duplicar valores al crear o al editar if (!empty($response)) { return $response; @@ -98,7 +99,7 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl } } } - })*/ + }) ->on('preCreate', function ($editor, &$values) { $session = session(); $datetime = (new \CodeIgniter\I18n\Time("now")); diff --git a/ci4/app/Language/en/TarifaEncuadernacionTiradas.php b/ci4/app/Language/en/TarifaEncuadernacionTiradas.php index 68bf7ef6..b244b4da 100644 --- a/ci4/app/Language/en/TarifaEncuadernacionTiradas.php +++ b/ci4/app/Language/en/TarifaEncuadernacionTiradas.php @@ -14,15 +14,13 @@ return [ 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'tirada_max' => [ - 'integer' => 'The {field} field must contain a integer number.', - 'required' => 'The {field} field is required.', - + 'integer' => 'The field must contain an integer.', + 'required' => 'The field is required.', ], - 'paginas_min' => [ - 'integer' => 'The {field} field must contain a integer number.', - 'required' => 'The {field} field is required.', - - ] + 'tirada_min' => [ + 'integer' => 'The field must contain an integer.', + 'required' => 'The field is required.', + ], ], ]; \ No newline at end of file diff --git a/ci4/app/Language/es/TarifaEncuadernacionTiradas.php b/ci4/app/Language/es/TarifaEncuadernacionTiradas.php index 068b065f..4edbc363 100644 --- a/ci4/app/Language/es/TarifaEncuadernacionTiradas.php +++ b/ci4/app/Language/es/TarifaEncuadernacionTiradas.php @@ -14,15 +14,13 @@ return [ 'error_tirada_overlap' => 'El rango [Tirada Min, Tirada Max] se solapa con otro existente para el tipo seleccionado.', 'error_tirada_range' => 'El campo Tirada Min debe ser menor que el campo Tirada Max', 'tirada_max' => [ - 'integer' => 'El campo {field} debe contener un número entero.', - 'required' => 'El campo {field} es obligatorio.', - + 'integer' => 'El campo debe contener un número entero.', + 'required' => 'El campo es obligatorio.', ], - 'paginas_min' => [ - 'integer' => 'El campo {field} debe contener un número entero.', - 'required' => 'El campo {field} es obligatorio.', - - ] + 'tirada_min' => [ + 'integer' => 'El campo debe contener un número entero.', + 'required' => 'El campo es obligatorio.', + ], ], ]; \ No newline at end of file diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php index 3b7174a9..c1984c89 100644 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php @@ -99,7 +99,7 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\GoBaseModel ->groupEnd(); } - public function checkIntervals($data = [], $id_linea = null, $tarifa_encuadernacion_id = null){ + public function checkIntervals($data = [], $id_tirada = null, $tarifa_encuadernacion_id = null){ helper('general'); @@ -112,12 +112,13 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\GoBaseModel ->select("id, tirada_min, tirada_max") ->where("is_deleted", 0) ->where("tarifa_encuadernacion_id", $tarifa_encuadernacion_id) + ->where("proveedor_id", $data["proveedor_id"]) ->get()->getResultObject(); foreach ($rows as $row) { - if (!is_null($id_linea)){ - if($row->id == $id_linea){ + if (!is_null($id_tirada)){ + if($row->id == $id_tirada){ continue; } } From 77cb70ede4ff90d2b5d41e89169c55e51fabfac1 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Fri, 18 Aug 2023 13:51:09 +0200 Subject: [PATCH 11/13] Finalizadas las tareas de modificacion --- ci4/app/Controllers/Tarifas/Tarifaacabado.php | 7 +- .../Tarifas/Tarifaacabadolineas.php | 21 ++-- .../Tarifas/Tarifaencuadernacionlineas.php | 5 + .../Tarifas/Tarifaencuadernaciontiradas.php | 40 ++++++++ .../Tarifas/Tarifamanipuladolineas.php | 22 +++-- .../Tarifas/Tarifasencuadernacion.php | 6 ++ .../Controllers/Tarifas/Tarifasmanipulado.php | 6 ++ .../Tarifas/TarifaEncuadernacionEntity.php | 2 + .../Tarifas/TarifaManipuladoEntity.php | 2 + .../Entities/Tarifas/TarifaacabadoEntity.php | 2 + .../en/TarifaEncuadernacionLineas.php | 1 + ci4/app/Language/en/Tarifaacabado.php | 1 + ci4/app/Language/en/Tarifaencuadernacion.php | 1 + ci4/app/Language/en/Tarifamanipulado.php | 1 + .../es/TarifaEncuadernacionLineas.php | 1 + ci4/app/Language/es/Tarifaacabado.php | 1 + ci4/app/Language/es/Tarifaencuadernacion.php | 1 + ci4/app/Language/es/Tarifamanipulado.php | 1 + .../TarifaEncuadernacionLineaModel.php | 12 +++ .../Tarifas/TarifaEncuadernacionModel.php | 8 +- .../Models/Tarifas/TarifaManipuladoModel.php | 7 +- ci4/app/Models/Tarifas/TarifaacabadoModel.php | 4 +- .../Tarifas/TarifapreimpresionModel.php | 4 +- .../acabado/_tarifaAcabadoFormItems.php | 10 ++ .../tarifas/acabado/viewTarifaAcabadoForm.php | 72 +++++++------- .../tarifas/acabado/viewTarifaAcabadoList.php | 10 ++ .../_tarifaEncuadernacionFormItems.php | 14 ++- .../viewTarifaEncuadernacionForm.php | 96 +++++++++---------- .../viewTarifaEncuadernacionList.php | 11 +++ .../manipulado/_tarifaManipuladoFormItems.php | 10 ++ .../manipulado/viewTarifaManipuladoForm.php | 48 +++++++--- .../manipulado/viewTarifaManipuladoList.php | 13 +++ .../_tarifapreimpresionFormItems.php | 6 +- .../viewTarifapreimpresionForm.php | 1 + 34 files changed, 318 insertions(+), 129 deletions(-) diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabado.php b/ci4/app/Controllers/Tarifas/Tarifaacabado.php index cc80c24d..1fa8ff55 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabado.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabado.php @@ -84,7 +84,9 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController // JJO $sanitizedData['user_created_id'] = $session->id_user; - + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -164,6 +166,9 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController // JJO $sanitizedData['user_updated_id'] = $session->id_user; + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; diff --git a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php index 70a9bbc9..457a0616 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaacabadolineas.php @@ -47,6 +47,11 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController $this->viewData['pageTitle'] = lang('TarifaAcabadoLineas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); + + // 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; } @@ -248,19 +253,19 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController // Build our Editor instance and process the data coming from _POST $response = Editor::inst($db, 'tarifa_acabado_lineas') ->fields( - Field::inst('paginas_min') + Field::inst('tirada_min') ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.decimal')) ) ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.required')) ), - Field::inst('paginas_max') + Field::inst('tirada_max') ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.decimal')) ) ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.required')) ), Field::inst('precio_min') ->validator('Validate::numeric', array( @@ -298,8 +303,8 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController // Si no se quiere borrar... if ($data['data'][$pkey]['is_deleted'] != 1) { - $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; - $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $process_data['tirada_min'] = $data['data'][$pkey]['tirada_min']; + $process_data['tirada_max'] = $data['data'][$pkey]['tirada_max']; $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_acabado_id']); // No se pueden duplicar valores al crear o al editar if (!empty($response)) { diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php index da5d9e93..33e35632 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -44,6 +44,11 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll $this->viewData['pageTitle'] = lang('TarifaEncuadernacionLineas.moduleTitle'); $this->viewData['usingSweetAlert'] = true; parent::initController($request, $response, $logger); + + // 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; } diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index 200cc139..ca32f89d 100644 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -8,6 +8,7 @@ use App\Models\Collection; use App\Entities\Tarifas\TarifaEncuadernacionTirada; use App\Models\Tarifas\TarifaEncuadernacionTiradaModel; +use App\Models\Tarifas\TarifaEncuadernacionLineaModel; use App\Models\Compras\ProveedorModel; use App\Models\Compras\ProveedorTipoModel; @@ -47,6 +48,45 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\GoBaseResourceControl parent::initController($request, $response, $logger); } + + public function delete($id = null) + { + if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) { + $objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc)); + } else { + $objName = lang('Basic.global.record'); + } + + if (!$this->soft_delete){ + + if (!$this->model->delete($id)) { + return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + } + } + else{ + $datetime = (new \CodeIgniter\I18n\Time("now")); + + $lineaModel = new TarifaEncuadernacionLineaModel(); + $lineaResult = $lineaModel->removeAllEncuadernacionLineas($id, $datetime, $this->delete_flag); + + $rawResult = $this->model->where('id',$id) + ->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'), + 'is_deleted' => $this->delete_flag]) + ->update(); + + if (!$rawResult && !$lineaResult) { + return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); + } + + } + + // $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented + $message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]); + $response = $this->respondDeleted(['id' => $id, 'msg' => $message]); + return $response; + } + + public function datatable_editor() { if ($this->request->isAJAX()) { diff --git a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php index a4372d4f..efc375a1 100644 --- a/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php @@ -43,6 +43,12 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController { $this->viewData['pageTitle'] = lang('TarifaManipuladoLineas.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; + parent::initController($request, $response, $logger); } @@ -210,19 +216,19 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController // Build our Editor instance and process the data coming from _POST $response = Editor::inst($db, 'tarifa_manipulado_lineas') ->fields( - Field::inst('paginas_min') + Field::inst('tirada_min') ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.decimal')) ) ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_min.required')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_min.required')) ), - Field::inst('paginas_max') + Field::inst('tirada_max') ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.decimal')) ) ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_max.required')) + 'message' => lang('TarifaAcabadoLineas.validation.tirada_max.required')) ), Field::inst('precio_min') ->validator('Validate::numeric', array( @@ -259,8 +265,8 @@ class Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController foreach ($data['data'] as $pkey => $values) { // Si no se quiere borrar... if ($data['data'][$pkey]['is_deleted'] != 1) { - $process_data['paginas_min'] = $data['data'][$pkey]['paginas_min']; - $process_data['paginas_max'] = $data['data'][$pkey]['paginas_max']; + $process_data['tirada_min'] = $data['data'][$pkey]['tirada_min']; + $process_data['tirada_max'] = $data['data'][$pkey]['tirada_max']; $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tarifa_manipulado_id']); // No se pueden duplicar valores al crear o al editar if (!empty($response)) { diff --git a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php index f9fc8713..96665d10 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php +++ b/ci4/app/Controllers/Tarifas/Tarifasencuadernacion.php @@ -89,6 +89,9 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController if (isset($this->model->user_updated_id)) { $sanitizedData['user_created_id'] = $session->id_user; } + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -170,6 +173,9 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController if (isset($this->model->user_updated_id)) { $sanitizedData['user_updated_id'] = $session->id_user; } + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : diff --git a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php index c045ac23..b245f1dd 100644 --- a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php +++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php @@ -86,6 +86,9 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController if (isset($this->model->user_updated_id)) { $sanitizedData['user_created_id'] = $session->id_user; } + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -167,6 +170,9 @@ class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController if (isset($this->model->user_updated_id)) { $sanitizedData['user_updated_id'] = $session->id_user; } + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php index bdc01d4b..9fa7fb51 100644 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php @@ -11,6 +11,7 @@ class TarifaEncuadernacionEntity extends \CodeIgniter\Entity\Entity "nombre" => null, "precio_min" => 0, "importe_fijo" => 0, + "mostrar_en_presupuesto" => 1, "user_created_id" => 0, "user_updated_id" => 0, "is_deleted" => 0, @@ -21,6 +22,7 @@ class TarifaEncuadernacionEntity extends \CodeIgniter\Entity\Entity protected $casts = [ "precio_min" => "float", "importe_fijo" => "float", + "mostrar_en_presupuesto" => "int", "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php b/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php index 33394422..aac261a4 100644 --- a/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaManipuladoEntity.php @@ -11,6 +11,7 @@ class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity "nombre" => null, "precio_min" => 0, "importe_fijo" => 0, + "mostrar_en_presupuesto" => 1, "user_created_id" => 0, "user_updated_id" => 0, "is_deleted" => 0, @@ -21,6 +22,7 @@ class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity protected $casts = [ "precio_min" => "float", "importe_fijo" => "float", + "mostrar_en_presupuesto" => "int", "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaacabadoEntity.php b/ci4/app/Entities/Tarifas/TarifaacabadoEntity.php index 8c0e69c7..0d2d9b91 100644 --- a/ci4/app/Entities/Tarifas/TarifaacabadoEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaacabadoEntity.php @@ -10,6 +10,7 @@ class TarifaacabadoEntity extends \CodeIgniter\Entity\Entity "nombre" => null, "precio_min" => 0, "importe_fijo" => 0, + "mostrar_en_presupuesto" => 1, "user_created_id" => 0, "user_updated_id" => 0, "is_deleted" => 0, @@ -20,6 +21,7 @@ class TarifaacabadoEntity extends \CodeIgniter\Entity\Entity protected $casts = [ "precio_min" => "float", "importe_fijo" => "float", + "mostrar_en_presupuesto" => "int", "user_created_id" => "int", "user_updated_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Language/en/TarifaEncuadernacionLineas.php b/ci4/app/Language/en/TarifaEncuadernacionLineas.php index 97f92970..9194f806 100644 --- a/ci4/app/Language/en/TarifaEncuadernacionLineas.php +++ b/ci4/app/Language/en/TarifaEncuadernacionLineas.php @@ -11,6 +11,7 @@ return [ 'precioUnidad' => 'Price Unit', 'paginasMax' => 'Max Pages', 'paginasMin' => 'Min Pages', + 'moduleExplanation' => 'The number of pages indicated in this section refers per copy, not to the total of the order.', 'margen' => 'Margin', 'validation' => [ 'error_seleccion_tiradas' => 'A line from the Printings table must be selected before creating a new record.', diff --git a/ci4/app/Language/en/Tarifaacabado.php b/ci4/app/Language/en/Tarifaacabado.php index 64532898..e9413fab 100644 --- a/ci4/app/Language/en/Tarifaacabado.php +++ b/ci4/app/Language/en/Tarifaacabado.php @@ -15,6 +15,7 @@ return [ 'precioMin' => 'Min Price', 'importeFijo' => 'Fixed amount', 'margen' => 'Margin', + 'mostrar_en_presupuesto' => 'Show in budget', 'tarifaacabado' => 'Finishing Rates', 'tarifaacabadoList' => 'Finishing Rates List', 'tarifasacabado' => 'Finishing Rates', diff --git a/ci4/app/Language/en/Tarifaencuadernacion.php b/ci4/app/Language/en/Tarifaencuadernacion.php index 99936ab0..60412c11 100644 --- a/ci4/app/Language/en/Tarifaencuadernacion.php +++ b/ci4/app/Language/en/Tarifaencuadernacion.php @@ -21,6 +21,7 @@ return [ 'tarifasencuadernacion' => 'Binding rates', 'tiradaMax' => 'Print Max', 'tiradaMin' => 'Print Min', + 'mostrar_en_presupuesto' => 'Show in budget', 'updatedAt' => 'Updated At', 'userCreatedId' => 'User Created ID', 'userUpdateId' => 'User Update ID', diff --git a/ci4/app/Language/en/Tarifamanipulado.php b/ci4/app/Language/en/Tarifamanipulado.php index a29c2097..da383fea 100644 --- a/ci4/app/Language/en/Tarifamanipulado.php +++ b/ci4/app/Language/en/Tarifamanipulado.php @@ -15,6 +15,7 @@ return [ 'precioMin' => 'Price Min', 'precioMin' => 'Min Price', 'importeFijo' => 'Fixed amount', + 'mostrar_en_presupuesto' => 'Show in budget', 'margen' => 'Margin', 'tarifamanipulado' => 'Handling rate', 'tarifamanipuladoList' => 'Handling rates List', diff --git a/ci4/app/Language/es/TarifaEncuadernacionLineas.php b/ci4/app/Language/es/TarifaEncuadernacionLineas.php index 69f95d65..d941975d 100644 --- a/ci4/app/Language/es/TarifaEncuadernacionLineas.php +++ b/ci4/app/Language/es/TarifaEncuadernacionLineas.php @@ -11,6 +11,7 @@ return [ 'precioUnidad' => 'Precio Unidad', 'paginasMax' => 'Páginas Max', 'paginasMin' => 'Páginas Min', + 'moduleExplanation' => 'El número de páginas reflejado en este apartado se refiere por ejemplar, no al total del pedido', 'margen' => 'Margen', 'validation' => [ 'error_seleccion_tiradas' => 'Debe seleccionar una línea de la tabla tiradas antes de crear un registro nuevo.', diff --git a/ci4/app/Language/es/Tarifaacabado.php b/ci4/app/Language/es/Tarifaacabado.php index 63db7206..fdb1d0e9 100644 --- a/ci4/app/Language/es/Tarifaacabado.php +++ b/ci4/app/Language/es/Tarifaacabado.php @@ -11,6 +11,7 @@ return [ 'nombre' => 'Nombre', 'precioMin' => 'Precio Mínimo', 'importeFijo' => 'Importe Fijo', + 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', 'tarifaacabado' => 'Tarifas Acabado', 'tarifaacabadoList' => 'Lista Tarifas Acabado', 'tarifasacabado' => 'Tarifas Acabado', diff --git a/ci4/app/Language/es/Tarifaencuadernacion.php b/ci4/app/Language/es/Tarifaencuadernacion.php index 1bf6306d..8b3aa73b 100644 --- a/ci4/app/Language/es/Tarifaencuadernacion.php +++ b/ci4/app/Language/es/Tarifaencuadernacion.php @@ -18,6 +18,7 @@ return [ 'tarifasencuadernacion' => 'Tarifas Encuadernación', 'tiradaMax' => 'Tirada Max', 'tiradaMin' => 'Tirada Min', + 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', 'updatedAt' => 'Actualizado en', 'userCreatedId' => 'ID Usuario \"Creado en\"', 'userUpdateId' => 'ID Usuario \"Actualizado en\"', diff --git a/ci4/app/Language/es/Tarifamanipulado.php b/ci4/app/Language/es/Tarifamanipulado.php index 0f0b0235..3e1fc7c5 100644 --- a/ci4/app/Language/es/Tarifamanipulado.php +++ b/ci4/app/Language/es/Tarifamanipulado.php @@ -13,6 +13,7 @@ return [ 'precioMax' => 'Precio Max', 'precioMin' => 'Precio Min', 'importeFijo' => 'Importe Fijo', + 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', 'tarifamanipulado' => 'Tarifa Manipulado', 'tarifamanipuladoList' => 'Lista Tarifas Manipulado', 'tarifasmanipulado' => 'Tarifas Manipulado', diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php index d714b390..2c2381aa 100644 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php @@ -156,4 +156,16 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel return ""; } + + public function removeAllEncuadernacionLineas($tiradaId = -1, $datetime = null, $delete_flag=1){ + + $builder = $this->db + ->table($this->table) + ->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'), + 'is_deleted' => $delete_flag]) + ->where('tirada_encuadernacion_id',$tiradaId) + ->update(); + + return $builder; + } } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php index 69d5a181..05be7bda 100644 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -14,12 +14,17 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel const SORTABLE = [ 0 => "t1.nombre", + 1 => "t1.precio_min", + 2 => "t1.importe_fijo", + 3 => "t1.mostrar_en_presupuesto", + ]; protected $allowedFields = [ "nombre", "precio_min", "importe_fijo", + "mostrar_en_presupuesto", "deleted_at", "is_deleted", "user_created_id", @@ -76,7 +81,8 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel */ public function getResource(string $search = "") { - $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo"); + $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, + t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, t1.mostrar_en_presupuesto AS mostrar_en_presupuesto"); //JJO $builder->where("t1.is_deleted", 0); diff --git a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php index f7accda2..8afc3ab4 100644 --- a/ci4/app/Models/Tarifas/TarifaManipuladoModel.php +++ b/ci4/app/Models/Tarifas/TarifaManipuladoModel.php @@ -14,12 +14,16 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel const SORTABLE = [ 0 => "t1.nombre", + 1 => "precio_min", + 2 => "importe_fijo", + 3 => "t1.mostrar_en_presupuesto", ]; protected $allowedFields = [ "nombre", "precio_min", "importe_fijo", + "mostrar_en_presupuesto", "deleted_at", "is_deleted", "user_created_id", @@ -76,7 +80,8 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel */ public function getResource(string $search = "") { - $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo"); + $builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo + ,t1.mostrar_en_presupuesto AS mostrar_en_presupuesto"); //JJO $builder->where("t1.is_deleted", 0); diff --git a/ci4/app/Models/Tarifas/TarifaacabadoModel.php b/ci4/app/Models/Tarifas/TarifaacabadoModel.php index 049b16f2..8d9d209d 100644 --- a/ci4/app/Models/Tarifas/TarifaacabadoModel.php +++ b/ci4/app/Models/Tarifas/TarifaacabadoModel.php @@ -16,12 +16,14 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel 0 => "t1.nombre", 1 => "precio_min", 2 => "importe_fijo", + 3 => "t1.mostrar_en_presupuesto", ]; protected $allowedFields = [ "nombre", "precio_min", "importe_fijo", + "mostrar_en_presupuesto", "deleted_at", "is_deleted", "user_created_id", @@ -79,7 +81,7 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel public function getResource(string $search = "") { $builder = $this->db->table($this->table . " t1")->select( - "t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo" + "t1.id AS id, t1.nombre AS nombre, t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, t1.mostrar_en_presupuesto AS mostrar_en_presupuesto" ); //JJO diff --git a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php index e56da859..b5c70fae 100644 --- a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php +++ b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php @@ -38,7 +38,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "label" => "Tarifapreimpresion.nombre", "rules" => "trim|required|max_length[255]", ], - "precio" => [ + "precio_pagina" => [ "label" => "Tarifapreimpresion.precio", "rules" => "required|decimal", ], @@ -61,7 +61,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "max_length" => "Tarifapreimpresion.validation.nombre.max_length", "required" => "Tarifapreimpresion.validation.nombre.required", ], - "precio" => [ + "precio_pagina" => [ "decimal" => "Tarifapreimpresion.validation.precio.decimal", "required" => "Tarifapreimpresion.validation.precio.required", ], diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php index f6508319..24fb87d6 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems.php @@ -24,6 +24,16 @@ value="importe_fijo) ?>"> +
+
+ + +
+
+ \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index 5683ecd8..c793fa29 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -1,6 +1,7 @@ include('themes/_commonPartialsBs/datatables') ?> include("themes/_commonPartialsBs/select2bs5") ?> include("themes/_commonPartialsBs/sweetalert") ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?> @@ -49,7 +50,7 @@
- + @@ -79,10 +80,10 @@ const actionBtns = function(data) { return ` - - - - `; + + + + `; }; @@ -96,11 +97,11 @@ table : "#tableOfTarifaacabadolineas", idSrc: 'id', fields: [ { - name: "paginas_min" + name: "tirada_min" }, { name: "precio_max" }, { - name: "paginas_max" + name: "tirada_max" }, { name: "precio_min" },{ @@ -165,9 +166,9 @@ async: true, }), columns: [ - { 'data': 'paginas_min' }, + { 'data': 'tirada_min' }, { 'data': 'precio_max' }, - { 'data': 'paginas_max' }, + { 'data': 'tirada_max' }, { 'data': 'precio_min' }, { 'data': 'margen' }, { @@ -193,7 +194,7 @@ editor: editor, formOptions: { submitTrigger: -1, - submitHtml: '' + submitHtml: '' } } ] } ); @@ -205,9 +206,9 @@ editor.inline( theTable.cells(this.parentNode.parentNode, '*').nodes(), { - cancelHtml: '', + cancelHtml: '', cancelTrigger: 'span.cancel', - submitHtml: '', + submitHtml: '', submitTrigger: 'span.edit', submit: 'allIfChanged' } @@ -216,32 +217,29 @@ // Delete row - $('#tableOfTarifaacabadolineas').on( 'click', 'tbody span.remove', 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) { - editor - .create( false ) - .edit( this.parentNode, false) - .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) - .set( 'is_deleted', 1 ) - .submit(); - - } - }); + $(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: `/tarifas/tarifaacabadolineas/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') ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php index 8f9a689f..86307c6e 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoList.php @@ -19,6 +19,7 @@ + @@ -89,10 +90,19 @@ { 'data': 'nombre' }, { 'data': 'precio_min' }, { 'data': 'importe_fijo' }, + { 'data': 'mostrar_en_presupuesto' }, { 'data': actionBtns } ] }); + theTable.on( 'draw.dt', function () { + const boolCols = [3]; + 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 = `/tarifas/tarifaacabado/edit/${$(this).attr('data-id')}`; diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php index 87bb6eb4..89e34635 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/_tarifaEncuadernacionFormItems.php @@ -1,6 +1,7 @@
-
+ +
@@ -21,6 +22,15 @@
-
+
+
+ +
+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index af1c9838..501757ee 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -69,6 +69,8 @@
+ +

@@ -117,11 +119,36 @@ `; }; + // Delete row $(document).on('click', '.btn-delete', function(e) { $(".btn-remove").attr('data-id', $(this).attr('data-id')); + if($(this).closest('table').attr('id').includes('tiradas')){ + $(".btn-remove").attr('table', "tiradas"); + } + else if($(this).closest('table').attr('id').includes('lineas')){ + $(".btn-remove").attr('table', "lineas"); + } + else{ + $(".btn-remove").attr('table', ); + } }); var selected_tirada_id = -1; + + + $(document).on('click', '.btn-remove', function(e) { + const dataId = $(this).attr('data-id'); + const row = $(this).closest('tr'); + if ($.isNumeric(dataId)) { + + if($(this).attr('table').includes('tiradas')){ + remove_tiradas(dataId, row); + } + else if ($(this).attr('table').includes('lineas')){ + remove_lineas(dataId, row); + } + } + }); endSection() ?> @@ -278,14 +305,11 @@ ); } ); - // Delete row - $(document).on('click', '.btn-remove', function(e) { - const dataId = $(this).attr('data-id'); - const row = $(this).closest('tr'); - if ($.isNumeric(dataId)) { - /*$.ajax({ - url: `/configuracion/papelimpresiontipologias/delete/${dataId}`, + function remove_lineas(dataId, row){ + + $.ajax({ + url: `/tarifas/tarifaencuadernacionlineas/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); @@ -294,44 +318,11 @@ popSuccessAlert(data.msg ?? jqXHR.statusText); }).fail((jqXHR, textStatus, errorThrown) => { popErrorAlert(jqXHR.responseJSON.messages.error) - })*/ - /*editor - .create( false ) - .edit( this.parentNode, false) - .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) - .set( 'is_deleted', 1 ) - .submit();*/ - } - }); - - /* - $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.remove', 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) { - editor - .create( false ) - .edit( this.parentNode, false) - .set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') ) - .set( 'is_deleted', 1 ) - .submit(); - - } }); - });*/ - + + } + + endSection() ?> @@ -505,23 +496,22 @@ // Delete row - $(document).on('click', '.btn-remove', function(e) { - const dataId = $(this).attr('data-id'); - const row = $(this).closest('tr'); - if ($.isNumeric(dataId)) { - $.ajax({ + function remove_tiradas(dataId, row){ + + $.ajax({ url: `/tarifas/tarifaencuadernaciontiradas/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); theTable2.clearPipeline(); theTable2.row($(row)).invalidate().draw(); + theTable.clearPipeline(); + theTable.draw(); popSuccessAlert(data.msg ?? jqXHR.statusText); }).fail((jqXHR, textStatus, errorThrown) => { - popErrorAlert(jqXHR.responseJSON.messages.error) - }) - } - }); + popErrorAlert(jqXHR.statusText) + }); + } endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php index 6810c9af..c053adf8 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php @@ -19,6 +19,7 @@ + @@ -89,10 +90,20 @@ { 'data': 'nombre' }, { 'data': 'precio_min' }, { 'data': 'importe_fijo' }, + { 'data': 'mostrar_en_presupuesto' }, { 'data': actionBtns } ] }); + theTable.on( 'draw.dt', function () { + const boolCols = [3]; + 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 = `/tarifas/tarifasencuadernacion/edit/${$(this).attr('data-id')}`; diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems.php index fced007e..7becab96 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems.php @@ -21,6 +21,16 @@ +
+
+ + +
+
+ \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index 1a12da80..a1276a7b 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -52,7 +52,7 @@
- + @@ -80,10 +80,10 @@ const actionBtns = function(data) { return ` - - - - `; + + + + `; }; @@ -97,11 +97,11 @@ table : "#tableOfTarifamanipuladolineas", idSrc: 'id', fields: [ { - name: "paginas_min" + name: "tirada_min" }, { name: "precio_max" }, { - name: "paginas_max" + name: "tirada_max" }, { name: "precio_min" }, { @@ -166,9 +166,9 @@ async: true, }), columns: [ - { 'data': 'paginas_min' }, + { 'data': 'tirada_min' }, { 'data': 'precio_max' }, - { 'data': 'paginas_max' }, + { 'data': 'tirada_max' }, { 'data': 'precio_min' }, { 'data': 'margen' }, { @@ -194,7 +194,7 @@ editor: editor, formOptions: { submitTrigger: -1, - submitHtml: '' + submitHtml: '' } } ] } ); @@ -206,9 +206,9 @@ editor.inline( theTable.cells(this.parentNode.parentNode, '*').nodes(), { - cancelHtml: '', + cancelHtml: '', cancelTrigger: 'span.cancel', - submitHtml: '', + submitHtml: '', submitTrigger: 'span.edit', submit: 'allIfChanged' } @@ -243,6 +243,30 @@ } }); }); + + + // 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: `/tarifas/tarifamanipuladolineas/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') ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php index 0f6212c1..3b8a6d64 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoList.php @@ -19,6 +19,7 @@ + @@ -88,15 +89,27 @@ { 'data': 'nombre' }, { 'data': 'precio_min' }, { 'data': 'importe_fijo' }, + { 'data': 'mostrar_en_presupuesto' }, { 'data': actionBtns } ] }); + theTable.on( 'draw.dt', function () { + const boolCols = [3]; + 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 = `/tarifas/tarifasmanipulado/edit/${$(this).attr('data-id')}`; }); + $(document).on('click', '.btn-delete', function(e) { $(".btn-remove").attr('data-id', $(this).attr('data-id')); }); diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php index 356faf7b..e2f00abc 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php @@ -21,13 +21,13 @@ diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php index 266655af..c4cc3555 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php @@ -1,4 +1,5 @@ include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/sweetalert") ?> extend('themes/backend/vuexy/main/defaultlayout') ?> section("content") ?>
From 8200de2d73df5fcaabda4e76425ccdf52c54e488 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Fri, 18 Aug 2023 14:02:47 +0200 Subject: [PATCH 12/13] =?UTF-8?q?A=C3=B1adida=20la=20funcionalidad=20en=20?= =?UTF-8?q?tarifas=20preimpresion=20de=20mostrar=20en=20presupuesto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Tarifas/Tarifapreimpresion.php | 7 +++++++ .../Tarifas/TarifapreimpresionEntity.php | 2 ++ ci4/app/Language/en/Tarifapreimpresion.php | 1 + ci4/app/Language/es/Tarifapreimpresion.php | 1 + .../Models/Tarifas/TarifapreimpresionModel.php | 1 + .../_tarifapreimpresionFormItems.php | 16 ++++++++++++++++ .../preimpresion/viewTarifapreimpresionList.php | 4 ++++ 7 files changed, 32 insertions(+) diff --git a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php index b7f74a3c..06de776c 100644 --- a/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php +++ b/ci4/app/Controllers/Tarifas/Tarifapreimpresion.php @@ -62,6 +62,10 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -140,6 +144,9 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController if (isset($this->model->user_updated_id)) { $sanitizedData['user_updated_id'] = $session->id_user; } + if ($this->request->getPost('mostrar_en_presupuesto') == null) { + $sanitizedData['mostrar_en_presupuesto'] = false; + } $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : diff --git a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php index 599bc822..7c3f9d0a 100644 --- a/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifapreimpresionEntity.php @@ -12,6 +12,7 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity "precio_min" => 0, "importe_fijo" => 0, "margen" => 0, + "mostrar_en_presupuesto" => 1, "user_created_id" => 1, "user_update_id" => 1, "is_deleted" => 0, @@ -24,6 +25,7 @@ class TarifapreimpresionEntity extends \CodeIgniter\Entity\Entity "precio_min" => "float", "importe_fijo" => "float", "margen" => "float", + "mostrar_en_presupuesto" => "int", "user_created_id" => "int", "user_update_id" => "int", "is_deleted" => "int", diff --git a/ci4/app/Language/en/Tarifapreimpresion.php b/ci4/app/Language/en/Tarifapreimpresion.php index a391b388..5d3070bc 100644 --- a/ci4/app/Language/en/Tarifapreimpresion.php +++ b/ci4/app/Language/en/Tarifapreimpresion.php @@ -15,6 +15,7 @@ return [ 'tarifapreimpresion' => 'Preprinting rate', 'tarifapreimpresionList' => 'Preprinting rates List', 'tarifaspreimpresion' => 'Preprinting rates', + 'mostrar_en_presupuesto' => 'Show in budget', 'updatedAt' => 'Updated At', 'userCreatedId' => 'User Created ID', 'userUpdateId' => 'User Update ID', diff --git a/ci4/app/Language/es/Tarifapreimpresion.php b/ci4/app/Language/es/Tarifapreimpresion.php index c579fecd..5107424b 100644 --- a/ci4/app/Language/es/Tarifapreimpresion.php +++ b/ci4/app/Language/es/Tarifapreimpresion.php @@ -10,6 +10,7 @@ return [ 'precio' => 'Precio/página', 'precioMin' => 'Precio Mínimo', 'importeFijo' => 'Importe Fijo', + 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', 'margen' => 'Margen', 'tarifapreimpresion' => 'Tarifa Preimpresión', 'tarifapreimpresionList' => 'Lista Tarifas Preimpresión', diff --git a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php index b5c70fae..0de5263f 100644 --- a/ci4/app/Models/Tarifas/TarifapreimpresionModel.php +++ b/ci4/app/Models/Tarifas/TarifapreimpresionModel.php @@ -18,6 +18,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel "precio_min", "importe_fijo", "margen", + "mostrar_en_presupuesto", "deleted_at", "is_deleted", "user_created_id", diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php index e2f00abc..cd018e2b 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/_tarifapreimpresionFormItems.php @@ -72,6 +72,22 @@ value="margen) ?>" >
+ + +
+
+ mostrar_en_presupuesto == true ? 'checked' : ''; ?> + > + +
+
+ \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php index 02247ff0..e83b5917 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionList.php @@ -20,6 +20,7 @@
+ @@ -41,6 +42,9 @@ +
margen) ?> + mostrar_en_presupuesto)==1?'':"" ?> + id), "", ['class'=>'text-body', 'data-id'=>$item->id,]); ?> ", ['class'=>'text-body', 'data-href'=>route_to('deleteTarifapreimpresion', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?> From bbde91f4b994dc35ca3946d39824b79aee626027 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Fri, 18 Aug 2023 15:08:07 +0200 Subject: [PATCH 13/13] Insertada la opcion Color HQ en la lista de tarifas impresion --- .../Controllers/Configuracion/Maquinastarifasimpresion.php | 1 + ci4/app/Language/en/MaquinasTarifasImpresions.php | 1 + ci4/app/Language/es/MaquinasTarifasImpresions.php | 1 + .../Models/Configuracion/MaquinasTarifasImpresionModel.php | 2 +- .../vuexy/form/configuracion/maquinas/viewMaquinaForm.php | 5 ++++- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php index 9515a89c..35923914 100644 --- a/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php +++ b/ci4/app/Controllers/Configuracion/Maquinastarifasimpresion.php @@ -419,6 +419,7 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController 'color' => 'color', 'negrohq' => 'negrohq', 'bicolor' => 'bicolor', + 'colorhq' => 'colorhq', ]; return $tipoOptions; } diff --git a/ci4/app/Language/en/MaquinasTarifasImpresions.php b/ci4/app/Language/en/MaquinasTarifasImpresions.php index 0cff47a2..31f29370 100644 --- a/ci4/app/Language/en/MaquinasTarifasImpresions.php +++ b/ci4/app/Language/en/MaquinasTarifasImpresions.php @@ -26,6 +26,7 @@ return [ 'negro' => 'Black', 'color' => 'Color', 'negrohq' => 'Black HQ', + 'colorhq' => 'Color HQ', 'bicolor' => 'Bicolor', 'validation' => [ 'duplicated_uso_tipo' => "Duplicate line (the combination 'use' and 'type' already exists)", diff --git a/ci4/app/Language/es/MaquinasTarifasImpresions.php b/ci4/app/Language/es/MaquinasTarifasImpresions.php index e7deb3eb..1fda1bb8 100644 --- a/ci4/app/Language/es/MaquinasTarifasImpresions.php +++ b/ci4/app/Language/es/MaquinasTarifasImpresions.php @@ -26,6 +26,7 @@ return [ 'negro' => 'Negro', 'color' => 'Color', 'negrohq' => 'Negro HQ', + 'colorhq' => 'Color HQ', 'bicolor' => 'Bicolor', 'validation' => [ 'duplicated_uso_tipo' => "Línea duplicada (la combinación 'uso' y 'tipo' ya existe)", diff --git a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php index f95608f9..62b3e037 100644 --- a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php +++ b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php @@ -37,7 +37,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel ], "tipo" => [ "label" => "MaquinasTarifasImpresions.tipo", - "rules" => "permit_empty|in_list[negro,color,negrohq,bicolor]", + "rules" => "permit_empty|in_list[negro,color,negrohq,bicolor,colorhq]", ], "uso" => [ "label" => "MaquinasTarifasImpresions.uso", diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php index e1bf226b..330e3874 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php @@ -243,7 +243,8 @@ {label:'', value:'negro'}, {label:'', value: 'negrohq'}, {label:'', value: 'bicolor'}, - {label:'', value: 'color'} + {label:'', value: 'color'}, + {label:'', value: 'colorhq'}, ]; editor = new $.fn.dataTable.Editor( { @@ -405,6 +406,8 @@ return ''; else if (data=='color') return ''; + else if (data=='colorhq') + return ''; } }, { 'data': 'precio' },