falta preview resumen

This commit is contained in:
2024-10-16 03:45:10 +02:00
parent 2c5ea4d7ba
commit b5924dceb5
19 changed files with 1132 additions and 126 deletions

View File

@ -0,0 +1,94 @@
class Direccionmodal {
constructor(modal, saveCallback) {
this.modal = modal;
this.saveCallback = saveCallback;
this.alias = $(this.modal.find('#add_alias'));
this.att = $(this.modal.find('#add_att'));
this.email = $(this.modal.find('#add_email'));
this.direccion = $(this.modal.find('#add_direccion'));
this.pais = $(this.modal.find('#add_pais_id'));
this.municipio = $(this.modal.find('#add_municipio'));
this.provincia = $(this.modal.find('#add_provincia'));
this.cp = $(this.modal.find('#add_cp'));
this.telefono = $(this.modal.find('#add_telefono'));
this.btnCancel = $(this.modal.find('#cancelAdd'));
this.btnSave = $(this.modal.find('#saveAdd'));
this.error = $(this.modal.find('.texto-error'));
}
init() {
this.btnCancel.on('click', () => {
this.modal.modal("hide");
});
this.modal.on('hidden.bs.modal', () => {
this.error.addClass('d-none');
this.alias.val("");
this.att.val("");
this.email.val("");
this.direccion.val("");
this.pais.val("").trigger('change');
this.municipio.val("");
this.provincia.val("");
this.cp.val("");
this.telefono.val("");
this.btnSave.off('click');
});
this.pais.on('change', () => {
var nombre_pais = $("#add_pais_id option:selected").text().trim();
if (nombre_pais.localeCompare('España') == 0) {
$('#divPais').removeClass('col-lg-12').addClass('col-lg-6')
$('#divMunicipio').removeClass('col-lg-12').addClass('col-lg-6')
$('.spain-data').css('display', 'inline')
}
else {
$('.spain-data').css('display', 'none')
$('#divPais').removeClass('col-lg-6').addClass('col-lg-12')
$('#divMunicipio').removeClass('col-lg-6').addClass('col-lg-12')
}
});
this.btnSave.on('click', () => {
if (this.#validatemodal()) {
this.saveCallback();
}
else {
$(this.modal.find('.texto-error')).removeClass('d-none');
}
});
this.modal.modal('show');
}
#validatemodal() {
if(this.alias.val() == "" || this.att.val() == "" || this.direccion.val() == "" || this.municipio.val() == "" || this.cp.val() == "" ){
return false;
}
if(this.pais.children("option:selected").val() < 1)
return false;
return true;
}
getData() {
return {
alias: this.alias.val(),
att: this.att.val(),
email: this.email.val(),
direccion: this.direccion.val(),
pais_id: this.pais.children("option:selected").val(),
municipio: this.municipio.val(),
provincia: this.provincia.val(),
cp: this.cp.val(),
telefono: this.telefono.val()
}
}
}
export default Direccionmodal;

View File

