diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index ee3b4f6b..01d79c6d 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -532,7 +532,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosLibro']['fajaColorSolapasAncho'] = $presupuesto->solapas_ancho_faja_color; $data['datosLibro']['fajaColorAlto'] = $presupuesto->alto_faja_color; - $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); + $modelAcabado = model("App\Models\Tarifas\Acabados\ServicioAcabadoModel"); $data['datosLibro']['acabadoCubierta']['id'] = $presupuesto->acabado_cubierta_id; if ($presupuesto->acabado_cubierta_id == 0) { $data['datosLibro']['acabadoCubierta']['text'] = "Ninguno"; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index 74e0986e..85137ca7 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -279,14 +279,10 @@ diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 9da3b166..fcf3c562 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -360,10 +360,10 @@ class Comparador { }); this.sobrecubierta.on('change', () => { if (this.sobrecubierta.select2('data')[0].id == 1) { - if ($('#solapas_sobrecubierta').prop('checked') == false) { - this.sobrecubierta.val(0); + /*if ($('#solapas_sobrecubierta').prop('checked') == false) { + this.sobrecubierta.val('0').trigger('change'); popErrorAlert(window.language.Presupuestos.errores.error_sobrecubierta_sin_solapas, 'divAlarmasComparador') - } + }*/ $('#solapas_sobrecubierta').prop('checked', true); $('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); $('#solapas_ancho_sobrecubierta').val(60); @@ -1458,7 +1458,7 @@ class Comparador { return; } if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { - if (this.sobrecubierta.val() == 1) { + if (this.sobrecubierta.select2('data').length >0 && parseInt(this.sobrecubierta.select2('data')[0].id) == 1) { datosComp.sobrecubierta = this.getDataForComp('sobrecubierta'); if (datosComp.sobrecubierta.error) { return; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 8b1da5ea..4920ee3f 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -92,7 +92,15 @@ class DatosLibro { $(document).trigger('remove-servicio-lineas', 'acabadoCubierta'); } else { - $(document).trigger('add-servicio-lineas', 'acabadoCubierta'); + const table = $('#tableLineasPresupuesto').DataTable(); + const rows = table.rows().data(); + for (let i = 0; i < rows.length; i++) { + const rowData = rows[i]; + if (rowData.row_id === 'lp_cubierta') { + $(document).trigger('add-servicio-lineas', 'acabadoCubierta'); + break; + } + } } }); @@ -106,7 +114,15 @@ class DatosLibro { $(document).trigger('remove-servicio-lineas', 'acabadoSobrecubierta'); } else { - $(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta'); + const table = $('#tableLineasPresupuesto').DataTable(); + const rows = table.rows().data(); + for (let i = 0; i < rows.length; i++) { + const rowData = rows[i]; + if (rowData.row_id === 'lp_sobrecubierta') { + $(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta'); + break; + } + } } }); @@ -119,7 +135,15 @@ class DatosLibro { $(document).trigger('remove-servicio-lineas', 'acabadoFaja'); } else { - $(document).trigger('add-servicio-lineas', 'acabadoFaja'); + const table = $('#tableLineasPresupuesto').DataTable(); + const rows = table.rows().data(); + for (let i = 0; i < rows.length; i++) { + const rowData = rows[i]; + if (rowData.row_id === 'lp_faja') { + $(document).trigger('add-servicio-lineas', 'acabadoFaja'); + break; + } + } } }); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 9da1b3e4..d7ecc331 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -1699,7 +1699,7 @@ class LineasPresupuesto { $(document).trigger('update-presupuesto', { update_lineas: false, - update_servicios: true, + update_servicios: false, update_envios: true, update_resumen: true, update_tiradas_alternativas: true @@ -2044,12 +2044,14 @@ class LineasPresupuesto { for (const row of rows) { this.rellenarDatosLinea('lp_faja', row, true); } + if ($('#acabado_faja_id').val() > 0) + $(document).trigger('add-servicio-lineas', 'acabadoFaja'); } $(document).trigger('update-presupuesto', { update_lineas: false, - update_servicios: true, + update_servicios: false, update_envios: true, update_resumen: true, update_tiradas_alternativas: true diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js index 93640653..24635c16 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/servicios.js @@ -555,13 +555,6 @@ class ServiciosAcabado { updateAcabadosExteriores(cubierta, sobrecubierta, faja) { - for (let i = this.table.rows().count() - 1; i >= 0; i--) { - let data = this.table.row(i).data(); - if (data && (data.cubierta == cubierta && data.sobrecubierta == sobrecubierta && data.faja == faja)) { - this.table.row(i).remove().draw(); - } - } - let tarifa_id = 0; let uso = 'cubierta'; if (cubierta == 1) { @@ -603,6 +596,32 @@ class ServiciosAcabado { new Ajax('/serviciosacabados/getvalues', datos, {}, function (response) { if (response.values) { + if(uso=='cubierta'){ + for (let i = self.table.rows().count() - 1; i >= 0; i--) { + let data = self.table.row(i).data(); + if (data && (data.cubierta == 1)) { + self.table.row(i).remove().draw(false); + } + } + } + else if(uso=='sobrecubierta'){ + for (let i = self.table.rows().count() - 1; i >= 0; i--) { + let data = self.table.row(i).data(); + if (data && (data.sobrecubierta == 1)) { + self.table.row(i).remove().draw(false); + } + } + } + else if(uso=='faja'){ + for (let i = self.table.rows().count() - 1; i >= 0; i--) { + let data = self.table.row(i).data(); + if (data && (data.faja == 1)) { + self.table.row(i).remove().draw(false); + break; + } + } + } + for (let i = 0; i < response.values.length; i++) { response.values[i].cubierta = 0; response.values[i].sobrecubierta = 0; @@ -617,12 +636,14 @@ class ServiciosAcabado { response.values[i].faja = 1; } } + if (updateSelect != null) { self.table.row(updateSelect.closest('tr')).data(response.values[0]).draw(); } else { - self.table.rows.add(response.values).draw(); + self.table.rows.add(response.values).draw(false); } + } }, function (error) { @@ -651,7 +672,7 @@ class ServiciosAcabado { }); if (!found) - this.getPresupuestoAcabado(this.selectorServicios.getVal()); + this.getPresupuestoAcabado(this.selectorServicios.getVal(), null, null, true); else popErrorAlert(window.language.Presupuestos.errores.error_servicios_duplicados, 'serv-acabado-alert'); }