From 5ad2fcd5667c12c2ed6014e8e362e8919d631b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 8 Feb 2025 22:34:31 +0100 Subject: [PATCH 1/2] =?UTF-8?q?a=C3=B1adido=20bot=C3=B3n=20duplicar=20pres?= =?UTF-8?q?upuesto=20en=20cliente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Config/Routes.php | 1 + ci4/app/Language/es/App.php | 2 +- .../presupuestos/cliente/items/_buttons.php | 6 +++ .../presupuestoCliente/presupuestoCliente.js | 40 +++++++++++++++++-- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 40d2641b..3b03dfa2 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -638,6 +638,7 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->get('papelimpresion', 'Presupuestoadmin::getPapelImpresion'); $routes->get('maquinas', 'Presupuestoadmin::getMaquinas'); $routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto'); + $routes->post('clone', 'Presupuestoadmin::datatable_2'); }); $routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index d41d02fe..44552d73 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -24,7 +24,7 @@ return [ "global_disable" => "Desactivar", "global_active" => "Activo", "global_inactive" => "Inactivo", - "global_copy" => "Dupdo", + "global_copy" => "Duplicar", "global_print" => "Impresión", "global_print2" => "Imprimir", "global_confirm" => "Confirmar", 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 aad9101e..62e7237c 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 @@ -18,8 +18,14 @@ + +
+
+ +
+
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 3cc4fd97..abb65479 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -22,6 +22,7 @@ class PresupuestoCliente { this.btnPrev = $('#btnPrev'); this.btnPrint = $('#btnPrint'); this.btnSave = $('#btnSave'); + this.btnDuplicate = $('#cloneForm'); this.btnConfirm = $('#btnConfirm'); this.btnUploadFile = $('#btnUploadFile') @@ -90,6 +91,7 @@ class PresupuestoCliente { this.btnNext.on('click', this.#nextStep.bind(this)); this.btnPrev.on('click', this.#prevtStep.bind(this)); this.btnSave.on('click', this.#savePresupuesto.bind(this)); + this.btnDuplicate.on('click', this.#clonePresupuesto.bind(this)); this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this)); this.btnPrint.on('click', this.#printPresupuesto.bind(this)); this.btnUploadFile.on('click', () => { @@ -417,6 +419,7 @@ class PresupuestoCliente { this.btnPrev.addClass('d-none'); this.btnNext.removeClass('d-none'); this.btnSave.addClass('d-none'); + this.btnDuplicate.addClass('d-none'); this.btnPrint.addClass('d-none'); this.btnConfirm.addClass('d-none'); break; @@ -427,6 +430,7 @@ class PresupuestoCliente { this.btnPrev.removeClass('d-none'); this.btnNext.removeClass('d-none'); this.btnSave.removeClass('d-none'); + this.btnDuplicate.addClass('d-none'); this.btnPrint.addClass('d-none'); this.btnConfirm.addClass('d-none'); break; @@ -434,6 +438,7 @@ class PresupuestoCliente { case 'resumen-libro': this.btnPrev.removeClass('d-none'); this.btnNext.addClass('d-none'); + this.btnDuplicate.removeClass('d-none'); this.btnSave.removeClass('d-none'); this.btnPrint.removeClass('d-none'); this.btnConfirm.removeClass('d-none'); @@ -469,6 +474,33 @@ class PresupuestoCliente { this.#solicitudGuardarPresupuesto(true); } + #clonePresupuesto() { + + const id = window.location.href.split("/").pop(); + new Ajax('/presupuestoadmin/clone', + { + tipo: 'duplicar', + presupuesto_id: id + }, + {}, + (response) => { + // check if response object has a property named 'id' + if (response.id) { + + const new_location = window.location.href.replace(id, response.id); + window.location.href = new_location; + } + else { + popErrorAlert("No se ha podido duplicar el presupuesto"); + } + }, + (error) => { + console.error('Error al duplicar el presupuesto:', error); + } + ).post(); + + } + #savePresupuesto() { @@ -573,7 +605,7 @@ class PresupuestoCliente { popAlert2Hide(); for (let i = 0; i < response.tiradas.length; i++) { - if(i==0){ + if (i == 0) { $('#eb').val(response.eb[i]); } new tarjetaTiradasPrecio( @@ -586,7 +618,7 @@ class PresupuestoCliente { if (this.actualizarTiradasEnvio) { this.direcciones.insertTirada(response.tiradas[i]); - if(i==0){ + if (i == 0) { $('#tiradaEnvios-' + response.tiradas[i]).trigger('click'); } } @@ -687,7 +719,7 @@ class PresupuestoCliente { }, } - if(this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0){ + if (this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0) { this.datos.selectedTirada = this.direcciones.getSelectedTirada(); } @@ -717,7 +749,7 @@ class PresupuestoCliente { carasImpresion: this.disenioCubierta.carasCubierta.val(), }; - + this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta(); this.datos.faja = this.disenioCubierta.getFaja(); From 32398d8742849f497722b6e4d918ca6a535d0a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sun, 9 Feb 2025 10:07:27 +0100 Subject: [PATCH 2/2] =?UTF-8?q?a=C3=B1adido=20mensaje=20para=20avisar=20de?= =?UTF-8?q?=20la=20cubierta=20sin=20acabado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Language/es/Presupuestos.php | 4 ++++ .../cliente/viewPresupuestoclienteForm.php | 16 ++++++++++++---- .../safekat/components/alerts/sweetAlert.js | 14 +++++++++++++- .../presupuestoCliente/presupuestoCliente.js | 19 ++++++++++++++++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index eebad4f8..1aff544c 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -337,6 +337,10 @@ return [ 'actualizacionSolapasCubierta' => 'El tamaño de las solapas de la cubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).', 'actualizacionSolapasSobrecubierta' => 'El tamaño de las solapas de la sobrecubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).', + + 'cubiertaSinAcabado' => 'Cubierta sin acabado', + 'cubiertaSinAcabadoText' => 'La falta de plastificado en la cubierta puede comprometer su calidad, ya que aumenta el riesgo de agrietamiento en los pliegues o hendidos, afectando su apariencia y resistencia', + 'files' => 'Ficheros', 'titulos' => [ 'libroFresadoTapaDura' => 'Rústica Fresado tapa dura', 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 7a23896f..9297ebd5 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php @@ -191,19 +191,23 @@ Ferro
    -
  • +
  • Ferro digital
    -
  • +
  • Marcapáginas
    -
  • +
  • Retractilado
    -
  • +
  • Retractilado de 5
@@ -290,6 +294,9 @@ + + + endSection() ?> @@ -302,6 +309,7 @@ + diff --git a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js index fec7c8c7..97f9bd66 100644 --- a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js +++ b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js @@ -3,7 +3,7 @@ export const alertConfirmationDelete = (title,type="primary") => { return Swal.fire({ - title: '¿Estás seguro?', + title: '¿Está seguro?', text: "Esta acción es irreversible.", icon: 'warning', showCancelButton: true, @@ -28,4 +28,16 @@ export const alertSuccessMessage = (title,type="primary") => { icon: "success", timer : 2000 }) +} + +export const alertWarningMessage = (title,message,type="primary") => { + return Swal.fire({ + title: title, + text: message, + icon: "warning", + customClass: { + confirmButton: 'btn btn-primary' + }, + buttonsStyling: false + }) } \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index abb65479..c085e377 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -4,6 +4,7 @@ import DisenioCubierta from './disenioCubierta.js'; import Direcciones from './direcciones.js'; import Resumen from './resumen.js'; import Ajax from '../../components/ajax.js'; +import { alertWarningMessage } from '../../components/alerts/sweetAlert.js'; import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js'; @@ -290,6 +291,10 @@ class PresupuestoCliente { if (currentElement !== 'resumen-libro') { this.#validateCurrentForm(currentElement, nextElement); + if (currentElement === 'cubierta-libro' && this.disenioCubierta.acabadoCubierta.getVal() == 0) { + alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText); + } + this.#goToForm(nextElement); } else { this.#goToForm(nextElement); @@ -486,8 +491,8 @@ class PresupuestoCliente { (response) => { // check if response object has a property named 'id' if (response.id) { - - const new_location = window.location.href.replace(id, response.id); + + const new_location = window.location.href.replace(id, response.id); window.location.href = new_location; } else { @@ -496,7 +501,7 @@ class PresupuestoCliente { }, (error) => { console.error('Error al duplicar el presupuesto:', error); - } + } ).post(); } @@ -650,6 +655,9 @@ class PresupuestoCliente { case 2: + if (this.disenioCubierta.acabadoCubierta.getVal() == 0) { + alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText); + } this.disenioCubierta.formValidation.validate(); break; @@ -666,6 +674,11 @@ class PresupuestoCliente { #prevtStep() { if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4) { + if(this.validationStepper._currentIndex == 2){ + if (this.disenioCubierta.acabadoCubierta.getVal() == 0) { + alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText); + } + } this.validationStepper.previous(); } $('html, body').animate({ scrollTop: 0 }, 'slow');