From 3809493c796546a092d858128925dacd46cec27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 27 Feb 2025 16:40:43 +0100 Subject: [PATCH] =?UTF-8?q?arreglado.=20a=C3=B1adida=20comprobaci=C3=B3n?= =?UTF-8?q?=20para=20los=20dem=C3=A1s=20servicios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presupuestoAdmin/presupuestoAdminEdit.js | 1 + .../presupuestoAdmin/sections/servicios.js | 162 ++++++++++-------- 2 files changed, 87 insertions(+), 76 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index ac19d7f2..07fc1099 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -390,6 +390,7 @@ class PresupuestoAdminEdit { self.tiradasAlternativas.cargar(response.data.tiradasAlternativas); self.resumen.cargar(response.data.resumen); + self.datosLibro.calcular_mermas(); setTimeout(() => { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js index 65b6a01f..d6291372 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js @@ -72,7 +72,7 @@ class Servicios { showBreadCrumbSaveButton(true); }); - $(document).on('update-servicios', async function(){ + $(document).on('update-servicios', async function () { await self.updateServicios() $(document).trigger('update-servicios-completed'); @@ -94,7 +94,7 @@ class Servicios { } - async guardar(){ + async guardar() { await this.serviciosAcabado.guardarServiciosAcabado(); await this.serviciosPreimpresion.guardarServiciosPreimpresion(); await this.ServiciosEncuadernacion.guardarServiciosEncuadernacion(); @@ -114,71 +114,81 @@ class Servicios { else if (servicio == 'acabadoFaja') { this.serviciosAcabado.updateAcabadosExteriores(0, 0, 1); } - else if (servicio == 'ferro'){ + else if (servicio == 'ferro') { const id = $('#ferro').attr('service-id'); + if(!this.checkServiceInTable(this.serviciosExtra.table, id)) this.serviciosExtra.getPresupuestoExtra(id); } - else if (servicio == 'prototipo'){ + else if (servicio == 'prototipo') { const id = $('#prototipo').attr('service-id'); - this.serviciosExtra.getPresupuestoExtra(id); + if (!this.checkServiceInTable(this.serviciosExtra.table, id)) + this.serviciosExtra.getPresupuestoExtra(id); } - else if (servicio == 'retractilado'){ + else if (servicio == 'retractilado') { const id = $('#retractilado').attr('service-id'); - this.serviciosAcabado.getPresupuestoAcabado(id); + if (!this.checkServiceInTable(this.serviciosAcabado.table, id)) + this.serviciosAcabado.getPresupuestoAcabado(id); } - else if (servicio == 'retractilado5'){ + else if (servicio == 'retractilado5') { const id = $('#retractilado5').attr('service-id'); - this.serviciosAcabado.getPresupuestoAcabado(id); + if (!this.checkServiceInTable(this.serviciosAcabado.table, id)) + this.serviciosAcabado.getPresupuestoAcabado(id); } - else if(servicio == 'plegado_guardas'){ + else if (servicio == 'plegado_guardas') { const id = $('#plegado_guardas').attr('service-id'); - for(let i = 0; i < this.ServiciosManipulado.table.rows().count(); i++){ - var data = this.ServiciosManipulado.table.row(i).data(); - if (data.tarifa_id == id) { - return; - } - }; - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'solapas_cubierta'){ + else if (servicio == 'solapas_cubierta') { const id = $('#serv_solapas_cubierta').attr('service-id'); - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'solapas_sobrecubierta'){ + else if (servicio == 'solapas_sobrecubierta') { const id = $('#serv_solapas_sobrecubierta').attr('service-id'); - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'solapas_faja'){ + else if (servicio == 'solapas_faja') { const id = $('#solapas_faja').attr('service-id'); - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'solapas_grandes_cubierta'){ + else if (servicio == 'solapas_grandes_cubierta') { const id = $('#solapas_grandes_cubierta').attr('service-id'); - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'solapas_grandes_sobrecubierta'){ + else if (servicio == 'solapas_grandes_sobrecubierta') { const id = $('#solapas_grandes_sobrecubierta').attr('service-id'); - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'solapas_grandes_faja'){ + else if (servicio == 'solapas_grandes_faja') { const id = $('#solapas_grandes_faja').attr('service-id'); - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } - else if (servicio == 'lomo_redondo'){ + else if (servicio == 'lomo_redondo') { const id = $('#compLomoRedondo').attr('service-id'); - for(let i = 0; i < this.ServiciosManipulado.table.rows().count(); i++){ - var data = this.ServiciosManipulado.table.row(i).data(); - if (data.tarifa_id == id) { - return; - } - }; - this.ServiciosManipulado.getPresupuestoManipulado(id); + if (!this.checkServiceInTable(this.ServiciosManipulado.table, id)) + this.ServiciosManipulado.getPresupuestoManipulado(id); } } + checkServiceInTable(table, id) { + for (let i = 0; i < table.rows().count(); i++) { + let data = table.row(i).data(); + if (data && data.tarifa_id == id) { + return true; + } + } + return false; + } + removeServicio(event, servicio) { - if (servicio == 'ferro'){ + if (servicio == 'ferro') { const id = $('#ferro').attr('service-id'); this.serviciosExtra.table.rows().every(function () { let data = this.data(); @@ -188,7 +198,7 @@ class Servicios { }); this.serviciosExtra.table.draw(); } - else if (servicio == 'prototipo'){ + else if (servicio == 'prototipo') { const id = $('#prototipo').attr('service-id'); this.serviciosExtra.table.rows().every(function () { var data = this.data(); @@ -198,7 +208,7 @@ class Servicios { }); this.serviciosExtra.table.draw(); } - else if (servicio == 'retractilado'){ + else if (servicio == 'retractilado') { const id = $('#retractilado').attr('service-id'); this.serviciosAcabado.table.rows().every(function () { let data = this.data(); @@ -208,7 +218,7 @@ class Servicios { }); this.serviciosAcabado.table.draw(); } - else if (servicio == 'retractilado5'){ + else if (servicio == 'retractilado5') { const id = $('#retractilado5').attr('service-id'); this.serviciosAcabado.table.rows().every(function () { let data = this.data(); @@ -218,7 +228,7 @@ class Servicios { }); this.serviciosAcabado.table.draw(); } - else if(servicio == 'plegado_guardas'){ + else if (servicio == 'plegado_guardas') { const id = $('#plegado_guardas').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { var data = this.data(); @@ -228,7 +238,7 @@ class Servicios { }); this.ServiciosManipulado.table.draw(); } - else if (servicio == 'solapas_cubierta'){ + else if (servicio == 'solapas_cubierta') { const id = $('#serv_solapas_cubierta').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { let data = this.data(); @@ -238,7 +248,7 @@ class Servicios { }); this.ServiciosManipulado.table.draw(); } - else if (servicio == 'solapas_sobrecubierta'){ + else if (servicio == 'solapas_sobrecubierta') { const id = $('#serv_solapas_sobrecubierta').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { let data = this.data(); @@ -248,7 +258,7 @@ class Servicios { }); this.ServiciosManipulado.table.draw(); } - else if (servicio == 'solapas_faja'){ + else if (servicio == 'solapas_faja') { const id = $('#solapas_faja').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { let data = this.data(); @@ -258,7 +268,7 @@ class Servicios { }); this.ServiciosManipulado.table.draw(); } - else if (servicio == 'solapas_grandes_cubierta'){ + else if (servicio == 'solapas_grandes_cubierta') { const id = $('#solapas_grandes_cubierta').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { let data = this.data(); @@ -268,7 +278,7 @@ class Servicios { }); this.ServiciosManipulado.table.draw(); } - else if (servicio == 'solapas_grandes_sobrecubierta'){ + else if (servicio == 'solapas_grandes_sobrecubierta') { const id = $('#solapas_grandes_sobrecubierta').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { var data = this.data(); @@ -278,7 +288,7 @@ class Servicios { }); this.ServiciosManipulado.table.draw(); } - else if (servicio == 'solapas_grandes_faja'){ + else if (servicio == 'solapas_grandes_faja') { const id = $('#solapas_grandes_faja').attr('service-id'); this.ServiciosManipulado.table.rows().every(function () { var data = this.data(); @@ -315,9 +325,9 @@ class Servicios { }; this.serviciosAcabado.table.draw(); } - else if (servicio == 'lomo_redondo'){ + else if (servicio == 'lomo_redondo') { const id = $('#compLomoRedondo').attr('service-id'); - for(let i = this.ServiciosManipulado.table.rows().count(); i >= 0; i--){ + for (let i = this.ServiciosManipulado.table.rows().count(); i >= 0; i--) { var data = this.ServiciosManipulado.table.row(i).data(); if (data && data.tarifa_id == id) { this.ServiciosManipulado.table.row(i).remove(); @@ -403,7 +413,7 @@ class ServiciosAcabado { { data: 'precio_total', render: function (data, type, row) { let total = 0; - if(data !==undefined) + if (data !== undefined) total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); return ` `; @@ -468,8 +478,8 @@ class ServiciosAcabado { self.check_serv_acabado_error(); $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : false, + update_lineas: false, + update_servicios: false, update_envios: false, update_resumen: true, update_tiradas_alternativas: true @@ -577,7 +587,7 @@ class ServiciosAcabado { new Ajax('/serviciosacabados/getvalues', datos, {}, function (response) { if (response.values) { - for(let i=0; i`; @@ -761,8 +771,8 @@ class ServiciosPreimpresion { self.check_serv_preimpresion_error(); $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : false, + update_lineas: false, + update_servicios: false, update_envios: false, update_resumen: true, update_tiradas_alternativas: true @@ -887,9 +897,9 @@ class ServiciosPreimpresion { }); const domain = window.location.origin; const id = window.location.href.split('/').pop(); - await fetch(domain + "/presupuestos/presupuestopreimpresiones/edit/" + id , { + await fetch(domain + "/presupuestos/presupuestopreimpresiones/edit/" + id, { method: "POST", - body: JSON.stringify({datos: datos}), + body: JSON.stringify({ datos: datos }), headers: { "Content-type": "application/json; charset=UTF-8" } @@ -974,7 +984,7 @@ class ServiciosEncuadernacion { { data: 'precio_total', render: function (data, type, row) { let total = 0; - if(data !==undefined) + if (data !== undefined) total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); return ` `; @@ -1077,8 +1087,8 @@ class ServiciosEncuadernacion { self.check_serv_enc_error(); $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : false, + update_lineas: false, + update_servicios: false, update_envios: false, update_resumen: true, update_tiradas_alternativas: true @@ -1271,9 +1281,9 @@ class ServiciosEncuadernacion { }); const domain = window.location.origin; const id = window.location.href.split('/').pop(); - await fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , { + await fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id, { method: "POST", - body: JSON.stringify({datos: datos}), + body: JSON.stringify({ datos: datos }), headers: { "Content-type": "application/json; charset=UTF-8" } @@ -1403,7 +1413,7 @@ class ServiciosManipulado { { data: 'precio_total', render: function (data, type, row) { let total = 0; - if(data !==undefined) + if (data !== undefined) total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); else data = 0; @@ -1425,8 +1435,8 @@ class ServiciosManipulado { self.check_serv_manipulado_error(); $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : false, + update_lineas: false, + update_servicios: false, update_envios: false, update_resumen: true, update_tiradas_alternativas: true @@ -1582,9 +1592,9 @@ class ServiciosManipulado { }); const domain = window.location.origin; const id = window.location.href.split('/').pop(); - await fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id , { + await fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id, { method: "POST", - body: JSON.stringify({datos: datos}), + body: JSON.stringify({ datos: datos }), headers: { "Content-type": "application/json; charset=UTF-8" } @@ -1669,7 +1679,7 @@ class ServiciosExtra { data: 'precio', render: function (data, type, row) { let total = 0; - if(data !==undefined) + if (data !== undefined) total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); return ` `; @@ -1690,8 +1700,8 @@ class ServiciosExtra { self.check_serv_extra_error(); $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : false, + update_lineas: false, + update_servicios: false, update_envios: false, update_resumen: true, update_tiradas_alternativas: true @@ -1758,9 +1768,9 @@ class ServiciosExtra { }); const domain = window.location.origin; const id = window.location.href.split('/').pop(); - await fetch(domain + "/presupuestos/presupuestoserviciosextra/edit/" + id , { + await fetch(domain + "/presupuestos/presupuestoserviciosextra/edit/" + id, { method: "POST", - body: JSON.stringify({datos: datos}), + body: JSON.stringify({ datos: datos }), headers: { "Content-type": "application/json; charset=UTF-8" }