mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en cubierta
This commit is contained in:
@ -164,6 +164,7 @@ class Comparador {
|
||||
this.btnInsertarCubierta = $('#insertarCubiertaBtn');
|
||||
|
||||
this.cargando = false;
|
||||
this.comparadorPlanaRunning = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -179,18 +180,19 @@ class Comparador {
|
||||
|
||||
initSelect2() {
|
||||
|
||||
this.paginasCubierta.select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
|
||||
if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 ||
|
||||
$('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) {
|
||||
$('#compCarasCubierta').select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
|
||||
$('#compPapelGuardas').select2({
|
||||
this.papelGuardas.select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
$('#compCarasGuardas').select2({
|
||||
this.carasGuardas.select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
@ -206,6 +208,11 @@ class Comparador {
|
||||
this.papelCubierta.init();
|
||||
this.gramajeCubierta.init();
|
||||
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({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
this.papelSobrecubierta.init();
|
||||
this.gramajeSobrecubierta.init();
|
||||
this.papelSobrecubierta.onChange(() => this.gramajeSobrecubierta.setVal(0))
|
||||
@ -268,6 +275,12 @@ class Comparador {
|
||||
$('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
|
||||
$('.comp_cubierta_items').on('change', this.obtenerComparadorExteriores.bind(this));
|
||||
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) {
|
||||
$('.comp_sobrecubierta_items').on('change', this.obtenerComparadorExteriores.bind(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#changePaginasComparador(element) {
|
||||
@ -343,6 +356,7 @@ class Comparador {
|
||||
|
||||
this.cargando = false;
|
||||
this.paginasNegro.trigger('change');
|
||||
this.paginasCubierta.trigger('change');
|
||||
}
|
||||
|
||||
|
||||
@ -580,6 +594,14 @@ class Comparador {
|
||||
|
||||
updateOpcionesComparador() {
|
||||
|
||||
$('.comp_negro_items').off('change');
|
||||
$('.comp_negrohq_items').off('change');
|
||||
$('.comp_color_items').off('change');
|
||||
$('.comp_colorhq_items').off('change');
|
||||
|
||||
this.tableCompIntPlana.clear().draw();
|
||||
this.tableCompIntRotativa.clear().draw();
|
||||
|
||||
const selValue = this.tipo_impresion.val();
|
||||
const elements_negro = $('.comp-negro-selected');
|
||||
const elements_negrohq = $('.comp-negrohq-selected');
|
||||
@ -597,6 +619,11 @@ class Comparador {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
else {
|
||||
Array.from(elements_colorhq).forEach(element => {
|
||||
$(element).addClass('d-none');
|
||||
});
|
||||
}
|
||||
Array.from(elements_negrohq).forEach(element => {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
@ -613,11 +640,21 @@ class Comparador {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
else {
|
||||
Array.from(elements_color).forEach(element => {
|
||||
$(element).addClass('d-none');
|
||||
});
|
||||
}
|
||||
Array.from(elements_negro).forEach(element => {
|
||||
$(element).removeClass('d-none');
|
||||
});
|
||||
}
|
||||
|
||||
$('.comp_negro_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
$('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this));
|
||||
|
||||
if (selValue.includes('color')) {
|
||||
$('.pos-paginas-color').removeClass('d-none');
|
||||
}
|
||||
@ -714,6 +751,7 @@ class Comparador {
|
||||
let papel_generico = {};
|
||||
let gramaje = {};
|
||||
let paginasColor = 0;
|
||||
let paginas = parseInt($('#paginas').val());
|
||||
|
||||
if (!$('#papelFormatoPersonalizado').prop('checked')) {
|
||||
const selectedFormat = $('#papelFormatoId').select2('data')[0].text;
|
||||
@ -780,27 +818,63 @@ class Comparador {
|
||||
};
|
||||
|
||||
if (this.tipo_impresion.val().includes('color')) {
|
||||
|
||||
if (this.tipo_impresion.val().includes('hq')) {
|
||||
papel_generico.color = { id: this.papelColorhq.getVal(), nombre: this.papelColorhq.getText() };
|
||||
gramaje.color = this.gramajeColorhq.getVal();
|
||||
paginasColor = this.paginasColorhq.val();
|
||||
}
|
||||
papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() };
|
||||
gramaje.negro = this.gramajeNegrohq.getVal();
|
||||
}
|
||||
else {
|
||||
if (this.tipo_impresion.val().includes('hq')) {
|
||||
else {
|
||||
papel_generico.color = { id: this.papelColor.getVal(), nombre: this.papelColor.getText() };
|
||||
gramaje.color = this.gramajeColor.getVal();
|
||||
paginasColor = this.paginasColor.val();
|
||||
}
|
||||
|
||||
}
|
||||
if (this.tipo_impresion.val().includes('hq')) {
|
||||
papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() };
|
||||
gramaje.negro = this.gramajeNegrohq.getVal();
|
||||
}
|
||||
else {
|
||||
papel_generico.negro = { id: this.papelNegro.getVal(), nombre: this.papelNegro.getText() };
|
||||
gramaje.negro = this.gramajeNegro.getVal();
|
||||
}
|
||||
|
||||
}
|
||||
else if (uso = 'cubierta') {
|
||||
if (this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
|
||||
|
||||
papel_generico = { id: this.papelCubierta.getVal(), nombre: this.papelCubierta.getText() };
|
||||
gramaje = this.gramajeCubierta.getVal();
|
||||
paginas = this.paginasCubierta.select2('data')[0].id
|
||||
}
|
||||
|
||||
else if (uso = 'sobrecubierta') {
|
||||
if (this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
|
||||
papel_generico = { id: this.papelSobrecubierta.getVal(), nombre: this.papelSobrecubierta.getText() };
|
||||
gramaje = this.gramajeSobrecubierta.getVal();
|
||||
paginas = 4;
|
||||
|
||||
}
|
||||
|
||||
const datosPedido = {
|
||||
paginas: $('#paginas').val(),
|
||||
paginas: paginas,
|
||||
tirada: $('#tirada').val(),
|
||||
merma: $('#merma').val(),
|
||||
ancho: ancho,
|
||||
@ -826,6 +900,10 @@ class Comparador {
|
||||
isHq: this.tipo_impresion.val().includes('hq'),
|
||||
paginas_color: paginasColor
|
||||
}
|
||||
// TO-DO
|
||||
if(uso == 'cubierta'){
|
||||
datos.lomoRedondo = false;
|
||||
}
|
||||
|
||||
|
||||
return { error: false, data: datos };
|
||||
@ -837,9 +915,10 @@ class Comparador {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
if (this.cargando || this.comparadorPlanaRunning) {
|
||||
return
|
||||
}
|
||||
this.comparadorPlanaRunning = true;
|
||||
|
||||
if (event.currentTarget.id.includes('Paginas')) {
|
||||
this.#changePaginasComparador(event.currentTarget.id);
|
||||
@ -848,113 +927,249 @@ class Comparador {
|
||||
this.tableCompIntPlana.clear().draw();
|
||||
this.tableCompIntRotativa.clear().draw();
|
||||
this.btnInsertarPlana.addClass('d-none');
|
||||
this.btnInsertarRotativa.addClass('d-none');
|
||||
$('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa);
|
||||
$('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana);
|
||||
|
||||
const datosComp = this.getDataForComp('interior');
|
||||
if (datosComp.error) {
|
||||
this.comparadorPlanaRunning = false;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
const isHq = this.tipo_impresion.val().includes('hq');
|
||||
const isColor = this.tipo_impresion.val().includes('color');
|
||||
|
||||
datosComp.data['tipo_maquina'] = 'plana';
|
||||
datosComp.data[this.csrf_token] = this.csrf_hash;
|
||||
new Ajax('/presupuestoadmin/comparadorplana',
|
||||
new Ajax('/presupuestoadmin/comparadorinterior',
|
||||
datosComp.data,
|
||||
{},
|
||||
(response) => {
|
||||
if (response.data.negro.length > 0) {
|
||||
const isHq = response.data.negro[0].fields.tipo_linea.includes('hq');
|
||||
let sorted = response.data.negro.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.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompIntPlana').DataTable().row
|
||||
.add(self.getRowFromLineaInt(isHq ? 'bnhq' : 'bn', linea))
|
||||
self.tableCompIntPlana.row
|
||||
.add(self.getRowFromLinea(isHq ? 'bnhq' : 'bn', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
if (response.data.color.length > 0) {
|
||||
const isHq = response.data.color[0].fields.tipo_linea.includes('hq');
|
||||
let sorted = response.data.color.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.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
$('#tableCompIntPlana').DataTable().row
|
||||
.add(self.getRowFromLineaInt(isHq ? 'colorhq' : 'color', linea))
|
||||
self.tableCompIntPlana.row
|
||||
.add(self.getRowFromLinea(isHq ? 'colorhq' : 'color', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
this.selectIntLineas();
|
||||
|
||||
self.selectLineas('plana');
|
||||
if ($('#tableCompIntPlana').DataTable().rows().count() > 0) {
|
||||
$('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana + ' (' + self.tableCompIntPlana.rows().count() + ')');
|
||||
$('#insertarPlanaBtn').removeClass('d-none');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana);
|
||||
$('#insertarPlanaBtn').addClass('d-none');
|
||||
}
|
||||
|
||||
// Rotativa
|
||||
if (!isHq) {
|
||||
if (!isColor || (isColor && datosComp.data.papel_generico.negro.id == datosComp.data.papel_generico.color.id &&
|
||||
datosComp.data.gramaje.negro == datosComp.data.gramaje.color)) {
|
||||
|
||||
datosComp.data['tipo_maquina'] = 'rotativa';
|
||||
datosComp.data.papel_generico.id = datosComp.data.papel_generico.negro.id;
|
||||
datosComp.data.papel_generico.nombre = datosComp.data.papel_generico.negro.nombre;
|
||||
datosComp.data.gramaje = datosComp.data.gramaje.negro;
|
||||
new Ajax('/presupuestoadmin/comparadorinterior',
|
||||
datosComp.data,
|
||||
{},
|
||||
(response) => {
|
||||
if (response.data.rotativa.length > 0) {
|
||||
let sorted = response.data.rotativa.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.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompIntRotativa.row
|
||||
.add(self.getRowFromLineaRot(linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
self.selectLineas('rotativa');
|
||||
if (self.tableCompIntRotativa.rows().count() > 0) {
|
||||
self.btnInsertarRotativa.removeClass('d-none');
|
||||
$('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa + ' (' + self.tableCompIntRotativa.rows().count() + ')');
|
||||
}
|
||||
else {
|
||||
$('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa);
|
||||
}
|
||||
|
||||
self.comparadorPlanaRunning = false;
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
).post();
|
||||
}
|
||||
else {
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
self.comparadorPlanaRunning = false;
|
||||
}
|
||||
).post();
|
||||
}
|
||||
/*
|
||||
elementos = getIDsComparador(is_color, is_hq)
|
||||
|
||||
|
||||
if ($('' + elementos.papel).select2('data').length > 0 &&
|
||||
$('' + elementos.gramaje).select2('data').length > 0 &&
|
||||
parseInt($('' + elementos.paginas).val()) >= 0 &&
|
||||
checkDatosPedidoForComp()) {
|
||||
|
||||
|
||||
getLineasIntPlana(is_color, is_hq, actualizarLineaPlana).then((result) => {
|
||||
// Para rotativa, si es color el papel y el gramaje tiene que ser igual
|
||||
if (!is_color) {
|
||||
getLineasIntRot(is_hq, actualizarLineaRot);
|
||||
}
|
||||
else {
|
||||
if (!is_hq) {
|
||||
if ($('#compPapelNegro').select2('data').length > 0 && $('#compPapelColor').select2('data').length > 0 &&
|
||||
$('#compGramajeNegro').select2('data').length > 0 && $('#compGramajeColor').select2('data').length > 0) {
|
||||
if (($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) {
|
||||
getLineasIntRot(is_hq, actualizarLineaRot);
|
||||
}
|
||||
else {
|
||||
$('#errorComRot').html('<?= lang("Presupuestos.errores.errorRotColor") ?>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
this.comparadorPlanaRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
obtenerComparadorExteriores(event, actualizarLineaPlana = false, actualizarLineaRot = false) {
|
||||
|
||||
try {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
return
|
||||
}
|
||||
|
||||
this.tableCompCubierta.clear().draw();
|
||||
this.btnInsertarCubierta.addClass('d-none');
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta);
|
||||
|
||||
let datosComp = {};
|
||||
datosComp.cubierta = this.getDataForComp('cubierta');
|
||||
if (datosComp.cubierta.error) {
|
||||
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) {
|
||||
datosComp.sobrecubierta = this.getDataForComp('sobrecubierta');
|
||||
if (datosComp.sobrecubierta.error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
datosComp.sobrecubierta = {};
|
||||
}
|
||||
}
|
||||
else{
|
||||
datosComp.sobrecubierta = {};
|
||||
}
|
||||
datosComp.cubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
if(Object.keys(datosComp.sobrecubierta).length > 0){
|
||||
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
}
|
||||
new Ajax('/presupuestoadmin/comparadorexteriores',
|
||||
{
|
||||
cubierta: datosComp.cubierta.data,
|
||||
sobrecubierta: datosComp.sobrecubierta.data
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
if (response.data.cubierta.length > 0) {
|
||||
let sorted = response.data.cubierta.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.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompCubierta.row
|
||||
add(self.getRowFromLinea('cubierta', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
if (response.data.sobrecubierta) {
|
||||
let sorted = 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.forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompCubierta.row
|
||||
.add(self.getRowFromLinea('sobrecubierta', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
|
||||
self.selectLineas('cubierta');
|
||||
if (self.tableCompCubierta.rows().count() > 0) {
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta +
|
||||
(' (' + self.tableCompCubierta.rows().count() + ')'));
|
||||
self.btnInsertarCubierta.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
$('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta);
|
||||
self.btnInsertarCubierta.addClass('d-none');
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
).post();
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
selectIntLineas() {
|
||||
var negro_selected = false;
|
||||
var color_selected = false;
|
||||
$("#tableCompIntPlana").DataTable().rows('.selected').deselect();
|
||||
$("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) {
|
||||
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
negro_selected = true;
|
||||
}
|
||||
if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) {
|
||||
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
color_selected = true;
|
||||
|
||||
selectLineas(tabla) {
|
||||
|
||||
let table = this.tableCompIntPlana;
|
||||
let select1 = false;
|
||||
let select2 = false;
|
||||
let tipo1 = 'bn';
|
||||
let tipo2 = 'color';
|
||||
let total_label = '#total_comp_plana'
|
||||
switch (tabla) {
|
||||
case 'cubierta':
|
||||
table = this.tableCompCubierta;
|
||||
tipo1 = 'lp_cubierta';
|
||||
tipo2 = 'lp_sobrecubierta';
|
||||
total_label = '#total_comp_cubierta';
|
||||
break;
|
||||
|
||||
case 'rotativa':
|
||||
table = this.tableCompIntRotativa;
|
||||
tipo1 = 'rotativa';
|
||||
total_label = '#total_comp_rot';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
table.rows('.selected').deselect();
|
||||
table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (!select1 && table.cell(rowIdx, 0).data().includes(tipo1)) {
|
||||
table.row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
select1 = true;
|
||||
}
|
||||
if (tabla == 'plana' || tabla == 'cubierta')
|
||||
if (!select2 && table.cell(rowIdx, 0).data().includes(tipo2)) {
|
||||
table.row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
select2 = true;
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#tableCompIntPlana").DataTable();
|
||||
var rows = table.rows('.selected').indexes();
|
||||
var data = table.rows(rows).data();
|
||||
|
||||
@ -965,10 +1180,10 @@ class Comparador {
|
||||
value_total += parseFloat(data[i]['total'])
|
||||
}
|
||||
|
||||
$('#total_comp_plana').html(value_total.toFixed(2));
|
||||
$(total_label).html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
getRowFromLineaInt(tipo, linea) {
|
||||
getRowFromLinea(tipo, linea) {
|
||||
|
||||
const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
||||
@ -1002,25 +1217,165 @@ class Comparador {
|
||||
data['paginas_impresion'] = linea.fields.paginas_impresion;
|
||||
return data;
|
||||
}
|
||||
|
||||
getRowFromLineaRot(linea) {
|
||||
|
||||
const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
|
||||
parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
|
||||
|
||||
return {
|
||||
'tipo': 'rotativa',
|
||||
'paginas': linea.fields.paginas,
|
||||
'papel': linea.fields.papel_generico,
|
||||
'gramaje': linea.fields.gramaje,
|
||||
'marca': linea.fields.papel_impresion,
|
||||
'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no',
|
||||
'maquina': linea.fields.maquina,
|
||||
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
|
||||
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
|
||||
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
|
||||
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
|
||||
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
|
||||
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
|
||||
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
|
||||
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
|
||||
'precioImpresion': precio_impresion,
|
||||
'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6),
|
||||
'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6),
|
||||
'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2),
|
||||
'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2),
|
||||
'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2),
|
||||
'maquinaId': linea.fields.maquina_id,
|
||||
'maquinaVelocidad': linea.fields.maquina_velocidad,
|
||||
'tiempoMaquina': linea.fields.tiempo_maquina,
|
||||
'papelGenericoId': linea.fields.papel_generico_id,
|
||||
'papelImpresionId': linea.fields.papel_impresion_id,
|
||||
'paginasColor': linea.fields.paginas_color,
|
||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
||||
}
|
||||
}
|
||||
|
||||
generateCompJSON() {
|
||||
|
||||
data = {}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
bn_obj = {
|
||||
"bn": {
|
||||
'paginas': $('#compPaginasNegro').val(),
|
||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bn_obj = {}
|
||||
}
|
||||
$.extend(data, bn_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
bnhq_obj = {
|
||||
"bnhq": {
|
||||
'paginas': $('#compPaginasNegrohq').val(),
|
||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
bnhq_obj = {}
|
||||
}
|
||||
$.extend(data, bnhq_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
try {
|
||||
color_obj = {
|
||||
"color": {
|
||||
'paginas': $('#compPaginasColor').val(),
|
||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
color_obj = {}
|
||||
}
|
||||
$.extend(data, color_obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
try {
|
||||
colorhq_obj = {
|
||||
"colorhq": {
|
||||
'paginas': $('#compPaginasColorhq').val(),
|
||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
colorhq_obj = {}
|
||||
}
|
||||
$.extend(data, colorhq_obj);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
cubierta_obj = {
|
||||
"cubierta": {
|
||||
'paginas': $('#compCarasCubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
cubierta_obj = {}
|
||||
}
|
||||
$.extend(data, cubierta_obj);
|
||||
|
||||
try {
|
||||
sobrecubierta_obj = {
|
||||
"sobrecubierta": {
|
||||
'imprimir': $('#compSobrecubierta option:selected').val(),
|
||||
'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
sobrecubierta_obj = {}
|
||||
}
|
||||
$.extend(data, sobrecubierta_obj);
|
||||
|
||||
if ($('#compCarasGuardas').length > 0) {
|
||||
try {
|
||||
guardas_obj = {
|
||||
"guardas": {
|
||||
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
|
||||
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
guardas_obj = {}
|
||||
}
|
||||
$.extend(data, guardas_obj);
|
||||
|
||||
}
|
||||
|
||||
data_str = JSON.stringify(data)
|
||||
$('#comparador_json_data').val(data_str)
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
$('#compSobrecubierta').on('change', function(){
|
||||
if ($('#compSobrecubierta').val()==1){
|
||||
value = false
|
||||
}
|
||||
else{
|
||||
value = 'disabled'
|
||||
$('#compPapelSobrecubierta').val(0)
|
||||
$('#compGramajeSobrecubierta').val('')
|
||||
$('#compGramajeSobrecubierta').select2("destroy")
|
||||
$('#compGramajeSobrecubierta').select2({allowClear: false, minimumResultsForSearch: Infinity})
|
||||
|
||||
}
|
||||
$('#compPapelSobrecubierta').prop('disabled', value);
|
||||
$('#compGramajeSobrecubierta').prop('disabled', value);
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user