diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 44c46df6..fd22f397 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -142,6 +142,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity(); $this->viewData['presupuestoEntity'] = $presupuestoEntity; $this->viewData['isCosido'] = (new TipoPresupuestoModel())->get_isCosido($this->viewData['tipo_impresion_id']); + $this->viewData['isTapaDura'] = (new TipoPresupuestoModel())->get_isTapaDura($this->viewData['tipo_impresion_id']); $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); @@ -304,6 +305,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['presupuestoId'] = $id; $this->viewData['presupuestoEntity'] = $presupuestoEntity; $this->viewData['isCosido'] = (new TipoPresupuestoModel())->get_isCosido($presupuestoEntity->tipo_impresion_id); + $this->viewData['isTapaDura'] = (new TipoPresupuestoModel())->get_isTapaDura($presupuestoEntity->tipo_impresion_id); if(!is_null($presupuestoEntity->comparador_json_data)) $this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data); @@ -634,6 +636,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController case 1: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleFresadoTD'); $viewData['isCosido'] = 0; + $viewData['isTapaDura'] = 1; $breadcrumbTitle = lang("App.menu_libros_fresasdo_tapa_dura"); break; @@ -641,6 +644,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController case 2: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleFresadoTB'); $viewData['isCosido'] = 0; + $viewData['isTapaDura'] = 0; $breadcrumbTitle = lang("App.menu_libros_fresasdo_tapa_blanda"); break; @@ -648,6 +652,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController case 3: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleCosidoTD'); $viewData['isCosido'] = 1; + $viewData['isTapaDura'] = 1; $breadcrumbTitle = lang("App.menu_libros_cosido_tapa_dura"); break; @@ -655,6 +660,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController case 4: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleCosidoTB'); $viewData['isCosido'] = 1; + $viewData['isTapaDura'] = 0; $breadcrumbTitle = lang("App.menu_libros_cosido_tapa_blanda"); break; diff --git a/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php b/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php index 13425d59..1a747781 100755 --- a/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php +++ b/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php @@ -9,6 +9,7 @@ class TipoPresupuestoEntity extends \CodeIgniter\Entity\Entity "id" => null, "codigo" => null, "is_cosido" => null, + "is_tapa_dura" => null, "is_deleted" => 0, "deleted_at" => null, "created_at" => null, diff --git a/ci4/app/Models/Configuracion/TipoPresupuestoModel.php b/ci4/app/Models/Configuracion/TipoPresupuestoModel.php index f26e4d3b..6ad22998 100755 --- a/ci4/app/Models/Configuracion/TipoPresupuestoModel.php +++ b/ci4/app/Models/Configuracion/TipoPresupuestoModel.php @@ -33,6 +33,22 @@ class TipoPresupuestoModel extends \App\Models\GoBaseModel return null; } + public function get_isTapaDura(int $id){ + + $builder = $this->db + ->table($this->table . " t1") + ->select("t1.is_tapa_dura AS is_tapa_dura") + ->where('t1.id', $id) + ->where('t1.is_deleted', 0); + + $result = $builder->get()->getResultObject(); + if(count($result)>0){ + return $result[0]->is_tapa_dura; + } + return null; + } + + } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php index b905b804..9eea332f 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems.php @@ -783,7 +783,7 @@ $('#tab-pv-cubierta').on( "click", function() { $('#tab-pv-esquema-cubierta').on( "click", function() { - previewEsquemaCubierta('ec', ); + previewEsquemaCubierta('ec', , ); } ); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js index 5d0e36d1..a83a1279 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/previews.js @@ -2,11 +2,6 @@ //var _isCosido = true; var pvObj; -var sangradoTexto = "Sangrado 5 mm"; -var sangradoValor = parseFloat(5); // mm -var offsetSolapaValor = parseFloat(0); // mm - - function previewInteriorPlana(lpTagName, isCosido) { // Local parameters @@ -99,7 +94,7 @@ function previewRotativa(lpTagName, isCosido) { // Guarda vertical if (pvObj.nFormasV > 1) { guardaV = 3; - } + } // Guarda horizontal if (pvObj.nFormasH > 1) { guardaH = 3; @@ -186,11 +181,153 @@ function getDecimalPart(floatNumber) { } -function previewEsquemaCubierta(lpTagName, isCosido) { +function previewEsquemaCubierta(_lpTagName, _isCosido, _isTapaDura) { + + if (_isTapaDura) { + portadaTapaDura(_lpTagName, _isCosido); + } else { + portadaTapaBlanda(_lpTagName, _isCosido); + } + +} + +function portadaTapaDura(lpTagName, isCosido) { + + // 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(6); // mm + let altoPliegue = parseFloat(7); // mm + + // Get the preview Object parameters + getObjetoLP(lpTagName, isCosido); + + // 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, + lomoLibro, + 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 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 + 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.lomoLibro + " mm", origenEC.x, 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.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) + " mm", + origenEC.x, + origenEC.y + (altoLibro / 2) + 50, + styleCotas); + + previewEC.update(); + +} + +function portadaTapaBlanda(lpTagName, isCosido) { // 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 // Get the preview Object parameters getObjetoLP(lpTagName, isCosido); @@ -294,12 +431,19 @@ function previewEsquemaCubierta(lpTagName, isCosido) { origenEC.y + (altoLibro / 2) + 35, 10); cotaAnchoCubierta.linewidth = 2; - var cotaAltoLibro = previewEC.makeDobleArrow( + 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), @@ -340,6 +484,7 @@ function previewEsquemaCubierta(lpTagName, isCosido) { 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, @@ -350,6 +495,7 @@ function previewEsquemaCubierta(lpTagName, isCosido) { } + function getLomoLibro() { let _anchoLomo = 0; $("#tableLineasPresupuesto tbody tr:visible td input[id*='_lomo']").each(function () { @@ -462,7 +608,7 @@ function getObjetoLP(lpName, _isCosido) { pvObj.anchoForma = auxReg; } $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - pvObj.altoClick = isNaN(parseFloat(rowData.alto_click))?305:parseFloat(rowData.alto_click); + pvObj.altoClick = isNaN(parseFloat(rowData.alto_click)) ? 305 : parseFloat(rowData.alto_click); pvObj.nFormasH = Math.trunc(pvObj.anchoImpresion / pvObj.anchoForma); pvObj.nFormasV = Math.trunc((pvObj.altoImpresion - 3) / (pvObj.altoForma + 4)); break;