mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Revert "Merge branch 'feat/add-chat-presupuesto-cliente' into 'main'"
This reverts merge request !352
This commit is contained in:
@ -1,220 +0,0 @@
|
||||
import previewFormas from "../preview.js";
|
||||
|
||||
class Resumen {
|
||||
constructor(domItem, datosGenerales, disenioInterior, disenioCubierta) {
|
||||
|
||||
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("#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() {
|
||||
|
||||
this.titulo.text(this.datosGenerales.titulo.val());
|
||||
this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id')));
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
this.divPreview.empty();
|
||||
|
||||
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());
|
||||
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.caras);
|
||||
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.removeClass('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;
|
||||
});
|
||||
|
||||
|
||||
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
||||
precio_u_text = precio_u_text.replace('€/u', '');
|
||||
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||
|
||||
const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data');
|
||||
let base_text = this.#changeDecimalFormat(base);
|
||||
|
||||
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
|
||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||
let iva_text = this.#changeDecimalFormat(iva);
|
||||
|
||||
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
|
||||
let total_text = this.#changeDecimalFormat(total);
|
||||
|
||||
this.precio_unidad.text(precio_u_text);
|
||||
this.total_base.text(base_text);
|
||||
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
|
||||
this.iva.text(iva_text);
|
||||
this.total.text(total_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
|
||||
#changeDecimalFormat(number) {
|
||||
|
||||
let cleanedNumber = String(number).replace(/[^\d.]/g, '');
|
||||
let partes = cleanedNumber.split('.');
|
||||
partes[0] = partes[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
|
||||
return partes.join(',');
|
||||
}
|
||||
}
|
||||
|
||||
export default Resumen;
|
||||
Reference in New Issue
Block a user