Merge branch 'dev/presu_cliente_v2' of https://git.imnavajas.es/jjimenez/safekat into dev/presu_cliente_v2

This commit is contained in:
amazuecos
2024-10-22 10:31:43 +02:00
4 changed files with 14476 additions and 310 deletions

View File

@ -1977,7 +1977,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
$return_data += [
'errors' => [],
'errors' => (object) ([
'status' => 0,
]),
//'total_lp' => $costeInterior + $coste_cubierta + $coste_sobrecubierta,
//'acabadoCubierta' => $acabadoCubierta,
//'acabadoSobrecubierta' => $acabadoSobrecubierta,

View File

@ -42,6 +42,7 @@ class PresupuestoCliente {
() => { $('#loader').modal('hide'); });
this.actualizarTiradasEnvio = false;
this.calcularPresupuesto = false;
}
@ -65,7 +66,7 @@ class PresupuestoCliente {
this.btnSave.on('click', this.#savePresupuesto.bind(this));
if (window.location.href.includes("edit")) {
$(".calcular-presupuesto").on('change', () => { });
this.#cargarPresupuesto();
const successMessage = sessionStorage.getItem('message');
if (successMessage) {
@ -74,14 +75,18 @@ class PresupuestoCliente {
}
}
else {
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
this.calcularPresupuesto = true;
}
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}
checkForm(event) {
if (this.calcularPresupuesto) {
if (event.target.id === 'divDirecciones') {
if (!this.direcciones.calcularPresupuesto) {
this.actualizarTiradasEnvio = false;
@ -127,6 +132,8 @@ class PresupuestoCliente {
}
}
}
/*RELLENAR_PRESUPUESTO(finalizar) {
@ -267,17 +274,19 @@ class PresupuestoCliente {
$('#loader').modal('hide');
if (Object.values(response.errors).some((value) => value !== "")) {
if (response.errors.status == 1) {
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
, "sk-alert-2", false);
return;
}
}
else {
popAlert2Hide();
}
if (response.tiradas && response.tiradas.length) {
let tiradas = {...response.tiradas};
let tiradas = { ...response.tiradas };
tiradas = Object.keys(tiradas).map((key) => tiradas[key]);
tiradas.sort((a, b) => a - b);
this.divTiradasPrecios.empty();
@ -301,6 +310,7 @@ class PresupuestoCliente {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
}, 0);
}
// DEBUG
//console.log(response);
}
@ -437,12 +447,13 @@ class PresupuestoCliente {
{},
(response) => {
setTimeout(() => {
if (response.status === 1) {
this.lc.val(parseFloat(response.data.lc).toFixed(2));
this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
this.calcularPresupuesto = false;
this.datosGenerales.cargarDatos(response.data.datosGenerales);
this.direcciones.handleChangeCliente();
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
@ -450,20 +461,20 @@ class PresupuestoCliente {
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
setTimeout(() => {
this.checkForm({ target: { id: 'tirada' } });
//this.checkForm({ target: { id: 'tirada' } });
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
$('#loader').modal('hide');
this.calcularPresupuesto = true;
this.checkForm({ target: { id: 'tirada' } });
}, 0);
}
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}, 0);
},
() => {
$('#loader').modal('hide');
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
this.calcularPresupuesto = true;
}
).get();
}

View File

@ -24,15 +24,15 @@ class previewFormas {
this.#portadaTapaBlanda();
}
}
/*else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) {
else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) {
if (this.tipoTapa.includes("dura"))
portadaEspiral(isThumbnail, true);
this.#portadaEspiral(isThumbnail, true);
else
portadaEspiral(isThumbnail, false);
this.#portadaEspiral(isThumbnail, false);
}
else if (this.tipoLibro.includes("grapado")) {
portadaGrapado(isThumbnail);
}*/
}
}
@ -80,7 +80,7 @@ class previewFormas {
// Clear the canvas element
this.container.empty();
// Get the element for placing the graphical elements
var previewEC = new Two({ fitted: true }).appendTo(this.container);
var previewEC = new Two({ fitted: true }).appendTo(this.container[0]);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
@ -126,8 +126,8 @@ class previewFormas {
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
@ -209,12 +209,12 @@ class previewFormas {
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
previewEC.makeText(lomoLibro.toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((altoLibro + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
@ -365,264 +365,8 @@ class previewFormas {
previewEC.update();
}
}
export default previewFormas;
/*
// Global parameters
var pvObj;
$('#toReview').on("click", function () {
previewEsquemaCubierta(true);
});
$(document).on('shown.bs.modal', function (e) {
previewEsquemaCubierta(false);
})
function previewEsquemaCubierta(isThumbnail = false) {
if ($('#cosidoDiv').length) {
if ($('#cosidoDiv').hasClass('checked') || $("#fresadoDiv").hasClass('checked')) {
//console.log("Cosido/Fresado");
if ($("#tapaBlanda").is(":checked")) {
portadaTapaBlanda(isThumbnail);
} else if ($("#tapaDura").is(":checked")) {
portadaTapaDura(isThumbnail);
}
} else if ($('#espiralDiv').hasClass('checked') || $('#wireoDiv').hasClass('checked')) {
//console.log("Espiral/Wireo");
if ($("#tapaBlanda").is(":checked")) {
portadaEspiral(isThumbnail, false);
} else if ($("#tapaDura").is(":checked")) {
portadaEspiral(isThumbnail, true);
}
} else if ($('#grapadoDiv').hasClass('checked')) {
portadaGrapado(isThumbnail);
}
}
else {
let titulo = $('#tipoLibro').text().toLowerCase();
if (titulo.includes("cosido") || titulo.includes("fresado")) {
if (titulo.includes("dura"))
portadaTapaDura(isThumbnail);
else {
portadaTapaBlanda(isThumbnail);
}
}
else if (titulo.includes("espiral") || titulo.includes("wire-o")) {
if (titulo.includes("dura"))
portadaEspiral(isThumbnail, true);
else
portadaEspiral(isThumbnail, false);
}
else if (titulo.includes("grapado")) {
portadaGrapado(isThumbnail);
}
}
}
function portadaTapaBlanda(isThumbnail = false) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm
let offsetSolapaValor = parseFloat(0); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (pvObj.anchoSolapa == 0) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 800; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.97;
anchoLibro = anchoSangrado * 0.419;
anchoSolapa = 0;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.95;
anchoLibro = anchoSangrado * 0.28;
anchoSolapa = anchoSangrado * 0.163;
lomoLibro = anchoSangrado * 0.09;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
}
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({ fitted: true }).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCubierta,
altoLibro);
solapas.stroke = 'black';
solapas.linewidth = 1;
// Cotas Solapas
if (!isThumbnail) {
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x - anchoLibro - lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x + anchoLibro + lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = { size: 18, family: 'Public Sans' };
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas:
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaLomo = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
origenEC.x + (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
10);
cotaLomo.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
let a = previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
// Sangrados
let styleSangrado = { size: 10, family: 'Public Sans', style: 'italic', fill: 'red' };
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
function portadaEspiral(isThumbnail = false, isTapaDura = false) {
#portadaEspiral(isTapaDura = false) {
// Variables locales
let altoLibro, anchoLibro, anchoCalle, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta;
@ -630,13 +374,9 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if ((pvObj.anchoSolapa !== 0) && (!isTapaDura)) {
if ((anchoSolapa !== 0) && (!isTapaDura)) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
@ -652,7 +392,7 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
anchoCubierta = 2 * (anchoLibro + anchoSolapa + sangrado) + anchoCalle;
offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa / 2 + sangrado;
} else {
if (isThumbnail) {
if (this.size == "thumbnail") {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
@ -667,11 +407,7 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa + sangradoValor;
}
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({ fitted: true }).appendTo(divEC);
var previewEC = new Two({ fitted: true }).appendTo(this.container[0]);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
@ -686,7 +422,7 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if ((pvObj.anchoSolapa != 0) && (!isTapaDura)) {
if ((anchoSolapa != 0) && (!isTapaDura)) {
var solapa1 = previewEC.makeRectangle(
origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
origenEC.y,
@ -726,8 +462,8 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
@ -820,15 +556,15 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
previewEC.makeText(sangradoTexto, origenEC.x + (anchoSangrado / 2) - 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (anchoSangrado / 2) + 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm",
previewEC.makeText(anchoLibro.toFixed(1) + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro.toFixed(1) + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((altoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x + (anchoSangrado / 2) + 30,
origenEC.y,
styleCotas
).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
previewEC.makeText(((2 * anchoLibro) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
@ -836,8 +572,266 @@ function portadaEspiral(isThumbnail = false, isTapaDura = false) {
previewEC.update();
}
}
export default previewFormas;
/*
// Global parameters
var pvObj;
$('#toReview').on("click", function () {
previewEsquemaCubierta(true);
});
$(document).on('shown.bs.modal', function (e) {
previewEsquemaCubierta(false);
})
function previewEsquemaCubierta(isThumbnail = false) {
if ($('#cosidoDiv').length) {
if ($('#cosidoDiv').hasClass('checked') || $("#fresadoDiv").hasClass('checked')) {
//console.log("Cosido/Fresado");
if ($("#tapaBlanda").is(":checked")) {
portadaTapaBlanda(isThumbnail);
} else if ($("#tapaDura").is(":checked")) {
portadaTapaDura(isThumbnail);
}
} else if ($('#espiralDiv').hasClass('checked') || $('#wireoDiv').hasClass('checked')) {
//console.log("Espiral/Wireo");
if ($("#tapaBlanda").is(":checked")) {
portadaEspiral(isThumbnail, false);
} else if ($("#tapaDura").is(":checked")) {
portadaEspiral(isThumbnail, true);
}
} else if ($('#grapadoDiv').hasClass('checked')) {
portadaGrapado(isThumbnail);
}
}
else {
let titulo = $('#tipoLibro').text().toLowerCase();
if (titulo.includes("cosido") || titulo.includes("fresado")) {
if (titulo.includes("dura"))
portadaTapaDura(isThumbnail);
else {
portadaTapaBlanda(isThumbnail);
}
}
else if (titulo.includes("espiral") || titulo.includes("wire-o")) {
if (titulo.includes("dura"))
portadaEspiral(isThumbnail, true);
else
portadaEspiral(isThumbnail, false);
}
else if (titulo.includes("grapado")) {
portadaGrapado(isThumbnail);
}
}
}
function portadaTapaBlanda(isThumbnail = false) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm
let offsetSolapaValor = parseFloat(0); // mm
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
// Get the preview Object parameters
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (anchoSolapa == 0) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 800; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.97;
anchoLibro = anchoSangrado * 0.419;
anchoSolapa = 0;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
} else {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
altoLibro = altoSangrado * 0.95;
anchoLibro = anchoSangrado * 0.28;
anchoSolapa = anchoSangrado * 0.163;
lomoLibro = anchoSangrado * 0.09;
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
}
// Clear the canvas element
$(`#${divIdName}`).empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById(divIdName);
var previewEC = new Two({ fitted: true }).appendTo(divEC);
// Calculate the center of the canvas element
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
var sangrado = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoSangrado,
altoSangrado
);
sangrado.stroke = 'black';
sangrado.dashes = [5, 5];
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
anchoCubierta,
altoLibro);
solapas.stroke = 'black';
solapas.linewidth = 1;
// Cotas Solapas
if (!isThumbnail) {
var cotaSolapa2 = previewEC.makeDobleArrow(
origenEC.x - anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x - anchoLibro - lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa2.linewidth = 2;
var cotaSolapa1 = previewEC.makeDobleArrow(
origenEC.x + anchoCubierta / 2,
origenEC.y - (altoLibro / 3),
origenEC.x + anchoLibro + lomoLibro / 2,
origenEC.y - (altoLibro / 3),
10);
cotaSolapa1.linewidth = 2;
// Textos Solapas
let stylesSolapa = { size: 18, family: 'Public Sans' };
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
var libro = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
((2 * anchoLibro) + lomoLibro),
altoLibro);
libro.stroke = 'black';
libro.linewidth = 1;
var lomo = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
lomoLibro,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// Cotas y textos
if (!isThumbnail) {
// Cotas:
var cotaAnchoCubierta = previewEC.makeDobleArrow(
origenEC.x - (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
origenEC.x + (anchoSangrado / 2),
origenEC.y + (altoLibro / 2) + 35,
10);
cotaAnchoCubierta.linewidth = 2;
var cotaAltoCubierta = previewEC.makeDobleArrow(
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y + (altoSangrado / 2),
origenEC.x + (anchoCubierta / 2) + 35,
origenEC.y - (altoSangrado / 2),
10);
cotaAltoCubierta.linewidth = 2;
var cotaAltoLibro = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y + (altoLibro / 2),
origenEC.x + (lomoLibro / 2) + 35,
origenEC.y - (altoLibro / 2),
10);
cotaAltoLibro.linewidth = 2;
var cotaLomo = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
origenEC.x + (lomoLibro / 2),
origenEC.y + (altoLibro / 3),
10);
cotaLomo.linewidth = 2;
var cotaContraportada = previewEC.makeDobleArrow(
origenEC.x - (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
origenEC.x - (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (lomoLibro / 2),
origenEC.y - (altoLibro / 3),
origenEC.x + (lomoLibro / 2 + anchoLibro),
origenEC.y - (altoLibro / 3),
10);
cotaPortada.linewidth = 2;
// Textos:
// Titulos generales
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
let a = previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
// Sangrados
let styleSangrado = { size: 10, family: 'Public Sans', style: 'italic', fill: 'red' };
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
}
previewEC.update();
}
function portadaGrapado(isThumbnail = false) {
// Variables locales
@ -853,7 +847,7 @@ function portadaGrapado(isThumbnail = false) {
getObjetoToPreview();
// Definicion de los parametros del Esquema de Cubierta (EC)
if (pvObj.anchoSolapa == 0) {
if (anchoSolapa == 0) {
if (isThumbnail) {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
@ -901,7 +895,7 @@ function portadaGrapado(isThumbnail = false) {
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (pvObj.anchoSolapa != 0) {
if (anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
@ -933,8 +927,8 @@ function portadaGrapado(isThumbnail = false) {
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
}
@ -1007,11 +1001,11 @@ function portadaGrapado(isThumbnail = false) {
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);

File diff suppressed because one or more lines are too long