From f50987dc2bb98d8654696eecd9831be25e8f0f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 28 Oct 2024 18:52:06 +0100 Subject: [PATCH 1/7] =?UTF-8?q?arreglado=20bug=20con=20tama=C3=B1o=20perso?= =?UTF-8?q?nalizado=20en=20presupuesto=20admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Controllers/Presupuestos/Cosidotapablanda.php | 4 ++-- .../presupuestos/cosidotapablanda/_datosLibroItems.js | 8 ++++---- .../presupuestos/cosidotapablanda/_datosLibroItems.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index f5a26275..fa04075c 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -1278,8 +1278,8 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController $input_data['is_duplicado'] = $presupuestoEntity->is_duplicado; if($presupuestoEntity->papel_formato_personalizado){ - $input_data['ancho'] = $presupuestoEntity->ancho; - $input_data['alto'] = $presupuestoEntity->alto; + $input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ; + $input_data['alto'] = $presupuestoEntity->papel_formato_alto ; } else{ $model = model("App\Models\Configuracion\PapelFormatoModel"); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js index 2c6027a1..2e974ab5 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js @@ -121,11 +121,11 @@ function calcular_mermas(){ $('#papelFormatoPersonalizado').on("click",function(){ - var checkbox = document.getElementById('papelFormatoPersonalizado'); - if(checkbox.checked == true){ + + if($('#papelFormatoPersonalizado').is(':checked')){ document.getElementById("papelFormatoAncho").style.display = "block"; document.getElementById("papelFormatoAlto").style.display = "block"; - $('#papelFormatoId').next(".select2-container").hide(); + $('#papelFormatoId').hide(); $('#papelFormatoId').val(0).change(); document.getElementById("label_papelFormatoId").innerHTML = window.Presupuestos.papelFormatoId + " (" + @@ -136,7 +136,7 @@ $('#papelFormatoPersonalizado').on("click",function(){ document.getElementById("papelFormatoAlto").value= ""; document.getElementById("papelFormatoAncho").style.display = "none"; document.getElementById("papelFormatoAlto").style.display = "none"; - $('#papelFormatoId').next(".select2-container").show(); + $('#papelFormatoId').show(); document.getElementById("label_papelFormatoId").innerHTML = window.Presupuestos.papelFormatoId + '*'; } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 48f5b0ae..bd524b58 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -42,7 +42,7 @@ * - papel_formato_personalizado == false ? '' : 'style="display: none"'; ?> name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;"> From 8556887567823407d394127c2fa772a6f7da10ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 30 Oct 2024 17:46:35 +0100 Subject: [PATCH 2/7] vuelta a importe minimo en tiradas --- ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php | 2 ++ ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php index be10cf9c..6a72e00c 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php @@ -15,6 +15,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity "precio_max" => 0, "tirada_min" => 0, "tirada_max" => 0, + "total_min" => 0, "margen" => 0, "user_created_id" => 0, "user_updated_id" => 0, @@ -31,6 +32,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity "precio_max" => "float", "tirada_min" => "float", "tirada_max" => "float", + "total_min" => "float", "margen" => "float", "user_created_id" => "int", "user_updated_id" => "int", diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php index 1a65fe07..91f35604 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionTirada.php @@ -11,7 +11,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity "tirada_min" => 0, "tirada_max" => 0, "proveedor_id" => 0, - "precio_min" => 0, "importe_fijo" => 0, "user_created_id" => 0, "user_updated_id" => 0, @@ -24,7 +23,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity "tirada_min" => "float", "tirada_max" => "float", "proveedor_id" => "int", - "precio_min" => "float", "importe_fijo" => "float", "user_created_id" => "int", "user_updated_id" => "int", From d0ee0b27bc294ea063f3e9a69c34badf63ac3f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 30 Oct 2024 18:36:35 +0100 Subject: [PATCH 3/7] precio minimo en tarifa encuadernacion a nivel de lineas --- .../Tarifas/Tarifaencuadernacionlineas.php | 156 +++++++++++------- .../Tarifaencuadernacionlineashoras.php | 143 ++++++++++------ .../Tarifas/Tarifaencuadernaciontiradas.php | 9 - .../TarifaEncuadernacionLineaHoras.php | 2 + .../PresupuestoEncuadernacionesModel.php | 17 +- .../TarifaEncuadernacionLineaHorasModel.php | 14 +- .../TarifaEncuadernacionLineaModel.php | 15 +- .../Tarifas/TarifaEncuadernacionModel.php | 4 +- .../TarifaEncuadernacionTiradaModel.php | 12 +- .../viewTarifaEncuadernacionForm.php | 12 +- .../viewTarifaEncuadernacionList.php | 2 +- 11 files changed, 244 insertions(+), 142 deletions(-) diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php index 60545c9d..850225b9 100755 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineas.php @@ -1,4 +1,5 @@ -request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -84,10 +85,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $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) { @@ -101,14 +102,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $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: return $this->redirect2listView('sweet-success', $message); @@ -134,20 +135,20 @@ class Tarifaencuadernacionlineas 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); $tarifaEncuadernacionLinea = $this->model->find($id); - if ($tarifaEncuadernacionLinea == false) : + if ($tarifaEncuadernacionLinea == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -156,10 +157,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $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) { @@ -176,12 +177,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $thenRedirect = false; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $tarifaEncuadernacionLinea->id ?? $id; $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: return $this->redirect2listView('sweet-success', $message); @@ -214,45 +215,90 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $response = Editor::inst($db, 'tarifa_encuadernacion_lineas') ->fields( Field::inst('paginas_libro_min') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')) + ->validator( + 'Validate::numeric', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required') + ) ), Field::inst('paginas_libro_max') - ->validator('Validate::numeric', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')) + ->validator( + 'Validate::numeric', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required') + ) ), Field::inst('precio_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') + ) ), Field::inst('precio_max') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') + ) + ), + Field::inst('total_min') + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( + "decimal" => ',', + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal') + ) + ) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required') + ) ), Field::inst('margen') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') + ) ), Field::inst('tirada_encuadernacion_id'), Field::inst('user_created_id'), @@ -322,10 +368,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - + $cleandatatable = $reqData['cleandatatable'] ?? 0; - - if($cleandatatable){ + + if ($cleandatatable) { $tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1; @@ -338,11 +384,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController $csrfTokenName => $newTokenHash ]; return $this->respond($data); - - } - else{ - + } else { + 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); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php index 7b306ebb..c3410e12 100755 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernacionlineashoras.php @@ -1,4 +1,5 @@ -request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -82,10 +83,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $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) { @@ -99,14 +100,14 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $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: return $this->redirect2listView('sweet-success', $message); @@ -134,20 +135,20 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $tarifaEncuadernacionLinea = $this->model->find($id); - if ($tarifaEncuadernacionLinea == false) : + if ($tarifaEncuadernacionLinea == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -156,10 +157,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $sanitizedData = $this->sanitized($postData, $nullIfEmpty); $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) { @@ -176,12 +177,12 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $thenRedirect = false; endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $tarifaEncuadernacionLinea->id ?? $id; $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: return $this->redirect2listView('sweet-success', $message); @@ -214,40 +215,79 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas') ->fields( Field::inst('tiempo_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required') + ) ), Field::inst('tiempo_max') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required') + ) ), Field::inst('precio_hora') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') + ) + ), + Field::inst('total_min') + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( + "decimal" => ',', + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal') + ) + ) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required') + ) ), Field::inst('margen') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( + ->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar') + ->validator( + 'Validate::numeric', + array( "decimal" => ',', - 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')) + 'message' => lang('TarifaAcabadoLineas.validation.margen.decimal') + ) ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaAcabadoLineas.validation.margen.required')) + ->validator( + 'Validate::notEmpty', + array( + 'message' => lang('TarifaAcabadoLineas.validation.margen.required') + ) ), Field::inst('tirada_encuadernacion_id'), Field::inst('user_created_id'), @@ -314,10 +354,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); - + $cleandatatable = $reqData['cleandatatable'] ?? 0; - - if($cleandatatable){ + + if ($cleandatatable) { $tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1; @@ -330,9 +370,8 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr $csrfTokenName => $newTokenHash ]; return $this->respond($data); - - } - else{ + + } else { 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); diff --git a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php index d67b6565..4ad0710c 100755 --- a/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php +++ b/ci4/app/Controllers/Tarifas/Tarifaencuadernaciontiradas.php @@ -126,15 +126,6 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\BaseResourceControlle ->validator('Validate::notEmpty', array( 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')) ), - Field::inst('precio_min') - ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') - ->validator('Validate::numeric', array( - "decimal" => ',', - 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')) - ) - ->validator('Validate::notEmpty', array( - 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')) - ), Field::inst('proveedor_id') ->validator('Validate::notEmpty', array( 'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required')) diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php index 2f5d6f0a..23a93e1d 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLineaHoras.php @@ -11,6 +11,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity "tiempo_min" => 0, "tiempo_max" => 0, "precio_hora" => 0, + "total_min" => 0, "margen" => 0, "user_created_id" => 0, "user_updated_id" => 0, @@ -22,6 +23,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity "tirada_encuadernacion_id" => "int", "tiempo_min" => "float", "tiempo_max" => "float", + "total_min" => "float", "precio_hora" => "float", "margen" => "float", "user_created_id" => "int", diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index f8af0109..f9bd0f84 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -267,7 +267,15 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $precio_total = floatval(1.0* $tarifa_proveedor->precio_hora* $tiempo) * (1+$tarifa_value[0]->margen/100.0); if (!$POD){ $precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo); - } + } + + $tarifa_precio_min = floatval($tarifa_proveedor->tarifa_precio_min); + + if($$tarifa_precio_min > $precio_total){ + $total = $total-($total * $margen/100.0); + $margen = round(100.0 * (floatval($$tarifa_precio_min) - $total) / floatval($$tarifa_precio_min), 0); + $total = floatval($$tarifa_precio_min); + } $result_data[0] = floatval($precio_total / $tirada); // Precio/unidad $result_data[1] = $precio_total; @@ -323,11 +331,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $total = $precio_unidad * $ejemplares; $margen = floatval($tarifa->margen); + $tarifa_precio_min = floatval($tarifa->tarifa_precio_min); - if($tarifa->tarifa_precio_min > $total){ + if($tarifa_precio_min > $total){ $total = $total-($total * $margen/100.0); - $margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0); - $total = floatval($tarifa->tarifa_precio_min); + $margen = round(100.0 * (floatval($tarifa_precio_min) - $total) / floatval($tarifa_precio_min), 0); + $total = floatval($tarifa_precio_min); $precio_unidad = round(floatval($total / $ejemplares), 2); } diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php index 976c8ade..d2c75a73 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaHorasModel.php @@ -17,7 +17,8 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel 1 => "t1.tiempo_min", 2 => "t1.tiempo_max", 3 => "t1.precio_hora", - 4 => "t1.margen", + 4 => "t1.total_min", + 5 => "t1.margen", ]; protected $allowedFields = [ @@ -25,6 +26,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel "tiempo_min", "tiempo_max", "precio_hora", + "total_min", "margen", "user_created_id", "is_deleted", @@ -54,6 +56,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel "label" => "TarifaEncuadernacionLineas.precioHora", "rules" => "required|decimal", ], + "total_min" => [ + "label" => "TarifaEncuadernacionLineas.precioHora", + "rules" => "required|decimal", + ], "margen" => [ "label" => "TarifaEncuadernacionLineas.margen", "rules" => "required|decimal", @@ -73,6 +79,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel "decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal", "required" => "TarifaEncuadernacionLineas.validation.tirada_max.required", ], + "total_min" => [ + "decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal", + "required" => "TarifaEncuadernacionLineas.validation.tirada_max.required", + ], "margen" => [ "decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal", "required" => "TarifaEncuadernacionLineas.validation.margen.required", @@ -92,7 +102,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.tiempo_min AS tiempo_min, - t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen, + t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.total_min AS total_min, t1.margen AS margen, t2.id AS tarifa_encuadernacion" ); //JJO diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php index ff1f71d1..23bb6096 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionLineaModel.php @@ -19,6 +19,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel 3 => "t1.paginas_libro_max", 4 => "t1.precio_min", 5 => "t1.precio_max", + 6 => "t1.total_min", + 7 => "t1.margen", ]; protected $allowedFields = [ @@ -30,6 +32,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel "precio_max", "tirada_min", "tirada_max", + "margen", + "total_min", "user_created_id", "is_deleted", @@ -62,6 +66,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel "label" => "TarifaEncuadernacionLineas.tiradaMin", "rules" => "required|decimal", ], + "total_min" => [ + "label" => "TarifaEncuadernacionLineas.precioMin", + "rules" => "required|decimal", + ], "paginas_libro_max" => [ "label" => "TarifaEncuadernacionLineas.paginasMax", "rules" => "required|decimal", @@ -93,6 +101,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel "decimal" => "TarifaEncuadernacionLineas.validation.tirada_min.decimal", "required" => "TarifaEncuadernacionLineas.validation.tirada_min.required", ], + "total_min" => [ + "decimal" => "TarifaEncuadernacionLineas.validation.precio_min.decimal", + "required" => "TarifaEncuadernacionLineas.validation.precio_min.required", + ], "paginas_libro_max" => [ "decimal" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.decimal", "required" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.required", @@ -120,7 +132,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_libro_min AS paginas_libro_min, t1.paginas_libro_max AS paginas_libro_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.tirada_min AS tirada_min, - t1.tirada_max AS tirada_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max, t3.descripcion as descripcion" + t1.tirada_max AS tirada_max, t1.total_min as total_min, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max, t3.descripcion as descripcion" ); //JJO $builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id); @@ -190,6 +202,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel return $builder; } + public function removeAllEncuadernacionLineasForTarifa($tarifaId = -1, $datetime = null, $delete_flag=1){ diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php index b014f83d..7ed9fa87 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionModel.php @@ -125,7 +125,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, + "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, t3.id AS tarifa_linea_id, t3.paginas_libro_min AS paginas_min, t3.paginas_libro_max AS paginas_max, t3.precio_min AS precio_min, t3.precio_max AS precio_max, t3.margen AS margen, t4.ancho_min AS ancho_min, t4.ancho_max AS ancho_max, t4.alto_min AS alto_min, t4.alto_max AS alto_max" @@ -161,7 +161,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, + "t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo, t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max, t3.id AS tarifa_linea_id, t3.tiempo_min AS tiempo_min, t3.tiempo_max AS tiempo_max, t3.precio_hora AS precio_hora, t3.margen AS margen" ) diff --git a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php index ac795645..ba1a7a28 100755 --- a/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php +++ b/ci4/app/Models/Tarifas/TarifaEncuadernacionTiradaModel.php @@ -16,7 +16,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel 0 => "t3.nombre", 1 => "t1.tirada_min", 2 => "t1.tirada_max", - 3 => "t1.precio_min", 4 => "t1.importe_fijo", ]; @@ -25,7 +24,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel "tirada_min", "tirada_max", "proveedor_id", - "precio_min", "importe_fijo", "user_created_id", "user_updated_id", @@ -53,10 +51,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel "label" => "TarifaEncuadernacionTiradas.tiradaMin", "rules" => "required|integer", ], - "precio_min" => [ - "label" => "Tarifaencuadernacion.precioMin", - "rules" => "required|decimal", - ], "importe_fijo" => [ "label" => "Tarifaencuadernacion.importeFijo", "rules" => "required|decimal", @@ -72,10 +66,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel "integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer", "required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required", ], - "precio_min" => [ - "required" => "Tarifaencuadernacion.validation.precio_min.required", - "decimal" => "Tarifaencuadernacion.validation.precio_min.decimal", - ], "importe_fijo" => [ "required" => "Tarifaencuadernacion.validation.importe_fijo.required", "decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal", @@ -95,7 +85,7 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel ->table($this->table . " t1") ->select( "t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id, - t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo, + t1.importe_fijo AS importe_fijo, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion" ); diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 6c09faa8..9ca27bdd 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -49,7 +49,6 @@ - @@ -83,6 +82,7 @@ + @@ -112,6 +112,7 @@ + @@ -298,6 +299,8 @@ name: "tiempo_max" }, { name: "precio_hora" + }, { + name: "total_min" }, { name: "margen" }, { @@ -366,6 +369,7 @@ { 'data': 'tiempo_min' }, { 'data': 'tiempo_max' }, { 'data': 'precio_hora' }, + { 'data': 'total_min' }, { 'data': 'margen' }, { data: actionBtns, @@ -477,6 +481,8 @@ name: "paginas_libro_max" }, { name: "precio_max" + }, { + name: "total_min" }, { name: "margen" }, { @@ -556,6 +562,7 @@ { 'data': 'precio_max' }, { 'data': 'paginas_libro_max' }, { 'data': 'precio_min' }, + { 'data': 'total_min' }, { 'data': 'margen' }, { data: actionBtns, @@ -661,8 +668,6 @@ name: "tirada_min" }, { name: "tirada_max" - }, { - name: "precio_min" }, { name: "importe_fijo" }, { @@ -746,7 +751,6 @@ }, { 'data': 'tirada_min' }, { 'data': 'tirada_max' }, - { 'data': 'precio_min' }, { 'data': 'importe_fijo' }, { data: actionBtns, diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php index 009e36b8..89f0f498 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionList.php @@ -98,7 +98,7 @@ }); theTable.on( 'draw.dt', function () { - const boolCols = [1,2,3]; + const boolCols = [1,2,3, 4]; for (let coln of boolCols) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { cell.innerHTML = cell.innerHTML == '1' ? '' : ''; From 83c86286454bda80b9cf99ac363c5120771eb111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 31 Oct 2024 08:42:41 +0100 Subject: [PATCH 4/7] presupuesto cliente para perfil cliente --- .../Presupuestos/Presupuestocliente.php | 1 + .../cliente/items/_datosGenerales.php | 32 ++++++--- .../presupuestoCliente/datosGenerales.js | 20 ++++-- .../pages/presupuestoCliente/direcciones.js | 2 +- .../presupuestoCliente/presupuestoCliente.js | 72 +++---------------- 5 files changed, 50 insertions(+), 77 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index cb6faeae..b0d20702 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -99,6 +99,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Se obtiene el cliente ID a partir del usuario de la sesion $model_user = model('App\Models\Usuarios\UserModel'); + $user = $model_user->find(auth()->user()->id); $clienteId = $user->cliente_id; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php index 4640397b..aff8e501 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -16,14 +16,15 @@ - +
@@ -32,35 +33,44 @@ - +
- -
+ +
-
- - + user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?> + class="calcular-presupuesto form-check-input" type="checkbox" id="excluirPortada" + name="excluir_portada" value="1"> +
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index c58c2bc7..99a0b0cd 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -64,7 +64,9 @@ class DatosGenerales { // Selects this.formatoLibro.init(); - this.cliente.init(); + if (this.excluirRotativa.length != 0) { + this.cliente.init(); + } // Inicializa el tipo de impresion this.#handlePaginas(); @@ -100,6 +102,8 @@ class DatosGenerales { message: window.translations["validation"].cliente, callback: function (input) { // Get the selected options + if(this.excluirRotativa.length == 0) + return true; const options = $("#clienteId").select2('data'); const hasValidOption = options.some(option => parseInt(option.id) > 0); return options !== null && options.length > 0 && hasValidOption; @@ -382,9 +386,11 @@ class DatosGenerales { this.coleccion.val(datos.coleccion); this.referenciaCliente.val(datos.referenciaCliente); - this.cliente.setOption(datos.clienteId, datos.clienteNombre); - this.cliente.setVal(datos.clienteId); - $(this.cliente).trigger('change'); + if (this.excluirRotativa.length != 0) { + this.cliente.setOption(datos.clienteId, datos.clienteNombre); + this.cliente.setVal(datos.clienteId); + $(this.cliente).trigger('change'); + } if (datos.excluirRotativa) { this.excluirRotativa.prop('checked', true); @@ -434,6 +440,12 @@ class DatosGenerales { this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change'); } + getCliente(){ + if (this.excluirRotativa.length == 0) + return $('#clienteId').val(); + return this.cliente.getVal(); + } + getDimensionLibro() { let ancho = 0; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index ce9cc8b5..286cae3a 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -37,7 +37,7 @@ class Direcciones { init() { - $("#clienteId").on('change', this.handleChangeCliente.bind(this)); + $("#clienteId").on('change', this.handleChangeCliente.bind(this)); this.direccionesCliente.init(); this.btnAdd.on('click', this.#insertDireccion.bind(this)); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 02560fd3..f1941b80 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -62,6 +62,11 @@ class PresupuestoCliente { this.disenioCubierta.init(); this.direcciones.init(); + if(this.datosGenerales.excluirRotativa.length == 0){ + + this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() }) + } + this.btnNext.on('click', this.#nextStep.bind(this)); this.btnPrev.on('click', this.#prevtStep.bind(this)); @@ -189,63 +194,6 @@ class PresupuestoCliente { } - - /*RELLENAR_PRESUPUESTO(finalizar) { - - if (finalizar) { - - $("#titulo").val("Titulo del libro"); - $("#titulo").trigger('change'); - - const clienteId = $("#clienteId"); - const newOption = new Option("Cliente Potencial", "1817", true, true); - clienteId.append(newOption).trigger('change'); - - const papelFormatoId = $("#papelFormatoId"); - const newOption2 = new Option("148 x 210", "1", true, true); - papelFormatoId.append(newOption2).trigger('change'); - - - $("#paginasColor").val("6"); - $("#paginasColor").trigger('change'); - - $("#fresado").trigger("click"); - - - $("#colorPremium").trigger("click"); - $("#offsetBlanco").trigger("click"); - - setTimeout(function () { - $("#gramaje90").trigger("click"); - }, 0); - - setTimeout(function () { - $("#tapaDura").trigger("click"); - }, 0); - - - setTimeout(function () { - $("#btnNext").trigger("click"); - }, 0); - setTimeout(function () { - $("#btnNext").trigger("click"); - }, 0); - setTimeout(function () { - $("#btnNext").trigger("click"); - }, 0); - - - setTimeout(function () { - $("#unidadesEnvio").val("50"); - }, 0); - - } - else { - $("#titulo").trigger('change'); - } - }*/ - - #handleTitulosMenu(event) { $('.titulos-menu').removeClass('crossed'); @@ -266,7 +214,7 @@ class PresupuestoCliente { } #goToForm(form) { - + switch (form) { case '#datos-generales': this.validationStepper.to(1); @@ -439,7 +387,7 @@ class PresupuestoCliente { } } else { - if(response.error){ + if (response.error) { popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial."); } else @@ -546,7 +494,7 @@ class PresupuestoCliente { this.datos = { - clienteId: this.datosGenerales.cliente.getVal(), + clienteId: this.datosGenerales.getCliente(), tamanio: this.datosGenerales.getDimensionLibro(), tirada: this.datosGenerales.getTiradas(), @@ -651,7 +599,9 @@ class PresupuestoCliente { this.calcularPresupuesto = false; this.datosGenerales.cargarDatos(response.data.datosGenerales); - this.direcciones.handleChangeCliente(); + if (this.datosGenerales.excluirRotativa.length !== 0) { + this.direcciones.handleChangeCliente(); + } this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta); this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales); From 315d2a3acda6c9a960d6b90c845695ee80361b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 4 Nov 2024 23:58:18 +0100 Subject: [PATCH 5/7] arreglado carga de cliente --- .../Presupuestos/Presupuestocliente.php | 16 +++++++++++++--- .../cliente/items/_datosGenerales.php | 4 ++-- .../pages/presupuestoCliente/datosGenerales.js | 8 ++++---- .../presupuestoCliente/presupuestoCliente.js | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index b0d20702..90dce5cd 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -99,10 +99,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Se obtiene el cliente ID a partir del usuario de la sesion $model_user = model('App\Models\Usuarios\UserModel'); - + $user = $model_user->find(auth()->user()->id); $clienteId = $user->cliente_id; + if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) { + if ($clienteId === false || $clienteId === null) { + return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.'); + } + } + $POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD(); $this->viewData['breadcrumb'] = [ @@ -140,6 +146,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $user = $model_user->find(auth()->user()->id); if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) { $clienteId = $user->cliente_id; + if ($clienteId === false || $clienteId === null) { + return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.'); + } } else { $clienteId = $presupuestoEntity->cliente_id; } @@ -375,7 +384,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if (array_key_exists('exception', $return_data)) { return $this->failServerError( $return_data['exception'] . ' - ' . - $return_data['file'] . ' - ' . $return_data['line'] + $return_data['file'] . ' - ' . $return_data['line'] ); } @@ -2135,7 +2144,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $color = 'negro'; $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); - $data = $model->where('presupuesto_id', $presupuestoId)->findAll();; + $data = $model->where('presupuesto_id', $presupuestoId)->findAll(); + ; foreach ($data as $linea) { if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq" diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php index aff8e501..d3e013f8 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -67,8 +67,8 @@
user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?> - class="calcular-presupuesto form-check-input" type="checkbox" id="excluirPortada" - name="excluir_portada" value="1"> + class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa" + name="excluir_rotativa" value="1">
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 99a0b0cd..9549212d 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -64,7 +64,7 @@ class DatosGenerales { // Selects this.formatoLibro.init(); - if (this.excluirRotativa.length != 0) { + if (!$(this.excluirRotativa).prop('hidden')){ this.cliente.init(); } @@ -102,7 +102,7 @@ class DatosGenerales { message: window.translations["validation"].cliente, callback: function (input) { // Get the selected options - if(this.excluirRotativa.length == 0) + if (!$(this.excluirRotativa).prop('hidden')) return true; const options = $("#clienteId").select2('data'); const hasValidOption = options.some(option => parseInt(option.id) > 0); @@ -386,7 +386,7 @@ class DatosGenerales { this.coleccion.val(datos.coleccion); this.referenciaCliente.val(datos.referenciaCliente); - if (this.excluirRotativa.length != 0) { + if (!$(this.excluirRotativa).prop('hidden')){ this.cliente.setOption(datos.clienteId, datos.clienteNombre); this.cliente.setVal(datos.clienteId); $(this.cliente).trigger('change'); @@ -441,7 +441,7 @@ class DatosGenerales { } getCliente(){ - if (this.excluirRotativa.length == 0) + if ($(this.excluirRotativa).prop('hidden')) return $('#clienteId').val(); return this.cliente.getVal(); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index f1941b80..005511e0 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -599,7 +599,7 @@ class PresupuestoCliente { this.calcularPresupuesto = false; this.datosGenerales.cargarDatos(response.data.datosGenerales); - if (this.datosGenerales.excluirRotativa.length !== 0) { + if (!$(this.datosGenerales.excluirRotativa).prop("hidden")) { this.direcciones.handleChangeCliente(); } this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); From 55b225ab49bee6015a7973ead6a6cb1a5205c63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 5 Nov 2024 17:47:30 +0100 Subject: [PATCH 6/7] errata de 109 en encuadernaciones model --- .../Models/Presupuestos/PresupuestoEncuadernacionesModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php index f9bd0f84..956bbe77 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoEncuadernacionesModel.php @@ -271,7 +271,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel $tarifa_precio_min = floatval($tarifa_proveedor->tarifa_precio_min); - if($$tarifa_precio_min > $precio_total){ + if($tarifa_precio_min > $precio_total){ $total = $total-($total * $margen/100.0); $margen = round(100.0 * (floatval($$tarifa_precio_min) - $total) / floatval($$tarifa_precio_min), 0); $total = floatval($$tarifa_precio_min); From 0b614d4d58e3fe5aefc75aaceacf0629cb8ee9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 6 Nov 2024 17:15:41 +0100 Subject: [PATCH 7/7] bug para presupuesto cliente (en direcciones) --- .../Presupuestos/Presupuestocliente.php | 14 +- .../presupuestos/cliente/items/_buttons.php | 56 ++++--- .../presupuestos/cliente/items/_resumen.php | 21 +++ .../cliente/viewPresupuestoclienteForm.php | 30 ++-- .../presupuestoCliente/datosGenerales.js | 15 +- .../presupuestoCliente/presupuestoCliente.js | 49 +++++- .../pages/presupuestoCliente/resumen.js | 156 +++++++++++++++++- 7 files changed, 276 insertions(+), 65 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 90dce5cd..68c93493 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -164,8 +164,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($presupuestoEntity->is_duplicado) { $this->model->removeIsDuplicado($presupuestoEntity->id); } - + $this->viewData['presupuestoId'] = $presupuestoEntity->id; + $this->viewData['state'] = intval($presupuestoEntity->estado_id); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); @@ -626,6 +627,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $datosCabecera = $reqData['datosCabecera'] ?? []; $confirmar = $reqData['confirmar'] ?? 0; + $confirmar = intval($confirmar); $cliente_id = $reqData['clienteId'] ?? -1; @@ -928,17 +930,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController { if ($this->request->isAJAX()) { - $modelPapelGenerico = new PapelGenericoModel(); $modelPapelFormato = new PapelFormatoModel(); $modelCliente = new ClienteModel(); - $reqData = $this->request->getPost(); - + $presupuesto = $this->model->find($id); $data = []; if ($presupuesto) { $data['lc'] = $presupuesto->lomo_cubierta; $data['lsc'] = $presupuesto->lomo_sobrecubierta; + $data['state'] = intval($presupuesto->estado_id); $data['datosGenerales']['titulo'] = $presupuesto->titulo; $data['datosGenerales']['autor'] = $presupuesto->autor; $data['datosGenerales']['isbn'] = $presupuesto->isbn; @@ -1005,6 +1006,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); + if(intval($presupuesto->estado_id) == 2){ + $data['resumen']['base'] = $presupuesto->total_aceptado; + $data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad; + } + $tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data); for ($i = 0; $i < count($tiradas_alternativas); $i++) { $tirada = $tiradas_alternativas[$i]; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php index a2ab40c9..aad9101e 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_buttons.php @@ -1,30 +1,36 @@
-
+
-
-
- +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + + +
+ +
+ +
+ +
+ +
+
- -
-
- -
-
- -
-
- -
-
- -
- -
- -
-
- -
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php index 1083ef86..7cdfa40f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php @@ -182,4 +182,25 @@
+ + +
+

Ficheros

+
+
+
+ Arrastre aquí los ficheros o haga click +
+
+ +
+
+
+ +
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php index fee3258d..e66e65b2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php @@ -12,7 +12,7 @@
- +

@@ -29,7 +29,7 @@
-
+
class="step active titulos-menu" data-target="#datos-generales">
-
+
class="step titulos-menu" data-target="#interior-libro">
-
+
class="step titulos-menu" data-target="#cubierta-libro">
-
+
class="step titulos-menu" data-target="#direcciones-libro">
-
+