mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
2111 lines
104 KiB
JavaScript
2111 lines
104 KiB
JavaScript
import ClassSelect from '../../../components/select2.js';
|
|
import { getToken } from '../../../common/common.js';
|
|
import Ajax from '../../../components/ajax.js';
|
|
|
|
|
|
|
|
class LineasPresupuesto {
|
|
|
|
constructor(domItem, functions = {}) {
|
|
this.domItem = domItem;
|
|
this.getDimensionLibro = functions.getDimensionLibro;
|
|
this.calcular_mermas = functions.calcular_mermas;
|
|
|
|
this.table = null;
|
|
|
|
this.csrf_token = getToken();
|
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
|
|
|
this.addLineaManual = this.domItem.find("#btn_addLinea");
|
|
}
|
|
|
|
|
|
init() {
|
|
const self = this;
|
|
|
|
this.#initTable();
|
|
|
|
this.addLineaManual.on('click', this.#insertLineaManual.bind(this));
|
|
|
|
// Botones de borrar de las lineas de presupuesto
|
|
$(document).on('click', '.btn-delete-lp', function (e) {
|
|
|
|
const row = $(this).closest('tr');
|
|
const data = self.table.row(row).data()
|
|
self.table.row(row)
|
|
.remove()
|
|
.draw();
|
|
|
|
$(document).trigger('update-presupuesto', {
|
|
update_lineas: false,
|
|
update_servicios: false,
|
|
update_envios: true,
|
|
update_resumen: true,
|
|
update_tiradas_alternativas: true
|
|
});
|
|
// TO-DO
|
|
/*
|
|
if (data.row_id == 'lp_guardas')
|
|
servicioGuardas(false)
|
|
*/
|
|
|
|
// Si existe cubierta, hay que actualizar con el valor del lomo
|
|
if (self.table.row('#lp_cubierta').length > 0) {
|
|
self.obtenerLinea('lp_cubierta', false, false);
|
|
}
|
|
});
|
|
|
|
// Evento para recalcular las lineas de presupuesto
|
|
$(document).on('update-lineas-presupuesto', async function () {
|
|
|
|
await self.updateLineasPresupuesto();
|
|
|
|
$(document).trigger('update-lineas-presupuesto-completed');
|
|
});
|
|
|
|
$('.insertarLinea').on("click", this.#insertarLineaComparador.bind(this));
|
|
$('.paginas-lp').on('change', this.checkPaginasLineasPresupuesto.bind(this));
|
|
}
|
|
|
|
|
|
#initTable() {
|
|
|
|
const self = this;
|
|
|
|
const lastColNr_lp = $('#tableLineasPresupuesto').find("tr:first th").length - 1;
|
|
|
|
const actionBtns_lp = function (data) {
|
|
return `
|
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-lp mx-2" data-id="${data.row_id}"></i></a>
|
|
`;
|
|
};
|
|
|
|
this.table = new DataTable('#tableLineasPresupuesto', {
|
|
scrollX: true,
|
|
searching: false,
|
|
paging: false,
|
|
info: false,
|
|
ordering: true,
|
|
responsive: true,
|
|
select: false,
|
|
rowId: 'row_id',
|
|
language: {
|
|
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
|
},
|
|
columnDefs: [
|
|
{
|
|
targets: 0,
|
|
className: 'dt-control',
|
|
orderable: false,
|
|
data: null,
|
|
defaultContent: ''
|
|
},
|
|
{
|
|
targets: [1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
orderable: false,
|
|
visible: false,
|
|
},
|
|
{
|
|
targets: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
|
orderable: false,
|
|
},
|
|
{
|
|
targets: [10],
|
|
orderable: true,
|
|
visible: false,
|
|
},
|
|
{
|
|
orderable: false,
|
|
searchable: false,
|
|
targets: [lastColNr_lp]
|
|
},
|
|
],
|
|
columns: [
|
|
{ data: null },
|
|
{ data: 'tarifa_impresion_id' },
|
|
{ data: 'maquina_ancho' },
|
|
{ data: 'maquina_alto' },
|
|
{ data: 'maquina_impresion_ancho' },
|
|
{ data: 'maquina_impresion_alto' },
|
|
{ data: 'formas' },
|
|
{ data: 'formas_v' },
|
|
{ data: 'formas_h' },
|
|
{ data: 'formas_orientacion' },
|
|
{
|
|
data: 'position',
|
|
type: "num",
|
|
render: function (data, type, row, meta) {
|
|
if (row.row_id.includes('_bn')) {
|
|
return 0;
|
|
}
|
|
else if (row.row_id.includes('_color')) {
|
|
return 1;
|
|
}
|
|
else if (row.row_id.includes('_cubierta')) {
|
|
return 2;
|
|
}
|
|
else if (row.row_id.includes('_sobrecubierta')) {
|
|
return 3;
|
|
}
|
|
else if (row.row_id.includes('_guardas')) {
|
|
return 4;
|
|
}
|
|
else if (row.row_id.includes('_faja')) {
|
|
return 5;
|
|
}
|
|
}
|
|
},
|
|
{
|
|
data: 'icon',
|
|
render: function (data, type, row, meta) {
|
|
return '<img style="padding: 0; margin:0;" src="' + data + '" />'
|
|
}
|
|
},
|
|
{
|
|
data: 'paginas',
|
|
render: function (data, type, row, meta) {
|
|
if (row.row_id != "lp_cubierta" && row.row_id != "lp_sobrecubierta" && row.row_id != "lp_guardas" && row.row_id != "lp_faja")
|
|
return '<td class="lp-td"><input id="' + row.row_id + '_paginas" name="' + row.row_id + '_paginas" class="lp-cell lp-input paginas-lp" type="text" value="' + data + '"></td>';
|
|
else if (row.row_id == "lp_cubierta") {
|
|
let select = '<select id="lp_cubierta_paginas" name="comp_paginas_cubierta" class="form-control form-select-sm lp-cell lp-select" style="min-width:50px;">'
|
|
if (data == 2) {
|
|
select += '<option value="2" selected >'
|
|
}
|
|
else {
|
|
select += '<option value="2">'
|
|
}
|
|
select += '<p>' + window.language.Presupuestos.unaCara + '</p>'
|
|
select += '</option>'
|
|
if (data == 4) {
|
|
select += '<option value="4" selected >'
|
|
}
|
|
else {
|
|
select += '<option value="4">'
|
|
}
|
|
select += '<p>' + window.language.Presupuestos.dosCaras + '</p>'
|
|
select += '</option>'
|
|
select += '</select>'
|
|
|
|
return select;
|
|
}
|
|
else if (row.row_id == "lp_guardas") {
|
|
let select = '<select id="lp_guardas_paginas" name="comp_paginas_guardas" class="form-control form-select-sm lp-cell lp-select" style="min-width:50px;">'
|
|
if (row.paginas_impresion == 0) {
|
|
select += '<option value="0" selected >'
|
|
}
|
|
else {
|
|
select += '<option value="0">'
|
|
}
|
|
select += '<p>' + window.language.Presupuestos.sinImpresion + '</p>'
|
|
select += '</option>'
|
|
if (row.paginas_impresion == 4) {
|
|
select += '<option value="4" selected >'
|
|
}
|
|
else {
|
|
select += '<option value="4">'
|
|
}
|
|
select += '<p>' + window.language.Presupuestos.unaCara + '</p>'
|
|
select += '</option>'
|
|
if (row.paginas_impresion == 8) {
|
|
select += '<option value="8" selected >'
|
|
}
|
|
else {
|
|
select += '<option value="8">'
|
|
}
|
|
select += '<p>' + window.language.Presupuestos.dosCaras + '</p>'
|
|
select += '</option>'
|
|
select += '</select>'
|
|
|
|
return select;
|
|
|
|
}
|
|
else {
|
|
return '';
|
|
}
|
|
}
|
|
},
|
|
{
|
|
data: 'papel',
|
|
render: function (data, type, row, meta) {
|
|
var select = $('<select>')
|
|
.attr('id', row.row_id + '_papel')
|
|
.attr('name', row.row_id + '_papel')
|
|
.addClass('form-control form-select-sm lp-cell lp-select')
|
|
.css('min-width', '150px')
|
|
|
|
let tipo = 'negro';
|
|
switch (row.row_id) {
|
|
case 'lp_bnhq':
|
|
tipo = 'negrohq';
|
|
break;
|
|
case 'lp_rot_color':
|
|
case 'lp_color':
|
|
tipo = 'color';
|
|
break;
|
|
case 'lp_colorhq':
|
|
case 'lp_guardas':
|
|
case 'lp_cubierta':
|
|
case 'lp_sobrecubierta':
|
|
tipo = 'colorhq';
|
|
break
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (data) {
|
|
var option = '<option value="' + data + '" selected>' + row.papel_nombre + '</option>';
|
|
select.append(option);
|
|
}
|
|
|
|
return select[0].outerHTML
|
|
}
|
|
},
|
|
{
|
|
data: 'gramaje',
|
|
render: function (data, type, row, meta) {
|
|
var select = $('<select>')
|
|
.attr('id', row.row_id + '_gramaje')
|
|
.attr('name', row.row_id + '_gramaje')
|
|
.addClass('form-control form-select-sm lp-cell lp-select ')//+ row.row_class + '-select')
|
|
.css('min-width', '40px')
|
|
|
|
if (data) {
|
|
var option = '<option value="' + parseInt(data) + '" selected>' + parseInt(data) + '</option>';
|
|
select.append(option);
|
|
}
|
|
|
|
return select[0].outerHTML
|
|
}
|
|
},
|
|
{
|
|
data: 'papel_impresion',
|
|
render: function (data, type, row, meta) {
|
|
var select = $('<select>')
|
|
.attr('id', row.row_id + '_papelImpresion')
|
|
.attr('name', row.row_id + '_papelImpresion')
|
|
.addClass('form-control form-select-sm lp-cell lp-select ' + row.row_class + '-select')
|
|
.css('min-width', '150px')
|
|
|
|
if (data) {
|
|
var option = '<option value="' + row.papel_impresion_id + '" selected>' + data + '</option>';
|
|
select.append(option);
|
|
}
|
|
|
|
return select[0].outerHTML
|
|
}
|
|
},
|
|
{
|
|
data: 'maquina',
|
|
render: function (data, type, row, meta) {
|
|
var select = $('<select>')
|
|
.attr('id', row.row_id + '_maquina')
|
|
.attr('name', row.row_id + '_maquina')
|
|
.addClass('form-control form-select-sm lp-cell lp-select ' + row.row_class + '-select')
|
|
.css('min-width', '110px')
|
|
|
|
if (data) {
|
|
var option = '<option value="' + row.maquina_id + '" selected>' + data + '</option>';
|
|
select.append(option);
|
|
}
|
|
|
|
return select[0].outerHTML
|
|
}
|
|
},
|
|
{
|
|
data: 'tiempo',
|
|
render: function (data, type, row, meta) {
|
|
return '<td class="lp-td"><input id="' + row.row_id + '_tiempo" name="' + row.row_id + '_tiempo" readonly class="lp-cell lp-cell-disabled lp-input ' + row.row_class + '-input " type="text" value="' + data + '"></td>';
|
|
}
|
|
},
|
|
{
|
|
data: 'lomo',
|
|
render: function (data, type, row, meta) {
|
|
return '<td class="lp-td"><input id="' + row.row_id + '_lomo" name="' + row.row_id + '_lomo" readonly class="lp-cell lp-cell-disabled lp-input ' + row.row_class + '-input" type="text" value="' + data + '"></td>';
|
|
}
|
|
},
|
|
{
|
|
data: 'peso',
|
|
render: function (data, type, row, meta) {
|
|
return '<td class="lp-td"><input id="' + row.row_id + '_peso" name="' + row.row_id + '_peso" readonly class="lp-cell lp-cell-disabled lp-input ' + row.row_class + '-input" type="text" value="' + data + '"></td>';
|
|
}
|
|
},
|
|
{
|
|
data: 'total_linea',
|
|
render: function (data, type, row, meta) {
|
|
return '<td class="lp-td"><input id="' + row.row_id + '_total_linea" name="' + row.row_id + '_total_linea" readonly class="lp-cell lp-cell-disabled lp-input ' + row.row_class + '-input " type="text" value="' + data + '"></td>';
|
|
}
|
|
},
|
|
{
|
|
data: actionBtns_lp,
|
|
className: 'row-edit dt-center'
|
|
}
|
|
],
|
|
"order": [10, 'asc'],
|
|
});
|
|
|
|
this.table.on('click', 'td.dt-control', function (e) {
|
|
let tr = e.target.closest('tr');
|
|
let row = self.table.row(tr);
|
|
|
|
if (row.child.isShown()) {
|
|
// This row is already open - close it
|
|
row.child.hide();
|
|
}
|
|
else {
|
|
// Open this row
|
|
row.child(self.formatRow(row.data())).show();
|
|
}
|
|
});
|
|
|
|
this.table.on('draw', function () {
|
|
|
|
$("#lomo_cubierta").val(self.getLomoInterior());
|
|
$("#lomo_sobrecubierta").val(parseFloat(self.getLomoInterior()) + parseFloat(self.getLomoCubierta()));
|
|
self.checkPaginasLineasPresupuesto();
|
|
self.mostrarTabsPreview();
|
|
});
|
|
}
|
|
|
|
|
|
async updateLineasPresupuesto() {
|
|
|
|
$('#tableLineasPresupuesto tbody tr:visible ').each(function () {
|
|
|
|
$('#' + this.id + '_maquina').trigger('change');
|
|
})
|
|
}
|
|
|
|
cargarDatos(data) {
|
|
|
|
const self = this;
|
|
|
|
data[1].forEach(function (lp) {
|
|
|
|
const formas = JSON.parse(lp.formas)
|
|
lp.dimensiones_maquina = [formas.maquina_ancho, formas.maquina_alto]
|
|
lp.dimensiones_maquina_impresion = [formas.maquina_impresion_ancho, formas.maquina_impresion_alto]
|
|
lp.num_formas = {
|
|
value: formas.formas,
|
|
num_formas_verticales: formas.formas_v,
|
|
num_formas_horizontales: formas.formas_h,
|
|
posicion_formas: formas.formas_orientacion
|
|
}
|
|
lp['tipo_maquina'] = lp['maquina_tipo']
|
|
lp['precio_impresion_horas'] = lp['precio_impresion']
|
|
lp['margen_impresion_horas'] = lp['margen_impresion']
|
|
lp['precio_libro'] = lp['libro']
|
|
lp['precio_pedido'] = lp['total_papel_pedido']
|
|
lp['total_impresion'] = lp['total_linea']
|
|
lp['precios_pliegos'] = lp['pliegos_precio']
|
|
lp['papel_generico_id'] = lp['papel_id']
|
|
|
|
let dateObj = new Date(lp['tiempo_maquina'] * 1000);
|
|
const hours = dateObj.getUTCHours();
|
|
const minutes = dateObj.getUTCMinutes();
|
|
const seconds = dateObj.getSeconds();
|
|
lp['tiempo_maquina'] = hours.toString().padStart(2, '0') + ':' +
|
|
minutes.toString().padStart(2, '0') + ':' +
|
|
seconds.toString().padStart(2, '0');
|
|
|
|
if (lp.maquina_tipo == 'inkjet') {
|
|
|
|
lp.datosTipologias = {
|
|
negro: lp.rotativa_negro,
|
|
cyan: lp.rotativa_cyan,
|
|
magenta: lp.rotativa_magenta,
|
|
amarillo: lp.rotativa_amarillo,
|
|
cg: lp.rotativa_cg,
|
|
gota_negro: lp.rotativa_gota_negro,
|
|
gota_color: lp.rotativa_gota_color,
|
|
}
|
|
|
|
lp['paginas_color'] = lp['rotativa_pag_color']
|
|
|
|
lp['totalImpresion'] = lp['rotativa_total_impresion']
|
|
lp['a_favor_fibra'] = lp['rotativa_a_favor_fibra']
|
|
|
|
lp['resolucion'] = lp['rotativa_resolucion']
|
|
lp['superficie'] = lp['rotativa_area_paginas']
|
|
|
|
lp['num_gotas_negro'] = lp['rotativa_num_gotas_negro']
|
|
lp['num_gotas_cyan'] = lp['rotativa_num_gotas_cyan']
|
|
lp['num_gotas_magenta'] = lp['rotativa_num_gotas_magenta']
|
|
lp['num_gotas_amarillo'] = lp['rotativa_num_gotas_amarillo']
|
|
lp['num_gotas_cg'] = lp['rotativa_num_gotas_cg']
|
|
|
|
lp['precio_pagina_negro'] = lp['rotativa_precio_pag_negro']
|
|
lp['precio_pagina_color'] = lp['rotativa_precio_pag_color']
|
|
lp['factor_altura'] = lp['rotativa_factor_altura']
|
|
lp['factor_anchura'] = lp['rotativa_factor_anchura']
|
|
lp['paginas_por_pliego'] = lp['rotativa_pag_por_pliego']
|
|
|
|
lp['clicks_libro'] = lp['rotativa_clicks_libro']
|
|
lp['peso_gotas_negro'] = lp['rotativa_peso_gotas_negro']
|
|
lp['peso_gotas_cyan'] = lp['rotativa_peso_gotas_cyan']
|
|
lp['peso_gotas_magenta'] = lp['rotativa_peso_gotas_magenta']
|
|
lp['peso_gotas_amarillo'] = lp['rotativa_peso_gotas_amarillo']
|
|
lp['peso_gotas_cg'] = lp['rotativa_peso_gotas_cg']
|
|
lp['clicks_pedido'] = lp['rotativa_clicks_total']
|
|
lp['precio_click_pedido'] = lp['precio_click_pedido']
|
|
lp['margen_click_pedido'] = lp['margen_click_pedido']
|
|
lp['precio_tinta'] = lp['rotativa_precio_tinta']
|
|
|
|
|
|
lp['peso_gotas_negro_pedido'] = lp['rotativa_peso_gotas_negro_pedido']
|
|
lp['peso_gotas_cyan_pedido'] = lp['rotativa_peso_gotas_cyan_pedido']
|
|
lp['peso_gotas_magenta_pedido'] = lp['rotativa_peso_gotas_magenta_pedido']
|
|
lp['peso_gotas_amarillo_pedido'] = lp['rotativa_peso_gotas_amarillo_pedido']
|
|
lp['peso_gotas_cg_pedido'] = lp['rotativa_peso_gotas_cg_pedido']
|
|
|
|
}
|
|
if (lp.tipo.includes('rot')) {
|
|
|
|
lp['maquina_velocidad'] = lp['rotativa_mxm']
|
|
lp['metros_papel_libro'] = lp['rotativa_metros_libro']
|
|
lp['metros_papel_total'] = lp['rotativa_metros_total']
|
|
lp['velocidad_corte'] = lp['rotativa_velocidad_corte']
|
|
lp['precio_hora_corte'] = lp['rotativa_precio_hora_corte']
|
|
lp['tiempo_corte'] = lp['rotativa_tiempo_corte']
|
|
lp['total_corte'] = lp['rotativa_total_corte']
|
|
}
|
|
|
|
lp['areaPaginas'] = lp['rotativa_superficie']
|
|
|
|
|
|
let rowData = self.#processRowData(lp, lp.tipo, lp.tipo.replace(/_/g, '-'));
|
|
|
|
let row = self.table.row("#" + lp.tipo);
|
|
|
|
self.table.row.add(rowData).draw()
|
|
row = self.table.row("#" + lp.tipo);
|
|
|
|
row.child(self.formatRow(row.data())).show();
|
|
|
|
self.#addEventosLineas(lp.tipo, lp.maquina_tipo == 'inkjet' ? true : false);
|
|
if (lp.tipo == 'lp_guardas')
|
|
lp['paginas_impresion'] = lp.paginas_impresion;
|
|
|
|
})
|
|
|
|
this.checkLomo();
|
|
}
|
|
|
|
async guardarLineasPresupuesto() {
|
|
|
|
let data = [];
|
|
const presupuesto_id = window.location.href.split('/').pop();
|
|
|
|
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
|
|
var rowData = this.data();
|
|
|
|
const formas = {
|
|
maquina_ancho: rowData.maquina_ancho,
|
|
maquina_alto: rowData.maquina_alto,
|
|
maquina_impresion_ancho: rowData.maquina_impresion_ancho,
|
|
maquina_impresion_alto: rowData.maquina_impresion_alto,
|
|
formas: rowData.formas,
|
|
formas_v: rowData.formas_v,
|
|
formas_h: rowData.formas_h,
|
|
formas_orientacion: rowData.formas_orientacion,
|
|
}
|
|
|
|
var t_maq_str = rowData.tiempo.split(':'); // split it at the colons
|
|
var t_maq = 0
|
|
|
|
if (t_maq_str.length == 3)
|
|
t_maq = (+t_maq_str[0]) * 3600 + (+t_maq_str[1]) * 60 + (+t_maq_str[2]);
|
|
|
|
let linea_data = {
|
|
presupuesto_id: presupuesto_id,
|
|
tipo: rowData.row_id,
|
|
paginas: (rowData.row_id == 'lp_guardas') ? (($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3) ? 8 : 4) : rowData.paginas,
|
|
papel_id: rowData.papel,
|
|
gramaje: rowData.gramaje,
|
|
papel_impresion_id: rowData.papel_impresion_id,
|
|
papel_impresion: rowData.papel_impresion,
|
|
maquina_id: rowData.maquina_id,
|
|
maquina: rowData.maquina,
|
|
maquina_tipo: rowData.maquinaTipo,
|
|
tiempo_maquina: t_maq,
|
|
pliegos_libro: rowData.numeroPliegos,
|
|
pliegos_pedido: rowData.pliegosPedido,
|
|
pliegos_precio: rowData.precioPliego,
|
|
libro: rowData.libro,
|
|
total_papel_pedido: rowData.totalPapelPedido,
|
|
margen_papel_pedido: rowData.margenPapelPedido,
|
|
mano: rowData.lomo,
|
|
peso: rowData.peso,
|
|
precio_click: rowData.click,
|
|
precio_click_pedido: rowData.totalClicks,
|
|
margen_click_pedido: rowData.margenClicks,
|
|
check_papel_total: $('#' + rowData.row_id + '_checkPapel').is(":checked") ? 1 : 0,
|
|
check_impresion_total: $('#' + rowData.row_id + '_checkClicks').is(":checked") ? 1 : 0,
|
|
tarifa_impresion_id: rowData.tarifa_impresion_id,
|
|
formas: JSON.stringify(formas),
|
|
|
|
horas_maquina: rowData.horasMaquina,
|
|
precio_hora: rowData.precioHora,
|
|
precio_impresion: rowData.precioImpresion,
|
|
margen_impresion: rowData.margenImpresion,
|
|
total_linea: rowData.total_linea,
|
|
}
|
|
|
|
if (rowData.row_id == 'lp_guardas')
|
|
linea_data.paginas_impresion = rowData.paginas_impresion
|
|
|
|
// maquina rotativa o inkjet
|
|
if (linea_data.maquina_tipo == 'inkjet') {
|
|
|
|
linea_data.rotativa_pag_color = rowData.numPagColor
|
|
|
|
linea_data.rotativa_total_impresion = rowData.totalImpresion
|
|
linea_data.rotativa_a_favor_fibra = rowData.aFavorFibra,
|
|
linea_data.rotativa_negro = rowData.cobNegro
|
|
linea_data.rotativa_cyan = rowData.cobCyan
|
|
linea_data.rotativa_magenta = rowData.cobMagenta
|
|
linea_data.rotativa_amarillo = rowData.cobAmarillo
|
|
linea_data.rotativa_cg = rowData.cobCG
|
|
linea_data.rotativa_gota_negro = rowData.gotaNegro
|
|
linea_data.rotativa_gota_color = rowData.gotaColor
|
|
|
|
|
|
linea_data.rotativa_resolucion = rowData.resolucion
|
|
linea_data.rotativa_area_paginas = rowData.areaPaginas
|
|
|
|
linea_data.rotativa_num_gotas_negro = rowData.gotaNegro
|
|
linea_data.rotativa_num_gotas_cyan = rowData.gotasCyan
|
|
linea_data.rotativa_num_gotas_magenta = rowData.gotasMagenta
|
|
linea_data.rotativa_num_gotas_amarillo = rowData.gotasAmarillo
|
|
linea_data.rotativa_num_gotas_cg = rowData.gotasCG
|
|
|
|
linea_data.rotativa_precio_pag_negro = rowData.precioPagNegro
|
|
linea_data.rotativa_precio_pag_color = rowData.precioPagColor
|
|
linea_data.rotativa_factor_altura = rowData.factorAltura
|
|
linea_data.rotativa_factor_anchura = rowData.factorAnchura
|
|
linea_data.rotativa_pag_por_pliego = rowData.paginasPliego
|
|
|
|
linea_data.rotativa_clicks_libro = rowData.clicksLibro
|
|
linea_data.rotativa_peso_gotas_negro = rowData.gTintaNegro
|
|
linea_data.rotativa_peso_gotas_cyan = rowData.gTintaCyan
|
|
linea_data.rotativa_peso_gotas_magenta = rowData.gTintaMagenta
|
|
linea_data.rotativa_peso_gotas_amarillo = rowData.gTintaAmarillo
|
|
linea_data.rotativa_peso_gotas_cg = rowData.gTintaCG
|
|
linea_data.rotativa_clicks_total = rowData.clicksPedido
|
|
linea_data.precio_click_pedido = rowData.totalClicksPedido
|
|
linea_data.rotativa_precio_tinta = rowData.totalTinta
|
|
|
|
|
|
linea_data.rotativa_peso_gotas_negro_pedido = rowData.gTintaNegroPed
|
|
linea_data.rotativa_peso_gotas_cyan_pedido = rowData.gTintaCyanPed
|
|
linea_data.rotativa_peso_gotas_magenta_pedido = rowData.gTintaMagentaPed
|
|
linea_data.rotativa_peso_gotas_amarillo_pedido = rowData.gTintaAmarilloPed
|
|
linea_data.rotativa_peso_gotas_cg_pedido = rowData.gTintaCGPed
|
|
|
|
}
|
|
if (linea_data.tipo.includes('rot')) {
|
|
|
|
linea_data.rotativa_mxm = rowData.metrosMinuto
|
|
linea_data.rotativa_metros_libro = rowData.metrosPapelLibro
|
|
linea_data.rotativa_metros_total = rowData.metrosPapelTotal
|
|
linea_data.rotativa_velocidad_corte = rowData.velocidadCorte
|
|
linea_data.rotativa_precio_hora_corte = rowData.precioHoraCorte
|
|
linea_data.rotativa_tiempo_corte = rowData.tiempoCorte
|
|
linea_data.rotativa_total_corte = rowData.totalCorte
|
|
linea_data.rotativa_a_favor_fibra = rowData.aFavorFibra == true ? 1 : 0
|
|
}
|
|
|
|
data.push(linea_data)
|
|
});
|
|
|
|
|
|
var datos = {
|
|
tipo: 'lineasPresupuesto',
|
|
datos: data,
|
|
presupuesto_id: presupuesto_id,
|
|
}
|
|
|
|
await $.ajax({
|
|
type: 'post',
|
|
url: '/presupuestoadmin/datatable_2',
|
|
data: datos,
|
|
dataType: 'json',
|
|
success: function (response) {
|
|
|
|
}
|
|
}).fail(function (jqXHR, textStatus, error) {
|
|
// Handle error here
|
|
console.log(jqXHR)
|
|
});
|
|
}
|
|
|
|
|
|
mostrarTabsPreview() {
|
|
|
|
const table = $('#tableLineasPresupuesto').DataTable();
|
|
|
|
// Clear all existing tabs
|
|
$('*[id*=tab-pv-]').hide().find('.active').removeClass('active');
|
|
$('*[id*=pv_]').removeClass('active show');
|
|
|
|
// Enable active tabs
|
|
table.rows().every(function () {
|
|
const lpName = this.data().row_id.replace('lp_', '');
|
|
const tabName = lpName.replace('_', '-');
|
|
|
|
if (['bn', 'bnhq', 'color', 'colorhq', 'rot_bn', 'rot_color', 'guardas', 'cubierta', 'sobrecubierta', 'faja'].includes(lpName)) {
|
|
$(`#tab-pv-${tabName}`).show();
|
|
if (lpName === 'cubierta') {
|
|
$(`#tab-pv-${tabName}`).show();
|
|
$(`#tab-pv-esquema-${tabName}`).show();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
checkPaginasLineasPresupuesto() {
|
|
|
|
let cantidad_total = 0
|
|
|
|
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' && rowData.row_id != 'lp_faja')
|
|
cantidad_total += parseInt(rowData.paginas)
|
|
})
|
|
let htmlString = ''
|
|
|
|
if (cantidad_total != parseInt($('#paginas').val())) {
|
|
htmlString = `
|
|
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
|
<span class="alert-icon alert-icon-lg text-primary me-2">
|
|
<i class="ti ti-bell ti-sm"></i>
|
|
</span>
|
|
<div class="d-flex flex-column ps-1">
|
|
<h5 class="alert-heading mb-2">` +
|
|
window.language.Presupuestos.errores.paginasLP +
|
|
`</h5>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
$('#divAlarmasLineasPresupuesto').html(htmlString)
|
|
}
|
|
|
|
#insertLineaManual() {
|
|
|
|
let dataRows = this.table.rows().data();
|
|
|
|
switch ($('#addLineasPresupuesto').val()) {
|
|
// Se chequean todas las lineas de negro y todas las de color
|
|
// (solo una de cada en interior)
|
|
|
|
case 'lp_bn':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_bn' ||
|
|
dataRows[number].row_id == 'lp_bnhq' ||
|
|
dataRows[number].row_id == 'lp_rot_bn') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_bn', 'lp-bn');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_bn', false);
|
|
break;
|
|
|
|
case 'lp_bnhq':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_bn' ||
|
|
dataRows[number].row_id == 'lp_bnhq' ||
|
|
dataRows[number].row_id == 'lp_rot_bn') {
|
|
hayLinea = true
|
|
continue
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_bnhq', 'lp-bnhq');
|
|
this.table.row.add(data).draw()
|
|
this.#addEventosLineas('lp_bnhq', false);
|
|
break
|
|
|
|
case 'lp_color':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_color' ||
|
|
dataRows[number].row_id == 'lp_colorhq' ||
|
|
dataRows[number].row_id == 'lp_rot_color') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_color', 'lp-color');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_color', false);
|
|
break
|
|
|
|
case 'lp_colorhq':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_color' ||
|
|
dataRows[number].row_id == 'lp_colorhq' ||
|
|
dataRows[number].row_id == 'lp_rot_color') {
|
|
hayLinea = true
|
|
continue
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_colorhq', 'lp-colorhq');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_colorhq', false);
|
|
break;
|
|
|
|
case 'lp_rot_bn':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_bn' ||
|
|
dataRows[number].row_id == 'lp_bnhq' ||
|
|
dataRows[number].row_id == 'lp_rot_bn') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_rot_bn', 'lp-rot-bn');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_rot_bn', false);
|
|
break
|
|
|
|
case 'lp_rot_color':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_color' ||
|
|
dataRows[number].row_id == 'lp_colorhq' ||
|
|
dataRows[number].row_id == 'lp_rot_color') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_rot_color', 'lp-rot-color');
|
|
this.table.row.add(data).draw()
|
|
this.#addEventosLineas('lp_rot_color', false);
|
|
break;
|
|
|
|
case 'lp_cubierta':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_cubierta') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_cubierta', 'lp-cubierta');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_cubierta', false);
|
|
break
|
|
|
|
case 'lp_sobrecubierta':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_sobrecubierta') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_sobrecubierta', 'lp-sobrecubierta');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_sobrecubierta', false);
|
|
break
|
|
|
|
case 'lp_faja':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_faja') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_faja', 'lp-faja');
|
|
this.table.row.add(data).draw();
|
|
this.#addEventosLineas('lp_faja', false);
|
|
break
|
|
|
|
case 'lp_guardas':
|
|
var hayLinea = false
|
|
for (let number = 0; number < dataRows.length; number++) {
|
|
if (dataRows[number].row_id == 'lp_guardas') {
|
|
hayLinea = true;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (hayLinea) {
|
|
popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto');
|
|
break;
|
|
}
|
|
|
|
var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_guardas', 'lp-guardas');
|
|
this.table.row.add(data).draw()
|
|
this.#addEventosLineas('lp_guardas', false);
|
|
servicioGuardas(true);
|
|
break
|
|
default:
|
|
break
|
|
}
|
|
this.table.columns.adjust();
|
|
}
|
|
|
|
#processRowData(row, rowId, rowClass) {
|
|
|
|
var icon = ""
|
|
if (rowId == 'lp_bn') {
|
|
if (row.tipo_maquina == 'toner')
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_bn.png'
|
|
else
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_bn.png';
|
|
}
|
|
|
|
else if (rowId == 'lp_bnhq') {
|
|
if (row.tipo_maquina == 'toner')
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_bnhq.png';
|
|
else
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_bn.png';
|
|
}
|
|
else if (rowId == 'lp_color') {
|
|
if (row.tipo_maquina == 'toner')
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_color.png';
|
|
else
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_color.png';
|
|
}
|
|
else if (rowId == 'lp_colorhq') {
|
|
if (row.tipo_maquina == 'toner')
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_colorhq.png';
|
|
else
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_color.png';
|
|
}
|
|
|
|
else if (rowId == 'lp_cubierta')
|
|
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')
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_rotativa_bn.png';
|
|
else if (rowId == 'lp_rot_color')
|
|
icon = '/themes/vuexy/img/safekat/presupuestos/icon_rotativa_color.png';
|
|
|
|
const blank_line = (typeof row.tarifa_impresion_id === 'undefined') ? 1 : 0;
|
|
var data = {
|
|
'row_id': rowId,
|
|
'row_class': rowClass,
|
|
|
|
'tarifa_impresion_id': blank_line ? 0 : isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id),
|
|
'maquina_ancho': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina[0])) ? "" : parseFloat(row.dimensiones_maquina[0]),
|
|
'maquina_alto': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina[1])) ? "" : parseFloat(row.dimensiones_maquina[1]),
|
|
'maquina_impresion_ancho': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina_impresion[0])) ? "" : parseFloat(row.dimensiones_maquina_impresion[0]),
|
|
'maquina_impresion_alto': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina_impresion[1])) ? "" : parseFloat(row.dimensiones_maquina_impresion[1]),
|
|
'formas': blank_line ? 0 : isNaN(parseInt(row.num_formas.value)) ? 0 : parseInt(row.num_formas.value),
|
|
'formas_v': blank_line ? 0 : isNaN(parseInt(row.num_formas.num_formas_verticales)) ? 0 : parseInt(row.num_formas.num_formas_verticales),
|
|
'formas_h': blank_line ? 0 : isNaN(parseInt(row.num_formas.num_formas_horizontales)) ? 0 : parseInt(row.num_formas.num_formas_horizontales),
|
|
'formas_orientacion': blank_line ? 0 : row.num_formas.posicion_formas,
|
|
|
|
'icon': icon,
|
|
'paginas': blank_line ? 0 : row.paginas,
|
|
'paginas_impresion': rowId == 'lp_guardas' ? row.paginas_impresion : 0,
|
|
'papel': blank_line ? "" : row.papel_generico_id,
|
|
'papel_nombre': blank_line ? "" : row.papel_generico,
|
|
'gramaje': blank_line ? "" : row.gramaje,
|
|
'papel_impresion': blank_line ? "" : row.papel_impresion,
|
|
'papel_impresion_id': blank_line ? "" : row.papel_impresion_id,
|
|
'maquina': blank_line ? "" : row.maquina,
|
|
'maquina_id': blank_line ? "" : row.maquina_id,
|
|
|
|
'tiempo': blank_line ? "" : row.tiempo_maquina,
|
|
'lomo': isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2),
|
|
'peso': isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2),
|
|
|
|
'total_linea': isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2),
|
|
|
|
'numeroPliegos': isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2),
|
|
'pliegosPedido': isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(0),
|
|
'precioPliego': isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6),
|
|
'libro': isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2),
|
|
'totalPapelPedido': isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2),
|
|
'margenPapelPedido': isNaN(parseFloat(row.margen_papel_pedido)) ? "" : parseFloat(row.margen_papel_pedido).toFixed(2),
|
|
'click': isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6),
|
|
'totalClicks': isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2),
|
|
'margenClicks': isNaN(parseFloat(row.margen_click_pedido)) ? "" : parseFloat(row.margen_click_pedido).toFixed(2),
|
|
'horasMaquina': isNaN(parseFloat(row.horas_maquina)) ? "" : parseFloat(row.horas_maquina).toFixed(4),
|
|
'precioHora': isNaN(parseFloat(row.precio_hora)) ? "" : parseFloat(row.precio_hora).toFixed(2),
|
|
'precioImpresion': isNaN(parseFloat(row.precio_impresion_horas)) ? "" : parseFloat(row.precio_impresion_horas).toFixed(2),
|
|
'margenImpresion': isNaN(parseFloat(row.margen_impresion_horas)) ? "" : parseFloat(row.margen_impresion_horas).toFixed(2),
|
|
'maquinaTipo': row.tipo_maquina,
|
|
'check_papel_total': row.check_papel_total,
|
|
'check_impresion_total': row.check_impresion_total,
|
|
}
|
|
|
|
if (row.tipo_maquina == 'inkjet') {
|
|
|
|
data.numPagColor = row.paginas_color
|
|
data.aFavorFibra = row.a_favor_fibra
|
|
data.cobNegro = isNaN(parseFloat(row.datosTipologias.negro)) ? "" : parseFloat(row.datosTipologias.negro).toFixed(2)
|
|
data.cobCyan = isNaN(parseFloat(row.datosTipologias.cyan)) ? "" : parseFloat(row.datosTipologias.cyan).toFixed(2)
|
|
data.cobMagenta = isNaN(parseFloat(row.datosTipologias.magenta)) ? "" : parseFloat(row.datosTipologias.magenta).toFixed(2)
|
|
data.cobAmarillo = isNaN(parseFloat(row.datosTipologias.amarillo)) ? "" : parseFloat(row.datosTipologias.amarillo).toFixed(2)
|
|
data.gotaNegro = isNaN(parseFloat(row.datosTipologias.gota_negro)) ? "" : parseFloat(row.datosTipologias.gota_negro).toFixed(2)
|
|
data.gotaColor = isNaN(parseFloat(row.datosTipologias.gota_color)) ? "" : parseFloat(row.datosTipologias.gota_color).toFixed(2)
|
|
|
|
data.resolucion = isNaN(parseFloat(row.resolucion)) ? "" : parseFloat(row.resolucion).toFixed(0)
|
|
data.areaPaginas = isNaN(parseFloat(row.superficie)) ? "" : parseFloat(row.superficie).toFixed(2)
|
|
|
|
data.gotasNegro = isNaN(parseFloat(row.num_gotas_negro)) ? "" : parseFloat(row.num_gotas_negro).toFixed(0)
|
|
data.gotasCyan = isNaN(parseFloat(row.num_gotas_cyan)) ? "" : parseFloat(row.num_gotas_cyan).toFixed(0)
|
|
data.gotasMagenta = isNaN(parseFloat(row.num_gotas_magenta)) ? "" : parseFloat(row.num_gotas_magenta).toFixed(0)
|
|
data.gotasAmarillo = isNaN(parseFloat(row.num_gotas_amarillo)) ? "" : parseFloat(row.num_gotas_amarillo).toFixed(0)
|
|
data.precioPagNegro = isNaN(parseFloat(row.precio_pagina_negro)) ? "" : parseFloat(row.precio_pagina_negro).toFixed(6)
|
|
data.precioPagColor = isNaN(parseFloat(row.precio_pagina_color)) ? "" : parseFloat(row.precio_pagina_color).toFixed(6)
|
|
data.factorAltura = isNaN(parseFloat(row.factor_altura)) ? "" : parseFloat(row.factor_altura).toFixed(2)
|
|
data.factorAnchura = isNaN(parseFloat(row.factor_anchura)) ? "" : parseFloat(row.factor_anchura).toFixed(2)
|
|
data.paginasPliego = isNaN(parseFloat(row.paginas_por_pliego)) ? "" : parseFloat(row.paginas_por_pliego).toFixed(2)
|
|
|
|
if (rowId.includes('rot')) {
|
|
data.metrosMinuto = isNaN(parseFloat(row.maquina_velocidad)) ? "" : parseFloat(row.maquina_velocidad).toFixed(2)
|
|
data.metrosPapelLibro = isNaN(parseFloat(row.metros_papel_libro)) ? "" : parseFloat(row.metros_papel_libro).toFixed(2)
|
|
data.metrosPapelTotal = isNaN(parseFloat(row.metros_papel_total)) ? "" : parseFloat(row.metros_papel_total).toFixed(2)
|
|
data.velocidadCorte = isNaN(parseFloat(row.velocidad_corte)) ? "" : parseFloat(row.velocidad_corte).toFixed(2)
|
|
data.precioHoraCorte = isNaN(parseFloat(row.precio_hora_corte)) ? "" : parseFloat(row.precio_hora_corte).toFixed(2)
|
|
data.tiempoCorte = isNaN(parseFloat(row.tiempo_corte)) ? "" : parseFloat(row.tiempo_corte).toFixed(2)
|
|
data.totalCorte = isNaN(parseFloat(row.total_corte)) ? "" : parseFloat(row.total_corte).toFixed(2)
|
|
}
|
|
else {
|
|
data.totalCorte = 0
|
|
}
|
|
|
|
data.clicksLibro = isNaN(parseFloat(row.clicks_libro)) ? "" : parseFloat(row.clicks_libro).toFixed(0)
|
|
data.gTintaNegro = isNaN(parseFloat(row.peso_gotas_negro)) ? "" : parseFloat(row.peso_gotas_negro).toFixed(2)
|
|
data.gTintaCyan = isNaN(parseFloat(row.peso_gotas_cyan)) ? "" : parseFloat(row.peso_gotas_cyan).toFixed(2)
|
|
data.gTintaMagenta = isNaN(parseFloat(row.peso_gotas_magenta)) ? "" : parseFloat(row.peso_gotas_magenta).toFixed(2)
|
|
data.gTintaAmarillo = isNaN(parseFloat(row.peso_gotas_amarillo)) ? "" : parseFloat(row.peso_gotas_amarillo).toFixed(2)
|
|
data.clicksPedido = isNaN(parseFloat(row.clicks_pedido)) ? "" : parseFloat(row.clicks_pedido).toFixed(0)
|
|
data.totalClicksPedido = isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)
|
|
data.totalTinta = isNaN(parseFloat(row.precio_tinta)) ? "" : parseFloat(row.precio_tinta).toFixed(2)
|
|
|
|
data.totalImpresion = isNaN(parseFloat(row.precio_click_pedido) + parseFloat(row.precio_tinta) + parseFloat(row.total_corte)) ? "" : (parseFloat(row.precio_click_pedido) + parseFloat(row.precio_tinta) + parseFloat(row.total_corte)).toFixed(2)
|
|
|
|
data.gTintaNegroPed = isNaN(parseFloat(row.peso_gotas_negro_pedido)) ? "" : parseFloat(row.peso_gotas_negro_pedido).toFixed(2)
|
|
data.gTintaCyanPed = isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)
|
|
data.gTintaMagentaPed = isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)
|
|
data.gTintaAmarilloPed = isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)
|
|
|
|
if (!rowId.includes('rot')) {
|
|
data.cobCG = isNaN(parseFloat(row.datosTipologias.cg)) ? "" : parseFloat(row.datosTipologias.cg).toFixed(2)
|
|
data.gotasCG = isNaN(parseFloat(row.num_gotas_cg)) ? "" : parseFloat(row.num_gotas_cg).toFixed(2)
|
|
data.gTintaCG = isNaN(parseFloat(row.peso_gotas_cg)) ? "" : parseFloat(row.peso_gotas_cg).toFixed(2)
|
|
data.gTintaCGPed = isNaN(parseFloat(row.peso_gotas_cg_pedido)) ? "" : parseFloat(row.peso_gotas_cg_pedido).toFixed(2)
|
|
}
|
|
|
|
|
|
data.alto_click = row.alto_click
|
|
}
|
|
|
|
if (rowId == 'lp_faja'){
|
|
data.alto_faja = row.alto_faja;
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
formatRow(d) {
|
|
|
|
var value = '<tr>' +
|
|
'<td></td>' +
|
|
'<td></td>' +
|
|
'<td colspan="10">' +
|
|
'<div class="lp-row">' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.numeroPliegos + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_numeroPliegos" name="' + d.row_id + '_numeroPliegos" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.numeroPliegos + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.pliegosPedido + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_pliegosPedido" name="' + d.row_id + '_pliegosPedido" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.pliegosPedido + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.precioPliego + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_precioPliego" name="' + d.row_id + '_precioPliego" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.precioPliego + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.libro + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_libro" name="' + d.row_id + '_libro" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.libro + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.totalPapelPedido + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_totalPapelPedido" name="' + d.row_id + '_totalPapelPedido" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.totalPapelPedido + '">' +
|
|
'</div>' +
|
|
'<input id="' + d.row_id + '_margenPapelPedido" name="' + d.row_id + '_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.margenPapelPedido + '" style="display: none;">' +
|
|
'<div class="d-flex col-md-auto justify-content-center align-items-center">' +
|
|
'<input id="' + d.row_id + '_checkPapel" name="' + d.row_id + '_checkPapel" class="update-totales" style="bottom:0;width: 15px; padding: 0; margin:0;" type="checkbox" ' + (d.check_papel_total == true ? 'checked' : '') + '>' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.click + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_click" name="' + d.row_id + '_click" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.click + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.costeClicks + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_totalClicks" name="' + d.row_id + '_totalClicks" class="lp-input lp-cell lp-cell-coste ' + d.row_class + '-input" type="text" value="' + (parseFloat(d.totalClicks) - parseFloat(d.margenClicks)).toFixed(2) + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.totalClicksMargen + '</label>' +
|
|
'<input id="' + d.row_id + '_margenClicks" name="' + d.row_id + '_margenClicks" readonly class="lp-input lp-cell lp-cell-margen ' + d.row_class + '-input" type="text" value="' + d.margenClicks + '" style="">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.horas + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_horasMaquina" name="' + d.row_id + '_horasMaquina" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.horasMaquina + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.precioHora + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_precioHora" name="' + d.row_id + '_precioHora" class="lp-input lp-cell lp-cell-disabled ' + d.row_class + '-input" type="text" value="' + d.precioHora + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.precioImpresion + '</label>' +
|
|
'<input readonly id="' + d.row_id + '_precioImpresion" name="' + d.row_id + '_precioImpresion" class="lp-input lp-cell lp-cell-margen ' + d.row_class + '-input" type="text" value="' + (parseFloat(d.precioImpresion) - parseFloat(d.margenImpresion)).toFixed(2) + '">' +
|
|
'</div>' +
|
|
'<div class="lp-cell-auto">' +
|
|
'<label>' + window.language.Presupuestos.precioImpresionMargen + '</label>' +
|
|
'<input id="' + d.row_id + '_margenImpresion" name="' + d.row_id + '_margenImpresion" readonly class="lp-input lp-cell lp-cell-margen ' + d.row_class + '-input" type="text" value="' + d.margenImpresion + '" style="">' +
|
|
'</div>' +
|
|
'<div class="d-flex col-md-auto justify-content-center align-items-center">' +
|
|
'<input id="' + d.row_id + '_checkClicks" name="' + d.row_id + '_checkClicks" class="update-totales" style="bottom:0;width: 15px; padding: 0; margin:0;" type="checkbox" ' + (d.check_impresion_total == true ? 'checked' : '') + '>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</td>'
|
|
|
|
value += '</tr>'
|
|
|
|
if (d.row_id == "lp_faja") {
|
|
value += '<tr>' +
|
|
'<td></td>' +
|
|
'<td></td>' +
|
|
'<td colspan="10">' +
|
|
'<div class="row flex-grow-1 d-flex align-items-end">' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.papelFormatoAlto + ' ' + window.language.Presupuestos.faja +
|
|
'<input id="' + d.row_id + '_altoFaja" name="' + d.row_id + '_altoFaja" class="lp-input lp-cell ' + d.row_class + '-input" type="text" value="' + d.alto_faja + '">' +
|
|
'</div>' +
|
|
'</td>' +
|
|
'</tr>'
|
|
}
|
|
|
|
if (d.maquinaTipo == 'inkjet') {
|
|
value +=
|
|
'<tr>' +
|
|
'<td></td>' +
|
|
'<td></td>' +
|
|
'<td colspan="10">' +
|
|
'<div class="row flex-grow-1 d-flex align-items-end">' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
'<button id="' + d.row_id + '_defecto" name="' + d.row_id + '_defecto" type="button" class="btn btn-label-primary waves-effect lp-button">' + window.language.Presupuestos.porDefecto + '</button>' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.numPagColor +
|
|
'<input type="number" id="' + d.row_id + '_numPagColor" name="' + d.row_id + '_numPagColor" class="lp-cell lp-input no-spinner' + (d.row_id.includes('color') ? '" ' : ' lp-cell-disabled" readonly ') + ' value="' + d.numPagColor + '">' +
|
|
'</div>' +
|
|
((d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.saturacion +
|
|
'<input readonly type="text" id="' + d.row_id + '_saturacion" name="' + d.row_id + '_saturacion" class="lp-cell lp-input lp-cell-disabled" readonly value="100">' +
|
|
'</div>' : '') +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.cobNegro +
|
|
'<input type="number" id="' + d.row_id + '_cobNegro" name="' + d.row_id + '_cobNegro" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.cobNegro + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.cobCyan +
|
|
'<input type="number" id="' + d.row_id + '_cobCyan" name="' + d.row_id + '_cobCyan" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.cobCyan + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.cobMagenta +
|
|
'<input type="number" id="' + d.row_id + '_cobMagenta" name="' + d.row_id + '_cobMagenta" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.cobMagenta + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.cobAmarillo +
|
|
'<input type="number" id="' + d.row_id + '_cobAmarillo" name="' + d.row_id + '_cobAmarillo" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.cobAmarillo + '">' +
|
|
'</div>' +
|
|
((!d.row_id.includes('rot')) ?
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.cobCG +
|
|
'<input type="number" id="' + d.row_id + '_cobCG" name="' + d.row_id + '_cobCG" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.cobCG + '">' +
|
|
'</div>' : '') +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gotaNegro +
|
|
'<input type="number" id="' + d.row_id + '_gotaNegro" name="' + d.row_id + '_gotaNegro" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.gotaNegro + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1 ">' +
|
|
window.language.Presupuestos.gotaColor +
|
|
'<input type="number" id="' + d.row_id + '_gotaColor" name="' + d.row_id + '_gotaColor" class="lp-cell lp-input no-spinner ' + d.row_class + '-input ' + d.row_class + '-tipologia" value="' + d.gotaColor + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1" style="display: grid;" >' +
|
|
window.language.Presupuestos.aFavorFibra +
|
|
'<input type="checkbox" id="' + d.row_id + '_aFavorFibra" name="' + d.row_id + '_aFavorFibra" ' + ((d.aFavorFibra == true || d.aFavorFibra == "true") ? 'checked' : '') + '>' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
'<button id="' + d.row_id + '_vercalculos" name="' + d.row_id + '_vercalculos" type="button" class="btn btn-label-primary waves-effect lp-button">' + window.language.Presupuestos.verCalculos + '</button>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
|
|
'</td>' +
|
|
'</tr>' +
|
|
'<tr class="calculos_' + d.row_id + '" style="display: none;">' +
|
|
'<td></td>' +
|
|
'<td></td>' +
|
|
'<td colspan="10">' +
|
|
'<div class="row flex-grow-1 d-flex align-items-end">' +
|
|
((!d.row_id.includes('rot')) ?
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.factorAltura +
|
|
'<input readonly type="text" id="' + d.row_id + '_factorAltura" name="' + d.row_id + '_factorAltura" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.factorAltura + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.factorAnchura +
|
|
'<input readonly type="text" id="' + d.row_id + '_factorAnchura" name="' + d.row_id + '_factorAnchura" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.factorAnchura + '">' +
|
|
'</div>' : '') +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.clicksMinuto +
|
|
'<input readonly type="text" id="' + d.row_id + '_metrosMinuto" name="' + d.row_id + '_metrosMinuto" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.metrosMinuto + '">' +
|
|
'</div>' +
|
|
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.resolucion +
|
|
'<input readonly type="text" id="' + d.row_id + '_resolucion" name="' + d.row_id + '_resolucion" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.resolucion + '">' +
|
|
'</div>' : '') +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.areaPaginas +
|
|
'<input readonly type="text" id="' + d.row_id + '_areaPaginas" name="' + d.row_id + '_areaPaginas" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.areaPaginas + '">' +
|
|
'</div>' : '') +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gotasNegro +
|
|
'<input readonly type="text" id="' + d.row_id + '_gotasNegro" name="' + d.row_id + '_gotasNegro" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gotasNegro + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gotasCyan +
|
|
'<input readonly type="text" id="' + d.row_id + '_gotasCyan" name="' + d.row_id + '_gotasCyan" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gotasCyan + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gotasMagenta +
|
|
'<input readonly type="text" id="' + d.row_id + '_gotasMagenta" name="' + d.row_id + '_gotasMagenta" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gotasMagenta + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gotasAmarillo +
|
|
'<input readonly type="text" id="' + d.row_id + '_gotasAmarillo" name="' + d.row_id + '_gotasAmarillo" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gotasAmarillo + '">' +
|
|
'</div>' +
|
|
(!(d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gotasCG +
|
|
'<input readonly type="text" id="' + d.row_id + '_gotasCG" name="' + d.row_id + '_gotasCG" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gotasCG + '">' +
|
|
'</div>' : '') +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.precioPagNegro +
|
|
'<input readonly type="text" id="' + d.row_id + '_precioPagNegro" name="' + d.row_id + '_precioPagNegro" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.precioPagNegro + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.precioPagColor +
|
|
'<input readonly type="text" id="' + d.row_id + '_precioPagColor" name="' + d.row_id + '_precioPagColor" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.precioPagColor + '">' +
|
|
'</div>' +
|
|
(d.row_id.includes('rot') ?
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.factorAltura +
|
|
'<input readonly type="text" id="' + d.row_id + '_factorAltura" name="' + d.row_id + '_factorAltura" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.factorAltura + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.factorAnchura +
|
|
'<input readonly type="text" id="' + d.row_id + '_factorAnchura" name="' + d.row_id + '_factorAnchura" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.factorAnchura + '">' +
|
|
'</div>' : '') +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.paginasPliego +
|
|
'<input readonly type="text" id="' + d.row_id + '_paginasPliego" name="' + d.row_id + '_paginasPliego" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.paginasPliego + '">' +
|
|
'</div>' : '') +
|
|
'</div>' +
|
|
'</td>' +
|
|
'</tr>' +
|
|
'<tr class="calculos_' + d.row_id + '" style="display: none;">' +
|
|
'<td></td>' +
|
|
'<td></td>' +
|
|
'<td colspan="10">' +
|
|
'<div class="row flex-grow-1 d-flex align-items-end">' +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.metrosPapelLibro +
|
|
'<input readonly type="text" id="' + d.row_id + '_metrosPapelLibro" name="' + d.row_id + '_metrosPapelLibro" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.metrosPapelLibro + '">' +
|
|
'</div>' +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.metrosPapelTotal +
|
|
'<input readonly type="text" id="' + d.row_id + '_metrosPapelTotal" name="' + d.row_id + '_metrosPapelTotal" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.metrosPapelTotal + '">' +
|
|
'</div>' +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.clicksLibro +
|
|
'<input readonly type="text" id="' + d.row_id + '_clicksLibro" name="' + d.row_id + '_clicksLibro" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.clicksLibro + '">' +
|
|
'</div>' : '') +
|
|
((!d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.saturacion +
|
|
'<input readonly type="text" id="' + d.row_id + '_saturacion" name="' + d.row_id + '_saturacion" class="lp-cell lp-input lp-cell-disabled" readonly value="100">' +
|
|
'</div>' : '') +
|
|
((!d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.paginasPliego +
|
|
'<input readonly type="text" id="' + d.row_id + '_paginasPliego" name="' + d.row_id + '_paginasPliego" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.paginasPliego + '">' +
|
|
'</div>' : '') +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaNegro +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaNegro" name="' + d.row_id + '_gTintaNegro" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaNegro + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaCyan +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaCyan" name="' + d.row_id + '_gTintaCyan" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaCyan + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaMagenta +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaMagenta" name="' + d.row_id + '_gTintaMagenta" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaMagenta + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaAmarillo +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaAmarillo" name="' + d.row_id + '_gTintaAmarillo" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaAmarillo + '">' +
|
|
'</div>' +
|
|
(!(d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaCG +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaCG" name="' + d.row_id + '_gTintaCG" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaCG + '">' +
|
|
'</div>' : '') +
|
|
((!d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.clicksLibro +
|
|
'<input readonly type="text" id="' + d.row_id + '_clicksLibro" name="' + d.row_id + '_clicksLibro" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.clicksLibro + '">' +
|
|
'</div>' : '') +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.clicksPedido +
|
|
'<input readonly type="text" id="' + d.row_id + '_clicksPedido" name="' + d.row_id + '_clicksPedido" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.clicksPedido + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.totalClicks +
|
|
'<input readonly type="text" id="' + d.row_id + '_totalClicksPedido" name="' + d.row_id + '_totalClicksPedido" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.totalClicksPedido + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.totalTinta +
|
|
'<input readonly type="text" id="' + d.row_id + '_totalTinta" name="' + d.row_id + '_totalTinta" class="lp-cell lp-cell-coste lp-input ' + d.row_class + '-input" readonly value="' + d.totalTinta + '">' +
|
|
'</div>' +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.totalCorte +
|
|
'<input readonly type="text" id="' + d.row_id + '_totalCorte" name="' + d.row_id + '_totalCorte" class="lp-cell lp-cell-coste lp-input ' + d.row_class + '-input" readonly value="' + d.totalCorte + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.totalImpresion +
|
|
'<input readonly type="text" id="' + d.row_id + '_totalImpresion" name="' + d.row_id + '_totalImpresion" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.totalImpresion + '">' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</td>' +
|
|
'</tr>' +
|
|
'<tr class="calculos_' + d.row_id + '" style="display: none;">' +
|
|
'<td></td>' +
|
|
'<td></td>' +
|
|
'<td colspan="10">' +
|
|
'<div class="row flex-grow-1 d-flex align-items-end" >' +
|
|
((!d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.resolucion +
|
|
'<input readonly type="text" id="' + d.row_id + '_resolucion" name="' + d.row_id + '_resolucion" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.resolucion + '">' +
|
|
'</div>' : '') +
|
|
((!d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.areaPaginas +
|
|
'<input readonly type="text" id="' + d.row_id + '_areaPaginas" name="' + d.row_id + '_areaPaginas" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.areaPaginas + '">' +
|
|
'</div>' : '') +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.velocidadCorte +
|
|
'<input readonly type="text" id="' + d.row_id + '_velocidadCorte" name="' + d.row_id + '_velocidadCorte" class="lp-cell lp-input lp-cell-disabled" readonly value="' + d.velocidadCorte + '">' +
|
|
'</div>' +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.precioHoraCorte +
|
|
'<input readonly type="text" id="' + d.row_id + '_precioHoraCorte" name="' + d.row_id + '_precioHoraCorte" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.precioHoraCorte + '">' +
|
|
'</div>' +
|
|
(d.row_id.includes('rot') ? '<div class="col-md-12 col-lg-1">' : '<div class="col-md-12 col-lg-1" style="display:none;">') +
|
|
window.language.Presupuestos.tiempoCorte +
|
|
'<input readonly type="text" id="' + d.row_id + '_tiempoCorte" name="' + d.row_id + '_tiempoCorte" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.tiempoCorte + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaNegroPed +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaNegroPed" name="' + d.row_id + '_gTintaNegroPed" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaNegroPed + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaCyanPed +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaCyanPed" name="' + d.row_id + '_gTintaCyanPed" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaCyanPed + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaMagentaPed +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaMagentaPed" name="' + d.row_id + '_gTintaMagentaPed" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaMagentaPed + '">' +
|
|
'</div>' +
|
|
'<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaAmarilloPed +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaAmarilloPed" name="' + d.row_id + '_gTintaAmarilloPed" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaAmarilloPed + '">' +
|
|
'</div>' +
|
|
(!(d.row_id.includes('rot')) ? '<div class="col-md-12 col-lg-1">' +
|
|
window.language.Presupuestos.gTintaCGPed +
|
|
'<input readonly type="text" id="' + d.row_id + '_gTintaCGPed" name="' + d.row_id + '_gTintaCGPed" class="lp-cell lp-cell-disabled lp-input ' + d.row_class + '-input" readonly value="' + d.gTintaCGPed + '">' +
|
|
'</div>' : '') +
|
|
'</div>' +
|
|
'</td>' +
|
|
'</tr>'
|
|
}
|
|
|
|
return $(value).toArray();
|
|
}
|
|
|
|
|
|
getLomoInterior() {
|
|
let lomo = 0;
|
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
var rowData = this.data();
|
|
if (rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
|
|
lomo += parseFloat(rowData.lomo);
|
|
}
|
|
);
|
|
return lomo;
|
|
}
|
|
|
|
|
|
getLomoCubierta() {
|
|
let lomo = 0;
|
|
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
|
var rowData = this.data();
|
|
if (rowData.row_id == 'lp_cubierta')
|
|
lomo += parseFloat(rowData.lomo);
|
|
}
|
|
);
|
|
return lomo;
|
|
}
|
|
|
|
|
|
obtenerLinea(linea = 'lp_bn', fromComparador = false, updatedTipologias = false, input_data = {}) {
|
|
|
|
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) {
|
|
|
|
input_data = {
|
|
papel_generico_id: $('#' + linea + '_papel option:selected').val(),
|
|
papel_generico: $('#' + linea + '_papel option:selected').text().trim(),
|
|
gramaje: $('#' + linea + '_gramaje option:selected').text().trim(),
|
|
maquina_id: $('#' + linea + '_maquina option:selected').val(),
|
|
papel_impresion_id: $('#' + linea + '_papelImpresion option:selected').val()
|
|
}
|
|
if (linea.includes('rot')) {
|
|
input_data.fibra = fromComparador == false ? ($('#lp_rot_color_aFavorFibra').prop('checked') ? 1 : 0) : 1;
|
|
}
|
|
if (linea == 'lp_cubierta') {
|
|
input_data.paginas = parseInt($('#lp_cubierta_paginas option:selected').val());
|
|
}
|
|
else if (linea == 'lp_sobrecubierta' || linea == 'lp_faja') {
|
|
input_data.paginas = 4;
|
|
}
|
|
else if (linea == 'lp_guardas') {
|
|
input_data.paginas = (parseInt($('#tipo_impresion_id').val()) == 1 || parseInt($('#tipo_impresion_id').val()) == 3) ? 8 : 4;
|
|
input_data.paginas_impresion = parseInt($('#lp_guardas_paginas').val());
|
|
}
|
|
else {
|
|
input_data.paginas = parseInt($('#' + linea + '_paginas').val());
|
|
}
|
|
}
|
|
|
|
|
|
if (input_data.maquina_id == undefined || input_data.maquina_id == '') {
|
|
return;
|
|
}
|
|
if (linea != 'lp_guardas' && linea != 'lp_sobrecubierta' && linea != 'lp_faja') {
|
|
if (input_data.paginas == 0)
|
|
return;
|
|
}
|
|
|
|
let uso = 'interior';
|
|
switch (linea) {
|
|
case 'lp_cubierta':
|
|
uso = 'cubierta';
|
|
break;
|
|
case 'lp_sobrecubierta':
|
|
uso = 'sobrecubierta';
|
|
break;
|
|
case 'lp_faja':
|
|
uso = 'faja';
|
|
break;
|
|
case 'lp_guardas':
|
|
uso = 'guardas';
|
|
break;
|
|
case 'lp_rot_bn':
|
|
case 'lp_rot_color':
|
|
uso = 'interior_rot';
|
|
break;
|
|
}
|
|
|
|
let color = 1;
|
|
if (linea == 'lp_bn' || linea == 'lp_bnhq' || linea == 'lp_rot_bn') {
|
|
color = 0;
|
|
}
|
|
else if(linea == 'lp_guardas'){
|
|
if(fromComparador){
|
|
color = $('#tipoImpresion').val().includes('color') ? 1 : 0;
|
|
}
|
|
else{
|
|
for (let i = 0; i < this.table.rows().data().length; i++) {
|
|
let row = this.table.row(i).data();
|
|
if (row.row_id == 'lp_color' || row.row_id == 'lp_colorhq' || row.row_id == 'lp_rot_color') {
|
|
color = 1;
|
|
break;
|
|
}
|
|
}
|
|
color = 0;
|
|
}
|
|
}
|
|
let hq = 1;
|
|
if (linea == 'lp_bn' || linea == 'lp_color' || linea == 'lp_rot_bn' || linea == 'lp_rot_color') {
|
|
hq = 0;
|
|
}
|
|
|
|
var datos = {
|
|
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
|
type: uso,
|
|
color: color,
|
|
hq: hq,
|
|
paginas: input_data.paginas,
|
|
tirada: parseInt($('#tirada').val()),
|
|
merma: parseInt($('#merma').val()),
|
|
ancho: dimension.ancho,
|
|
alto: dimension.alto,
|
|
papel_generico_id: input_data.papel_generico_id,
|
|
papel_generico: input_data.papel_generico,
|
|
gramaje: input_data.gramaje,
|
|
cliente_id: $('#clienteId').find(":selected").val(),
|
|
};
|
|
|
|
if($('#alert-datosLibro').html().includes(window.language.Presupuestos.validation.no_lp_for_merma) &&
|
|
(uso == 'interior' || uso == 'interior_rot')){
|
|
|
|
datos.calcular_merma = 1;
|
|
}
|
|
|
|
if (datos.ancho == 0 || datos.alto == 0 || datos.ancho == '' || datos.alto == '' || isNaN(datos.ancho) || isNaN(datos.alto)) {
|
|
return;
|
|
}
|
|
|
|
if (linea.includes('rot')) {
|
|
if (fromComparador) {
|
|
datos.paginas_negro = parseInt($('#compPaginasNegro').val())
|
|
datos.paginas_color = parseInt($('#compPaginasColor').val())
|
|
}
|
|
else {
|
|
let paginas_color = isNaN(parseInt($('#lp_rot_color_numPagColor').val())) ? 0 : parseInt($('#lp_rot_color_numPagColor').val())
|
|
datos.paginas_negro = input_data.paginas - paginas_color;
|
|
datos.paginas_color = paginas_color;
|
|
}
|
|
datos.a_favor_fibra = fromComparador == false ? ($('#lp_rot_color_aFavorFibra').prop('checked') ? 1 : 0) : 1;
|
|
}
|
|
else if (linea == 'lp_cubierta') {
|
|
datos.solapas = $('#solapas').is(':checked') ? 1 : 0;
|
|
datos.solapas_ancho = $('#solapas').is(':checked') ? parseInt($('#solapas_ancho').val()) : 0;
|
|
datos.lomo = $('#lomo_cubierta').val();
|
|
}
|
|
else if (linea == 'lp_sobrecubierta') {
|
|
datos.solapas = $('#solapas_sobrecubierta').is(':checked') ? 1 : 0;
|
|
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;
|
|
}
|
|
datos = Object.assign(datos, window.token_ajax);
|
|
|
|
// Si es inkjet, existe este check
|
|
if ($('#' + linea + '_aFavorFibra').length) {
|
|
datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1 : 0;
|
|
}
|
|
|
|
if (updatedTipologias && $('#' + linea + '_gotaNegro').length) {
|
|
datos.gota_negro = $('#' + linea + '_gotaNegro').val()
|
|
datos.gota_color = $('#' + linea + '_gotaColor').val()
|
|
datos.negro = $('#' + linea + '_cobNegro').val()
|
|
datos.cyan = $('#' + linea + '_cobCyan').val()
|
|
datos.magenta = $('#' + linea + '_cobMagenta').val()
|
|
datos.amarillo = $('#' + linea + '_cobAmarillo').val()
|
|
if ($('#' + linea + '_cobCG').length) {
|
|
datos.cg = $('#' + linea + '_cobCG').val()
|
|
}
|
|
}
|
|
|
|
new Ajax('/presupuestoadmin/getlinea',
|
|
datos,
|
|
{},
|
|
(response) => {
|
|
if (response.lineas.length > 0) {
|
|
|
|
let borrar_linea = true;
|
|
// Si viene del comparador
|
|
if (dataFromComparador) {
|
|
borrar_linea = false;
|
|
}
|
|
|
|
for (let $i = 0; $i < response.lineas.length; $i++) {
|
|
|
|
// Se cogen los valores de la linea con los datos correspondientes
|
|
if (response.lineas[$i].fields.maquina_id === input_data.maquina_id &&
|
|
response.lineas[$i].fields.papel_generico_id === input_data.papel_generico_id &&
|
|
response.lineas[$i].fields.papel_impresion_id === input_data.papel_impresion_id) {
|
|
|
|
borrar_linea = false;
|
|
|
|
// Si viene del comparador
|
|
if (Object.keys(input_data).length == 0) {
|
|
response.lineas[$i].fields.check_papel_total = $('#' + linea + '_checkPapel').is(":checked") ? 1 : 0
|
|
response.lineas[$i].fields.check_impresion_total = $('#' + linea + '_checkClicks').is(":checked") ? 1 : 0
|
|
|
|
}
|
|
else {
|
|
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;
|
|
}
|
|
}
|
|
if (borrar_linea) {
|
|
self.table.row('#' + linea).remove().draw();
|
|
}
|
|
}
|
|
else {
|
|
let pags = $("#" + linea + "_paginas").val()
|
|
$("." + linea + "-input").val("0")
|
|
$("#" + linea + "_paginas").val(pags)
|
|
|
|
}
|
|
},
|
|
(error) => {
|
|
console.error(error);
|
|
}
|
|
).post();
|
|
|
|
}
|
|
|
|
rellenarDatosLinea(linea, row, fromComparator = false) {
|
|
|
|
if (fromComparator) {
|
|
|
|
let input_data = {
|
|
paginas: row.paginas,
|
|
papel_generico_id: row.papelGenericoId,
|
|
gramaje: row.gramaje,
|
|
papel_impresion_id: row.papelImpresionId,
|
|
maquina_id: row.maquinaId,
|
|
}
|
|
if (linea.includes('guardas')) {
|
|
input_data.paginas_impresion = parseInt($('#compCarasGuardas').select2('data')[0].id);
|
|
}
|
|
this.obtenerLinea(linea, fromComparator, false, input_data)
|
|
}
|
|
else {
|
|
// Se guarda el estado de "ver calculos"
|
|
const mostrar_calculos = ($(".calculos_" + linea).css('display') == 'table-row')
|
|
|
|
// Si viene de hacerlo a mano...
|
|
let data = this.#processRowData(row, linea, linea.replace('_', '-'));
|
|
|
|
let currentRow = this.table.row('#' + linea);
|
|
if (currentRow.length > 0)
|
|
this.table.row('#' + linea).data(data).draw()
|
|
else {
|
|
this.table.row.add(data).draw()
|
|
currentRow = this.table.row('#' + linea);
|
|
}
|
|
|
|
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);
|
|
|
|
|
|
$('#' + linea + '_checkPapel').trigger('change');
|
|
|
|
|
|
this.calcular_mermas()
|
|
|
|
|
|
$(document).trigger('update-presupuesto', {
|
|
update_lineas: false,
|
|
update_servicios: false,
|
|
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' && linea != 'lp_faja' && this.table.row('#lp_cubierta').length > 0) {
|
|
this.obtenerLinea('lp_cubierta', false, false);
|
|
}
|
|
if (mostrar_calculos) {
|
|
$(".calculos_" + linea).css('display', 'table-row')
|
|
}
|
|
}
|
|
|
|
this.table.columns.adjust();
|
|
|
|
this.checkLomo();
|
|
|
|
}
|
|
|
|
checkLomo() {
|
|
|
|
let lomo = 0.0;
|
|
|
|
for (let i = 0; i < this.table.rows().count(); i++) {
|
|
|
|
var rowData = this.table.row(i).data();
|
|
if (rowData.row_id !== 'lp_cubierta' && rowData.row_id !== 'lp_sobrecubierta' && rowData.row_id !== 'lp_guardas' && rowData.row_id !== 'lp_faja') {
|
|
if (rowData.lomo && rowData.lomo !== null && rowData.lomo !== '') {
|
|
lomo += parseFloat(rowData.lomo);
|
|
}
|
|
}
|
|
}
|
|
new Ajax('/presupuestoadmin/checklomointerior',
|
|
{ tipo_impresion_id: $("#tipo_impresion_id").val(), lomo: lomo}, {},
|
|
function (response) {
|
|
if (response.status !== true) {
|
|
popErrorAlert(response.message, 'sk-alert-lomo', false);
|
|
$(window).scrollTop(0);
|
|
}
|
|
else{
|
|
popAlert2Hide('sk-alert-lomo');
|
|
}
|
|
},
|
|
function (error) {
|
|
popErrorAlert(error.statusText? error.statusText : error);
|
|
}
|
|
).get();
|
|
|
|
}
|
|
|
|
|
|
#addEventosLineas(tipoLinea, isInkjet = false) {
|
|
|
|
const self = this;
|
|
|
|
let tipo = 'negro';
|
|
let uso = 'interior';
|
|
switch (tipoLinea) {
|
|
case 'lp_bnhq':
|
|
tipo = 'negrohq';
|
|
break;
|
|
case 'lp_rot_color':
|
|
case 'lp_color':
|
|
tipo = 'color';
|
|
break;
|
|
case 'lp_colorhq':
|
|
case 'lp_cubierta':
|
|
case 'lp_sobrecubierta':
|
|
case 'lp_faja':
|
|
tipo = 'colorhq';
|
|
break
|
|
case 'lp_guardas':
|
|
tipo = 'negrohq';
|
|
for (let i = 0; i < this.table.rows().data().length; i++) {
|
|
let row = this.table.row(i).data();
|
|
if (row.row_id == 'lp_color' || row.row_id == 'lp_colorhq' || row.row_id == 'lp_rot_color') {
|
|
tipo = 'colorhq';
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
switch (tipoLinea) {
|
|
case 'lp_cubierta':
|
|
uso = 'cubierta';
|
|
break;
|
|
case 'lp_sobrecubierta':
|
|
case 'lp_faja':
|
|
uso = 'sobrecubierta';
|
|
break;
|
|
case 'lp_guardas':
|
|
uso = 'guardas';
|
|
break;
|
|
case 'lp_rot_bn':
|
|
case 'lp_rot_color':
|
|
uso = 'rotativa';
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
let select_papel = new ClassSelect($('#' + tipoLinea + '_papel'),
|
|
'/presupuestoadmin/papelgenerico', 'Seleccione papel', false,
|
|
{
|
|
[this.csrf_token]: this.csrf_hash,
|
|
tipo_impresion: () => $("#tipo_impresion_id").val(),
|
|
tirada: () => $('#tirada').val(),
|
|
tipo: tipo,
|
|
uso: uso,
|
|
}, $('body'));
|
|
select_papel.init();
|
|
|
|
|
|
let select_gramaje = new ClassSelect($('#' + tipoLinea + '_gramaje'),
|
|
'/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false,
|
|
{
|
|
[this.csrf_token]: this.csrf_hash,
|
|
papel_generico: () => select_papel.getVal(),
|
|
tipo_impresion: () => $("#tipo_impresion_id").val(),
|
|
tirada: () => $('#tirada').val(),
|
|
tipo: tipo,
|
|
uso: uso,
|
|
}, $('body'));
|
|
select_gramaje.init();
|
|
|
|
let papel_impresion = new ClassSelect($('#' + tipoLinea + '_papelImpresion'),
|
|
'/presupuestoadmin/papelimpresion', 'Seleccione papel', false,
|
|
{
|
|
[this.csrf_token]: this.csrf_hash,
|
|
papel_generico: () => select_papel.getVal(),
|
|
gramaje: () => select_gramaje.getVal(),
|
|
tipo_impresion: () => $("#tipo_impresion_id").val(),
|
|
tipo: tipo,
|
|
uso: uso,
|
|
}, $('body'));
|
|
papel_impresion.init();
|
|
|
|
let merma = uso == 'interior' ? $('#merma').val() : $('#mermacubierta').val();
|
|
uso = ((uso == 'guardas') ? 'interior' : uso);
|
|
|
|
let maquinas = new ClassSelect($('#' + tipoLinea + '_maquina'),
|
|
'/presupuestoadmin/maquinas', 'Seleccione maquina', false,
|
|
{
|
|
[this.csrf_token]: this.csrf_hash,
|
|
ancho: () => this.getDimensionLibro().ancho,
|
|
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(),
|
|
merma: merma,
|
|
papel_impresion: () => papel_impresion.getVal(),
|
|
tipo_impresion: () => $("#tipo_impresion_id").val(),
|
|
tarifa_tipo: tipo,
|
|
uso_tarifa: uso == 'rotativa' ? 'interior' : uso,
|
|
is_rotativa: () => tipoLinea.includes('rot') ? 1 : 0,
|
|
lomo_redondo: () => (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) ? $('#compLomoRedondo').val() : 0,
|
|
lomo: () => uso == 'sobrecubierta' ? this.getLomoCubierta() + this.getLomoInterior() : this.getLomoInterior(),
|
|
}, $('body'));
|
|
maquinas.init();
|
|
|
|
|
|
$('#' + tipoLinea + '_papel').on("change", () => {
|
|
select_gramaje.reset();
|
|
papel_impresion.reset();
|
|
maquinas.reset();
|
|
});
|
|
$('#' + tipoLinea + '_gramaje').on('change', () => {
|
|
papel_impresion.reset();
|
|
maquinas.reset();
|
|
});
|
|
$('#' + tipoLinea + '_papelImpresion').on("change", () => { maquinas.reset(); });
|
|
|
|
$('#' + tipoLinea + '_maquina').on("change", function (event) {
|
|
self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea'
|
|
}.bind(this));
|
|
$('#' + tipoLinea + '_paginas').on("change", function (event) {
|
|
if (tipoLinea != 'lp_sobrecubierta') {
|
|
self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea'
|
|
}
|
|
}.bind(this));
|
|
$('#' + tipoLinea + '_vercalculos').on("click", () => self.verCalculosInkjet(tipoLinea));
|
|
|
|
if (isInkjet) {
|
|
$('.' + tipoLinea.replace('_', '-') + '-tipologia').on("change", () => { this.change_tipologia(tipoLinea); });
|
|
$('#' + 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));
|
|
}
|
|
}
|
|
|
|
|
|
verCalculosInkjet(linea) {
|
|
if ($(".calculos_" + linea).css('display') == 'none')
|
|
$(".calculos_" + linea).css('display', 'table-row')
|
|
else {
|
|
$(".calculos_" + linea).css('display', 'none')
|
|
}
|
|
}
|
|
|
|
change_aFavorFibra(linea) {
|
|
|
|
let paginas_ok = true;
|
|
|
|
if (linea.includes('lp_bn') || linea.includes('lp_color') || linea.includes('lp_rot')) {
|
|
paginas_ok = parseInt($('#' + linea + '_paginas').val()) > 0;
|
|
}
|
|
|
|
if (paginas_ok &&
|
|
parseInt($('#' + linea + '_papel option:selected').val()) > 0 &&
|
|
$('#' + linea + '_gramaje option:selected').text().length > 0 &&
|
|
parseInt($('#' + linea + '_papelImpresion option:selected').val()) > 0
|
|
) {
|
|
var rowData = this.table.row('#' + linea).data()
|
|
rowData.aFavorFibra = $('#' + linea + '_aFavorFibra').prop('checked')
|
|
this.table.row('#' + linea).data(rowData).draw(false)
|
|
|
|
this.obtenerLinea(linea, false, true);
|
|
}
|
|
}
|
|
|
|
change_tipologia(linea) {
|
|
|
|
let paginas_ok = true;
|
|
|
|
if (linea.includes('lp_bn') || linea.includes('lp_color') || linea.includes('lp_rot')) {
|
|
paginas_ok = parseInt($('#' + linea + '_paginas').val()) > 0;
|
|
}
|
|
|
|
if (paginas_ok &&
|
|
parseInt($('#' + linea + '_papel option:selected').val()) > 0 &&
|
|
$('#' + linea + '_gramaje option:selected').text().length > 0 &&
|
|
parseInt($('#' + linea + '_papelImpresion option:selected').val()) > 0
|
|
) {
|
|
|
|
this.obtenerLinea(linea, false, true, {});
|
|
}
|
|
}
|
|
|
|
|
|
lp_por_defecto(linea) {
|
|
|
|
let paginas_ok = true;
|
|
|
|
if (linea.includes('lp_bn') || linea.includes('lp_color') || linea.includes('lp_rot')) {
|
|
paginas_ok = parseInt($('#' + linea + '_paginas').val()) > 0;
|
|
}
|
|
|
|
if (paginas_ok &&
|
|
parseInt($('#' + linea + '_papel option:selected').val()) > 0 &&
|
|
$('#' + linea + '_gramaje option:selected').text().length > 0 &&
|
|
parseInt($('#' + linea + '_papelImpresion option:selected').val()) > 0
|
|
) {
|
|
|
|
this.obtenerLinea(linea);
|
|
}
|
|
}
|
|
|
|
#insertarLineaComparador(e) {
|
|
|
|
const self = this;
|
|
|
|
if (e.target.id.includes("Plana") || e.target.id.includes("Rotativa")) {
|
|
|
|
for (let i = self.table.rows().data().length - 1; i >= 0; i--) {
|
|
let row = self.table.row(i).data();
|
|
|
|
if (row.row_id.includes('lp_bn') || row.row_id.includes('lp_color') || row.row_id.includes('lp_rot')) {
|
|
self.table.row(i).remove();
|
|
}
|
|
}
|
|
self.table.draw();
|
|
|
|
|
|
if (e.target.id.includes("Plana")) {
|
|
|
|
var rows = $("#tableCompIntPlana").DataTable().rows('.selected').data().toArray();
|
|
|
|
for (const row of rows) {
|
|
if (row['tipo'] == 'bn') {
|
|
this.rellenarDatosLinea('lp_bn', row, true);
|
|
}
|
|
else if (row['tipo'] == 'bnhq') {
|
|
this.rellenarDatosLinea('lp_bnhq', row, true);
|
|
}
|
|
else if (row['tipo'] == 'color') {
|
|
this.rellenarDatosLinea('lp_color', row, true);
|
|
}
|
|
else if (row['tipo'] == 'colorhq') {
|
|
this.rellenarDatosLinea('lp_colorhq', row, true);
|
|
}
|
|
}
|
|
}
|
|
if (e.target.id.includes("Rotativa")) {
|
|
|
|
var rows = $("#tableCompIntRotativa").DataTable().rows('.selected').data().toArray();
|
|
for (const row of rows) {
|
|
if (row['paginasColor'] == 0) {
|
|
this.rellenarDatosLinea('lp_rot_bn', row, true);
|
|
}
|
|
else if (row['paginasColor'] > 0) {
|
|
this.rellenarDatosLinea('lp_rot_color', row, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
else if (e.target.id.includes("Cubierta")) {
|
|
|
|
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_cubierta') || row.row_id.includes('lp_sobrecubierta')) {
|
|
self.table.row(i).remove(); // Eliminar fila
|
|
}
|
|
}
|
|
self.table.draw();
|
|
|
|
|
|
var rows = $("#tableCompCubierta").DataTable().rows('.selected').data().toArray();
|
|
for (const row of rows) {
|
|
if (row.tipo == 'cubierta') {
|
|
this.rellenarDatosLinea('lp_cubierta', row, true);
|
|
|
|
if ($('#acabado_cubierta_id').val() > 0)
|
|
$(document).trigger('add-servicio-lineas', 'acabadoCubierta');
|
|
|
|
}
|
|
if (row.tipo == 'sobrecubierta') {
|
|
this.rellenarDatosLinea('lp_sobrecubierta', row, true);
|
|
if ($('#acabado_sobrecubierta_id').val() > 0)
|
|
$(document).trigger('add-servicio-lineas', 'acabadoSobrecubierta');
|
|
}
|
|
}
|
|
}
|
|
|
|
else if (e.target.id.includes("Guardas")) {
|
|
|
|
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_guardas')) {
|
|
self.table.row(i).remove(); // Eliminar fila
|
|
}
|
|
}
|
|
self.table.draw();
|
|
|
|
var rows = $("#tableCompGuardas").DataTable().rows('.selected').data().toArray();
|
|
for (const row of rows) {
|
|
this.rellenarDatosLinea('lp_guardas', row, true);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
if ($('#acabado_faja_id').val() > 0)
|
|
$(document).trigger('add-servicio-lineas', 'acabadoFaja');
|
|
}
|
|
|
|
|
|
$(document).trigger('update-presupuesto', {
|
|
update_lineas: false,
|
|
update_servicios: true,
|
|
update_envios: true,
|
|
update_resumen: true,
|
|
update_tiradas_alternativas: true
|
|
});
|
|
|
|
showBreadCrumbSaveButton(true);
|
|
}
|
|
}
|
|
|
|
export default LineasPresupuesto; |