mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
comprobando presupuestos
This commit is contained in:
@ -27,6 +27,7 @@ class DatosGenerales {
|
||||
this.papelFormatoId = this.domItem.find("#papelFormatoId");
|
||||
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
|
||||
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
|
||||
this.formatoEstandar = this.domItem.find("#formatoEstandar");
|
||||
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
|
||||
this.altoPersonalizado = this.domItem.find("#papelFormatoAlto");
|
||||
|
||||
@ -346,6 +347,14 @@ class DatosGenerales {
|
||||
this.coleccion.val(datos.coleccion);
|
||||
this.referenciaCliente.val(datos.referenciaCliente);
|
||||
|
||||
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
|
||||
this.cliente.setVal(datos.clienteId);
|
||||
$(this.cliente).trigger('change');
|
||||
|
||||
if (datos.excluirRotativa) {
|
||||
this.excluirRotativa.prop('checked', true);
|
||||
}
|
||||
|
||||
this.tirada1.val(parseInt(datos.tirada));
|
||||
if (datos.tirada2)
|
||||
this.tirada2.val(parseInt(datos.tirada2));
|
||||
@ -355,8 +364,10 @@ class DatosGenerales {
|
||||
this.tirada4.val(parseInt(datos.tirada4));
|
||||
|
||||
if (datos.papelFormatoPersonalizado) {
|
||||
this.checkFormatoPersonalizado.prop(':checked', datos.checkFormatoPersonalizado);
|
||||
this.checkFormatoPersonalizado.trigger('change');
|
||||
this.checkFormatoPersonalizado.prop('checked', true);
|
||||
this.formatoEstandar.addClass('d-none');
|
||||
this.formatoPersonalizado.removeClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_id');
|
||||
this.altoPersonalizado.val(datos.papelFormatoAlto);
|
||||
this.anchoPersonalizado.val(datos.papelFormatoAncho);
|
||||
}
|
||||
@ -365,41 +376,27 @@ class DatosGenerales {
|
||||
this.formatoLibro.setVal(datos.papelFormatoId);
|
||||
}
|
||||
|
||||
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
|
||||
this.cliente.setVal(datos.clienteId);
|
||||
$(this.cliente).trigger('change');
|
||||
|
||||
this.paginas.val(parseInt(datos.paginas));
|
||||
this.paginasNegro.val(parseInt(datos.paginasNegro));
|
||||
this.paginasColor.val(parseInt(datos.paginasColor));
|
||||
this.paginasColor.trigger('change');
|
||||
this.paginasColor.val(parseInt(datos.paginasColor)).trigger('change');
|
||||
|
||||
this.pagColorConsecutivas.prop('checked', datos.paginasColorConsecutivas);
|
||||
if (datos.paginasColorConsecutivas) {
|
||||
this.divPapelDiferente.removeClass('d-none');
|
||||
this.papelDiferente.prop('checked', datos.papelInteriorDiferente).trigger('change');
|
||||
}
|
||||
this.posPaginasColor.val(datos.posPaginasColor);
|
||||
|
||||
/*
|
||||
|
||||
this.papelFormatoId = this.domItem.find("#papelFormatoId");
|
||||
this.checkFormatoPersonalizado = this.domItem.find("#papelFormatoPersonalizado");
|
||||
this.formatoPersonalizado = this.domItem.find("#formatoPersonalizado");
|
||||
this.anchoPersonalizado = this.domItem.find("#papelFormatoAncho");
|
||||
this.altoPersonalizado = this.domItem.find("#papelFormatoAlto");
|
||||
this.paginasCuadernillo.val(datos.paginasCuadernillo);
|
||||
|
||||
this.fresado = $(this.domItem.find("#fresado")[0]);
|
||||
this.cosido = $(this.domItem.find("#cosido")[0]);
|
||||
if (datos.tipo != "") {
|
||||
this.tiposLibro.removeClass('selected');
|
||||
this.tiposLibro.find('.image-presupuesto').removeClass('selected');
|
||||
this.domItem.find('#' + datos.tipo).addClass('selected');
|
||||
}
|
||||
|
||||
this.tiposLibro = this.domItem.find(".tipo-libro");
|
||||
|
||||
|
||||
this.paginasCuadernillo = this.domItem.find("#paginasCuadernillo");
|
||||
this.pagColorConsecutivas = this.domItem.find("#pagColorConsecutivas");
|
||||
this.divPapelDiferente = this.domItem.find("#divPapelDiferente");
|
||||
this.papelDiferente = this.domItem.find("#papelDiferente");
|
||||
this.divPosPaginasColor = this.domItem.find("#divPosPaginasColor");
|
||||
this.posPaginasColor = this.domItem.find("#posPaginasColor");
|
||||
|
||||
this.ivaReducido = this.domItem.find("#ivaReducido");
|
||||
this.excluirRotativa = this.domItem.find("#excluirRotativa");
|
||||
this.prototipo = this.domItem.find("#prototipo");*/
|
||||
this.prototipo.prop('checked', datos.prototipo);
|
||||
this.ivaReducido.val(datos.ivaReducido? 1: 0).trigger('change');
|
||||
}
|
||||
|
||||
getDimensionLibro() {
|
||||
@ -452,13 +449,13 @@ class DatosGenerales {
|
||||
#handleFormatoLibro() {
|
||||
|
||||
if (this.checkFormatoPersonalizado.is(':checked')) {
|
||||
this.formatoLibro.item.hide();
|
||||
this.formatoPersonalizado.show();
|
||||
this.formatoEstandar.addClass('d-none');
|
||||
this.formatoPersonalizado.removeClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_id');
|
||||
}
|
||||
else {
|
||||
this.formatoLibro.item.show();
|
||||
this.formatoPersonalizado.hide();
|
||||
this.formatoEstandar.removeClass('d-none');
|
||||
this.formatoPersonalizado.addClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_ancho');
|
||||
this.formValidation.revalidateField('papel_formato_alto');
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class Direcciones {
|
||||
|
||||
init() {
|
||||
|
||||
$("#clienteId").on('change', this.#handleChangeCliente.bind(this));
|
||||
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
|
||||
|
||||
this.direccionesCliente.init();
|
||||
this.btnAdd.on('click', this.#insertDireccion.bind(this));
|
||||
@ -44,7 +44,74 @@ class Direcciones {
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datos, datosGenerales) {
|
||||
|
||||
self = this;
|
||||
|
||||
try {
|
||||
|
||||
let tiradas_envio = [datosGenerales.tirada];
|
||||
if (datosGenerales.tirada2) {
|
||||
tiradas_envio.push(datosGenerales.tirada2);
|
||||
}
|
||||
if (datosGenerales.tirada3) {
|
||||
tiradas_envio.push(datosGenerales.tirada3);
|
||||
}
|
||||
if (datosGenerales.tirada4) {
|
||||
tiradas_envio.push(datosGenerales.tirada4);
|
||||
}
|
||||
tiradas_envio.sort((a, b) => a - b);
|
||||
|
||||
setTimeout(() => {
|
||||
tiradas_envio.forEach(tirada => {
|
||||
self.insertTirada(tirada);
|
||||
});
|
||||
}, 0);
|
||||
|
||||
setTimeout(function () {
|
||||
$(`#containerTiradasEnvios .tirada-envio input[tirada="${datosGenerales.tirada}"]`).trigger('click');
|
||||
}, 0);
|
||||
|
||||
|
||||
for (let i = 0; i < datos.length; i++) {
|
||||
|
||||
let id = datos[i].id;
|
||||
let unidades = datos[i].unidades;
|
||||
let entregaPalets = datos[i].palets;
|
||||
let divId = "dirEnvio-1";
|
||||
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
|
||||
if (direccionesActuales.length > 0) {
|
||||
// the the lass item
|
||||
let last = direccionesActuales[direccionesActuales.length - 1];
|
||||
divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
|
||||
}
|
||||
|
||||
if (id == null || id <= 0 || id == undefined)
|
||||
return;
|
||||
if (unidades == null || unidades <= 0 || unidades == undefined)
|
||||
return;
|
||||
|
||||
let peticion = new Ajax('/misdirecciones/get/' + id, {}, {},
|
||||
(response) => {
|
||||
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
|
||||
tarjeta.setUnidades(unidades);
|
||||
tarjeta.setEntregaPalets(entregaPalets);
|
||||
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
|
||||
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
|
||||
this.divDirecciones.append(tarjeta.card);
|
||||
this.direcciones.push(tarjeta);
|
||||
},
|
||||
() => {
|
||||
console.error('Error getting address');
|
||||
});
|
||||
|
||||
peticion.get();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
$('#loader').modal('hide');
|
||||
}
|
||||
}
|
||||
|
||||
initValidation() {
|
||||
|
||||
@ -248,7 +315,7 @@ class Direcciones {
|
||||
}
|
||||
|
||||
|
||||
#handleChangeCliente() {
|
||||
handleChangeCliente() {
|
||||
|
||||
this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
||||
this.direccionesCliente.empty();
|
||||
|
||||
@ -25,9 +25,15 @@ class DisenioCubierta {
|
||||
this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas");
|
||||
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
|
||||
|
||||
this.papelGuardas = this.domItem.find("#papelGuardas");
|
||||
this.guardasImpresas = this.domItem.find("#guardasImpresas");
|
||||
this.cabezada = this.domItem.find("#cabezada");
|
||||
|
||||
this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada");
|
||||
this.estucadoMate = this.domItem.find("#estucadoMate");
|
||||
|
||||
this.divPapelCubierta = this.domItem.find("#divPapelCubierta");
|
||||
|
||||
this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta");
|
||||
this.gramaje = this.domItem.find(".check-gramaje-cubierta");
|
||||
this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta"));
|
||||
@ -38,8 +44,16 @@ class DisenioCubierta {
|
||||
|
||||
this.checksGramaje = $('.check-gramaje-cubierta');
|
||||
|
||||
this.cubiertaPlastificado = this.domItem.find("#plastificado");
|
||||
this.cubiertaBarniz = this.domItem.find("#barniz");
|
||||
this.cubiertaEstampado = this.domItem.find("#estampado");
|
||||
this.cubiertaRetractilado = this.domItem.find("#retractilado");
|
||||
|
||||
this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta");
|
||||
this.sobrecubierta = this.domItem.find("#addSobrecubierta");
|
||||
this.papelSobrecubierta = this.domItem.find("#papelSobrecubierta");
|
||||
this.plastificadoSobrecubierta = this.domItem.find("#plastificadoSobrecubierta");
|
||||
|
||||
this.configuracionFaja = this.domItem.find(".config-faja");
|
||||
this.faja = this.domItem.find("#addFaja");
|
||||
|
||||
@ -113,6 +127,63 @@ class DisenioCubierta {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta) {
|
||||
|
||||
if (datosCubierta.lomoRedondo) {
|
||||
this.tapaDuraLomoRedondo.trigger('click');
|
||||
}
|
||||
else {
|
||||
if (datosCubierta.tapa == "dura") {
|
||||
this.tapaDuraLomoRecto.trigger('click');
|
||||
}
|
||||
else {
|
||||
this.tapaBlanda.trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
if (datosCubierta.tapa == "dura") {
|
||||
this.papelGuardas.val(datosGuardas.papel.code + "_" + datosGuardas.gramaje).trigger('change');
|
||||
this.guardasImpresas.val(datosGuardas.paginas).trigger('change');
|
||||
this.cabezada.val(datosCubierta.cabezada).trigger('change');
|
||||
}
|
||||
else {
|
||||
this.carasCubierta.val(datosCubierta.caras).trigger('change');
|
||||
if (datosCubierta.solapas) {
|
||||
this.conSolapas.trigger('click');
|
||||
this.tamanioSolapasCubierta.val(datosCubierta.solapas_ancho);
|
||||
|
||||
}
|
||||
else {
|
||||
this.sinSolapas.trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
this.divPapelCubierta.find(`[cod="${datosCubierta.papel.code}"]`).addClass('selected');
|
||||
|
||||
setTimeout(function () {
|
||||
$(`#divGramajeCubierta .gramaje-cubierta input[data-value="${datosCubierta.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
|
||||
this.cubiertaPlastificado.val(datosCubierta.plastificado).trigger('change');
|
||||
this.cubiertaBarniz.val(datosCubierta.barniz).trigger('change');
|
||||
this.cubiertaEstampado.val(datosCubierta.estampado).trigger('change');
|
||||
if (datosCubierta.retractilado) {
|
||||
setTimeout(() => {
|
||||
this.cubiertaRetractilado.trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (datosSobrecubierta) {
|
||||
this.sobrecubierta.trigger('click');
|
||||
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
|
||||
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
|
||||
this.plastificadoSobrecubierta.val(datosSobrecubierta.plastificado).trigger('change');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
initValidation() {
|
||||
|
||||
const stepper = this.validatorStepper;
|
||||
@ -356,13 +427,13 @@ class DisenioCubierta {
|
||||
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text();
|
||||
guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1];
|
||||
guardas.gramaje = papelGuardas.split(' ')[2];
|
||||
guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").text();
|
||||
guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").text();
|
||||
}
|
||||
else {
|
||||
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val();
|
||||
guardas.papel = papelGuardas.split('_')[0];
|
||||
guardas.gramaje = papelGuardas.split('_')[1];
|
||||
guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").val();
|
||||
guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").val();
|
||||
}
|
||||
return guardas;
|
||||
}
|
||||
|
||||
@ -7,6 +7,9 @@ class DisenioInterior {
|
||||
this.validatorStepper = validatorStepper;
|
||||
|
||||
this.disenioInterior = this.domItem.find(".disenio-interior");
|
||||
this.divPapelInterior = this.domItem.find("#divPapelInterior");
|
||||
this.divPapelInteriorColor = this.domItem.find("#divPapelInteriorColor");
|
||||
this.divGramajeInterior = this.domItem.find("#divGramajeInterior");
|
||||
this.papelInterior = this.domItem.find(".papel-interior");
|
||||
|
||||
this.negroEstandar = this.domItem.find("#negroEstandar");
|
||||
@ -108,6 +111,78 @@ class DisenioInterior {
|
||||
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datos, papelInteriorDiferente) {
|
||||
|
||||
if (papelInteriorDiferente) {
|
||||
|
||||
if (datos.negro) {
|
||||
if (datos.negro.tipo.includes("Premium")) {
|
||||
this.negroPremium.addClass('selected');
|
||||
}
|
||||
else {
|
||||
this.negroEstandar.addClass('selected');
|
||||
}
|
||||
|
||||
this.divPapelInterior.find(`[cod="${datos.negro.papel.code}"]`).addClass('selected');
|
||||
|
||||
setTimeout(function () {
|
||||
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.negro.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
|
||||
}
|
||||
if (datos.color) {
|
||||
if (datos.color.tipo.includes("Premium")) {
|
||||
this.colorPremium_color.addClass('selected');
|
||||
}
|
||||
else {
|
||||
this.colorEstandar_color.addClass('selected');
|
||||
}
|
||||
|
||||
this.divPapelInteriorColor.find(`[cod="${datos.color.papel.code}"]`).addClass('selected');
|
||||
|
||||
setTimeout(function () {
|
||||
$(`#divGramajeInteriorColor .gramaje-interior-color input[data-value="${datos.color.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
if (datos.color) {
|
||||
if (datos.color.tipo.includes("Premium")) {
|
||||
this.colorPremium.addClass('selected');
|
||||
}
|
||||
else {
|
||||
this.colorEstandar.addClass('selected');
|
||||
}
|
||||
this.divPapelInterior.find(`[cod="${datos.color.papel.code}"]`).addClass('selected');
|
||||
|
||||
setTimeout(function () {
|
||||
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.color.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
else {
|
||||
if (datos.negro.tipo.includes("Premium")) {
|
||||
this.negroPremium.addClass('selected');
|
||||
}
|
||||
else {
|
||||
this.negroEstandar.addClass('selected');
|
||||
}
|
||||
// mismo papel y gramaje
|
||||
this.divPapelInterior.find(`[cod="${datos.negro.papel.code}"]`).addClass('selected');
|
||||
|
||||
setTimeout(function () {
|
||||
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.negro.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
initValidation() {
|
||||
|
||||
const stepper = this.validatorStepper;
|
||||
@ -311,7 +386,7 @@ class DisenioInterior {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@ -324,30 +399,29 @@ class DisenioInterior {
|
||||
if (this.papelInterior.filter('.selected').length > 0) {
|
||||
|
||||
if (this.papelInterior_color.filter('.selected').length > 0) {
|
||||
if(forResumen)
|
||||
{
|
||||
if (forResumen) {
|
||||
return {
|
||||
negro: $(this.papelInterior.filter('.selected').find('.form-label')).text(),
|
||||
color: $(this.papelInterior_color.filter('.selected').find('.form-label')).text(),
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return {
|
||||
negro: this.papelInterior.filter('.selected').attr('cod'),
|
||||
color: this.papelInterior_color.filter('.selected').attr('cod')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (this.interiorColor.filter('.d-none').length > 0){
|
||||
if(forResumen){
|
||||
if (this.interiorColor.filter('.d-none').length > 0) {
|
||||
if (forResumen) {
|
||||
return $(this.papelInterior.filter('.selected').find('.form-label')).text();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return this.papelInterior.filter('.selected').attr('cod')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
return null;
|
||||
}
|
||||
@ -361,9 +435,9 @@ class DisenioInterior {
|
||||
getGramaje() {
|
||||
|
||||
try {
|
||||
if (this.interiorColor.filter('.d-none').length == 0){
|
||||
if (this.interiorColor.filter('.d-none').length == 0) {
|
||||
let values = {
|
||||
negro: this.gramaje.filter(':checked') .attr('data-value'),
|
||||
negro: this.gramaje.filter(':checked').attr('data-value'),
|
||||
color: this.gramaje_color.filter(':checked').attr('data-value')
|
||||
}
|
||||
if (values.negro && values.color) {
|
||||
@ -371,10 +445,10 @@ class DisenioInterior {
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return this.gramaje.filter(':checked').attr('data-value');
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class PresupuestoCliente {
|
||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
$(".calcular-presupuesto").on('change', ()=>{});
|
||||
$(".calcular-presupuesto").on('change', () => { });
|
||||
this.#cargarPresupuesto();
|
||||
const successMessage = sessionStorage.getItem('message');
|
||||
if (successMessage) {
|
||||
@ -73,10 +73,10 @@ class PresupuestoCliente {
|
||||
sessionStorage.removeItem('message');
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -103,13 +103,13 @@ class PresupuestoCliente {
|
||||
if (datos_to_check.direcciones) {
|
||||
delete datos_to_check.direcciones;
|
||||
}
|
||||
if(datos_to_check.posPaginasColor){
|
||||
if (datos_to_check.posPaginasColor) {
|
||||
delete datos_to_check.posPaginasColor;
|
||||
}
|
||||
|
||||
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
||||
try {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
$('#loader').modal('show');
|
||||
}, 0);
|
||||
|
||||
@ -238,13 +238,12 @@ class PresupuestoCliente {
|
||||
{},
|
||||
(response) => {
|
||||
$('#loader').modal('hide');
|
||||
console.log(response);
|
||||
if (this.datos["confirmar"] || window.location.href.includes("add")) {
|
||||
if(response.status){
|
||||
if (response.status) {
|
||||
sessionStorage.setItem('message', response.message);
|
||||
window.location.href = response.url + '/' + response.status;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
|
||||
}
|
||||
}
|
||||
@ -272,29 +271,35 @@ class PresupuestoCliente {
|
||||
, "sk-alert-2", false);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
popAlert2Hide();
|
||||
}
|
||||
|
||||
if (response.tiradas && response.tiradas.length) {
|
||||
|
||||
let tiradas = {...response.tiradas};
|
||||
tiradas = Object.keys(tiradas).map((key) => tiradas[key]);
|
||||
tiradas.sort((a, b) => a - b);
|
||||
this.divTiradasPrecios.empty();
|
||||
|
||||
for (let i = 0; i < response.tiradas.length; i++) {
|
||||
for (let i = 0; i < tiradas.length; i++) {
|
||||
new tarjetaTiradasPrecio(
|
||||
this.divTiradasPrecios,
|
||||
('precio-tiradas-' + response.tiradas[i]),
|
||||
response.tiradas[i],
|
||||
(parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2),
|
||||
tiradas[i],
|
||||
(parseFloat(response.precio_u[i]) * parseInt(tiradas[i])).toFixed(2),
|
||||
response.precio_u[i]
|
||||
);
|
||||
|
||||
if (this.actualizarTiradasEnvio)
|
||||
this.direcciones.insertTirada(response.tiradas[i]);
|
||||
this.direcciones.insertTirada(tiradas[i]);
|
||||
|
||||
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
|
||||
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
|
||||
}
|
||||
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
|
||||
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
|
||||
setTimeout(() => {
|
||||
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
// DEBUG
|
||||
//console.log(response);
|
||||
@ -350,6 +355,7 @@ class PresupuestoCliente {
|
||||
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
|
||||
|
||||
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
||||
|
||||
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
|
||||
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
|
||||
@ -362,6 +368,7 @@ class PresupuestoCliente {
|
||||
|
||||
cubierta: {
|
||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
lomoRedondo: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0,
|
||||
papelCubierta: this.disenioCubierta.getPapel(),
|
||||
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
||||
cabezada: this.disenioCubierta.getCabezada(),
|
||||
@ -429,16 +436,30 @@ class PresupuestoCliente {
|
||||
{},
|
||||
{},
|
||||
(response) => {
|
||||
if (response.status === 1) {
|
||||
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
/*this.disenioInterior.cargarDatos(response);
|
||||
this.disenioCubierta.cargarDatos(response);
|
||||
this.direcciones.cargarDatos(response);
|
||||
*/
|
||||
}
|
||||
console.log(response);
|
||||
$('#loader').modal('hide');
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
|
||||
setTimeout(() => {
|
||||
if (response.status === 1) {
|
||||
|
||||
this.lc.val(parseFloat(response.data.lc).toFixed(2));
|
||||
this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||
|
||||
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
this.direcciones.handleChangeCliente();
|
||||
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
|
||||
setTimeout(() => {
|
||||
this.checkForm({ target: { id: 'tirada' } });
|
||||
this.validationStepper.next();
|
||||
this.validationStepper.next();
|
||||
this.validationStepper.next();
|
||||
this.validationStepper.next();
|
||||
$('#loader').modal('hide');
|
||||
}, 0);
|
||||
}
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
}, 0);
|
||||
},
|
||||
() => {
|
||||
$('#loader').modal('hide');
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import previewFormas from "../preview.js";
|
||||
|
||||
class Resumen {
|
||||
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta, direcciones) {
|
||||
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
@ -39,18 +41,39 @@ class Resumen {
|
||||
this.divSobrecubierta = $(this.domItem.find("#divResumenSobrecubierta"));
|
||||
this.papelSobrecubierta = $(this.domItem.find("#resumenPapelSobrecubierta"));
|
||||
this.gramajeSobrecubierta = $(this.domItem.find("#resumenGramajeSobrecubierta"));
|
||||
this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapasSobrecubierta"));
|
||||
this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobrecubierta"));
|
||||
this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapaSobrecubierta"));
|
||||
this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobreCubierta"));
|
||||
|
||||
this.precio_unidad = $(this.domItem.find("#resumenPrecioU"));
|
||||
this.total_base = $(this.domItem.find("#resumenTotalBase"));
|
||||
this.iva_porcentaje = $(this.domItem.find("#resumenIvaPorcentaje"));
|
||||
this.iva = $(this.domItem.find("#resumenIva"));
|
||||
this.total = $(this.domItem.find("#resumenTotal"));
|
||||
|
||||
this.divPreview = $(this.domItem.find("#pv_ec_shape"));
|
||||
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
|
||||
this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this));
|
||||
}
|
||||
|
||||
|
||||
#btnPreview() {
|
||||
|
||||
if(this.divPreview.hasClass('d-none')){
|
||||
this.btnPreviewCubierta.text('Ocultar desarrollo cubierta');
|
||||
this.divPreview.removeClass('d-none');
|
||||
this.generate();
|
||||
}
|
||||
else{
|
||||
this.btnPreviewCubierta.text('Mostrar desarrollo cubierta');
|
||||
this.divPreview.addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
generate() {
|
||||
@ -58,10 +81,32 @@ class Resumen {
|
||||
this.titulo.text(this.datosGenerales.titulo.val());
|
||||
this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id')));
|
||||
|
||||
if (this.datosGenerales.checkFormatoPersonalizado.is(':checked'))
|
||||
this.formato.text(this.datosGenerales.anchoPersonalizado.val() + ' x ' + this.datosGenerales.altoPersonalizado.val());
|
||||
else
|
||||
let ancho = 0, alto = 0;
|
||||
if (this.datosGenerales.checkFormatoPersonalizado.is(':checked')) {
|
||||
ancho = parseFloat(this.datosGenerales.anchoPersonalizado.val());
|
||||
alto = parseFloat(this.datosGenerales.altoPersonalizado.val());
|
||||
this.formato.text(ancho + ' x ' + alto);
|
||||
}
|
||||
|
||||
else {
|
||||
ancho = parseFloat(this.datosGenerales.papelFormatoId.find('option:selected').text().split(" x ")[0]);
|
||||
alto = parseFloat(this.datosGenerales.papelFormatoId.find('option:selected').text().split(" x ")[1]);
|
||||
this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text());
|
||||
}
|
||||
|
||||
new previewFormas(
|
||||
this.divPreview,
|
||||
this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
"resumen",
|
||||
{
|
||||
ancho: ancho,
|
||||
alto: alto,
|
||||
lomo: $('#lc').val() === '' ? parseFloat('0.0') : parseFloat($('#lc').val()),
|
||||
solapas: this.disenioCubierta.getSolapasCubierta(),
|
||||
lomoRedondo: this.disenioCubierta.tapaDuraLomoRedondo.hasClass('selected'),
|
||||
}
|
||||
).previewEsquemaCubierta();
|
||||
|
||||
this.paginas.text(this.datosGenerales.paginas.val());
|
||||
this.paginasColor.text(this.datosGenerales.paginasColor.val());
|
||||
@ -105,7 +150,7 @@ class Resumen {
|
||||
this.itemsCubiertaTapaBlanda.addClass('d-none');
|
||||
const guardas = this.disenioCubierta.getGuardas(true);
|
||||
this.papelGuardas.text(guardas.papel + ' ' + guardas.gramaje);
|
||||
this.guardasImpresas.text(guardas.guardasImpresas);
|
||||
this.guardasImpresas.text(guardas.caras);
|
||||
this.cabezada.text(this.disenioCubierta.getCabezada(true));
|
||||
|
||||
}
|
||||
|
||||
1046
httpdocs/assets/js/safekat/pages/preview.js
Normal file
1046
httpdocs/assets/js/safekat/pages/preview.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user