diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php
index 18e5f56b..4a8f06c5 100755
--- a/ci4/app/Language/es/Presupuestos.php
+++ b/ci4/app/Language/es/Presupuestos.php
@@ -166,6 +166,7 @@ return [
'solapasSobrecubierta' => 'Solapas sobrecub.',
'solapasAnchoCubierta' => 'Ancho solapas cub.',
'solapasAnchoSobrecubierta' => 'Ancho solapas sobrecub.',
+
'sinImpresion' => 'Sin impresion',
'unaCara' => '1 cara',
'dosCaras' => '2 caras',
@@ -387,7 +388,8 @@ return [
'noInterior' => 'No se hay resultados para el interior',
'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta',
'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador',
- 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa'
+ 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa',
+ 'error_faja_sin_solapas' => 'Debe seleccionar "faja" en los datos del libro para introducir el ancho de solapa'
],
];
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php
index d2149259..c8172bbe 100644
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php
+++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php
@@ -162,6 +162,47 @@
+
+
-
+
= lang('Presupuestos.totalAceptado') ?>
>
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminAdd.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminAdd.js
index 6f5b4830..03f8cf38 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminAdd.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminAdd.js
@@ -50,6 +50,7 @@ class PresupuestoAdminAdd {
$('#div_solapas_ancho_sobrecubierta').addClass('d-none');
$('.solapas-cubierta-div').addClass('d-none');
$('.solapas-sobrecubierta-div').addClass('d-none');
+ $('.container-faja').addClass('d-none');
this.cliente.init();
this.pais.init();
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js
index efd004f7..35ec8dab 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js
@@ -55,6 +55,9 @@ class PresupuestoAdminEdit {
this.guardar = $('#saveForm');
this.calcularPresupuesto = false;
+ this.cargandoPresupuesto = false;
+
+
this.configUploadDropzone = {
domElement: '#dropzone-presupuesto-admin-files',
nameId: "presupuesto_id",
@@ -130,10 +133,6 @@ 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()
- }
-
}
@@ -282,6 +281,8 @@ class PresupuestoAdminEdit {
update_resumen = true,
update_tiradas_alternativas = true
}) {
+
+ const self = this;
const waitForEvent = (eventName) => {
return new Promise((resolve) => {
$(document).one(eventName, () => {
@@ -290,30 +291,32 @@ class PresupuestoAdminEdit {
});
};
- // Ejecutar los pasos de forma secuencial si están habilitados
- if (update_lineas) {
- $(document).trigger('update-lineas-presupuesto');
- await waitForEvent('update-lineas-presupuesto-completed');
- }
+ if (self.cargandoPresupuesto == false) {
+ // Ejecutar los pasos de forma secuencial si están habilitados
+ if (update_lineas) {
+ $(document).trigger('update-lineas-presupuesto');
+ await waitForEvent('update-lineas-presupuesto-completed');
+ }
- if (update_servicios) {
- $(document).trigger('update-servicios');
- await waitForEvent('update-servicios-completed');
- }
+ if (update_servicios) {
+ $(document).trigger('update-servicios');
+ await waitForEvent('update-servicios-completed');
+ }
- if (update_envios) {
- $(document).trigger('update-envios');
- await waitForEvent('update-envios-completed');
- }
+ if (update_envios) {
+ $(document).trigger('update-envios');
+ await waitForEvent('update-envios-completed');
+ }
- if (update_resumen) {
- $(document).trigger('update-totales');
- await waitForEvent('update-totales-completed');
- }
+ if (update_resumen) {
+ $(document).trigger('update-totales');
+ await waitForEvent('update-totales-completed');
+ }
- if (update_tiradas_alternativas) {
- $(document).trigger('update-tiradas-alternativas');
- await waitForEvent('update-tiradas-alternativas-completed');
+ if (update_tiradas_alternativas) {
+ $(document).trigger('update-tiradas-alternativas');
+ await waitForEvent('update-tiradas-alternativas-completed');
+ }
}
}
@@ -321,6 +324,7 @@ class PresupuestoAdminEdit {
#cargarPresupuesto() {
const self = this;
+ this.cargandoPresupuesto = true;
$('#loader').modal('show');
let id = window.location.href.split("/").pop()
@@ -338,15 +342,18 @@ 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.comparador.cargarDatos(response.data.comparador);
+
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
self.servicios.cargar(response.data.servicios);
self.envios.cargar(response.data.direcciones);
+ self.comparador.cargarDatos(response.data.comparador);
+
$('#comentariosCliente').val(response.data.comentarios_cliente);
$('#comentariosSafekat').val(response.data.comentarios_safekat);
$('#comentariosPdf').val(response.data.comentarios_presupuesto);
@@ -363,8 +370,10 @@ class PresupuestoAdminEdit {
if (response.data.state != 2) {
self.calcularPresupuesto = true;
+ self.cargandoPresupuesto = false;
}
+
}, 0);
this.calcularSolapas();
@@ -380,6 +389,7 @@ class PresupuestoAdminEdit {
() => {
$('#loader').modal('hide');
this.calcularPresupuesto = true;
+ self.cargandoPresupuesto = false;
}
).get();
}
@@ -389,12 +399,12 @@ class PresupuestoAdminEdit {
let cantidad_total = 0;
- this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
+ $('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
var rowData = this.data();
if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
cantidad_total += parseInt(rowData.paginas)
})
- htmlString = ''
+ let htmlString = ''
if (cantidad_total != parseInt($('#paginas').val())) {
htmlString = `
@@ -430,7 +440,7 @@ class PresupuestoAdminEdit {
calcularSolapas() {
- let anchoTotal = 2*this.getDimensionLibro().ancho;
+ let anchoTotal = 2 * this.getDimensionLibro().ancho;
let maxSolapas = 120;
let mano = 0;
@@ -443,29 +453,28 @@ class PresupuestoAdminEdit {
}
});
- if (mano > 0) {
+ if (mano > 0) {
anchoTotal += 6 + 5; // dobleces + sangre
- maxSolapas = Math.min(Math.floor((865-anchoTotal)/2), 0.75*this.getDimensionLibro().ancho);
+ maxSolapas = Math.min(Math.floor((865 - anchoTotal) / 2), 0.75 * this.getDimensionLibro().ancho);
}
- else{
- maxSolapas = 0.75*this.getDimensionLibro().ancho;
+ else {
+ maxSolapas = 0.75 * this.getDimensionLibro().ancho;
}
- if($('#solapas_ancho').length>0 && $('#solapas_ancho').attr('max') != maxSolapas){
+ if ($('#solapas_ancho').length > 0 && $('#solapas_ancho').attr('max') != maxSolapas) {
$('#solapas_ancho').attr('max', maxSolapas);
- $('#solapas_ancho').trigger('change');
+ $('#solapas_ancho').trigger('change');
$('#solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
}
- if($('#solapas_ancho_sobrecubierta').length>0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas){
+ if ($('#solapas_ancho_sobrecubierta').length > 0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas) {
$('#solapas_ancho_sobrecubierta').attr('max', maxSolapas);
$('#solapas_ancho_sobrecubierta').trigger('change');
$('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
}
- if($('#solapas_ancho_faja').length>0 && $('#solapas_ancho_faja').attr('max') != maxSolapas){
+ if ($('#solapas_ancho_faja').length > 0 && $('#solapas_ancho_faja').attr('max') != maxSolapas) {
$('#solapas_ancho_faja').attr('max', maxSolapas);
$('#solapas_ancho_faja').trigger('change');
$('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
}
- console.log('maxSolapas', maxSolapas);
}
getDimensionLibro() {
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js
index 4e39be5a..c9fffc26 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js
@@ -220,6 +220,35 @@ class Comparador {
this.btnInsertarGuardas = $('#insertarGuardasBtn');
}
+ this.faja = $('#compFaja');
+ this.papelFaja = new ClassSelect($('#compPapelFaja'),
+ '/presupuestoadmin/papelgenerico', 'Seleccione papel', false,
+ {
+ [this.csrf_token]: this.csrf_hash,
+ tipo_impresion: this.tipo_impresion_id,
+ tirada: () => $('#tirada').val(),
+ ancho: () => this.getDimensionLibro().ancho,
+ alto: () => $('faja_alto').val(),
+ sopalas: () => $('#faja_solapas_ancho').val(),
+ lomo: () => $('#lomo_sobrecubierta').val(),
+ tipo: 'colorhq',
+ uso: 'sobrecubierta',
+ });
+ this.gramajeFaja = new ClassSelect($('#compGramajeFaja'),
+ '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false,
+ {
+ [this.csrf_token]: this.csrf_hash,
+ papel_generico: () => this.papelFaja.getVal(),
+ tipo_impresion: this.tipo_impresion_id,
+ tirada: () => $('#tirada').val(),
+ ancho: () => this.getDimensionLibro().ancho,
+ alto: () => $('faja_alto').val(),
+ sopalas: () => $('#faja_solapas_ancho').val(),
+ lomo: () => $('#lomo_sobrecubierta').val(),
+ tipo: 'colorhq',
+ uso: 'sobrecubierta',
+ });
+
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
this.lomoRedondo = $('#compLomoRedondo');
this.cabezada = $('#cabezada');
@@ -232,9 +261,11 @@ class Comparador {
this.tableCompGuardas = null;
this.tableCompIntPlana = null;
this.tableCompIntRotativa = null;
+ this.tableCompFaja = null;
this.btnInsertarPlana = $('#insertarPlanaBtn');
this.btnInsertarRotativa = $('#insertarRotativaBtn');
this.btnInsertarCubierta = $('#insertarCubiertaBtn');
+ this.btnInsertarFaja = $('#insertarFajaBtn');
this.cargando = false;
this.comparadorPlanaRunning = false;
@@ -292,6 +323,14 @@ class Comparador {
});
}
+ this.faja.select2({
+ allowClear: false,
+ minimumResultsForSearch: Infinity,
+ });
+ this.papelFaja.init();
+ this.gramajeFaja.init();
+ this.papelFaja.onChange(() => self.gramajeFaja.empty());
+
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) {
this.sobrecubierta.select2({
@@ -323,6 +362,28 @@ class Comparador {
});
}
+ this.faja.on('change', () => {
+ if (this.faja.select2('data')[0].id == 1) {
+ if ($('#faja').prop('checked') == false) {
+ this.faja.val(0);
+ popErrorAlert(window.language.Presupuestos.errores.error_faja_sin_solapas, 'divAlarmasComparador');
+ }
+ $('#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);
+ }
+ else {
+ this.papelFaja.setVal(0);
+ this.gramajeFaja.setVal(0);
+ $('#compPapelFaja').prop('disabled', true);
+ $('#compGramajeFaja').prop('disabled', true);
+ }
+ });
+
+
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();
@@ -360,6 +421,9 @@ class Comparador {
else if (e.target.id.includes("guardas")) {
$("#tableCompGuardas").DataTable().columns.adjust();
}
+ else if (e.target.id.includes("faja")) {
+ $("#tableCompFaja").DataTable().columns.adjust();
+ }
else if (e.target.id.includes("LineasPresupuesto")) {
$("#tableLineasPresupuesto").DataTable().columns.adjust();
}
@@ -378,6 +442,8 @@ class Comparador {
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
$('.comp_guardas_items').on('change', this.obtenerComparadorGuardas.bind(this));
}
+
+ $('.comp_faja_items').on('change', this.obtenerComparadorFaja.bind(this));
}
#changePaginasComparador(element) {
@@ -477,22 +543,25 @@ class Comparador {
}
this.cargando = false;
- if (this.paginasNegro.val() > 0) {
- this.paginasNegro.trigger('change');
- }
- else if (this.paginasNegrohq.val() > 0) {
- this.paginasNegrohq.trigger('change');
- }
- else if (this.paginasColor.val() > 0) {
+
+ if (this.paginasColor.val() > 0) {
this.paginasColor.trigger('change');
}
else if (this.paginasColorhq.val() > 0) {
this.paginasColorhq.trigger('change');
}
+ else if (this.paginasNegro.val() > 0) {
+ this.paginasNegro.trigger('change');
+ }
+ else if (this.paginasNegrohq.val() > 0) {
+ this.paginasNegrohq.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) {
this.carasGuardas.trigger('change');
}
+ this.faja.trigger('change');
}
@@ -673,6 +742,57 @@ class Comparador {
"order": [[0, 'asc'], [15, 'asc']]
});
+ this.tableCompFaja = new DataTable('#tableCompFaja', {
+ scrollX: true,
+ searching: false,
+ paging: false,
+ info: false,
+ ordering: true,
+ responsive: true,
+ select: false,
+ language: {
+ url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
+ },
+ columns: [
+ {
+ 'data': 'tipo',
+ 'render': function (data, type, row, meta) {
+ if (data == 'faja')
+ return window.language.Presupuestos.faja;
+ }
+ },
+ { 'data': 'paginas' },
+ { 'data': 'papel' },
+ { 'data': 'gramaje' },
+ { 'data': 'marca' },
+ { 'data': 'maquina' },
+ { 'data': 'numeroPliegos' },
+ { 'data': 'pliegosPedido' },
+ { 'data': 'precioPliego' },
+ { 'data': 'libro' },
+ { 'data': 'totalPapelPedido' },
+ { 'data': 'lomo' },
+ { 'data': 'peso' },
+ { 'data': 'horasMaquina' },
+ { 'data': 'precioImpresion' },
+ { 'data': 'total' },
+ { 'data': 'maquinaId' },
+ { 'data': 'maquinaVelocidad' },
+ { 'data': 'tiempoMaquina' },
+ { 'data': 'papelGenericoId' },
+ { 'data': 'papelImpresionId' },
+ { 'data': 'tarifa_impresion_id' }
+ ],
+ columnDefs: [
+ {
+ target: [16, 17, 18, 19, 20, 21],
+ visible: false,
+ searchable: false
+ },
+ ],
+ "order": [[15, 'asc']]
+ });
+
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
this.tableCompGuardas = new DataTable('#tableCompGuardas', {
scrollX: true,
@@ -1019,6 +1139,23 @@ class Comparador {
}
+ else if (uso == 'faja') {
+ if (this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) {
+ popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
+ return { error: true, data: {} };
+ }
+ if (this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) {
+ popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
+ return { error: true, data: {} };
+ }
+
+ papel_generico = { id: this.papelFaja.getVal(), nombre: this.papelFaja.getText() };
+ gramaje = this.gramajeFaja.getVal();
+ paginas = 4;
+ alto = $('#faja_alto').val();
+
+ }
+
else if (uso == 'guardas') {
if (this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
@@ -1053,7 +1190,7 @@ class Comparador {
let datos = {
datosPedido: datosPedido,
- uso: uso,
+ uso: uso == 'faja' ? 'sobrecubierta' : uso,
tipo_impresion_id: this.tipo_impresion_id,
cliente_id: $('#clienteId').select2('data')[0].id,
papel_generico: papel_generico,
@@ -1076,6 +1213,13 @@ class Comparador {
datos.datosPedido.solapas = $('#solapas_sobrecubierta').prop('checked') ? 1 : 0;
datos.datosPedido.solapas_ancho = $('#solapas_sobrecubierta').prop('checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0;
}
+
+ else if (uso == 'faja') {
+ datos.datosPedido.lomo = $("#lomo_sobrecubierta").val();
+ datos.datosPedido.solapas = 1;
+ datos.datosPedido.solapas_ancho = parseInt($('#faja_solapas_ancho').val());
+ }
+
else if (uso == 'guardas') {
datos.datosPedido.isCosido = 1;
datos.datosPedido.isHq = 1;
@@ -1273,7 +1417,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.select2('data')[0].id == 1) {
+ if (this.sobrecubierta.val() == 1) {
datosComp.sobrecubierta = this.getDataForComp('sobrecubierta');
if (datosComp.sobrecubierta.error) {
return;
@@ -1297,6 +1441,7 @@ class Comparador {
},
{},
(response) => {
+ this.tableCompCubierta.clear().draw();
if (response.data.cubierta && Object.keys(response.data.cubierta).length > 0) {
let sorted = Object.values(response.data.cubierta).sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
@@ -1342,6 +1487,67 @@ class Comparador {
}
}
+
+ obtenerComparadorFaja(event, actualizarLineaPlana = false, actualizarLineaRot = false) {
+
+ try {
+
+ const self = this;
+
+ if (this.cargando) {
+ return
+ }
+
+ this.tableCompFaja.clear().draw();
+ this.btnInsertarFaja.addClass('d-none');
+ $('#title_faja').html(window.language.Presupuestos.faja);
+
+ let datosComp = {};
+ datosComp.sobrecubierta = this.getDataForComp('faja');
+
+ datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
+
+ new Ajax('/presupuestoadmin/comparadorexteriores',
+ {
+ sobrecubierta: datosComp.sobrecubierta.data
+ },
+ {},
+ (response) => {
+
+ if (response.data.sobrecubierta && Object.keys(response.data.sobrecubierta).length > 0) {
+ 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)) ?
+ -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
+ sorted[0].forEach(function (linea) {
+ if (typeof linea.error == "undefined")
+ self.tableCompFaja.row
+ .add(self.getRowFromLinea('faja', linea))
+ .draw()
+ });
+ }
+
+ self.selectLineas('faja');
+ if (self.tableCompFaja.rows().count() > 0) {
+ $('#title_faja').html(window.language.Presupuestos.faja +
+ (' (' + self.tableCompFaja.rows().count() + ')'));
+ self.btnInsertarFaja.removeClass('d-none');
+ }
+ else {
+ $('#title_faja').html(window.language.Presupuestos.faja);
+ self.btnInsertarFaja.addClass('d-none');
+ }
+ },
+ (error) => {
+ console.log(error);
+ }
+ ).post();
+
+
+ } catch (e) {
+ console.log(e)
+ }
+ }
+
obtenerComparadorGuardas(event, actualizarLineaPlana = false, actualizarLineaRot = false) {
try {
@@ -1425,6 +1631,12 @@ class Comparador {
total_label = '#total_comp_cubierta';
break;
+ case 'faja':
+ table = this.tableCompFaja;
+ tipo1 = 'faja';
+ total_label = '#total_comp_faja';
+ break;
+
case 'rotativa':
table = this.tableCompIntRotativa;
tipo1 = 'rotativa';
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js
index b14e3026..e34d08fe 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js
@@ -55,6 +55,11 @@ class DatosLibro {
this.ferroDigital = this.domItem.find('#ferroDigital');
this.marcapaginas = this.domItem.find('#marcapaginas');
+ this.faja = this.domItem.find('#faja');
+ this.fajaAlto = this.domItem.find('#faja_alto');
+ this.fajaSolapasAncho = this.domItem.find('#faja_solapas_ancho');
+ this.div_faja = this.domItem.find('.faja-div');
+
}
init() {
@@ -96,12 +101,27 @@ class DatosLibro {
this.paginas.on('change', this.changePaginas.bind(this));
this.tirada.on('change', this.changeTirada.bind(this));
- this.anchoSolapasCubierta.on('focusout', this.checkSolapasMax.bind(this));
- this.anchoSolapasSobrecubierta.on('focusout', this.checkSolapasMax.bind(this));
+ this.anchoSolapasCubierta.on('focusout', this.checkSolapaAncho.bind(this));
+ this.anchoSolapasSobrecubierta.on('focusout', this.checkSolapaAncho.bind(this));
+
+ this.faja.on('change', this.changeFaja.bind(this));
}
}
- checkSolapasMax(event) {
+ changeFaja() {
+
+ if (this.faja.prop('checked')) {
+ this.div_faja.removeClass('d-none');
+ $('#compFaja').val(1).trigger('change');
+ }
+ else {
+ this.div_faja.addClass('d-none');
+ $('#compFaja').val(0).trigger('change');
+ }
+ }
+
+ checkSolapaAncho(event) {
+
const el = event.target;
if (el.value != "") {
if (parseInt(el.value) < parseInt(el.min)) {
@@ -116,15 +136,6 @@ class DatosLibro {
}
}
- changeFajaColor() {
-
- if (this.imprimirFajaColor.prop('checked')) {
- $(document).trigger('add-servicio-lineas', 'facaColor');
- }
- else {
- $(document).trigger('remove-servicio-lineas', 'fajaColor');
- }
- }
changeFerro() {
@@ -243,7 +254,7 @@ class DatosLibro {
}, 100);
// para que se actualice el comparador
- this.updateComparador();
+ $('#compCarasCubierta').trigger('change');
}
changeAnchoSolapasCubierta() {
@@ -256,7 +267,7 @@ class DatosLibro {
}
// para que se actualice el comparador
- this.updateComparador();
+ $('#compCarasCubierta').trigger('change');
}
@@ -287,8 +298,7 @@ class DatosLibro {
}
// para que se actualice el comparador
- this.updateComparador();
-
+ $('#compSobrecubierta').trigger('change');
}
checkSolapasGrandes(elemento) {
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js
index 3888600a..167d85b9 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js
@@ -31,7 +31,7 @@ class LineasPresupuesto {
const row = $(this).closest('tr');
const data = self.table.row(row).data()
- if(data.row_id == 'lp_guardas'){
+ if (data.row_id == 'lp_guardas') {
$(document).trigger('remove-servicio-lineas', 'plegado_guardas');
}
self.table.row(row)
@@ -152,6 +152,9 @@ class LineasPresupuesto {
else if (row.row_id.includes('_guardas')) {
return 4;
}
+ else if (row.row_id.includes('_faja')) {
+ return 5;
+ }
}
},
{
@@ -163,7 +166,7 @@ class LineasPresupuesto {
{
data: 'paginas',
render: function (data, type, row, meta) {
- if (row.row_id != "lp_cubierta" && row.row_id != "lp_sobrecubierta" && row.row_id != "lp_guardas")
+ if (row.row_id != "lp_cubierta" && row.row_id != "lp_sobrecubierta" && row.row_id != "lp_guardas" && row.row_id != "lp_faja")
return ' ';
else if (row.row_id == "lp_cubierta") {
let select = ''
@@ -615,13 +618,13 @@ class LineasPresupuesto {
data.push(linea_data)
});
-
+
var datos = {
tipo: 'lineasPresupuesto',
datos: data,
presupuesto_id: presupuesto_id,
}
-
+
await $.ajax({
type: 'post',
url: '/presupuestoadmin/datatable_2',
@@ -666,7 +669,7 @@ class LineasPresupuesto {
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
let rowData = this.data();
- if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
+ if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_faja')
cantidad_total += parseInt(rowData.paginas)
})
let htmlString = ''
@@ -917,6 +920,8 @@ class LineasPresupuesto {
icon = '/themes/vuexy/img/safekat/presupuestos/icon_cubierta.png';
else if (rowId == 'lp_sobrecubierta')
icon = '/themes/vuexy/img/safekat/presupuestos/icon_sobrecubierta.png';
+ else if (rowId == 'lp_faja')
+ icon = '/themes/vuexy/img/safekat/presupuestos/icon_faja.png';
else if (rowId == 'lp_guardas')
icon = '/themes/vuexy/img/safekat/presupuestos/icon_guardas.png';
else if (rowId == 'lp_rot_bn')
@@ -1100,11 +1105,22 @@ class LineasPresupuesto {
'
' +
''
-
-
-
value += ''
+ if (d.row_id == "lp_faja") {
+ value += '
' +
+ ' ' +
+ ' ' +
+ '' +
+ '' +
+ '
' +
+ window.language.Presupuestos.papelFormatoAlto + ' ' + window.language.Presupuestos.faja +
+ ' ' +
+ '
' +
+ '
' +
+ ' '
+ }
+
if (d.maquinaTipo == 'inkjet') {
value +=
'
' +
@@ -1389,6 +1405,22 @@ class LineasPresupuesto {
const self = this;
const dimension = this.getDimensionLibro();
+ if (linea == 'lp_faja') {
+ if (Object.keys(input_data).length == 0) {
+ let altoSelected = parseInt($('#' + linea + '_altoFaja').val());
+ if(altoSelected == 0 || isNaN(altoSelected) || altoSelected == '' || altoSelected < 50){
+ altoSelected = 50;
+ }
+ else if(altoSelected > dimension.alto){
+ altoSelected = dimension.alto;
+ }
+ dimension.alto = altoSelected;
+ }
+ else{
+ dimension.alto = parseInt($('#faja_alto').val());
+ }
+ }
+
const dataFromComparador = fromComparador;
if (Object.keys(input_data).length == 0) {
@@ -1406,7 +1438,7 @@ class LineasPresupuesto {
if (linea == 'lp_cubierta') {
input_data.paginas = parseInt($('#lp_cubierta_paginas option:selected').val());
}
- else if (linea == 'lp_sobrecubierta') {
+ else if (linea == 'lp_sobrecubierta' || linea == 'lp_faja') {
input_data.paginas = 4;
}
else if (linea == 'lp_guardas') {
@@ -1433,6 +1465,7 @@ class LineasPresupuesto {
uso = 'cubierta';
break;
case 'lp_sobrecubierta':
+ case 'lp_faja':
uso = 'sobrecubierta';
break;
case 'lp_guardas':
@@ -1453,7 +1486,6 @@ class LineasPresupuesto {
hq = 0;
}
-
var datos = {
tipo_impresion_id: $('#tipo_impresion_id').val(),
type: uso,
@@ -1496,6 +1528,11 @@ class LineasPresupuesto {
datos.solapas_ancho = $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0;
datos.lomo = $('#lomo_sobrecubierta').val();
}
+ else if (linea == 'lp_faja') {
+ datos.solapas = 1;
+ datos.solapas_ancho = parseInt($('#faja_solapas_ancho').val());
+ datos.lomo = $('#lomo_sobrecubierta').val();
+ }
else if (linea == 'lp_guardas') {
datos.paginas_impresion = input_data.paginas_impresion;
}
@@ -1503,7 +1540,7 @@ class LineasPresupuesto {
// Si es inkjet, existe este check
if ($('#' + linea + '_aFavorFibra').length) {
- datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1: 0;
+ datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1 : 0;
}
if (updatedTipologias && $('#' + linea + '_gotaNegro').length) {
@@ -1549,6 +1586,9 @@ class LineasPresupuesto {
response.lineas[$i].fields.check_papel_total = 1;
response.lineas[$i].fields.check_impresion_total = 1;
}
+ if (linea == 'lp_faja') {
+ response.lineas[$i].fields.alto_faja = dimension.alto;
+ }
self.rellenarDatosLinea(linea, response.lineas[$i].fields);
return true;
@@ -1583,7 +1623,7 @@ class LineasPresupuesto {
papel_impresion_id: row.papelImpresionId,
maquina_id: row.maquinaId,
}
- if(linea.includes('guardas')) {
+ if (linea.includes('guardas')) {
input_data.paginas_impresion = parseInt($('#compCarasGuardas').select2('data')[0].id);
}
this.obtenerLinea(linea, fromComparator, false, input_data)
@@ -1602,7 +1642,13 @@ class LineasPresupuesto {
this.table.row.add(data).draw()
currentRow = this.table.row('#' + linea);
}
- currentRow.child(this.formatRow(currentRow.data())).show();
+
+ let datosLinea = currentRow.data();
+ if(linea == 'lp_faja') {
+ datosLinea.alto_faja = row.alto_faja;
+ }
+
+ currentRow.child(this.formatRow(datosLinea)).show();
this.#addEventosLineas(linea, data.maquinaTipo == 'inkjet' ? true : false);
@@ -1615,16 +1661,16 @@ class LineasPresupuesto {
*/
$(document).trigger('update-presupuesto', {
- update_lineas : false,
- update_servicios : true,
+ update_lineas: false,
+ update_servicios: true,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
});
-
+
// Si existe cubierta, hay que actualizar con el valor del lomo
- if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && this.table.row('#lp_cubierta').length > 0) {
+ if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && linea != 'lp_faja' && this.table.row('#lp_cubierta').length > 0) {
this.obtenerLinea('lp_cubierta', false, false);
}
if (mostrar_calculos) {
@@ -1666,6 +1712,7 @@ class LineasPresupuesto {
uso = 'cubierta';
break;
case 'lp_sobrecubierta':
+ case 'lp_faja':
uso = 'sobrecubierta';
break;
case 'lp_guardas':
@@ -1765,6 +1812,12 @@ class LineasPresupuesto {
$('#' + tipoLinea + '_defecto').on("click", () => { this.lp_por_defecto(tipoLinea); });
$('#' + tipoLinea + '_aFavorFibra').on("change", () => { this.change_aFavorFibra(tipoLinea); });
}
+
+ if(tipoLinea == 'lp_faja') {
+ $('#' + tipoLinea + '_altoFaja').on("change", function (event) {
+ self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea'
+ }.bind(this));
+ }
}
@@ -1922,19 +1975,36 @@ class LineasPresupuesto {
}
}
self.table.draw();
-
+
var rows = $("#tableCompGuardas").DataTable().rows('.selected').data().toArray();
for (const row of rows) {
this.rellenarDatosLinea('lp_guardas', row, true);
}
-
+
$(document).trigger('add-servicio-lineas', 'plegado_guardas');
}
+ else if (e.target.id.includes("Faja")) {
+
+ for (let i = self.table.rows().data().length - 1; i >= 0; i--) {
+ let row = self.table.row(i).data(); // Obtener datos de la fila actual
+
+ if (row.row_id.includes('lp_faja')) {
+ self.table.row(i).remove(); // Eliminar fila
+ }
+ }
+ self.table.draw();
+
+ var rows = $("#tableCompFaja").DataTable().rows('.selected').data().toArray();
+ for (const row of rows) {
+ this.rellenarDatosLinea('lp_faja', row, true);
+ }
+ }
+
$(document).trigger('update-presupuesto', {
- update_lineas : false,
- update_servicios : true,
+ update_lineas: false,
+ update_servicios: true,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js
index 897566d1..f2c327ce 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js
@@ -147,7 +147,7 @@ class TiradasAlernativas {
const self = this;
const id = window.location.href.split('/').pop();
- const tirada = tiradaExterna === null ? parseInt(this.tirada.val()) : tiradaExterna;
+ const tirada = tiradaExterna === null || isNaN(tiradaExterna) ? parseInt(this.tirada.val()) : tiradaExterna;
const tirada_ejemplo = parseInt($('#tirada').val());
const POD = parseInt($('#POD').val());