mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadidos todos los servicios a falta del solapas grandes (incluido plegado de guardas)
This commit is contained in:
@ -246,6 +246,9 @@ class PresupuestoAdminEdit {
|
||||
|
||||
datos = { ...datos, ...this.resumen.getData() };
|
||||
|
||||
this.comparador.generateCompJSON();
|
||||
datos.comparador_json_data = $('#comparador_json_data').val();
|
||||
|
||||
return datos;
|
||||
}
|
||||
|
||||
|
||||
@ -399,7 +399,7 @@ class Comparador {
|
||||
this.gramajeSobrecubierta.setOption(datos.json_data.sobrecubierta.gramaje, datos.json_data.sobrecubierta.gramaje);
|
||||
}
|
||||
if (datos.json_data.guardas) {
|
||||
this.carasGuardas.val(datos.json_data.guardas.paginas).trigger('change');
|
||||
this.carasGuardas.val(datos.json_data.guardas.paginas_impresion).trigger('change');
|
||||
this.papelGuardas.setOption(datos.json_data.guardas.papel_id, datos.json_data.guardas.papel_nombre);
|
||||
this.gramajeGuardas.setOption(datos.json_data.guardas.gramaje, datos.json_data.guardas.gramaje);
|
||||
}
|
||||
@ -970,7 +970,7 @@ class Comparador {
|
||||
|
||||
papel_generico = { id: this.papelGuardas.getVal(), nombre: this.papelGuardas.getText() };
|
||||
gramaje = this.gramajeGuardas.getVal();
|
||||
paginas = this.carasGuardas.val();
|
||||
paginas = 8;
|
||||
|
||||
}
|
||||
|
||||
@ -1019,6 +1019,7 @@ class Comparador {
|
||||
datos.datosPedido.isCosido = 1;
|
||||
datos.datosPedido.isHq = 1;
|
||||
datos.paginas_color = datos.datosPedido.paginas;
|
||||
datos.paginas_impresion = this.carasGuardas.val();
|
||||
}
|
||||
|
||||
|
||||
@ -1471,6 +1472,127 @@ class Comparador {
|
||||
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
|
||||
}
|
||||
}
|
||||
|
||||
generateCompJSON() {
|
||||
|
||||
let data = {}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
let bn_obj = {};
|
||||
try {
|
||||
bn_obj = {
|
||||
"bn": {
|
||||
'paginas': $('#compPaginasNegro').val(),
|
||||
'papel_id': $('#compPapelNegro').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
}
|
||||
$.extend(data, bn_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
let bnhq_obj = {};
|
||||
try {
|
||||
bnhq_obj = {
|
||||
"bnhq": {
|
||||
'paginas': $('#compPaginasNegrohq').val(),
|
||||
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
$.extend(data, bnhq_obj);
|
||||
}
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
let color_obj = {};
|
||||
try {
|
||||
color_obj = {
|
||||
"color": {
|
||||
'paginas': $('#compPaginasColor').val(),
|
||||
'papel_id': $('#compPapelColor').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
$.extend(data, color_obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
let colorhq_obj = {};
|
||||
try {
|
||||
colorhq_obj = {
|
||||
"colorhq": {
|
||||
'paginas': $('#compPaginasColorhq').val(),
|
||||
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
$.extend(data, colorhq_obj);
|
||||
}
|
||||
|
||||
let cubierta_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) {
|
||||
}
|
||||
$.extend(data, cubierta_obj);
|
||||
|
||||
let sobrecubierta_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) {
|
||||
}
|
||||
$.extend(data, sobrecubierta_obj);
|
||||
|
||||
if ($('#compCarasGuardas').length > 0) {
|
||||
let guardas_obj = {};
|
||||
try {
|
||||
guardas_obj = {
|
||||
"guardas": {
|
||||
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
|
||||
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
|
||||
'gramaje': $('#compGramajeGuardas').select2('data')[0].text.trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
$.extend(data, guardas_obj);
|
||||
|
||||
}
|
||||
|
||||
const data_str = JSON.stringify(data)
|
||||
$('#comparador_json_data').val(data_str)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -117,9 +117,7 @@ class DatosLibro {
|
||||
changePrototipo() {
|
||||
|
||||
if (this.prototipo.prop('checked')) {
|
||||
|
||||
$(document).trigger('add-servicio-lineas', 'prototipo');
|
||||
this.ferro.prop('checked', true).trigger('change');
|
||||
}
|
||||
else {
|
||||
$(document).trigger('remove-servicio-lineas', 'prototipo');
|
||||
@ -127,18 +125,18 @@ class DatosLibro {
|
||||
}
|
||||
|
||||
|
||||
checkRetractilado(element) {
|
||||
checkRetractilado(event) {
|
||||
|
||||
switch (element.id) {
|
||||
switch (event.currentTarget.id) {
|
||||
case 'retractilado':
|
||||
if ($('#' + element.id).prop('checked')) {
|
||||
if ($('#' + event.currentTarget.id).prop('checked')) {
|
||||
$('#retractilado5').prop('checked', false);
|
||||
$(document).trigger('remove-servicio-lineas', 'retractilado5');
|
||||
$(document).trigger('add-servicio-lineas', 'retractilado');
|
||||
}
|
||||
break;
|
||||
case 'retractilado5':
|
||||
if ($('#' + element.id).prop('checked')) {
|
||||
if ($('#' + event.currentTarget.id).prop('checked')) {
|
||||
$('#retractilado').prop('checked', false);
|
||||
$(document).trigger('remove-servicio-lineas', 'retractilado');
|
||||
$(document).trigger('add-servicio-lineas', 'retractilado5');
|
||||
|
||||
@ -31,6 +31,9 @@ class LineasPresupuesto {
|
||||
|
||||
const row = $(this).closest('tr');
|
||||
const data = self.table.row(row).data()
|
||||
if(data.row_id == 'lp_guardas'){
|
||||
$(document).trigger('remove-servicio-lineas', 'plegado_guardas');
|
||||
}
|
||||
self.table.row(row)
|
||||
.remove()
|
||||
.draw();
|
||||
@ -1386,6 +1389,8 @@ class LineasPresupuesto {
|
||||
const self = this;
|
||||
const dimension = this.getDimensionLibro();
|
||||
|
||||
const dataFromComparador = fromComparador;
|
||||
|
||||
if (Object.keys(input_data).length == 0) {
|
||||
|
||||
input_data = {
|
||||
@ -1406,7 +1411,7 @@ class LineasPresupuesto {
|
||||
}
|
||||
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 option:selected').val());
|
||||
input_data.paginas_impresion = parseInt($('#compCarasGuardas').select2('data')[0].id);
|
||||
}
|
||||
else {
|
||||
input_data.paginas = parseInt($('#' + linea + '_paginas').val());
|
||||
@ -1521,7 +1526,7 @@ class LineasPresupuesto {
|
||||
|
||||
let borrar_linea = true;
|
||||
// Si viene del comparador
|
||||
if (Object.keys(input_data).length == 0) {
|
||||
if (dataFromComparador) {
|
||||
borrar_linea = false;
|
||||
}
|
||||
|
||||
@ -1546,7 +1551,7 @@ class LineasPresupuesto {
|
||||
}
|
||||
self.rellenarDatosLinea(linea, response.lineas[$i].fields);
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (borrar_linea) {
|
||||
@ -1569,16 +1574,18 @@ class LineasPresupuesto {
|
||||
|
||||
rellenarDatosLinea(linea, row, fromComparator = false) {
|
||||
|
||||
|
||||
if (fromComparator) {
|
||||
|
||||
var input_data = {
|
||||
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 {
|
||||
@ -1876,7 +1883,7 @@ class LineasPresupuesto {
|
||||
}
|
||||
}
|
||||
|
||||
if (e.target.id.includes("Cubierta")) {
|
||||
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
|
||||
@ -1905,23 +1912,23 @@ class LineasPresupuesto {
|
||||
}
|
||||
}
|
||||
|
||||
if (e.target.id.includes("Guardas")) {
|
||||
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
|
||||
|
||||
self.table.rows().data().toArray().forEach((row, index) => {
|
||||
const rowIdx = self.table.row(index).index(); // Obtener el índice actual de la fila
|
||||
if (row.row_id.includes('lp_guardas')) {
|
||||
self.table.row(rowIdx).remove(); // Eliminar fila por índice
|
||||
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);
|
||||
}
|
||||
/* TO-DO
|
||||
servicioGuardas(true)
|
||||
*/
|
||||
|
||||
$(document).trigger('add-servicio-lineas', 'plegado_guardas');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -113,14 +113,83 @@ class Servicios {
|
||||
else if (servicio == 'solapas') {
|
||||
this.ServiciosManipulado.addSolapas();
|
||||
}
|
||||
|
||||
|
||||
else if (servicio == 'ferro'){
|
||||
const id = $('#ferro').attr('service-id');
|
||||
this.serviciosExtra.getPresupuestoExtra(id);
|
||||
}
|
||||
else if (servicio == 'prototipo'){
|
||||
const id = $('#prototipo').attr('service-id');
|
||||
this.serviciosExtra.getPresupuestoExtra(id);
|
||||
}
|
||||
else if (servicio == 'retractilado'){
|
||||
const id = $('#retractilado').attr('service-id');
|
||||
this.serviciosAcabado.getPresupuestoAcabado(id);
|
||||
}
|
||||
else if (servicio == 'retractilado5'){
|
||||
const id = $('#retractilado5').attr('service-id');
|
||||
this.serviciosAcabado.getPresupuestoAcabado(id);
|
||||
}
|
||||
else if(servicio == 'plegado_guardas'){
|
||||
const id = $('#plegado_guardas').attr('service-id');
|
||||
for(let i = 0; i < this.ServiciosManipulado.table.rows().count(); i++){
|
||||
var data = this.ServiciosManipulado.table.row(i).data();
|
||||
if (data.tarifa_id == id) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
this.ServiciosManipulado.getPresupuestoManipulado(id);
|
||||
}
|
||||
}
|
||||
|
||||
removeServicio(event, servicio) {
|
||||
if (servicio == 'solapas') {
|
||||
this.ServiciosManipulado.removeSolapas();
|
||||
}
|
||||
else if (servicio == 'ferro'){
|
||||
const id = $('#ferro').attr('service-id');
|
||||
this.serviciosExtra.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (servicio == 'prototipo'){
|
||||
const id = $('#prototipo').attr('service-id');
|
||||
this.serviciosExtra.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (servicio == 'retractilado'){
|
||||
const id = $('#retractilado').attr('service-id');
|
||||
this.serviciosAcabado.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (servicio == 'retractilado5'){
|
||||
const id = $('#retractilado5').attr('service-id');
|
||||
this.serviciosAcabado.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(servicio == 'plegado_guardas'){
|
||||
const id = $('#plegado_guardas').attr('service-id');
|
||||
this.ServiciosManipulado.table.rows().every(function () {
|
||||
var data = this.data();
|
||||
if (data.tarifa_id == id) {
|
||||
this.remove().draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async updateServicios() {
|
||||
|
||||
Reference in New Issue
Block a user