diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 72d4370f..d45c9ea8 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -821,7 +821,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $borrar_antes = false; if ($id != 0) { - $borrar_antes = true; + $borrar_antes = true; } if ($datos_presupuesto['sobrecubierta']) { @@ -832,9 +832,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } $acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']); if (count($acabado_id) > 0) { - $datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id[0]; - $datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id[1]; - $datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id[2]; + if(array_key_exists('plastificado', $acabado_id)){ + $datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id['plastificado']; + } + if(array_key_exists('barniz', $acabado_id)){ + $datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id['barniz']; + } + if(array_key_exists('estampado', $acabado_id)){ + $datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id['estampado']; + } } else { $datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0; } @@ -963,8 +969,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['cubierta']['cabezada'] = $presupuesto->cabezada; $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); $data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id); + if($data['cubierta']['plastificado'] == ''){ + $data['cubierta']['plastificado'] = 'NONE'; + } $data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id); + if($data['cubierta']['barniz'] == ''){ + $data['cubierta']['barniz'] = 'NONE'; + } $data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id); + if($data['cubierta']['estampado'] == ''){ + $data['cubierta']['estampado'] = 'NONE'; + } $data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0; $data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : []; @@ -2389,7 +2404,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($value != 'NONE') { $data = $model->where('code', $value)->first(); $data = $data->id; - array_push($tarifas, $data); + array_push($tarifas, [$acabado => $data]); } else { array_push($tarifas, 0); } diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index df045c24..a6c1074b 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -1801,6 +1801,9 @@ class PresupuestoService extends BaseService $linea = PresupuestoService::getLineaPresupuestoPlana($data); + if (empty($linea)) + continue; + if ( $tipo_impresion_id == 5 || $tipo_impresion_id == 6 || $tipo_impresion_id == 7 || $tipo_impresion_id == 8 @@ -1812,9 +1815,6 @@ class PresupuestoService extends BaseService } } - if (empty($linea)) - continue; - if (!array_key_exists('tipo_linea', $linea['fields'])) { if ($isColor) { if ($isHq) diff --git a/httpdocs/assets/js/safekat/pages/preview.js b/httpdocs/assets/js/safekat/pages/preview.js index d5feed42..1b881164 100644 --- a/httpdocs/assets/js/safekat/pages/preview.js +++ b/httpdocs/assets/js/safekat/pages/preview.js @@ -10,7 +10,11 @@ class previewFormas { this.ancho = datos.ancho; this.alto = datos.alto; this.lomo = datos.lomo; - this.solapa = datos.solapa; + + if(datos.solapas == undefined || datos.solapas == null || datos.solapas == false) + this.solapa = 0; + else + this.solapa = datos.solapas; this.lomoRedondo = datos.lomoRedondo; } @@ -25,7 +29,7 @@ class previewFormas { } } else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) { - if (this.tipoTapa.includes("dura")) + if (this.tipoTapa.toLowerCase().includes("dura")) this.#portadaEspiral(true); else this.#portadaEspiral(false); @@ -233,7 +237,7 @@ class previewFormas { let styleCotas = { size: 12, family: 'Public Sans' }; let sangradoTexto = "Sangrado 20 mm"; let sangradoValor = parseFloat(20); // mm - if(this.ancho > 210 || this.alto > 297){ + if(this.ancho >= 210 || this.alto >= 297){ sangradoValor = parseFloat(15); // mm sangradoTexto = "Sangrado 15 mm"; } @@ -369,14 +373,14 @@ class previewFormas { #portadaEspiral(isTapaDura = false) { // Variables locales - let altoLibro, anchoLibro, anchoCalle, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta, anchoCubierta; + let altoLibro, anchoLibro, anchoSolapa, anchoCalle, altoSangrado, anchoSangrado, offsetCubierta, anchoCubierta; let styleCotas = { size: 12, family: 'Public Sans' }; let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm"; let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm // Definicion de los parametros del Esquema de Cubierta (EC) - if ((anchoSolapa !== 0) && (!isTapaDura)) { + if ((this.solapa !== 0) && (!isTapaDura)) { if (this.size == "thumbnail") { anchoSangrado = 350; // px altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px @@ -392,15 +396,15 @@ class previewFormas { anchoCubierta = 2 * (anchoLibro + anchoSolapa + sangrado) + anchoCalle; offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa / 2 + sangrado; } else { - if (this.size == "thumbnail") { + if (this.size == "thumbnail") { 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 = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.97; - anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.419; + altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.9; + anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.44; anchoCalle = anchoSangrado * 0.02; anchoSolapa = 0; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle; @@ -422,7 +426,7 @@ class previewFormas { sangrado.fill = '#FCEAF1'; sangrado.linewidth = 1; - if ((anchoSolapa != 0) && (!isTapaDura)) { + if ((this.solapa != 0) && (!isTapaDura)) { var solapa1 = previewEC.makeRectangle( origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor), origenEC.y, @@ -462,8 +466,8 @@ class previewFormas { 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((anchoSolapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); - previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText((this.solapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText(this.solapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); } } @@ -556,15 +560,15 @@ class previewFormas { 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(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", + previewEC.makeText(this.ancho.toFixed(1) + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText(this.ancho.toFixed(1) + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; + previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (anchoSangrado / 2) + 30, origenEC.y, styleCotas ).rotation = -Math.PI / 2; - previewEC.makeText(((2 * anchoLibro) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm", + previewEC.makeText(((2 * this.ancho) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 2) + 50, styleCotas); @@ -585,7 +589,7 @@ class previewFormas { let offsetSolapaValor = parseFloat(0); // mm // Definicion de los parametros del Esquema de Cubierta (EC) - if (anchoSolapa == 0) { + if (this.solapa == 0) { if (this.size == "thumbnail") { anchoSangrado = 350; // px altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px @@ -629,7 +633,7 @@ class previewFormas { sangrado.fill = '#FCEAF1'; sangrado.linewidth = 1; - if (anchoSolapa != 0) { + if (this.solapa != 0) { var solapas = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -661,8 +665,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(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(this.solapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText(this.solapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); } } @@ -750,445 +754,3 @@ class previewFormas { } 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 - 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 = 750; // px - altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px - } - altoLibro = altoSangrado * 0.97; - anchoLibro = anchoSangrado * 0.48; - anchoSolapa = 0; - lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO - 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.3; - anchoSolapa = anchoSangrado * 0.18; - lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO - 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 y textos - if (!isThumbnail) { - // Cotas - 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 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); - // 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(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(); - -} - - - -*/ \ No newline at end of file