mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into refactor/sk-21
This commit is contained in:
@ -108,7 +108,7 @@ class previewFormas {
|
||||
anchoMaquina: parseFloat(rowData.maquina_ancho),
|
||||
altoImpresion: parseFloat(rowData.maquina_impresion_alto),
|
||||
anchoImpresion: parseFloat(rowData.maquina_impresion_ancho),
|
||||
altoLibro: lpName=='faja'? parseFloat(rowData.alto_faja).toFixed(0):this.alto(),
|
||||
altoLibro: lpName=='faja'? parseFloat(parseFloat(rowData.alto_faja).toFixed(0)):parseFloat(this.alto()),
|
||||
anchoLibro: this.ancho(),
|
||||
offsetSolapa: 0
|
||||
};
|
||||
@ -116,7 +116,7 @@ class previewFormas {
|
||||
//console.log(pvObj);
|
||||
|
||||
// Printing shape definition
|
||||
this.pvObj.anchoForma = parseInt(_isCosido) ? 2 * this.pvObj.anchoLibro : this.pvObj.anchoLibro;
|
||||
this.pvObj.anchoForma = parseInt(_isCosido) ? parseInt(2 * this.pvObj.anchoLibro) : parseInt(this.pvObj.anchoLibro);
|
||||
this.pvObj.altoForma = this.pvObj.altoLibro;
|
||||
|
||||
|
||||
@ -204,9 +204,8 @@ class previewFormas {
|
||||
let anchoSolapaFaja = $('#faja').is(':checked') ? parseFloat($('#faja_solapas_ancho').val()) : parseFloat(0); // mm
|
||||
if (_isTapaDura) {
|
||||
let anchoPliegue = parseFloat(7); // mm
|
||||
let altoPliegue = parseFloat(7); // mm
|
||||
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaFaja + this.pvObj.offsetSolapa)) + (2 * sangreFaja) + this.pvObj.lomoLibroSobrecubierta);
|
||||
this.pvObj.altoForma += altoPliegue + parseFloat(2 * sangreFaja);
|
||||
this.pvObj.altoForma += parseFloat(2 * sangreFaja);
|
||||
} else {
|
||||
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaFaja + this.pvObj.offsetSolapa)) + (2 * sangreFaja) + this.pvObj.lomoLibroSobrecubierta);
|
||||
this.pvObj.altoForma = parseFloat(this.pvObj.altoForma) + parseFloat(2 * sangreFaja);
|
||||
|
||||
@ -29,14 +29,18 @@ class PresupuestoAdminEdit {
|
||||
|
||||
this.tipoTapa = $('.card-title').text().toLowerCase().includes('dura') ? 'dura' : 'blanda';
|
||||
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'),
|
||||
() => { return this.cargandoPresupuesto },
|
||||
{
|
||||
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
calcularSolapas: this.calcularSolapas.bind(this)
|
||||
calcularSolapas: this.calcularSolapas.bind(this),
|
||||
});
|
||||
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'),
|
||||
() => { return this.cargandoPresupuesto },
|
||||
{
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
});
|
||||
@ -56,8 +60,6 @@ class PresupuestoAdminEdit {
|
||||
this.guardar = $('#saveForm');
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
|
||||
this.configUploadDropzone = {
|
||||
domElement: '#dropzone-presupuesto-admin-files',
|
||||
@ -134,6 +136,10 @@ class PresupuestoAdminEdit {
|
||||
|
||||
$('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta);
|
||||
$('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta);
|
||||
if ($(this.configUploadDropzone.domElement).length > 0) {
|
||||
this.fileUploadDropzone.init()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -207,7 +213,7 @@ class PresupuestoAdminEdit {
|
||||
}
|
||||
if (this.datosLibro.tamanioPersonalizado.prop('checked')) {
|
||||
datos.papel_formato_ancho = this.datosLibro.anchoPersonalizado.val(),
|
||||
datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val()
|
||||
datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val()
|
||||
}
|
||||
datos.selectedTirada = this.datosLibro.tirada.val();
|
||||
datos.acabado_cubierta_id = this.datosLibro.acabadoCubierta.getVal();
|
||||
@ -245,7 +251,7 @@ class PresupuestoAdminEdit {
|
||||
datos.solapas_sobrecubierta = this.datosLibro.solapasSobrecubierta.is(':checked') ? 1 : 0;
|
||||
datos.solapas_ancho_sobrecubierta = this.datosLibro.anchoSolapasSobrecubierta.val();
|
||||
|
||||
datos.faja_color = this.datosLibro.faja.prop('checked') ? 1: 0;
|
||||
datos.faja_color = this.datosLibro.faja.prop('checked') ? 1 : 0;
|
||||
datos.solapas_ancho_faja_color = this.datosLibro.fajaSolapasAncho.val();
|
||||
datos.alto_faja_color = this.datosLibro.fajaAlto.val();
|
||||
|
||||
@ -297,6 +303,9 @@ class PresupuestoAdminEdit {
|
||||
};
|
||||
|
||||
if (self.cargandoPresupuesto == false) {
|
||||
|
||||
self.comparador.updateComparador();
|
||||
|
||||
// Ejecutar los pasos de forma secuencial si están habilitados
|
||||
if (update_lineas) {
|
||||
$(document).trigger('update-lineas-presupuesto');
|
||||
@ -330,6 +339,8 @@ class PresupuestoAdminEdit {
|
||||
|
||||
const self = this;
|
||||
this.cargandoPresupuesto = true;
|
||||
self.comparador.cargando = true;
|
||||
self.datosLibro.cargando = true;
|
||||
|
||||
$('#loader').modal('show');
|
||||
let id = window.location.href.split("/").pop()
|
||||
@ -347,11 +358,10 @@ class PresupuestoAdminEdit {
|
||||
self.POD.val(response.data.POD);
|
||||
|
||||
self.calcularPresupuesto = false;
|
||||
self.comparador.cargando = true;
|
||||
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
self.datosLibro.cargarDatos(response.data.datosLibro);
|
||||
|
||||
|
||||
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
|
||||
|
||||
self.servicios.cargar(response.data.servicios);
|
||||
@ -376,6 +386,10 @@ class PresupuestoAdminEdit {
|
||||
|
||||
self.calcularPresupuesto = true;
|
||||
self.cargandoPresupuesto = false;
|
||||
self.datosLibro.cargando = false;
|
||||
self.comparador.cargando = false;
|
||||
|
||||
self.comparador.updateComparador();
|
||||
}
|
||||
|
||||
|
||||
@ -400,6 +414,8 @@ class PresupuestoAdminEdit {
|
||||
$('#loader').modal('hide');
|
||||
this.calcularPresupuesto = true;
|
||||
self.cargandoPresupuesto = false;
|
||||
self.datosLibro.cargando = false;
|
||||
self.comparador.cargando = false;
|
||||
}
|
||||
).get();
|
||||
}
|
||||
@ -424,7 +440,7 @@ class PresupuestoAdminEdit {
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2">` +
|
||||
window.Presupuestos.errores.paginasLP +
|
||||
window.language.Presupuestos.errores.paginasLP +
|
||||
`</h5>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
@ -4,10 +4,12 @@ import Ajax from '../../../components/ajax.js';
|
||||
|
||||
class Comparador {
|
||||
|
||||
constructor(domItem, functions = {}) {
|
||||
constructor(domItem, cargando, functions = {}) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
this.cargando = cargando;
|
||||
|
||||
this.getDimensionLibro = functions.getDimensionLibro;
|
||||
|
||||
this.tipo_impresion_id = parseInt($('#tipo_impresion_id').val());
|
||||
@ -267,8 +269,10 @@ class Comparador {
|
||||
this.btnInsertarCubierta = $('#insertarCubiertaBtn');
|
||||
this.btnInsertarFaja = $('#insertarFajaBtn');
|
||||
|
||||
this.cargando = false;
|
||||
this.comparadorPlanaRunning = false;
|
||||
this.comparadorExterioresRunning = false;
|
||||
this.comparadorGuardasRunning = false;
|
||||
this.comparadorFajaRunning = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -339,7 +343,9 @@ class Comparador {
|
||||
});
|
||||
this.papelSobrecubierta.init();
|
||||
this.gramajeSobrecubierta.init();
|
||||
this.papelSobrecubierta.onChange(() => self.gramajeSobrecubierta.empty());
|
||||
this.papelSobrecubierta.item.on('select2:select', function() {
|
||||
self.gramajeSobrecubierta.empty()
|
||||
});
|
||||
this.sobrecubierta.on('change', () => {
|
||||
if (this.sobrecubierta.select2('data')[0].id == 1) {
|
||||
if ($('#solapas_sobrecubierta').prop('checked') == false) {
|
||||
@ -370,8 +376,6 @@ class Comparador {
|
||||
}
|
||||
$('#faja').prop('checked', true);
|
||||
$('.faja-div').removeClass('d-none');
|
||||
$('#faja_solapas_ancho').val(60);
|
||||
$('#faja_alto').val(50);
|
||||
$('#compPapelFaja').prop('disabled', false);
|
||||
$('#compGramajeFaja').prop('disabled', false);
|
||||
}
|
||||
@ -387,14 +391,30 @@ class Comparador {
|
||||
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.gramajeGuardas.init();
|
||||
this.papelGuardas.onChange(() => self.gramajeGuardas.empty());
|
||||
this.papelGuardas.item.on('select2:select', function() {
|
||||
self.gramajeGuardas.empty()
|
||||
});
|
||||
}
|
||||
|
||||
this.papelNegro.onChange(() => self.gramajeNegro.empty());
|
||||
this.papelNegrohq.onChange(() => self.gramajeNegrohq.empty());
|
||||
this.papelColor.onChange(() => self.gramajeColor.empty());
|
||||
this.papelColorhq.onChange(() => self.gramajeColorhq.empty());
|
||||
this.papelCubierta.onChange(() => self.gramajeCubierta.empty());
|
||||
this.papelNegro.item.on('select2:select', function() {
|
||||
self.gramajeNegro.empty()
|
||||
});
|
||||
this.papelNegrohq.item.on('select2:select', function() {
|
||||
self.gramajeNegrohq.empty()
|
||||
});
|
||||
this.papelColor.item.on('select2:select', function(){
|
||||
self.gramajeColor.empty()
|
||||
});
|
||||
this.papelColorhq.item.on('select2:select', function() {
|
||||
self.gramajeColorhq.empty()
|
||||
});
|
||||
this.papelCubierta.item.on('select2:select', function() {
|
||||
self.gramajeCubierta.empty()
|
||||
});
|
||||
|
||||
this.papelFaja.item.on('select2:select', function() {
|
||||
self.gramajeFaja.empty()
|
||||
});
|
||||
|
||||
|
||||
this.tipo_impresion.select2({
|
||||
@ -475,8 +495,6 @@ class Comparador {
|
||||
|
||||
cargarDatos(datos) {
|
||||
|
||||
this.cargando = true;
|
||||
|
||||
this.tipo_impresion.val(datos.tipo_impresion).trigger('change');
|
||||
this.updateOpcionesComparador();
|
||||
|
||||
@ -546,9 +564,10 @@ class Comparador {
|
||||
this.#computarPaginasColor(datos.posPagColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.cargando = false;
|
||||
|
||||
updateComparador(){
|
||||
|
||||
if (this.paginasColor.val() > 0) {
|
||||
this.paginasColor.trigger('change');
|
||||
}
|
||||
@ -567,7 +586,6 @@ class Comparador {
|
||||
this.carasGuardas.trigger('change');
|
||||
}
|
||||
this.faja.trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1011,6 +1029,9 @@ class Comparador {
|
||||
|
||||
getDataForComp(uso = 'interior') {
|
||||
|
||||
if(this.cargando)
|
||||
return { error: true, data: {} };
|
||||
|
||||
let ancho = 0;
|
||||
let alto = 0;
|
||||
let papel_generico = {};
|
||||
@ -1071,7 +1092,7 @@ class Comparador {
|
||||
for (let element of papeles) {
|
||||
if (element.getVal() == 0 || element.getVal() == null) {
|
||||
const tipo = element.item.attr('id').split('Papel')[1];
|
||||
if ($('#compPaginas' + tipo).val() > 0) {
|
||||
if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1081,7 +1102,7 @@ class Comparador {
|
||||
|
||||
if (element.getVal() == 0 || element.getVal() == null) {
|
||||
const tipo = element.item.attr('id').split('Gramaje')[1];
|
||||
if ($('#compPaginas' + tipo).val() > 0) {
|
||||
if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1113,11 +1134,11 @@ class Comparador {
|
||||
|
||||
}
|
||||
else if (uso == 'cubierta') {
|
||||
if (this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) {
|
||||
if ((this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) {
|
||||
if ((this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1129,11 +1150,11 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'sobrecubierta') {
|
||||
if (this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) {
|
||||
if ((this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) {
|
||||
if ((this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1145,11 +1166,11 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'faja') {
|
||||
if (this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) {
|
||||
if ((this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) && this.faja.getVal()>0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) {
|
||||
if ((this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) && this.faja.getVal()>0 && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1162,11 +1183,12 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'guardas') {
|
||||
if (this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) {
|
||||
|
||||
if ((this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeGuardas.getVal() == 0 || this.gramajeGuardas.getVal() == null) {
|
||||
if ((this.gramajeGuardas.getVal() == 0 || this.gramajeGuardas.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1408,7 +1430,7 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando && this.comparadorExterioresRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1439,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,
|
||||
@ -1481,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1499,7 +1525,7 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando && this.comparadorFajaRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1509,10 +1535,13 @@ class Comparador {
|
||||
|
||||
let datosComp = {};
|
||||
datosComp.sobrecubierta = this.getDataForComp('faja');
|
||||
if(datosComp.sobrecubierta.error){
|
||||
return;
|
||||
}
|
||||
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
|
||||
@ -1542,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1560,7 +1592,7 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando && this.comparadorGuardasRunning) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1575,7 +1607,7 @@ class Comparador {
|
||||
}
|
||||
|
||||
datosComp.data[this.csrf_token] = this.csrf_hash;
|
||||
|
||||
this.comparadorGuardasRunning = true;
|
||||
new Ajax('/presupuestoadmin/comparadorguardas',
|
||||
datosComp.data,
|
||||
{},
|
||||
@ -1603,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { getToken } from '../../../common/common.js';
|
||||
|
||||
class DatosLibro {
|
||||
|
||||
constructor(domItem, functions = {}) {
|
||||
constructor(domItem, cargando, functions = {}) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
@ -48,6 +48,15 @@ class DatosLibro {
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
this.acabadoFaja = new ClassSelect($("#acabado_faja_id"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
this.retractilado = this.domItem.find('#retractilado');
|
||||
this.retractilado5 = this.domItem.find('#retractilado5');
|
||||
@ -61,6 +70,8 @@ class DatosLibro {
|
||||
this.fajaSolapasAncho = this.domItem.find('#faja_solapas_ancho');
|
||||
this.div_faja = this.domItem.find('.faja-div');
|
||||
|
||||
this.cargando = cargando;
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -70,13 +81,43 @@ class DatosLibro {
|
||||
this.tamanio.init();
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadoSobrecubierta.init();
|
||||
this.acabadoFaja.init();
|
||||
|
||||
this.acabadoCubierta.item.on('select2:select', function () {
|
||||
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if(self.acabadoCubierta.getVal() == 0){
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoCubierta');
|
||||
}
|
||||
else{
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
||||
}
|
||||
});
|
||||
this.acabadoSobrecubierta.item.on('select2:select', function () {
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if(self.acabadoCubierta.getVal() == 0){
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoSobrecubierta');
|
||||
}
|
||||
else{
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
||||
}
|
||||
});
|
||||
this.acabadoFaja.item.on('select2:select', function () {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if(self.acabadoFaja.getVal() == 0){
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoFaja');
|
||||
}
|
||||
else{
|
||||
$(document).trigger('add-servicio-lineas', 'acabadoFaja');
|
||||
}
|
||||
});
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
@ -98,6 +139,7 @@ class DatosLibro {
|
||||
|
||||
this.anchoSolapasCubierta.on('change', this.changeAnchoSolapasCubierta.bind(this));
|
||||
this.anchoSolapasSobrecubierta.on('change', this.changeAnchoSolapasSobrecubierta.bind(this));
|
||||
this.fajaSolapasAncho.on('change', this.changeAnchoSolapasFaja.bind(this));
|
||||
|
||||
this.paginas.on('change', this.changePaginas.bind(this));
|
||||
this.tirada.on('change', this.changeTirada.bind(this));
|
||||
@ -116,15 +158,33 @@ class DatosLibro {
|
||||
if (this.faja.prop('checked')) {
|
||||
this.div_faja.removeClass('d-none');
|
||||
$('#compFaja').val(1).trigger('change');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_faja');
|
||||
$('.acabado-faja').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
this.div_faja.addClass('d-none');
|
||||
$('#compFaja').val(0).trigger('change');
|
||||
$('.acabado-faja').addClass('d-none');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
$(document).trigger('remove-servicio-lineas', 'acabadoFaja');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_faja');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_faja');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
checkMinMaxInput(event) {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
const el = event.target;
|
||||
if (el.value != "") {
|
||||
if (parseInt(el.value) < parseInt(el.min)) {
|
||||
@ -142,6 +202,9 @@ class DatosLibro {
|
||||
|
||||
changeFerro() {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.ferro.prop('checked')) {
|
||||
$(document).trigger('add-servicio-lineas', 'ferro');
|
||||
}
|
||||
@ -152,6 +215,9 @@ class DatosLibro {
|
||||
|
||||
changePrototipo() {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.prototipo.prop('checked')) {
|
||||
$(document).trigger('add-servicio-lineas', 'prototipo');
|
||||
}
|
||||
@ -163,6 +229,9 @@ class DatosLibro {
|
||||
|
||||
checkRetractilado(event) {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
switch (event.currentTarget.id) {
|
||||
case 'retractilado':
|
||||
if ($('#' + event.currentTarget.id).prop('checked')) {
|
||||
@ -254,10 +323,14 @@ class DatosLibro {
|
||||
setTimeout(() => {
|
||||
if (this.solapasCubierta.prop('checked')) {
|
||||
$('#div_solapas_ancho').removeClass('d-none');
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_cubierta');
|
||||
}
|
||||
else {
|
||||
$('#div_solapas_ancho').addClass('d-none');
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_cubierta');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
|
||||
}
|
||||
@ -269,15 +342,19 @@ class DatosLibro {
|
||||
|
||||
changeAnchoSolapasCubierta() {
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compCarasCubierta').trigger('change');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.checkSolapasGrandes('cubierta')) {
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta');
|
||||
}
|
||||
else {
|
||||
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
|
||||
}
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compCarasCubierta').trigger('change');
|
||||
}
|
||||
|
||||
|
||||
@ -285,30 +362,58 @@ class DatosLibro {
|
||||
|
||||
if (this.solapasSobrecubierta.prop('checked')) {
|
||||
this.divSolapasSobrecubierta.removeClass('d-none');
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_sobrecubierta');
|
||||
}
|
||||
else {
|
||||
this.divSolapasSobrecubierta.addClass('d-none');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_sobrecubierta');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
if ($('#compSobrecubierta').length) {
|
||||
$('#compSobrecubierta').val(0).trigger('change');
|
||||
}
|
||||
if(this.cargando)
|
||||
return;
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_sobrecubierta');
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeAnchoSolapasSobrecubierta() {
|
||||
|
||||
|
||||
// para que se actualice el comparador
|
||||
if($('#compGramajeSobrecubierta').select2('data').length > 0)
|
||||
$('#compGramajeSobrecubierta').trigger('change');
|
||||
|
||||
if (this.checkSolapasGrandes('cubierta')) {
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.checkSolapasGrandes('sobrecubierta')) {
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
}
|
||||
else {
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeAnchoSolapasFaja() {
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compSobrecubierta').trigger('change');
|
||||
if($('#compGramajeFaja').select2('data').length > 0){
|
||||
$('#compGramajeFaja').trigger('change');
|
||||
}
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
if (this.checkSolapasGrandes('faja')) {
|
||||
$(document).trigger('add-servicio-lineas', 'solapas_grandes_faja');
|
||||
}
|
||||
else {
|
||||
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_faja');
|
||||
}
|
||||
}
|
||||
|
||||
checkSolapasGrandes(elemento) {
|
||||
@ -317,12 +422,16 @@ class DatosLibro {
|
||||
let ancho_solapas = 0.0;
|
||||
let lomo = 0.0;
|
||||
if (elemento == 'cubierta') {
|
||||
ancho_solapas = 2 * parseFloat($('solapas_ancho').val());
|
||||
lomo = parseFloat($('lomo_cubierta').val());
|
||||
ancho_solapas = 2 * parseFloat($('#solapas_ancho').val());
|
||||
lomo = parseFloat($('#lomo_cubierta').val());
|
||||
}
|
||||
else if (elemento == 'sobrecubierta') {
|
||||
ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val());
|
||||
lomo = parseFloat($('lomo_sobrecubierta').val());
|
||||
ancho_solapas = 2 * parseFloat($('#solapas_ancho_sobrecubierta').val());
|
||||
lomo = parseFloat($('#lomo_sobrecubierta').val());
|
||||
}
|
||||
else if (elemento == 'faja') {
|
||||
ancho_solapas = 2 * parseFloat($('#faja_solapas_ancho').val());
|
||||
lomo = parseFloat($('#lomo_sobrecubierta').val());
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@ -515,6 +624,7 @@ class DatosLibro {
|
||||
this.div_faja.removeClass('d-none');
|
||||
this.fajaAlto.val(datos.fajaColorAlto).trigger('change');
|
||||
this.fajaSolapasAncho.val(datos.fajaColorSolapasAncho).trigger('change');
|
||||
$('.acabado-faja').removeClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
@ -530,6 +640,8 @@ class DatosLibro {
|
||||
this.acabadoSobrecubierta.setOption(datos.acabadoSobrecubierta.id, datos.acabadoSobrecubierta.text);
|
||||
}
|
||||
|
||||
this.acabadoFaja.setOption(datos.acabadoFaja.id, datos.acabadoFaja.text);
|
||||
|
||||
this.retractilado.prop('checked', datos.retractilado);
|
||||
this.retractilado5.prop('checked', datos.retractilado5);
|
||||
this.prototipo.prop('checked', datos.prototipo);
|
||||
|
||||
@ -1796,7 +1796,7 @@ class LineasPresupuesto {
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
alto: () => {return tipoLinea == 'lp_faja' ? $('faja_alto').val() : this.getDimensionLibro().alto},
|
||||
solapas: () => uso == 'cubierta' ? $('#solapas').prop('checked') : $('#solapas_sobrecubierta').prop('checked'),
|
||||
solapas_ancho: () => uso == 'cubierta' ? $('#solapas_ancho').val() : $('#solapas_ancho_sobrecubierta').val(),
|
||||
tirada: () => $('#tirada').val(),
|
||||
|
||||
@ -79,6 +79,8 @@ class Resumen {
|
||||
|
||||
async updateTotales(event, data = {}) {
|
||||
|
||||
const self = this;
|
||||
|
||||
let updateLP = data.updateLP || true;
|
||||
let updateServicios = data.updateServicios || true;
|
||||
let updateEnvio = data.updateEnvio || true;
|
||||
@ -89,8 +91,8 @@ class Resumen {
|
||||
let totalImpresionforMargen = 0;
|
||||
let margenImpresion = 0;
|
||||
|
||||
let totalServicios = 0;
|
||||
let margenServicios = 0;
|
||||
let totalServicios = parseFloat(0);
|
||||
let margenServicios = parseFloat(0);
|
||||
|
||||
let totalEnvios = 0;
|
||||
let margenEnvios = 0;
|
||||
@ -116,28 +118,25 @@ class Resumen {
|
||||
|
||||
}
|
||||
if (rowData.check_impresion_total) {
|
||||
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||
|
||||
if (rowData.maquinaTipo == 'inkjet') {
|
||||
totalImpresion += parseFloat(rowData.totalTinta)
|
||||
totalImpresion += parseFloat(rowData.totalCorte)
|
||||
|
||||
totalImpresion += parseFloat(rowData.totalCorte)?? 0;
|
||||
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
||||
}
|
||||
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
|
||||
|
||||
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
if (!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))) {
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||
if (!isNaN(parseFloat($('#' + rowData.row_id + '_totalTinta').val()))) {
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -177,53 +176,56 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
|
||||
totalServicios += total_servicio
|
||||
margenServicios = total_servicio - coste_servicio;
|
||||
margenServicios += total_servicio - coste_servicio;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
|
||||
totalServicios += total_servicio
|
||||
margenServicios = total_servicio - coste_servicio;
|
||||
margenServicios += total_servicio - coste_servicio;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios = total_servicio - base;
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
@ -346,6 +348,10 @@ class Resumen {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
roundToTwoDecimals(num) {
|
||||
return parseFloat(num.toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
export default Resumen;
|
||||
@ -105,10 +105,13 @@ class Servicios {
|
||||
addServicio(event, servicio) {
|
||||
|
||||
if (servicio == 'acabadoCubierta') {
|
||||
this.serviciosAcabado.updateAcabadosExteriores(1, 0);
|
||||
this.serviciosAcabado.updateAcabadosExteriores(1, 0, 0);
|
||||
}
|
||||
else if (servicio == 'acabadoSobrecubierta') {
|
||||
this.serviciosAcabado.updateAcabadosExteriores(0, 1);
|
||||
this.serviciosAcabado.updateAcabadosExteriores(0, 1, 0);
|
||||
}
|
||||
else if (servicio == 'acabadoFaja') {
|
||||
this.serviciosAcabado.updateAcabadosExteriores(0, 0, 1);
|
||||
}
|
||||
else if (servicio == 'ferro'){
|
||||
const id = $('#ferro').attr('service-id');
|
||||
@ -144,6 +147,10 @@ class Servicios {
|
||||
const id = $('#serv_solapas_sobrecubierta').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
else if (servicio == 'solapas_faja'){
|
||||
const id = $('#solapas_faja').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_cubierta'){
|
||||
const id = $('#solapas_grandes_cubierta').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
@ -152,6 +159,10 @@ class Servicios {
|
||||
const id = $('#solapas_grandes_sobrecubierta').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_faja'){
|
||||
const id = $('#solapas_grandes_faja').attr('service-id');
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
}
|
||||
|
||||
removeServicio(event, servicio) {
|
||||
@ -226,6 +237,16 @@ class Servicios {
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'solapas_faja'){
|
||||
const id = $('#solapas_faja').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
let data = this.data();
|
||||
if (data && data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_cubierta'){
|
||||
const id = $('#solapas_grandes_cubierta').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
@ -246,6 +267,43 @@ class Servicios {
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'solapas_grandes_faja'){
|
||||
const id = $('#solapas_grandes_faja').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data && data.tarifa_id == id) {
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
this.ServiciosManipulado.table.draw();
|
||||
}
|
||||
else if (servicio == 'acabadoCubierta') {
|
||||
for (let i = 0; i < this.serviciosAcabado.table.rows().count(); i++) {
|
||||
let data = this.serviciosAcabado.table.row(i).data();
|
||||
if (data.cubierta == 1) {
|
||||
this.serviciosAcabado.table.row(i).remove();
|
||||
}
|
||||
};
|
||||
this.serviciosAcabado.table.draw();
|
||||
}
|
||||
else if (servicio == 'acabadoSobrecubierta') {
|
||||
for (let i = 0; i < this.serviciosAcabado.table.rows().count(); i++) {
|
||||
let data = this.serviciosAcabado.table.row(i).data();
|
||||
if (data.sobrecubierta == 1) {
|
||||
this.serviciosAcabado.table.row(i).remove();
|
||||
}
|
||||
};
|
||||
this.serviciosAcabado.table.draw();
|
||||
}
|
||||
else if (servicio == 'acabadoFaja') {
|
||||
for (let i = 0; i < this.serviciosAcabado.table.rows().count(); i++) {
|
||||
let data = this.serviciosAcabado.table.row(i).data();
|
||||
if (data.faja == 1) {
|
||||
this.serviciosAcabado.table.row(i).remove();
|
||||
}
|
||||
};
|
||||
this.serviciosAcabado.table.draw();
|
||||
}
|
||||
}
|
||||
|
||||
async updateServicios() {
|
||||
@ -296,6 +354,9 @@ class ServiciosAcabado {
|
||||
else if (row.sobrecubierta == 1) {
|
||||
return row.nombre + ' (' + window.language.Presupuestos.sobrecubierta + ')';
|
||||
}
|
||||
else if (row.faja == 1) {
|
||||
return row.nombre + ' (' + window.language.Presupuestos.faja + ')';
|
||||
}
|
||||
else {
|
||||
return row.nombre;
|
||||
}
|
||||
@ -330,6 +391,7 @@ class ServiciosAcabado {
|
||||
{ data: 'margen' },
|
||||
{ data: 'cubierta', visible: false },
|
||||
{ data: 'sobrecubierta', visible: false },
|
||||
{ data: 'faja', visible: false },
|
||||
{
|
||||
data: function (row) {
|
||||
return `
|
||||
@ -414,10 +476,11 @@ class ServiciosAcabado {
|
||||
const proveedor_ids = this.table.rows().data().toArray().map(row => row.proveedor_id);
|
||||
const cubiertas = this.table.rows().data().toArray().map(row => row.cubierta);
|
||||
const sobrecubiertas = this.table.rows().data().toArray().map(row => row.sobrecubierta);
|
||||
const fajas = this.table.rows().data().toArray().map(row => row.fajas);
|
||||
// emparejar los tarifa_ids con los proveedor_ids
|
||||
let tarifa_data = [];
|
||||
for (let i = 0; i < tarifa_ids.length; i++) {
|
||||
tarifa_data.push({ tarifa_id: tarifa_ids[i], proveedor_id: proveedor_ids[i], cubierta: cubiertas[i], sobrecubierta: sobrecubiertas[i] });
|
||||
tarifa_data.push({ tarifa_id: tarifa_ids[i], proveedor_id: proveedor_ids[i], cubierta: cubiertas[i], sobrecubierta: sobrecubiertas[i], faja: fajas[i] });
|
||||
}
|
||||
|
||||
let tirada = 0;
|
||||
@ -444,25 +507,33 @@ class ServiciosAcabado {
|
||||
|
||||
}
|
||||
|
||||
updateAcabadosExteriores(cubierta, sobrecubierta) {
|
||||
updateAcabadosExteriores(cubierta, sobrecubierta, faja) {
|
||||
|
||||
this.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.cubierta == cubierta && data.sobrecubierta == sobrecubierta) {
|
||||
if (data && (data.cubierta == cubierta && data.sobrecubierta == sobrecubierta && data.faja == faja)) {
|
||||
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
|
||||
let tarifa_id = 0;
|
||||
let uso = 'cubierta';
|
||||
if (cubierta == 1) {
|
||||
tarifa_id = $('#acabado_cubierta_id').val();
|
||||
}
|
||||
else if (sobrecubierta == 1) {
|
||||
tarifa_id = $('#acabado_sobrecubierta_id').val();
|
||||
uso = 'sobrecubierta';
|
||||
}
|
||||
else if (faja == 1) {
|
||||
tarifa_id = $('#acabado_faja_id').val();
|
||||
uso = 'faja';
|
||||
}
|
||||
|
||||
this.getPresupuestoAcabado(tarifa_id, cubierta == 1 ? 'cubierta' : 'sobrecubierta', null);
|
||||
|
||||
|
||||
this.getPresupuestoAcabado(tarifa_id, uso, null);
|
||||
}
|
||||
|
||||
getPresupuestoAcabado(tarifa_id = -1, uso = null, updateSelect = null) {
|
||||
@ -491,12 +562,16 @@ class ServiciosAcabado {
|
||||
if (response.values) {
|
||||
response.values[0].cubierta = 0;
|
||||
response.values[0].sobrecubierta = 0;
|
||||
response.values[0].faja = 0;
|
||||
if (uso == 'cubierta') {
|
||||
response.values[0].cubierta = 1;
|
||||
}
|
||||
else if (uso == 'sobrecubierta') {
|
||||
response.values[0].sobrecubierta = 1;
|
||||
}
|
||||
else if (uso == 'faja') {
|
||||
response.values[0].faja = 1;
|
||||
}
|
||||
if (updateSelect != null) {
|
||||
|
||||
self.table.row(updateSelect.closest('tr')).data(response.values[0]).draw();
|
||||
|
||||
@ -96,8 +96,9 @@ class TiradasAlernativas {
|
||||
|
||||
self.table.row(row).remove().draw();
|
||||
|
||||
$(document).trigger('update-envios', { tirada_inicial: $('#tirada').val(), tirada: data.tirada });
|
||||
$('#tirada').val(data.tirada).trigger('change');
|
||||
|
||||
$(document).trigger('update-envios', { tirada_inicial: $('#tirada').val(), tirada: data.tirada });
|
||||
});
|
||||
|
||||
$(document).on('update-tiradas-alternativas', async function () {
|
||||
@ -181,6 +182,8 @@ class TiradasAlernativas {
|
||||
json_acabados: this.generate_json_servicios('acabados'),
|
||||
json_encuadernaciones: this.generate_json_servicios('encuadernaciones'),
|
||||
json_manipulado: this.generate_json_servicios('manipulado'),
|
||||
json_presimpresion: this.generate_json_servicios('presimpresion'),
|
||||
json_extra: this.generate_json_servicios('extra'),
|
||||
json_envios: envios,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
@ -190,6 +193,8 @@ class TiradasAlernativas {
|
||||
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked') ? 1 : 0,
|
||||
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0,
|
||||
lomo: $('#lomo_cubierta').val(),
|
||||
faja_alto: $('#faja_alto').val(),
|
||||
solapas_faja: $('#faja_solapas_ancho').val(),
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
|
||||
@ -92,6 +92,7 @@ class DatosGenerales {
|
||||
|
||||
// Eventos
|
||||
this.checkFormatoPersonalizado.bind('change', this.#handleFormatoLibro.bind(this));
|
||||
this.formatoLibro.item.on('change', this.#handleFormatoLibro.bind(this));
|
||||
this.tiposLibro.on('click', this.#handleTipolibro.bind(this));
|
||||
this.domItem.find('.input-paginas').on('change', this.#handlePaginas.bind(this));
|
||||
this.anchoPersonalizado.on('blur', this.#handleCheckFormatoPersonalizado.bind(this));
|
||||
@ -674,6 +675,8 @@ class DatosGenerales {
|
||||
this.formValidation.revalidateField('papel_formato_ancho');
|
||||
this.formValidation.revalidateField('papel_formato_alto');
|
||||
}
|
||||
const alto = this.getDimensionLibro().alto;
|
||||
$('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + alto + ' mm');
|
||||
}
|
||||
|
||||
#checkValue(event){
|
||||
|
||||
@ -33,12 +33,12 @@ class DisenioCubierta {
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho},
|
||||
alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto},
|
||||
solapas: () => {return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val()},
|
||||
lomo: () => {return $('#lc').val()},
|
||||
tapa_dura: () => {return this.tapaBlanda.hasClass("selected") ? 0 : 1},
|
||||
tirada: () => {return this.presupuestoCliente.datosGenerales.getTiradas()[0]},
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
|
||||
solapas: () => { return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val() },
|
||||
lomo: () => { return $('#lc').val() },
|
||||
tapa_dura: () => { return this.tapaBlanda.hasClass("selected") ? 0 : 1 },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
}
|
||||
);
|
||||
|
||||
@ -77,11 +77,47 @@ class DisenioCubierta {
|
||||
|
||||
this.configuracionFaja = this.domItem.find(".config-faja");
|
||||
this.faja = this.domItem.find("#addFaja");
|
||||
this.papelFaja = new ClassSelect($("#papelFaja"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
sobrecubierta: 1,
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return $('#altoFaja').val() },
|
||||
solapas: () => { return $('#solapasFaja').val() },
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
}
|
||||
);
|
||||
this.gramajeFaja = new ClassSelect($("#gramajeFaja"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectGramaje"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
papel: () => { return this.papelFaja.getVal() },
|
||||
sobrecubierta: 1,
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return $('#altoFaja').val() },
|
||||
solapas: () => { return $('#solapasFaja').val() },
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
this.solapasSobrecubierta = this.domItem.find("#solapasSobrecubierta");
|
||||
this.textoSolapasSobrecubierta = this.domItem.find("#textoLimitesSolapasSobrecubierta");
|
||||
|
||||
this.solapasFaja = this.domItem.find("#solapasFaja");
|
||||
this.altoFaja = this.domItem.find("#altoFaja");
|
||||
this.textoSolapasFaja = this.domItem.find("#textoLimitesSolapasFaja");
|
||||
|
||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
||||
this.cosido = $(this.domItem.find("#cosido")[0]);
|
||||
@ -117,6 +153,16 @@ class DisenioCubierta {
|
||||
}
|
||||
);
|
||||
|
||||
this.acabadoFaja = new ClassSelect($("#acabadoFaja"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
this.initValidation();
|
||||
|
||||
// Creamos un nuevo observador que detecta cambios en los atributos
|
||||
@ -153,6 +199,10 @@ class DisenioCubierta {
|
||||
this.papelEspecial.init();
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadoSobrecubierta.init();
|
||||
this.acabadoFaja.init();
|
||||
|
||||
this.papelFaja.init();
|
||||
this.gramajeFaja.init();
|
||||
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
@ -171,10 +221,12 @@ class DisenioCubierta {
|
||||
}
|
||||
);
|
||||
this.faja.on('change', () => {
|
||||
this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none")
|
||||
}
|
||||
);
|
||||
this.faja.is(":checked") ? this.configuracionFaja.removeClass("d-none") : this.configuracionFaja.addClass("d-none");
|
||||
const div = $('#divExtras'); // Selecciona el div
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
});
|
||||
|
||||
this.papelFaja.item.on('change', () => { this.gramajeFaja.empty(); });
|
||||
|
||||
// Observadores
|
||||
this.observer.observe(this.tapaBlanda[0], { attributes: true });
|
||||
@ -185,7 +237,7 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta) {
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta, datosFaja) {
|
||||
|
||||
this.papelCubierta = datosCubierta.papel.id;
|
||||
this.gramaje = datosCubierta.gramaje;
|
||||
@ -234,6 +286,15 @@ class DisenioCubierta {
|
||||
this.acabadoSobrecubierta.setOption(datosSobrecubierta.acabado.id, datosSobrecubierta.acabado.text);
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(datosFaja) === '[object Object]') {
|
||||
this.faja.trigger('click');
|
||||
this.papelFaja.setOption(datosFaja.papel.papel_id, datosFaja.papel.papel);
|
||||
this.gramajeFaja.setOption(datosFaja.papel.gramaje, datosFaja.papel.gramaje);
|
||||
this.solapasFaja.val(datosFaja.solapas_ancho);
|
||||
this.altoFaja.val(datosFaja.alto);
|
||||
this.acabadoFaja.setOption(datosFaja.acabado.id, datosFaja.acabado.text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -371,6 +432,36 @@ class DisenioCubierta {
|
||||
}
|
||||
}
|
||||
},
|
||||
div_extras: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
|
||||
const div = $('#divExtras'); // Selecciona el div
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
|
||||
if($("#addFaja").prop("checked") == false)
|
||||
return true;
|
||||
const papelFaja = $('#papelFaja').select2('data').length > 0;
|
||||
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
|
||||
if (papelFaja && gramajeFaja) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].extras_cubierta}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
@ -388,6 +479,8 @@ class DisenioCubierta {
|
||||
case 'div_gramaje_cubierta':
|
||||
case 'div_papel_especial_cubierta':
|
||||
return '.col-sm-10';
|
||||
case 'div_extras':
|
||||
return '.col-sm-12';
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
}
|
||||
@ -638,16 +731,15 @@ class DisenioCubierta {
|
||||
|
||||
try {
|
||||
if (!this.faja.is(":checked")) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
let faja = {};
|
||||
faja.alto = this.domItem.find("#altoFaja").val();
|
||||
let papel = this.domItem.find("#papelFaja").children("option:selected").val();
|
||||
faja.papel = papel.split('_')[0];
|
||||
faja.gramaje = papel.split('_')[1];
|
||||
faja.papel = this.papelFaja.getVal();
|
||||
faja.gramaje = this.gramajeFaja.getVal();
|
||||
faja.solapas = this.domItem.find("#solapasFaja").val();
|
||||
faja.plastificado = this.domItem.find("#plastificadoFaja").children("option:selected").val();
|
||||
faja.acabado = this.acabadoFaja.getVal();
|
||||
return faja;
|
||||
}
|
||||
|
||||
|
||||
@ -178,6 +178,7 @@ class PresupuestoCliente {
|
||||
this.disenioCubierta.solapasSobrecubierta.attr('max', response);
|
||||
this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm");
|
||||
this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm");
|
||||
this.disenioCubierta.textoSolapasFaja.text("Entre 60 y " + response + " mm");
|
||||
},
|
||||
() => { }
|
||||
).post();
|
||||
@ -810,7 +811,7 @@ class PresupuestoCliente {
|
||||
console.log("Error al cargar diseño interior: " + e);
|
||||
}
|
||||
try {
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta, response.data.faja);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("Error al cargar diseño cubierta: " + e);
|
||||
|
||||
Reference in New Issue
Block a user