diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index 7196d9ba..43ef6206 100755 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -72,9 +72,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -84,36 +84,36 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { $noException = false; $this->dealWithException($e); } - else : + else: $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $this->model->db->insertID(); $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else : + else: return $this->redirect2listView('sweet-success', $message); endif; - else : + else: $this->session->setFlashData('sweet-success', $message); endif; @@ -133,20 +133,20 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $papelGenerico = $this->model->find($id); - if ($papelGenerico == false) : + if ($papelGenerico == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -159,24 +159,24 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController if ($this->request->getPost('show_in_client_special') == null) { $sanitizedData['show_in_client_special'] = false; } - - if($sanitizedData['show_in_client_special']){ + + if ($sanitizedData['show_in_client_special']) { $sanitizedData['show_in_client'] = true; } $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); } catch (\Exception $e) { $noException = false; $this->dealWithException($e); } - else : + else: $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); @@ -186,17 +186,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $thenRedirect = false; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $papelGenerico->id ?? $id; - $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]).'.'; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else : + else: return $this->redirect2listView('sweet-success', $message); endif; - else : + else: $this->session->setFlashData('sweet-success', $message); endif; @@ -210,7 +210,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelGenerico.moduleTitle') . ' ' . lang('Basic.global.edit3'); $this->viewData['usingServerSideDataTable'] = true; - + return $this->displayForm(__METHOD__, $id); } // end function edit(...) @@ -297,15 +297,14 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController public function getPapelCliente() { if ($this->request->isAJAX()) { - + $tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null; $POD = null; - if($tirada != null){ + if ($tirada != null) { $POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value; - if(intval($tirada) <= intval($POD_value)){ + if (intval($tirada) <= intval($POD_value)) { $POD = true; - } - else{ + } else { $POD = false; } } @@ -313,17 +312,38 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null; $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; $tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null; - + $sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0; + $ancho = floatval($this->request->getGet('ancho') ?? 0); $alto = floatval($this->request->getGet('alto') ?? 0); $solapas = floatval($this->request->getGet('solapas') ?? 0); $lomo = floatval($this->request->getGet('lomo') ?? 0); - $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; - - $menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada); - $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); - + $forSelect2 = intval($this->request->getGet('forSelect2') ?? 0); + + $anchoLibro = 2 * $ancho + 2 * $solapas + $lomo; + + $menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada); + $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); + + if ($forSelect2) { + $menu = array_map(function ($item) { + if (isset($item->id)) { + return [ + 'id' => $item->id, + 'name' => $item->nombre + ]; + } else { + return [ + 'id' => $item->gramaje, + 'name' => $item->gramaje + ]; + } + }, $menu); + + return $this->respond($menu); + } + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); $data = [ @@ -340,23 +360,23 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController public function selectPapelEspecial() { - + if ($this->request->isAJAX()) { - + $tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null; $POD = null; - if($tirada != null){ + if ($tirada != null) { $POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value; - if(intval($tirada) <= intval($POD_value)){ + if (intval($tirada) <= intval($POD_value)) { $POD = true; - } - else{ + } else { $POD = false; } } $tipo = goSanitize($this->request->getGet('tipo'))[0]; $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; - + $sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0; + $ancho = floatval($this->request->getGet('ancho') ?? 0); $alto = floatval($this->request->getGet('alto') ?? 0); $solapas = floatval($this->request->getGet('solapas') ?? 0); @@ -364,9 +384,9 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $tapa_dura = $this->request->getGet('tapa_dura') ?? 0; - $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; + $anchoLibro = 2 * $ancho + 2 * $solapas + $lomo; - $items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); + $items = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); $items = array_map(function ($item) { return [ 'id' => $item->id, diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index cc5f99b8..72bbadad 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -125,6 +125,7 @@ return [ 'faja' => 'Faja', 'altoFaja' => 'Alto faja', 'papelFaja' => 'Papel faja', + 'gramajeFaja' => 'Gramaje faja', 'tamanioSolapasFaja' => 'Tamaño solapas faja', 'plastificadoFaja' => 'Plastificado faja', 'estucadoMate170gr' => 'Estucado mate 170 gr', @@ -263,7 +264,7 @@ return [ 'formatoLibro' => "Formato libro", 'selectCliente' => "Seleccione cliente", 'selectPapel' => "Seleccione papel", - + 'selectGramaje' => "Seleccione gramaje", // Preview 'preview' => 'Previsualización de configuraciones', @@ -370,6 +371,7 @@ return [ 'opcion_solapas' => 'Seleccione la opción para las solapas', 'paginas_multiplo_4' => 'El número de páginas para cosido o grapado debe ser múltiplo de 4', 'paginas_pares' => 'El número de páginas debe ser par', + 'extras_cubierta' => 'Rellene todos los campos', ], 'errores' => [ diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 41aa10d7..619ae1ac 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -129,16 +129,16 @@ class PapelGenericoModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } @@ -413,6 +413,7 @@ class PapelGenericoModel extends \App\Models\BaseModel public function getPapelCliente( $tipo, $is_cubierta = false, + $is_sobrecubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false, @@ -517,6 +518,9 @@ class PapelGenericoModel extends \App\Models\BaseModel if ($tapa_dura == true) { $builder->where("t2.use_for_tapa_dura", 1); } + } else if ($is_sobrecubierta == true) { + $builder->where("t2.sobrecubierta", 1); + $builder->where("t5.uso", 'sobrecubierta'); } else { $builder->where("t2.interior", 1); $builder->where("t5.uso", 'interior'); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php index 34e3a455..6f035b2f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php @@ -172,8 +172,9 @@