@ -1,6 +1,9 @@
import ClassSelect from '../../components/select2.js';
import Ajax from '../../components/ajax.js';
import tarjetaDireccion from '../../components/tarjetaDireccionPresupuesto.js';
import SelectorTiradaEnvio from './selectorTiradaEnvio.js';
import DireccionForm from '../../components/modalDireccion.js';
class Direcciones {
@ -12,11 +15,15 @@ class Direcciones {
this.unidadesAdd = this.domItem.find('#unidadesEnvio');
this.btnAdd = this.domItem.find('#insertarDireccion');
this.btnNew = this.domItem.find('#nuevaDireccion');
this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
this.direccionesCliente = new ClassSelect($("#direcciones"), '/clientedirecciones/menuitems');
this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2');
this.divDirecciones = $(this.domItem.find('#divDirecciones'));
this.divTiradas = this.domItem.find('#containerTiradasEnvios');
this.checksTiradasEnvio = $('.tirada-envio');
this.direcciones = [];
@ -31,16 +38,51 @@ class Direcciones {
this.direccionesCliente.init();
this.btnAdd.on('click', this.#insertDireccion.bind(this));
this.btnNew.on('click', this.#nuevaDireccion.bind(this));
}
initValidation() {
const stepper = this.validatorStepper;
this.formValidation = FormValidation.formValidation(this.wizardStep, {
fields: {
div_error_envios: {
validators: {
callback: {
callback: () => {
const div = $('#divErrorEnvios'); // Selecciona el div
div.find('.fv-plugins-message-container').remove();
if ($('.check-tirada-envio:checked').length > 0) {
let unidades = parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada'));
let total_envio = 0;
// se recorre el array this.direcciones
this.direcciones.forEach(direccion => {
total_envio += parseInt(direccion.getUnidades());
});
if (total_envio == unidades) {
return true;
}
}
div.append(`
<div class="fv-plugins-message-container invalid-feedback">
<div data-field="div_tipo_cubierta" data-validator="callback">
El total de unidades enviadas no se corresponde con las unidades del pedido
</div>
</div>
`);
return false;
},
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
@ -52,7 +94,7 @@ class Direcciones {
// field is the field name
// ele is the field element
switch (field) {
case ' ':
case 'div_error_envios':
return '.col-sm-10';
default:
return '.col-sm-3';
@ -68,24 +110,79 @@ class Direcciones {
}
getDirecciones(){
getDirecciones() {
let direcciones = this.divDirecciones.find('.direccion-cliente')
if(direcciones.length > 0){
if (direcciones.length > 0) {
direcciones.forEach(element => {
});
}
}
insertTirada(tirada) {
const self = this;
let tarjeta = new SelectorTiradaEnvio(this.divTiradas, 'tiradaEnvios-' + tirada, tirada);
let customOption = tarjeta.card.find('.check-tirada-envio');
customOption.on('click', function () {
self.#handleTiradaEnvio(customOption);
});
}
#nuevaDireccion() {
let dialog = new DireccionForm($("#addressModal"), function () {
try {
let data = dialog.getData();
data.cliente_id = $("#clienteId").select2('data')[0].id;
new Ajax(
'/misdirecciones/add',
data,
{},
() => { dialog.modal.modal('hide') },
() => { dialog.modal.modal('hide') }
).post();
}
catch (e) {
console.error(e);
dialog.modal.modal('hide');
}
});
dialog.init();
}
#handleTiradaEnvio(customOption) {
const el = customOption[0];
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option').classList.remove('checked')
})
}
el.closest('.custom-option').classList.add('checked')
} else {
el.closest('.custom-option').classList.remove('checked')
}
}
#insertDireccion() {
self = this;
try {
let id = this.direccionesCliente.getValue();
let id = this.direccionesCliente.getVal();
let unidades = this.unidadesAdd.val();
let entregaPalets = this.entregaPieCallero.is(':checked');
let dirId = "dirEnvio-" + id;
@ -111,7 +208,7 @@ class Direcciones {
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({ "id": id, "unidades": unidades, "enPallets": entregaPalets});
this.direcciones.push(tarjeta);
self.divDirecciones.trigger('change');
$('#loader').hide();
},
@ -139,7 +236,8 @@ class Direcciones {
#editUnits(event) {
let tarjeta = $(event.currentTarget.closest('.direccion-cliente'));
let id = $(event.currentTarget.closest('.direccion-cliente')).id;
let tarjeta = this.direcciones.find(direccion => direccion.id == id).card;
let unidades = tarjeta.find('.unidades').text().split(' ')[0];
let modal = $('#modalInput');
@ -170,7 +268,7 @@ class Direcciones {
tarjeta.remove();
this.divDirecciones.trigger('change');
this.direcciones = this.direcciones.filter(direccion => direccion.id != id);
}
}

View File

@ -23,7 +23,7 @@ class DisenioCubierta {
this.sinSolapas = this.domItem.find("#solapasCubiertaNo");
this.conSolapas = this.domItem.find("#solapasCubiertaSi");
this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas");
this.tamanioSolapasCubierta = this.domItem.find("#solapasCubierta");
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada");
this.estucadoMate = this.domItem.find("#estucadoMate");
@ -254,10 +254,12 @@ class DisenioCubierta {
if (this.solapasCubierta.hasClass("selected").length == 0)
return null;
else {
if (this.solapasCubierta.hasClass("selected").attr("id") == "solapasCubiertaNo")
if (this.sinSolapas.hasClass("selected"))
return false;
else if (this.conSolapas.hasClass("selected"))
return parseInt(this.tamanioSolapasCubierta.val());
else
parseInt(this.tamanioSolapasCubierta.val());
return null;
}
}
catch (error) {
@ -284,7 +286,7 @@ class DisenioCubierta {
try {
if(this.divGramajeCubierta.hasClass("d-none"))
if (this.divGramajeCubierta.hasClass("d-none"))
return null;
if (this.gramaje.filter(':checked').length > 0)
@ -298,13 +300,26 @@ class DisenioCubierta {
}
}
getAcabados() {
getAcabados(forResumen = false) {
try {
let acabados = {};
acabados.plastificado = this.domItem.find("#plastificado ").children("option:selected").val();
acabados.barniz = this.domItem.find("#barniz").children("option:selected").val();
acabados.estampado = this.domItem.find("#estampado").children("option:selected").val();
acabados.retractilado = this.domItem.find("#retractilado").hasClass('selected') ? true : false;
if (forResumen) {
acabados = 'Plastificado ' + this.domItem.find("#plastificado").children("option:selected").text();
if (this.domItem.find("#barniz").children("option:selected").val() != 'NONE')
acabados += ", Barniz UVI " + this.domItem.find("#barniz").children("option:selected").text();
if (this.domItem.find("#estampado").children("option:selected").val() != 'NONE')
acabados += ", Estampado " + this.domItem.find("#estampado").children("option:selected").text();
if (this.domItem.find("#retractilado").hasClass('selected')) {
acabados += ", Retractilado ";
}
return acabados;
}
else {
acabados.plastificado = this.domItem.find("#plastificado ").children("option:selected").val();
acabados.barniz = this.domItem.find("#barniz").children("option:selected").val();
acabados.estampado = this.domItem.find("#estampado").children("option:selected").val();
acabados.retractilado = this.domItem.find("#retractilado").hasClass('selected') ? true : false;
}
return acabados;
} catch (e) {
return null;
@ -312,20 +327,23 @@ class DisenioCubierta {
}
getCabezada() {
getCabezada(forResumen = false) {
try {
if (this.tapaBlanda.hasClass("selected"))
return false;
else
return this.domItem.find("#cabezada").children("option:selected").val();
if (forResumen)
return this.domItem.find("#cabezada").children("option:selected").text();
else
return this.domItem.find("#cabezada").children("option:selected").val();
} catch (e) {
return null;
}
}
getGuardas() {
getGuardas(forResumen = false) {
try {
if (this.tapaBlanda.hasClass("selected")) {
@ -333,10 +351,19 @@ class DisenioCubierta {
}
else {
let guardas = {};
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();
if (forResumen) {
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();
}
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();
}
return guardas;
}
@ -345,20 +372,30 @@ class DisenioCubierta {
}
}
getSobrecubierta() {
getSobrecubierta(forResumen = false) {
try {
if (!this.sobrecubierta.is(":checked")) {
return false;
}
else {
let sobrecubierta = {};
let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val();
sobrecubierta.papel = papel.split('_')[0];
sobrecubierta.gramaje = papel.split('_')[1];
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
sobrecubierta.plastificado = this.domItem.find("#plastificadoSobrecubierta").children("option:selected").val();
return sobrecubierta;
if (forResumen) {
let sobrecubierta = {};
const papel = this.domItem.find("#papelSobrecubierta").children("option:selected").text();
sobrecubierta.papel = papel.split(' ')[0] + ' ' + papel.split(' ')[1];
sobrecubierta.gramaje = papel.split(' ')[2];
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
sobrecubierta.plastificado = 'Plastificado ' + this.domItem.find("#plastificadoSobrecubierta").children("option:selected").text();
}
else {
let sobrecubierta = {};
let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val();
sobrecubierta.papel = papel.split('_')[0];
sobrecubierta.gramaje = papel.split('_')[1];
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
sobrecubierta.plastificado = this.domItem.find("#plastificadoSobrecubierta").children("option:selected").val();
return sobrecubierta;
}
}
} catch (e) {
@ -389,12 +426,12 @@ class DisenioCubierta {
}
}
#handleCarasCubierta(){
#handleCarasCubierta() {
// Si es a dos caras
if(this.carasCubierta.val() == 4){
if (this.carasCubierta.val() == 4) {
this.cartulinaEstucada.addClass("d-none");
}
else{
else {
this.cartulinaEstucada.removeClass("d-none");
}
}
@ -420,7 +457,7 @@ class DisenioCubierta {
$(".papel-cubierta").removeClass("selected");
if (this.tapaBlanda.hasClass("selected")) {
if(this.carasCubierta.val() == 2){
if (this.carasCubierta.val() == 2) {
this.cartulinaEstucada.removeClass("d-none");
}
this.divGramajeCubierta.addClass("d-none");

View File

@ -318,19 +318,36 @@ class DisenioInterior {
}
getPapel() {
getPapel(forResumen = false) {
try {
if (this.papelInterior.filter('.selected').length > 0) {
if (this.papelInterior_color.filter('.selected').length > 0) {
return {
negro: this.papelInterior.filter('.selected').attr('cod'),
color: this.papelInterior_color.filter('.selected').attr('cod')
if(forResumen)
{
return {
negro: $(this.papelInterior.filter('.selected').find('.form-label')).text(),
color: $(this.papelInterior_color.filter('.selected').find('.form-label')).text(),
}
}
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){
return $(this.papelInterior.filter('.selected').find('.form-label')).text();
}
else{
return this.papelInterior.filter('.selected').attr('cod')
}
}
if (this.interiorColor.filter('.d-none').length > 0)
return this.papelInterior.filter('.selected').attr('cod')
else
return null;
}

View File

@ -2,6 +2,7 @@ import DatosGenerales from './datosGenerales.js';
import DisenioInterior from './disenioInterior.js';
import DisenioCubierta from './disenioCubierta.js';
import Direcciones from './direcciones.js';
import Resumen from './resumen.js';
import Ajax from '../../components/ajax.js';
@ -26,6 +27,7 @@ class PresupuestoCliente {
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.resumen = new Resumen($("#resumen-libro"), this.datosGenerales, this.disenioInterior, this.disenioCubierta, this.direcciones);
this.divTiradasPrecios = $("#divTiradasPrecio");
@ -34,6 +36,8 @@ class PresupuestoCliente {
{}, this.datos,
this.#procesarPresupuesto.bind(this),
() => { $('#loader').hide(); });
this.actualizarTiradasEnvio = false;
}
@ -49,7 +53,7 @@ class PresupuestoCliente {
document.querySelector('.select2-search__field').focus();
});
this.validationStepper._element.addEventListener('shown.bs-stepper', this.buttonsHandler.bind(this));
this.validationStepper._element.addEventListener('shown.bs-stepper', this.stepperHandler.bind(this));
this.datosGenerales.init();
this.disenioInterior.init();
@ -63,9 +67,27 @@ class PresupuestoCliente {
checkForm(event) {
if (event.target.id === 'divDirecciones') {
this.actualizarTiradasEnvio = false;
if(this.direcciones.direcciones.length == 1 && this.direcciones.direcciones[0].getEntregaPalets() == false) {
return;
}
}
else {
this.actualizarTiradasEnvio = true;
this.direcciones.divTiradas.empty();
}
this.#getDatos();
if (Object.values(this.datos).every(this.#isValidDataForm)) {
this.divTiradasPrecios.empty();
let datos_to_check = this.datos;
if (datos_to_check.direcciones) {
delete datos_to_check.direcciones;
}
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try {
$('#loader').show();
@ -97,24 +119,25 @@ class PresupuestoCliente {
const newOption2 = new Option("148 x 210", "1", true, true);
papelFormatoId.append(newOption2).trigger('change');
$("#paginasColor").val("6");
$("#paginasColor").trigger('change');
$("#fresado").trigger("click");
$("#colorEstandar").trigger("click");
$("#colorPremium").trigger("click");
$("#offsetBlanco").trigger("click");
setTimeout(function () {
$("#gramaje80").trigger("click");
$("#gramaje90").trigger("click");
}, 0);
setTimeout(function () {
$("#tapaDura").trigger("click");
}, 0);
/*
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
@ -127,14 +150,17 @@ class PresupuestoCliente {
setTimeout(function () {
$("#unidadesEnvio").val("100");
}, 0);*/
$("#unidadesEnvio").val("50");
}, 0);
}
buttonsHandler() {
switch (this.validationStepper._currentIndex + 1) {
case 0:
stepperHandler() {
const element = $('.fv-plugins-bootstrap5.fv-plugins-framework.active');
switch (element.attr('id')) {
case 'datos-generales':
this.btnPrev.addClass('d-none');
this.btnNext.removeClass('d-none');
this.btnPrint.addClass('d-none');
@ -142,13 +168,27 @@ class PresupuestoCliente {
this.btnConfirm.addClass('d-none');
break;
case 1:
case 'interior-libro':
case 'cubierta-libro':
case 'direcciones-libro':
this.btnPrev.removeClass('d-none');
this.btnNext.removeClass('d-none');
this.btnPrint.addClass('d-none');
this.btnSave.addClass('d-none');
this.btnConfirm.addClass('d-none');
break;
case 'resumen-libro':
this.btnPrev.removeClass('d-none');
this.btnNext.addClass('d-none');
this.btnPrint.removeClass('d-none');
this.btnSave.removeClass('d-none');
this.btnConfirm.removeClass('d-none');
this.resumen.generate();
break;
default:
break;
}
}
@ -166,10 +206,13 @@ class PresupuestoCliente {
this.divTiradasPrecios,
('precio-tiradas-' + response.tiradas[i]),
response.tiradas[i],
(parseFloat(response.precio_u[i])*parseInt(response.tiradas[i])).toFixed(2),
(parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2),
response.precio_u[i]
);
if (this.actualizarTiradasEnvio)
this.direcciones.insertTirada(response.tiradas[i]);
}
}
// DEBUG
@ -204,8 +247,9 @@ class PresupuestoCliente {
#prevtStep() {
if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4)
if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4){
this.validationStepper.previous();
}
}
@ -220,12 +264,12 @@ class PresupuestoCliente {
paginas: this.datosGenerales.paginas.val(),
paginasColor: this.datosGenerales.paginasColor.val(),
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked');
papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0,
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
isColor: this.datosGenerales.getIsColor(),
isHq: this.disenioInterior.getIsHq(),
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
interior: {
papelInterior: this.disenioInterior.getPapel(),
@ -245,31 +289,31 @@ class PresupuestoCliente {
sobrecubierta: this.disenioCubierta.getSobrecubierta(),
faja: this.disenioCubierta.getFaja(),
excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked'),
excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked') ? 1 : 0,
ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(),
servicios: {
'prototipo' : this.datosGenerales.prototipo.is(':checked'),
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
},
};
if(this.datos.tipo == "cosido"){
if (this.datos.tipo == "cosido") {
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();
}
let solapasCubierta = this.disenioCubierta.getSolapasCubierta();
if (solapasCubierta !== null && solapasCubierta !== undefined) {
if (solapasCubierta === false)
this.datos.cubierta.solapas = false;
this.datos.cubierta.solapas = 0;
else {
this.datos.cubierta.solapas = true;
this.datos.cubierta.solapas = 1;
this.datos.cubierta.tamanioSolapas = solapasCubierta;
}
}
else{
this.datos.cubierta.solapas = false;
else {
this.datos.cubierta.solapas = 0;
}
if(this.direcciones.direcciones.length > 0){
if (this.direcciones.direcciones.length > 0) {
this.datos.direcciones = this.direcciones.direcciones;
}
}

View File

@ -0,0 +1,143 @@
class Resumen {
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta, direcciones) {
this.domItem = domItem;
this.datosGenerales = datosGenerales;
this.disenioInterior = disenioInterior;
this.disenioCubierta = disenioCubierta;
this.titulo = $(this.domItem.find("#resumenTitulo"));
this.tipoLibro = $(this.domItem.find("#resumenTipoLibro"));
this.formato = $(this.domItem.find("#resumenFormato"));
this.paginas = $(this.domItem.find("#resumenPaginas"));
this.paginasColor = $(this.domItem.find("#resumenPaginasColor"));
this.paginasNegro = $(this.domItem.find("#resumenPaginasNegro"));
this.tirada = $(this.domItem.find("#resumenTirada"));
this.prototipo = $(this.domItem.find("#resumenPrototipo"));
this.impresionInterior = $(this.domItem.find("#resumenImpresion"));
this.papelInterior = $(this.domItem.find("#resumenPapelInterior"));
this.gramajeInterior = $(this.domItem.find("#resumenGramajeInterior"));
this.papelInteriorColor = $(this.domItem.find("#resumenPapelInteriorColor"));
this.gramajeInteriorColor = $(this.domItem.find("#resumenGramajeInteriorColor"));
this.papelInteriorNegro = $(this.domItem.find("#resumenPapelInteriorNegro"));
this.gramajeInteriorNegro = $(this.domItem.find("#resumenGramajeInteriorNegro"));
this.cubiertaTipo = $(this.domItem.find("#resumenCubiertaTipo"));
this.itemsCubiertaTapaBlanda = $(this.domItem.find(".cubierta-tapa-blanda"));
this.itemsCubiertaTapaDura = $(this.domItem.find(".cubierta-tapa-dura"));
this.carasCubierta = $(this.domItem.find("#resumenCarasCubierta"));
this.papelCubierta = $(this.domItem.find("#resumenPapelCubierta"));
this.gramajeCubierta = $(this.domItem.find("#resumenGramajeCubierta"));
this.solapasCubierta = $(this.domItem.find("#resumenSolapasCubierta"));
this.papelGuardas = $(this.domItem.find("#resumenPapelGuardas"));
this.guardasImpresas = $(this.domItem.find("#resumenGuardasImpresas"));
this.cabezada = $(this.domItem.find("#resumenCabezada"));
this.cubiertaAcabados = $(this.domItem.find("#resumenCubiertaAcabados"));
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.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"));
}
init() {
}
generate() {
this.titulo.text(this.datosGenerales.titulo.val());
this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id')));
this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text());
this.paginas.text(this.datosGenerales.paginas.val());
this.paginasColor.text(this.datosGenerales.paginasColor.val());
this.paginasNegro.text(this.datosGenerales.paginasNegro.val());
this.tirada.text(parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada')));
this.prototipo.text(this.datosGenerales.prototipo.is(':checked') ? 'Sí' : 'No');
const HQ = this.disenioInterior.getIsHq();
const color = this.datosGenerales.getIsColor();
const papelInterior = this.disenioInterior.getPapel(true);
const gramajeInterior = this.disenioInterior.getGramaje();
if ($(".interior-color").hasClass('d-none')) {
this.domItem.find(".mismoInterior").removeClass('d-none');
this.domItem.find(".diferenteInterior").addClass('d-none');
const impInterior = (color ? "Color " : "Blanco y Negro") + (HQ ? "Premium" : "Estándar");
this.impresionInterior.text(impInterior);
this.papelInterior.text(papelInterior);
this.gramajeInterior.text(gramajeInterior);
}
else {
this.domItem.find(".mismoInterior").addClass('d-none');
this.domItem.find(".diferenteInterior").removeClass('d-none');
const impInterior = ("Negro " + (HQ.negro ? "Premium" : "Estándar") + " / Color" + (HQ.color ? "Premium" : "Estándar"));
this.impresionInterior.text(impInterior);
this.papelInteriorNegro.text(papelInterior.negro);
this.papelInteriorColor.text(papelInterior.color);
this.gramajeInteriorNegro.text(gramajeInterior.negro);
this.gramajeInteriorColor.text(gramajeInterior.color);
}
this.cubiertaTipo.text($($('.tipo-cubierta.selected').find('.form-label')).text());
this.carasCubierta.text(this.disenioCubierta.carasCubierta.find('option:selected').text());
if (this.cubiertaTipo.text().toLowerCase().includes('blanda')) {
this.itemsCubiertaTapaBlanda.removeClass('d-none');
this.itemsCubiertaTapaDura.addClass('d-none');
const solapasCubierta = this.disenioCubierta.getSolapasCubierta();
this.solapasCubierta.text( solapasCubierta == false ? 'No' : solapasCubierta);
}
else {
this.itemsCubiertaTapaDura.removeClass('d-none');
this.itemsCubiertaTapaBlanda.addClass('d-none');
const guardas = this.disenioCubierta.getGuardas(true);
this.papelGuardas.text(guardas.papel + ' ' + guardas.gramaje);
this.guardasImpresas.text(guardas.guardasImpresas);
this.cabezada.text(this.disenioCubierta.getCabezada(true));
}
this.papelCubierta.text($($('.papel-cubierta.selected').find('.form-label')).text())
this.gramajeCubierta.text(this.disenioCubierta.getGramaje());
this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true));
if (this.disenioCubierta.getSobrecubierta()) {
this.divSobrecubierta.rempveClass('d-none');
const sobrecubierta = this.disenioCubierta.getSobrecubierta(true);
this.papelSobrecubierta.text(sobrecubierta.papel);
this.gramajeSobrecubierta.text(sobrecubierta.gramaje);
this.solapasSobrecubierta.text(sobrecubierta.solapas);
this.plastificadoSobrecubierta.text(sobrecubierta.plastificado);
}
else {
this.divSobrecubierta.addClass('d-none');
}
const unidades = parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada'));
const tarjetaPrecio = $('.tarjeta-tiradas-precios').filter(function () {
return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades;
});
this.precio_unidad.text(tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').attr('data'));
const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data');
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
this.total_base.text(base);
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
this.iva.text(iva);
this.total.text((parseFloat(base) + parseFloat(iva)).toFixed(2));
}
#capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
}
export default Resumen;

View File

@ -1,45 +1,58 @@
class SelectorTiradaEnvio {
constructor(container, id, tirada, precio_u) {
constructor(container, id, tirada) {
this.container = container;
this.card = this.#generateHTML(id, tirada, precio_u);
this.tirada = tirada;
this.card = this.#generateHTML(id, tirada);
this.container.append(this.card);
}
#generateHTML(id, tirada, precio_u) {
#generateHTML(id, tirada) {
var $div = $('<div>', {
var $checkboxContainer = $('<div>', {
class: 'checkbox-presupuesto-tiradas-envio mb-md-0 mb-3'
});
// Crear el segundo div con clase form-check
var $formCheckDiv = $('<div>', {
class: 'form-check custom-option custom-option-icon tirada-envio'
});
// Crear el label
var $label = $('<label>', {
class: 'form-check-label custom-option-content',
for: id
});
// Crear los spans para el título
var $spanBody = $('<span>', { class: 'custom-option-body' });
var $spanTitle = $('<span>', { class: 'custom-option-title', text: tirada + ' ud.' });
// Crear el input radio
var $inputRadio = $('<input>', {
id: id,
class: 'form-check custom-option custom-option-basic custom-option-tiradasDirecciones'
}).append(
$('<label>', {
class: 'form-check-label custom-option-content',
for: 'tiradaEnvios1'
}).append(
$('<input>', {
class: 'form-check-input',
type: 'radio',
value: '',
}),
$('<span>', { class: 'custom-option-header' }).append(
$('<span>', {
class: 'h6 mb-0',
text: tirada
}),
$('<span>', {
class: 'text-muted precio-tirada-envio',
text: 'Total: ' + parseFloat(precio_u * tirada).toFixed(2) + '€'
})
),
$('<span>', { class: 'custom-option-body' }).append(
$('<small>', {
text: precio_u + '€/ud'
})
)
)
);
name: 'customRadioTiradaEnvio',
class: 'check-tirada-envio form-check-input',
type: 'radio',
tirada: tirada,
value: ''
});
// Añadir el span del título al span del cuerpo
$spanBody.append($spanTitle);
// Añadir los elementos al label
$label.append($spanBody).append($inputRadio);
// Añadir el label al div form-check
$formCheckDiv.append($label);
// Añadir el form-check div al contenedor principal
$checkboxContainer.append($formCheckDiv);
return $div;
return $checkboxContainer;
}
}

View File

@ -15,7 +15,7 @@ class tarjetaTiradasPrecio {
let $html = $('<div>', {
id: id,
class: 'list-group mb-2'
class: 'list-group mb-2 tarjeta-tiradas-precios'
});
let $link = $('<a>', {
@ -33,21 +33,21 @@ class tarjetaTiradasPrecio {
$listContent.append($('<h7>', {
id: 'ud_' + id,
class: 'mb-1',
class: 'mb-1 tarjeta-tiradas-precios-tirada',
text: tirada + ' ud.'
}));
}).attr('data', tirada));
$listContent.append($('<h6>', {
id: 'tot_' + id,
class: 'mb-1',
class: 'mb-1 tarjeta-tiradas-precios-precio',
text: 'Total: ' + precio + '€'
}));
}).attr('data', precio));
$listContent.append($('<h7>', {
id: 'pu_' + id,
class: 'mb-1',
class: 'mb-1 tarjeta-tiradas-precios-precio-unidad',
text: precio_unidad + '€/ud'
}));
}).attr('data', precio_unidad));
$liWrapper.append($listContent);
$link.append($liWrapper);

View File

@ -43,7 +43,24 @@
min-width: 110px !important;
}
.checkbox-presupuesto-tiradas-envio {
width: 130px !important;
max-width: 130px !important;
min-width: 130px !important;
}
.min-width-fit {
min-width: fit-content !important;
}
.texto-error {
color: #ea5455;
font-weight: bold;
}
.col-item-resumen-table {
max-width: 200px;
width: 200px;
font-weight: bold;
}