modificado para presupuesto admin

This commit is contained in:
2025-02-27 14:45:51 +01:00
parent c86f1799b5
commit a9333448ee
4 changed files with 59 additions and 26 deletions

View File

@ -390,6 +390,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value, 'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value,
'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value, 'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value,
'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value, 'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value,
'lomo_redondo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_lomo_redondo')->value,
]; ];
$this->viewData['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; // Cosido tapa blanda JJO $this->viewData['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; // Cosido tapa blanda JJO

View File

@ -229,7 +229,7 @@
<label id="label_compLomoRedondo" for="compLomoRedondo" class="form-label"> <label id="label_compLomoRedondo" for="compLomoRedondo" class="form-label">
<?= lang('Presupuestos.lomoRedondo') ?>* <?= lang('Presupuestos.lomoRedondo') ?>*
</label> </label>
<select id="compLomoRedondo" name="lomo_redondo" <select id="compLomoRedondo" name="lomo_redondo" service-id="<?= $serviciosAutomaticos['lomo_redondo'] ?>"
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;"> class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
<option value="0"> <option value="0">
<p> <p>

View File

@ -321,6 +321,18 @@ class Comparador {
allowClear: false, allowClear: false,
minimumResultsForSearch: Infinity, minimumResultsForSearch: Infinity,
}); });
this.lomoRedondo.on('change', function () {
if (!self.cargando && self.lomoRedondo.select2('data').length > 0) {
if (self.lomoRedondo.select2('data')[0].id == 1) {
$(document).trigger('add-servicio-lineas', 'lomo_redondo');
}
else {
$(document).trigger('remove-servicio-lineas', 'lomo_redondo');
}
}
});
this.cabezada.select2({ this.cabezada.select2({
allowClear: false, allowClear: false,
minimumResultsForSearch: Infinity, minimumResultsForSearch: Infinity,
@ -343,7 +355,7 @@ class Comparador {
}); });
this.papelSobrecubierta.init(); this.papelSobrecubierta.init();
this.gramajeSobrecubierta.init(); this.gramajeSobrecubierta.init();
this.papelSobrecubierta.item.on('select2:select', function() { this.papelSobrecubierta.item.on('select2:select', function () {
self.gramajeSobrecubierta.empty() self.gramajeSobrecubierta.empty()
}); });
this.sobrecubierta.on('change', () => { this.sobrecubierta.on('change', () => {
@ -391,28 +403,28 @@ class Comparador {
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
this.papelGuardas.init(); this.papelGuardas.init();
this.gramajeGuardas.init(); this.gramajeGuardas.init();
this.papelGuardas.item.on('select2:select', function() { this.papelGuardas.item.on('select2:select', function () {
self.gramajeGuardas.empty() self.gramajeGuardas.empty()
}); });
} }
this.papelNegro.item.on('select2:select', function() { this.papelNegro.item.on('select2:select', function () {
self.gramajeNegro.empty() self.gramajeNegro.empty()
}); });
this.papelNegrohq.item.on('select2:select', function() { this.papelNegrohq.item.on('select2:select', function () {
self.gramajeNegrohq.empty() self.gramajeNegrohq.empty()
}); });
this.papelColor.item.on('select2:select', function(){ this.papelColor.item.on('select2:select', function () {
self.gramajeColor.empty() self.gramajeColor.empty()
}); });
this.papelColorhq.item.on('select2:select', function() { this.papelColorhq.item.on('select2:select', function () {
self.gramajeColorhq.empty() self.gramajeColorhq.empty()
}); });
this.papelCubierta.item.on('select2:select', function() { this.papelCubierta.item.on('select2:select', function () {
self.gramajeCubierta.empty() self.gramajeCubierta.empty()
}); });
this.papelFaja.item.on('select2:select', function() { this.papelFaja.item.on('select2:select', function () {
self.gramajeFaja.empty() self.gramajeFaja.empty()
}); });
@ -566,8 +578,8 @@ class Comparador {
} }
} }
updateComparador(){ updateComparador() {
if (this.paginasColor.val() > 0) { if (this.paginasColor.val() > 0) {
this.paginasColor.trigger('change'); this.paginasColor.trigger('change');
} }
@ -579,8 +591,8 @@ class Comparador {
} }
else if (this.paginasNegrohq.val() > 0) { else if (this.paginasNegrohq.val() > 0) {
this.paginasNegrohq.trigger('change'); this.paginasNegrohq.trigger('change');
} }
this.paginasCubierta.trigger('change'); this.paginasCubierta.trigger('change');
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
this.carasGuardas.trigger('change'); this.carasGuardas.trigger('change');
@ -1023,7 +1035,7 @@ class Comparador {
} }
} }
if (!this.cargando){ if (!this.cargando) {
$('#paginas').trigger('change'); $('#paginas').trigger('change');
this.updateComparador(); this.updateComparador();
} }
@ -1031,7 +1043,7 @@ class Comparador {
getDataForComp(uso = 'interior') { getDataForComp(uso = 'interior') {
if(this.cargando) if (this.cargando)
return { error: true, data: {} }; return { error: true, data: {} };
let ancho = 0; let ancho = 0;
@ -1104,7 +1116,7 @@ class Comparador {
if (element.getVal() == 0 || element.getVal() == null) { if (element.getVal() == 0 || element.getVal() == null) {
const tipo = element.item.attr('id').split('Gramaje')[1]; const tipo = element.item.attr('id').split('Gramaje')[1];
if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) { if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1136,7 +1148,7 @@ class Comparador {
} }
else if (uso == 'cubierta') { else if (uso == 'cubierta') {
if ((this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) && !this.cargando) { if ((this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1156,7 +1168,7 @@ class Comparador {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
if ((this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) && !this.cargando) { if ((this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1168,11 +1180,11 @@ class Comparador {
} }
else if (uso == 'faja') { else if (uso == 'faja') {
if (this.papelFaja.getText() == "" && this.faja.val()>0 && !this.cargando) { if (this.papelFaja.getText() == "" && this.faja.val() > 0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
if (this.gramajeFaja.getText() == "" && this.faja.val()>0 && !this.cargando) { if (this.gramajeFaja.getText() == "" && this.faja.val() > 0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1185,7 +1197,7 @@ class Comparador {
} }
else if (uso == 'guardas') { else if (uso == 'guardas') {
if ((this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) && !this.cargando) { if ((this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
@ -1537,11 +1549,11 @@ class Comparador {
let datosComp = {}; let datosComp = {};
datosComp.sobrecubierta = this.getDataForComp('faja'); datosComp.sobrecubierta = this.getDataForComp('faja');
if(datosComp.sobrecubierta.error){ if (datosComp.sobrecubierta.error) {
return; return;
} }
datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
this.comparadorFajaRunning = true; this.comparadorFajaRunning = true;
new Ajax('/presupuestoadmin/comparadorexteriores', new Ajax('/presupuestoadmin/comparadorexteriores',
@ -1550,7 +1562,7 @@ class Comparador {
}, },
{}, {},
(response) => { (response) => {
if (response.data.sobrecubierta && Object.keys(response.data.sobrecubierta).length > 0) { if (response.data.sobrecubierta && Object.keys(response.data.sobrecubierta).length > 0) {
let sorted = Object.values(response.data.sobrecubierta).sort( let sorted = Object.values(response.data.sobrecubierta).sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
@ -1580,7 +1592,7 @@ class Comparador {
self.comparadorFajaRunning = false; self.comparadorFajaRunning = false;
} }
).post(); ).post();
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View File

@ -164,6 +164,16 @@ class Servicios {
const id = $('#solapas_grandes_faja').attr('service-id'); const id = $('#solapas_grandes_faja').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id); this.ServiciosManipulado.getPresupuestoManipulado(id);
} }
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);
}
} }
removeServicio(event, servicio) { removeServicio(event, servicio) {
@ -305,6 +315,16 @@ class Servicios {
}; };
this.serviciosAcabado.table.draw(); this.serviciosAcabado.table.draw();
} }
else if (servicio == 'lomo_redondo'){
const id = $('#compLomoRedondo').attr('service-id');
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();
}
};
this.ServiciosManipulado.table.draw();
}
} }
async updateServicios() { async updateServicios() {