Modificaciones en el preview para Espiral y Wire-O

This commit is contained in:
imnavajas
2024-04-04 14:05:44 +02:00
parent 2906da8200
commit 910a711b08
2 changed files with 182 additions and 14 deletions

View File

@ -886,9 +886,9 @@ class PresupuestoService extends BaseService
}
// Sangre externa (dependiendo si es tapa dura o blanda)
// Tapa dura
// Tapa dura (se le añaden 7mm de ancho de pliegue)
if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
$ancho_total += (2 * self::SANGRE_FORMAS_CUBIERTA);
$ancho_total += (2 * (self::SANGRE_FORMAS_CUBIERTA + 2*7));
}
// Tapa blanda
else {
@ -914,14 +914,18 @@ class PresupuestoService extends BaseService
$alto_total = floatval($datosPedido->alto);
// Tapa dura (cosido y fresado)
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
// Se añaden 20mm de sangre por cada lado + 7mm extra que sobresale -> total 47
// Se añaden 20mm de sangre por cada lado + 7mm extra que sobresale por cada lado para el pliegue del carton
if ($uso == "cubierta")
$alto_total += (7 + 2 * self::SANGRE_FORMAS_CUBIERTA);
$alto_total += (2*7 + 2 * self::SANGRE_FORMAS_CUBIERTA);
// si es sobrecubierta
// Se añaden 5mm de sangre por cada lado + 7mm de vuelo -> total 52
else
$alto_total += (7 + 2 * self::SANGRE_FORMAS);
}
// Tapa dura (espiral y wire-0)
if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
$alto_total += (2 * (self::SANGRE_FORMAS_CUBIERTA + 7));
}
// En cualquier otro caso se le suma 5mm de sangre por cada lado
else {
$alto_total += (2 * self::SANGRE_FORMAS);

View File

@ -183,11 +183,23 @@ function getDecimalPart(floatNumber) {
function previewEsquemaCubierta(_lpTagName, _isCosido, _isTapaDura) {
if (_isTapaDura) {
let tipoImpresion = parseInt($('#tipo_impresion_id').val());
// Fresado TD y Cosido TD
if (tipoImpresion === 1 || tipoImpresion === 3) {
portadaTapaDura(_lpTagName, _isCosido, _isTapaDura);
} else {
}
// Fresado TB y Cosido TB
else if (tipoImpresion === 2 || tipoImpresion === 4) {
portadaTapaBlanda(_lpTagName, _isCosido, _isTapaDura);
}
// Espiral TD y TB, Wire-o TD y TB
else if (tipoImpresion === 5 || tipoImpresion === 6 ||
tipoImpresion === 7 || tipoImpresion === 8) {
portadaEspiralWireo(_lpTagName, _isCosido, _isTapaDura);
} else {
// ?
}
}
@ -201,7 +213,7 @@ function portadaTapaDura(lpTagName, isCosido, isTapaDura) {
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
let anchoCarton = parseFloat(7); // mm
// Get the preview Object parameters
getObjetoLP(lpTagName, isCosido, isTapaDura);
@ -299,7 +311,7 @@ function portadaTapaDura(lpTagName, isCosido, isTapaDura) {
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;
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 + 13), styleSangrado);
@ -496,6 +508,127 @@ function portadaTapaBlanda(lpTagName, isCosido, isTapaDura) {
}
function portadaEspiralWireo(lpTagName, isCosido, isTapaDura) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = {size: 12, family: 'Public Sans'};
let sangradoTexto = "Sangrado 20 mm";
let sangradoValor = parseFloat(20); // mm
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
let anchoCarton = parseFloat(7); // mm
// Get the preview Object parameters
getObjetoLP(lpTagName, isCosido, isTapaDura);
// Definicion de los parametros del Esquema de Cubierta (EC) -
anchoSangrado = 600; // px
altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px
altoLibro = altoSangrado * 0.88;
anchoLibro = anchoSangrado * 0.39;
lomoLibro = anchoSangrado * 0.133;
anchoCubierta = (2 * anchoLibro) + lomoLibro;
// Clear the canvas element
$('#pv_ec_shape').empty();
// Get the element for placing the graphical elements
var divEC = document.getElementById('pv_ec_shape');
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;
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,
4,
altoLibro);
lomo.stroke = 'black';
lomo.fill = '#F4F8F2';
lomo.linewidth = 1;
// 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 - (4 / 2),
origenEC.y - (altoLibro / 3),
10);
cotaContraportada.linewidth = 2;
var cotaPortada = previewEC.makeDobleArrow(
origenEC.x + (4 / 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 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 13), styleSangrado);
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + 13), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + 13), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(pvObj.anchoLibro + anchoPliegue + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + anchoPliegue + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + altoPliegue + " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + altoPliegue + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
previewEC.update();
}
function getLomoLibro() {
const anchoLomoInputs = $("#tableLineasPresupuesto tbody tr:visible td input[id*='_lomo']");
@ -542,6 +675,7 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) {
pvObj = {
idIndex: lpName,
tipoImpresion: parseInt($('#tipo_impresion_id').val()),
gramajeLibro: parseInt(rowData.gramaje),
manoLP: parseFloat(rowData.lomo),
lomoLibro: getLomoLibro(),
@ -564,6 +698,7 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) {
pvObj.anchoForma = (_isCosido) ? 2 * pvObj.anchoLibro : pvObj.anchoLibro;
pvObj.altoForma = pvObj.altoLibro;
// Update preview info fields
let pvName = '#pv_' + lpName;
$(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + rowData.papel);
@ -591,31 +726,45 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) {
// Custom overwrites
switch (pvObj.idIndex) {
case 'cubierta':
if(_isTapaDura){
// Fresado TD or Cosido TD
if (pvObj.tipoImpresion === 1 || pvObj.tipoImpresion === 3) {
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
let sangre = parseFloat(20); // mm
pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * sangre) + pvObj.lomoLibro);
pvObj.altoForma += altoPliegue + (2 * sangre);
}else{
}
// Fresado TB y Cosido TB
else if (pvObj.tipoImpresion === 2 || pvObj.tipoImpresion === 4) {
let sangre = parseFloat(5); // mm
pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + (2 * sangre) + pvObj.lomoLibro);
pvObj.altoForma += (2 * sangre);
}
// Espiral TD y TB, Wire-o TD y TB
else if (pvObj.tipoImpresion === 5 || pvObj.tipoImpresion === 6 ||
pvObj.tipoImpresion === 7 || pvObj.tipoImpresion === 8) {
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
let sangre = parseFloat(20); // mm
pvObj.anchoForma = ((pvObj.anchoLibro) + (2 * anchoPliegue));
pvObj.altoForma += altoPliegue;
} else {
// ?
}
// Update labels
$(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma);
break;
case 'sobrecubierta':
let sangre = parseFloat(5); // mm
sangre = parseFloat(5); // mm
let anchoSolapaSobrecubierta = $('#solapas_sobrecubierta').is(':checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : parseFloat(0); // mm
if(_isTapaDura){
if (_isTapaDura) {
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaSobrecubierta + offsetSolapaValor)) + (2 * sangre) + pvObj.lomoLibro);
pvObj.altoForma += altoPliegue + (2 * sangre);
}else{
} else {
pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * (anchoSolapaSobrecubierta + offsetSolapaValor)) + (2 * sangre) + pvObj.lomoLibro);
pvObj.altoForma += (2 * sangre);
}
@ -659,7 +808,22 @@ function getObjetoLP(lpName, _isCosido, _isTapaDura) {
$(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma);
break;
case 'guardas':
pvObj.anchoForma = (_isTapaDura) ? 2 * pvObj.anchoLibro : pvObj.anchoLibro;
// Fresado TD y Cosido TD
if (pvObj.tipoImpresion === 1 || pvObj.tipoImpresion === 3) {
pvObj.anchoForma = 2 * pvObj.anchoLibro;
}
// Fresado TB y Cosido TB
else if (pvObj.tipoImpresion === 2 || pvObj.tipoImpresion === 4) {
pvObj.anchoForma = pvObj.anchoLibro;
}
// Espiral TD y TB, Wire-o TD y TB
else if (pvObj.tipoImpresion === 5 || pvObj.tipoImpresion === 6 ||
pvObj.tipoImpresion === 7 || pvObj.tipoImpresion === 8) {
pvObj.anchoForma = pvObj.anchoLibro;
} else {
// ?
}
// Conditional assignements depending on rotation of the printing shape
if (pvObj.orientacionFormas == 'v') {
let auxReg = pvObj.altoForma;