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:
@ -1,18 +1,3 @@
|
||||
/*******************************
|
||||
* Eventos asociados a elementos HTML
|
||||
*******************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#compPosPaginasColor').on("keyup", function () {
|
||||
computarPaginasColor(this.value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@ -23,163 +8,6 @@ $('#compPosPaginasColor').on("keyup", function () {
|
||||
*******************************/
|
||||
|
||||
|
||||
function getRowFromLineaRot(linea) {
|
||||
|
||||
$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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function clearIntLineas(is_color) {
|
||||
//$("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect();
|
||||
var tabla = $('#tableCompIntPlana').DataTable();
|
||||
tabla
|
||||
.rows(function (idx, data, node) {
|
||||
return data['tipo'].includes(is_color ? 'color' : 'bn');
|
||||
})
|
||||
.remove()
|
||||
.draw();
|
||||
//$('#tableCompIntPlana').DataTable().clear().draw();
|
||||
$('#insertarPlanaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
|
||||
function clearCubierta() {
|
||||
|
||||
var tabla = $('#tableCompCubierta').DataTable();
|
||||
tabla
|
||||
.rows(function (idx, data, node) {
|
||||
return data['tipo'] === 'cubierta';
|
||||
})
|
||||
.remove()
|
||||
.draw();
|
||||
if(tabla.rows().count()==0)
|
||||
$('#insertarCubiertaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
function clearSobrecubierta() {
|
||||
|
||||
|
||||
var tabla = $('#tableCompCubierta').DataTable();
|
||||
tabla
|
||||
.rows(function (idx, data, node) {
|
||||
return data['tipo'] === 'sobrecubierta';
|
||||
})
|
||||
.remove()
|
||||
.draw();
|
||||
if(tabla.rows().count()==0)
|
||||
$('#insertarCubiertaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
function clearGuardas() {
|
||||
|
||||
$('#tableCompGuardas').DataTable().clear().draw();
|
||||
$('#insertarGuardasBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
function clearIntRot() {
|
||||
|
||||
$('#errorComRot').html('');
|
||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
||||
$('#insertarRotativaBtn').css('display', 'none');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function selectIntRotLineas() {
|
||||
|
||||
$("#tableCompIntRotativa").DataTable().rows('.selected').deselect();
|
||||
|
||||
let value_total = 0.00;
|
||||
|
||||
if ($("#tableCompIntRotativa").DataTable().rows().count() > 0) {
|
||||
|
||||
$("#tableCompIntRotativa").DataTable().row(0).nodes().to$().toggleClass('selected');
|
||||
value_total = parseFloat($("#tableCompIntRotativa").DataTable().rows(0).data()[0]['total'])
|
||||
};
|
||||
|
||||
|
||||
$('#total_comp_rot').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function selectCubiertaLineas() {
|
||||
|
||||
$("#tableCompCubierta").DataTable().rows('.selected').deselect();
|
||||
|
||||
cubierta_selected = false;
|
||||
sobrecubierta_selected = false;
|
||||
|
||||
if ($("#tableCompCubierta").DataTable().rows().count() > 0) {
|
||||
|
||||
$("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') {
|
||||
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
cubierta_selected = true;
|
||||
}
|
||||
if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') {
|
||||
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||
sobrecubierta_selected = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var table = $("#tableCompCubierta").DataTable();
|
||||
var rows = table.rows('.selected').indexes();
|
||||
var data = table.rows(rows).data();
|
||||
|
||||
var value_total = 0.00;
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
|
||||
value_total += parseFloat(data[i]['total'])
|
||||
}
|
||||
|
||||
|
||||
$('#total_comp_cubierta').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function selectGuardasLineas() {
|
||||
|
||||
@ -197,140 +25,12 @@ function selectGuardasLineas() {
|
||||
$('#total_comp_guardas').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function getIDsComparador(is_color, is_hq) {
|
||||
|
||||
if (!is_color) {
|
||||
if (is_hq) {
|
||||
var papel = '#compPapelNegrohq';
|
||||
var gramaje = '#compGramajeNegrohq';
|
||||
var paginas = '#compPaginasNegrohq';
|
||||
}
|
||||
else {
|
||||
var papel = '#compPapelNegro';
|
||||
var gramaje = '#compGramajeNegro';
|
||||
var paginas = '#compPaginasNegro';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_hq) {
|
||||
var papel = '#compPapelColorhq';
|
||||
var gramaje = '#compGramajeColorhq';
|
||||
var paginas = '#compPaginasColorhq';
|
||||
}
|
||||
else {
|
||||
var papel = '#compPapelColor';
|
||||
var gramaje = '#compGramajeColor';
|
||||
var paginas = '#compPaginasColor';
|
||||
}
|
||||
}
|
||||
return {
|
||||
papel: papel,
|
||||
gramaje: gramaje,
|
||||
paginas: paginas,
|
||||
}
|
||||
}
|
||||
|
||||
function getDimensionLibro() {
|
||||
var ancho = 0;
|
||||
var alto = 0;
|
||||
|
||||
// TO-DO
|
||||
if (!document.getElementById('papelFormatoPersonalizado').checked) {
|
||||
ancho = 170//parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]);
|
||||
alto = 240//parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]);
|
||||
|
||||
}
|
||||
|
||||
else if (document.getElementById('papelFormatoPersonalizado').checked) {
|
||||
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
|
||||
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
|
||||
}
|
||||
return {
|
||||
ancho: ancho,
|
||||
alto: alto
|
||||
}
|
||||
}
|
||||
|
||||
function checkInputsForRotativa() {
|
||||
|
||||
// Si es color, el gramaje y el papel tiene que ser el mismo
|
||||
try {
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
if ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ($('#tipoImpresion').select2('data')[0].id == 'negro') {
|
||||
if ($('#compPapelNegro').select2('data')[0].id.length > 0 &&
|
||||
$('#compGramajeNegro').select2('data')[0].text.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function fillIntPlana(data, is_color, is_hq) {
|
||||
let sorted = data.lineas.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(getRowFromLineaInt(is_color ? (is_hq ? 'colorhq' : 'color') : (is_hq ? 'bnhq' : 'bn'), linea))
|
||||
.draw()
|
||||
})
|
||||
}
|
||||
|
||||
function fillIntRot(data) {
|
||||
let sorted = data.lineas.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") {
|
||||
$('#tableCompIntRotativa').DataTable().row
|
||||
.add(getRowFromLineaRot(linea))
|
||||
.draw()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function fillCubierta(data) {
|
||||
|
||||
let sorted = data.lineas.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")
|
||||
$('#tableCompCubierta').DataTable().row
|
||||
.add(getRowFromLineaInt('cubierta', linea))
|
||||
.draw()
|
||||
})
|
||||
}
|
||||
|
||||
function fillSobrecubierta(data) {
|
||||
|
||||
let sorted = data.lineas.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")
|
||||
$('#tableCompCubierta').DataTable().row
|
||||
.add(getRowFromLineaInt('sobrecubierta', linea))
|
||||
.draw()
|
||||
})
|
||||
}
|
||||
|
||||
function fillGuardas(data) {
|
||||
|
||||
@ -345,130 +45,5 @@ function fillGuardas(data) {
|
||||
})
|
||||
}
|
||||
|
||||
function clearCompTable() {
|
||||
|
||||
$('#insertarPlanaBtn').addClass('d-none')
|
||||
$('#insertarRotativaBtn').addClass('d-none')
|
||||
$('#total_comp_plana').html('0.00')
|
||||
$('#total_comp_rot').html('0.00')
|
||||
}
|
||||
|
||||
function 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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user