diff --git a/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php b/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php index aa99bb4e..01dfd842 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestomanipulados.php @@ -115,7 +115,19 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController if (count($datos_tarifas) > 0) { foreach ($datos_tarifas as $tarifa) { - $tarifa_id = is_array($tarifa) ? $tarifa['tarifa_manipulado_id'] : $tarifa; + $tarifa_id = 0; + if(is_array($tarifa)){ + //check if $tarifa['tarifa_manipulado_id'] exists + if(array_key_exists('tarifa_manipulado_id', $tarifa)){ + $tarifa_id = $tarifa['tarifa_manipulado_id']; + } + else if(array_key_exists('tarifa_id', $tarifa)){ + $tarifa_id = $tarifa['tarifa_id']; + } + } + else{ + $tarifa_id = $tarifa; + } $values = $model->getPrecioTarifa($tarifa_id, $tirada, $POD); $values[0]->cubierta = $tarifa['cubierta'] ?? 0; $values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 6854a92d..c319499e 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -270,6 +270,9 @@ class Comparador { this.btnInsertarFaja = $('#insertarFajaBtn'); this.comparadorPlanaRunning = false; + this.comparadorExterioresRunning = false; + this.comparadorGuardasRunning = false; + this.comparadorFajaRunning = false; } init() { @@ -541,7 +544,7 @@ class Comparador { this.gramajeSobrecubierta.setOption(datos.json_data.sobrecubierta.gramaje, datos.json_data.sobrecubierta.gramaje); } if (datos.json_data.guardas) { - this.carasGuardas.val(datos.json_data.guardas.paginas).trigger('change'); + this.carasGuardas.val(datos.json_data.guardas.paginas_impresion).trigger('change'); this.papelGuardas.setOption(datos.json_data.guardas.papel_id, datos.json_data.guardas.papel_nombre); this.gramajeGuardas.setOption(datos.json_data.guardas.gramaje, datos.json_data.guardas.gramaje); } @@ -1180,6 +1183,7 @@ class Comparador { } else if (uso == 'guardas') { + if ((this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) && !this.cargando) { popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); return { error: true, data: {} }; @@ -1426,7 +1430,7 @@ class Comparador { const self = this; - if (this.cargando) { + if (this.cargando && this.comparadorExterioresRunning) { return } @@ -1457,6 +1461,7 @@ class Comparador { if (Object.keys(datosComp.sobrecubierta).length > 0) { datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; } + this.comparadorExterioresRunning = true; new Ajax('/presupuestoadmin/comparadorexteriores', { cubierta: datosComp.cubierta.data, @@ -1499,14 +1504,17 @@ class Comparador { $('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta); self.btnInsertarCubierta.addClass('d-none'); } + self.comparadorExterioresRunning = false; }, (error) => { console.log(error); + self.comparadorExterioresRunning = false; } ).post(); } catch (e) { - console.log(e) + console.log(e); + self.comparadorExterioresRunning = false; } } @@ -1517,7 +1525,7 @@ class Comparador { const self = this; - if (this.cargando) { + if (this.cargando && this.comparadorFajaRunning) { return } @@ -1533,7 +1541,7 @@ class Comparador { datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; - + this.comparadorFajaRunning = true; new Ajax('/presupuestoadmin/comparadorexteriores', { sobrecubierta: datosComp.sobrecubierta.data @@ -1563,15 +1571,18 @@ class Comparador { $('#title_faja').html(window.language.Presupuestos.faja); self.btnInsertarFaja.addClass('d-none'); } + self.comparadorFajaRunning = false; }, (error) => { console.log(error); + self.comparadorFajaRunning = false; } ).post(); } catch (e) { - console.log(e) + console.log(e); + self.comparadorFajaRunning = false; } } @@ -1581,7 +1592,7 @@ class Comparador { const self = this; - if (this.cargando) { + if (this.cargando && this.comparadorGuardasRunning) { return } @@ -1596,7 +1607,7 @@ class Comparador { } datosComp.data[this.csrf_token] = this.csrf_hash; - + this.comparadorGuardasRunning = true; new Ajax('/presupuestoadmin/comparadorguardas', datosComp.data, {}, @@ -1624,14 +1635,17 @@ class Comparador { $('#title_guardas').html(window.language.Presupuestos.Guardas); self.btnInsertarGuardas.addClass('d-none'); } + self.comparadorGuardasRunning = false; }, (error) => { console.log(error); + self.comparadorGuardasRunning = false; } ).post(); } catch (e) { - console.log(e) + console.log(e); + self.comparadorGuardasRunning = false; } }