diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index eb141076..b7dd5d7d 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -76,6 +76,8 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ( $routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']); $routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']); $routes->get('select', 'TarifaAcabados::show_select', ["as" => "showSelectTarifaAcabado"]); + $routes->get('gettarifas', 'TarifaAcabados::getSelect2'); + $routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) { $routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']); $routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']); @@ -652,10 +654,10 @@ $routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuest $routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']); $routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { - $routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']); + $routes->post('getvalues', 'Presupuestoacabados::getRowValues'); $routes->post('menuitems', 'Presupuestoacabados::menuItems', ['as' => 'menuItemsOfPresupuestoAcabados']); $routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']); - $routes->get('getacabados', 'Presupuestoacabados::getAcabados'); + $routes->get('cargar', 'Presupuestoacabados::cargar'); }); $routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) { diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php index 18dc5743..e39e9df1 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoacabados.php @@ -92,7 +92,27 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController return $this->respond($data); } - public function datatable() + public function cargar() + { + if($this->request->isAJAX()) { + $presupuesto_id = $this->request->getGet('presupuesto_id') ?? null; + + $rows = $this->model->getResource($presupuesto_id)->get()->getResultObject(); + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'rows' => $rows, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function getRowValues() { if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); @@ -100,7 +120,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController $tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0; $tirada = $reqData['tirada'] ?? 0; $proveedor_id = $reqData['proveedor_id'] ?? -1; - $POD = $reqData['POD'] ?? 0; + $POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value; $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -195,4 +215,6 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController return $this->failUnauthorized('Invalid request', 403); } } + + } diff --git a/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php b/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php index 7c4d4c54..e2553235 100644 --- a/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php +++ b/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php @@ -336,4 +336,25 @@ class TarifaAcabados extends BaseResourceController } return $this->response->setJSON($query->get()->getResultObject()); } + + public function getSelect2() + { + if ($this->request->isAJAX()) { + $query = $this->model->builder()->select( + [ + "id", + "nombre as name" + ] + )->where("deleted_at", null); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_tarifas_acabado.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } } diff --git a/ci4/app/Language/es/Tarifaacabado.php b/ci4/app/Language/es/Tarifaacabado.php index 3c6622ff..5bdd61e9 100755 --- a/ci4/app/Language/es/Tarifaacabado.php +++ b/ci4/app/Language/es/Tarifaacabado.php @@ -9,6 +9,7 @@ return [ 'id' => 'ID', 'moduleTitle' => 'Tarifas Acabado', 'nombre' => 'Nombre', + 'margen' => 'Margen', 'precioMin' => 'Precio Mínimo', 'importeFijo' => 'Importe Fijo', 'mostrar_en_presupuesto' => 'Mostrar en presupuesto', diff --git a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php index c0dcf401..57d2167c 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php @@ -76,8 +76,10 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel $ret_array[] = (object)[ 'tarifa_id'=> $tarifa_value[0]->tarifa_acabado_id, 'tarifa_nombre'=> $tarifa_value[0]->tarifa_acabado_nombre, - 'precio_unidad'=> $result_data[0], - 'total'=> $result_data[1], + 'nombre'=> $tarifa_value[0]->tarifa_acabado_nombre, + 'precio_unidad'=> round($result_data[0], 2), + 'total'=> round($result_data[1], 2), + 'precio_total'=> round($result_data[1], 2), 'margen'=> $result_data[2], 'proveedor' => $tarifa_value[0]->proveedor_nombre, 'proveedor_id' => $tarifa_value[0]->proveedor_id, @@ -88,9 +90,13 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel $ret_array[] = (object)[ 'tarifa_id'=> $tarifa_acabado_id, 'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre, + 'nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre, 'precio_unidad' => 0, + 'total' => 0, + 'precio_total' => 0, 'margen' => 0, - 'total'=> 0, + 'proveedor' => '', + 'proveedor_id' => 0, ]; return $ret_array; } @@ -194,7 +200,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad, + "t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.tarifa_acabado_id AS tarifa_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor," ); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js index f1871aef..e19a166c 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.js @@ -1,14 +1,8 @@ /**************************************************************************************** * Seccion para las funciones generales de la pagina ***************************************************************************************/ +/* -$('.nav-servicios button').on('shown.bs.tab', function(){ - $("#tableOfServiciosEncuadernacion").DataTable().columns.adjust(); - $("#tableOfServiciosPreimpresion").DataTable().columns.adjust(); - $("#tableOfServiciosManipulado").DataTable().columns.adjust(); - $("#tableOfServiciosAcabado").DataTable().columns.adjust(); - $("#tableOfServiciosExtra").DataTable().columns.adjust(); -}) $('#serv_default').on('click', function(){ @@ -159,12 +153,12 @@ function save_servicios(){ }) ) } - +*/ /**************************************************************************************** * Seccion para los servicios de acabado ***************************************************************************************/ -var tableServiciosAcabado = new DataTable('#tableOfServiciosAcabado',{ +/*var tableServiciosAcabado = new DataTable('#tableOfServiciosAcabado',{ scrollX: true, searching: false, paging: false, @@ -625,7 +619,7 @@ async function get_servAcabados_tiradasAlternativas(tirada){ return serviciosAcabados; } - +*/ /**************************************************************************************** * Seccion para los servicios de encuadernación ***************************************************************************************/ @@ -1116,6 +1110,7 @@ async function get_servEncuadernacion_tiradasAlternativas(tirada, paginas, ancho /**************************************************************************************** * Seccion para los servicios de manipulado ***************************************************************************************/ +/* var tableServiciosManipulado = new DataTable('#tableOfServiciosManipulado',{ scrollX: true, searching: false, @@ -1369,6 +1364,7 @@ async function get_servManipulado_tiradasAlternativas(tirada){ } return serviciosManipulado; } + */ /**************************************************************************************** * Seccion para los servicios de preimpresión diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php index 4804f3a3..37fecab2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php @@ -93,7 +93,7 @@ - + @@ -103,12 +103,6 @@
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/previews.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/previews.js deleted file mode 100644 index 0997fef0..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/previews.js +++ /dev/null @@ -1,1110 +0,0 @@ -// Global parameters -var pvObj; - -function previewInteriorPlana(lpTagName, isCosido, isTapaDura) { - - // Local parameters - let guardaV = 0; - let guardaH = 0; - let styleText = {size: 12, family: 'Public Sans'}; - - // Get the preview Object parameters - getObjetoLP(lpTagName, isCosido, isTapaDura); - - // Configuracion de las guardas - // Guarda vertical - if (pvObj.nFormasV > 1) { - guardaV = 3; - } - // Guarda horizontal - if (pvObj.nFormasH > 1) { - guardaH = 3; - } - // Constantes relativas a las dimnesiones de la forma - let LVo = pvObj.altoForma / 2; - let LHo = pvObj.anchoForma / 2; - - // Clear the canvas element - $('#pv_' + pvObj.idIndex + '_shape').empty(); - // Get the element for placing the graphical elements - var divPlana = document.getElementById('pv_' + pvObj.idIndex + '_shape'); - var _pvPlana = new Two({fitted: true}).appendTo(divPlana); - // Calculate the center of the canvas element - var origenPlana = new Two.Vector(_pvPlana.width / 2, _pvPlana.height / 2); - - var areaMaquinaPlana = _pvPlana.makeRectangle( - origenPlana.x, - origenPlana.y, - pvObj.anchoMaquina, - pvObj.altoMaquina); - areaMaquinaPlana.stroke = 'black'; - areaMaquinaPlana.fill = '#E69F6E'; - areaMaquinaPlana.linewidth = 1; - - var areaImpresionPlana = _pvPlana.makeRectangle( - origenPlana.x, - origenPlana.y, - pvObj.anchoImpresion, - pvObj.altoImpresion); - areaImpresionPlana.stroke = 'red'; - areaImpresionPlana.fill = '#FCEAF1'; - areaImpresionPlana.linewidth = 1; - - var formas = []; - - for (let iV = 0; iV < pvObj.nFormasV; iV++) { - - for (let iH = 0; iH < pvObj.nFormasH; iH++) { - - let _offsetX = ((((pvObj.nFormasH - 1) - 2 * iH) * LHo) + (((pvObj.nFormasH - 1) / 2 - iH) * guardaH)); - let _offsetY = ((((pvObj.nFormasV - 1) - 2 * iV) * LVo) + (((pvObj.nFormasV - 1) / 2 - iV) * guardaV)); - - formas[iV + iH] = _pvPlana.makeRectangle( - origenPlana.x + _offsetX, - origenPlana.y + _offsetY, - pvObj.anchoForma, - pvObj.altoForma); - formas[iV + iH].stroke = 'grey'; - formas[iV + iH].fill = '#F4F8F2'; - formas[iV + iH].linewidth = 1; - - // Texts - _pvPlana.makeText(pvObj.altoForma, (origenPlana.x + _offsetX) + (pvObj.anchoForma / 2 - 25), (origenPlana.y + _offsetY), styleText); - _pvPlana.makeText(pvObj.anchoForma, (origenPlana.x + _offsetX), (origenPlana.y + _offsetY) + (pvObj.altoForma / 2 - 15), styleText); - - } - } - _pvPlana.update(); -} - -function previewRotativa(lpTagName, isCosido, isTapaDura) { - - // Local parameters - let styleText = {size: 12, family: 'Public Sans'}; - let margenTop = 3; - let guardaV = 0; - let guardaH = 0; - - // Get the preview Object parameters - getObjetoLP(lpTagName, isCosido, isTapaDura); - - // Calculos - // Configuracion de las guardas - // Guarda vertical - if (pvObj.nFormasV > 1) { - guardaV = 3; - } - // Guarda horizontal - if (pvObj.nFormasH > 1) { - guardaH = 3; - } - // Constantes relativas al libro - let LVo = pvObj.altoForma / 2; - let LHo = pvObj.anchoForma / 2; - - // offset Y - let nTopForms = (pvObj.altoImpresion / 2.0 - margenTop) / (LVo + guardaV); - let yOffset = LVo * getDecimalPart(nTopForms); - - //console.log(yOffset); - - // Clear the canvas element - $('#pv_' + pvObj.idIndex + '_shape').empty(); - // Get the element for placing the graphical elements - var divRotativa = document.getElementById('pv_' + pvObj.idIndex + '_shape'); - var _pvRotativa = new Two({fitted: true}).appendTo(divRotativa); - // Calculate the center of the canvas element - var origenRotativa = new Two.Vector(_pvRotativa.width / 2, _pvRotativa.height / 2); - - var areaMaquinaRotativa = _pvRotativa.makeRectangle( - origenRotativa.x, - origenRotativa.y, - pvObj.anchoMaquina, - pvObj.altoMaquina); - areaMaquinaRotativa.stroke = 'black'; - areaMaquinaRotativa.fill = '#E69F6E'; - areaMaquinaRotativa.linewidth = 1; - - var areaImpresionRotativa = _pvRotativa.makeRectangle( - origenRotativa.x, - origenRotativa.y, - pvObj.anchoImpresion, - pvObj.altoImpresion); - areaImpresionRotativa.stroke = 'red'; - areaImpresionRotativa.fill = '#FCEAF1'; - areaImpresionRotativa.linewidth = 1; - - var areaClickRotativa = _pvRotativa.makeRectangle( - origenRotativa.x, - origenRotativa.y - (pvObj.altoImpresion / 2 - pvObj.altoClick / 2), - pvObj.anchoImpresion - 10, - pvObj.altoClick); - areaClickRotativa.stroke = 'blue'; - //areaClickRotativa.fill = '#FCEAF1'; - areaClickRotativa.linewidth = 2; - - var formas = []; - - for (let iV = 0; iV < pvObj.nFormasV; iV++) { - - for (let iH = 0; iH < pvObj.nFormasH; iH++) { - - let _offsetX = ((((pvObj.nFormasH - 1) - 2 * iH) * LHo) + (((pvObj.nFormasH - 1) / 2 - iH) * guardaH)); - let _offsetY = ((((pvObj.nFormasV - 1) - 2 * iV) * LVo) + (((pvObj.nFormasV - 1) / 2 - iV) * guardaV)); - - formas[iV + iH] = _pvRotativa.makeRectangle( - origenRotativa.x + _offsetX, - (origenRotativa.y - yOffset) + _offsetY, - pvObj.anchoForma, - pvObj.altoForma); - formas[iV + iH].stroke = 'grey'; - formas[iV + iH].fill = '#F4F8F2'; - formas[iV + iH].linewidth = 1; - - // Texts - _pvRotativa.makeText(pvObj.altoForma, (origenRotativa.x + _offsetX) + (pvObj.anchoForma / 2 - 25), ((origenRotativa.y - yOffset) + _offsetY), styleText); - _pvRotativa.makeText(pvObj.anchoForma, (origenRotativa.x + _offsetX), ((origenRotativa.y - yOffset) + _offsetY) + (pvObj.altoForma / 2 - 15), styleText); - - } - - } - - _pvRotativa.update(); - -} - -function getDecimalPart(floatNumber) { - let int_part = Math.trunc(floatNumber); - let float_part = Number((floatNumber - int_part).toFixed(2)); - return float_part; -} - - -function previewEsquemaCubierta(_lpTagName, _isCosido, _isTapaDura) { - - let tipoImpresion = parseInt($('#tipo_impresion_id').val()); - - // Fresado TD y Cosido TD - if (tipoImpresion === 1 || tipoImpresion === 3) { - portadaTapaDura(_lpTagName, _isCosido, _isTapaDura); - } - // 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) { - portadaEspiral(_lpTagName, _isCosido, _isTapaDura); - } - else if (tipoImpresion === 21) { - portadaGrapado(_lpTagName, _isCosido, _isTapaDura); - } - else { - // ? - } - -} - -function portadaTapaDura(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, - 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); - 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 + anchoCarton + " 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) + anchoCarton + " mm", - origenEC.x, - origenEC.y + (altoLibro / 2) + 50, - styleCotas); - - previewEC.update(); - -} - -function portadaTapaBlanda(lpTagName, isCosido, isTapaDura) { - - // 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 - - // Get the preview Object parameters - getObjetoLP(lpTagName, isCosido, isTapaDura); - - // Definicion de los parametros del Esquema de Cubierta (EC) - if (pvObj.anchoSolapa == 0) { - anchoSangrado = 600; // px - altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px - altoLibro = altoSangrado * 0.97; - anchoLibro = anchoSangrado * 0.419; - anchoSolapa = 0; - lomoLibro = anchoSangrado * 0.133; - anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; - - } else { - anchoSangrado = 600; // px - altoSangrado = (anchoSangrado * 0.418 > 350) ? anchoSangrado * 0.418 : 350; // 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 - $('#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; - - if (pvObj.anchoSolapa != 0) { - var solapas = previewEC.makeRectangle( - origenEC.x, - origenEC.y, - anchoCubierta, - altoLibro); - solapas.stroke = 'black'; - solapas.linewidth = 1; - - // Cotas Solapas - 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 - 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 + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); - previewEC.makeText(pvObj.anchoLibro + " 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 + pvObj.offsetSolapa)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm", - origenEC.x, - origenEC.y + (altoLibro / 2) + 50, - styleCotas); - - previewEC.update(); - -} - -function portadaEspiral(lpTagName, isCosido, isTapaDura) { - - // Variables locales - let altoLibro, anchoLibro, anchoCalle, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta; - let styleCotas = {size: 12, family: 'Public Sans'}; - let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm"; - let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm - - // Get the preview Object parameters - getObjetoLP(lpTagName, isCosido, isTapaDura); - - // Definicion de los parametros del Esquema de Cubierta (EC) - anchoSangrado = 600; // px - - if((pvObj.anchoSolapa !== 0) && (isTapaDura === 0)){ - altoSangrado = (anchoSangrado * 0.418 > 350) ? anchoSangrado * 0.418 : 350; // px - altoLibro = altoSangrado * 0.95; - anchoLibro = anchoSangrado * 0.28; - anchoCalle = anchoSangrado * 0.02; - anchoSolapa = anchoSangrado * 0.163; - sangrado = anchoSangrado * 0.03; - anchoCubierta = 2 * (anchoLibro + anchoSolapa+ sangrado) + anchoCalle; - offsetCubierta = anchoLibro/2 + anchoCalle/2 + anchoSolapa/2 + sangrado; - } - else { - altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px - altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.97; - anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.419; - anchoCalle = anchoSangrado * 0.02; - anchoSolapa = 0; - anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle; - offsetCubierta = anchoLibro/2 + anchoCalle/2 + anchoSolapa + sangradoValor; - } - - // 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; - - if (pvObj.anchoSolapa != 0) { - var solapa1 = previewEC.makeRectangle( - origenEC.x + (anchoLibro + anchoCalle/2 + anchoSolapa/2 + sangradoValor), - origenEC.y, - anchoSolapa, - altoLibro); - solapa1.stroke = 'black'; - solapa1.linewidth = 1; - - var solapa2 = previewEC.makeRectangle( - origenEC.x - (anchoLibro + anchoCalle/2 + anchoSolapa/2 + sangradoValor), - origenEC.y, - anchoSolapa, - altoLibro); - solapa2.stroke = 'black'; - solapa2.linewidth = 1; - - // Cotas Solapas - var cotaSolapa2 = previewEC.makeDobleArrow( - origenEC.x - (anchoCalle/2 + sangradoValor + anchoLibro + anchoSolapa), - origenEC.y - (altoLibro / 3), - origenEC.x - (anchoLibro + sangradoValor + anchoCalle / 2), - origenEC.y - (altoLibro / 3), - 10); - cotaSolapa2.linewidth = 2; - var cotaSolapa1 = previewEC.makeDobleArrow( - origenEC.x + (anchoCalle/2 + sangradoValor + anchoLibro + anchoSolapa), - origenEC.y - (altoLibro / 3), - origenEC.x + (anchoLibro + sangradoValor + anchoCalle / 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 + (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); - - } - - var portada = previewEC.makeRectangle( - origenEC.x + (anchoLibro/2 + anchoCalle/2 + sangradoValor), - origenEC.y, - anchoLibro, - altoLibro); - portada.stroke = 'black'; - portada.linewidth = 1; - - var contraportada = previewEC.makeRectangle( - origenEC.x - (anchoLibro/2 + anchoCalle/2 + sangradoValor), - origenEC.y, - anchoLibro, - altoLibro); - contraportada.stroke = 'black'; - contraportada.linewidth = 1; - - var calle = previewEC.makeRectangle( - origenEC.x, - origenEC.y, - anchoCalle, - altoSangrado); - calle.stroke = 'black'; - calle.dashes = [2, 5]; - calle.fill = '#F4F8F2'; - calle.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 + (anchoSangrado / 2) + 15, - origenEC.y + (altoSangrado / 2), - origenEC.x + (anchoSangrado / 2) + 15, - origenEC.y - (altoSangrado / 2), - 10); - cotaAltoCubierta.linewidth = 2; - var cotaAltoLibro = previewEC.makeDobleArrow( - origenEC.x + (anchoCalle / 2) + 35, - origenEC.y + (altoLibro / 2), - origenEC.x + (anchoCalle / 2) + 35, - origenEC.y - (altoLibro / 2), - 10); - cotaAltoLibro.linewidth = 2; - var cotaContraportada = previewEC.makeDobleArrow( - origenEC.x - (anchoCalle / 2 + anchoLibro + sangradoValor), - origenEC.y - (altoLibro / 3), - origenEC.x - ((anchoCalle / 2) + sangradoValor), - origenEC.y - (altoLibro / 3), - 10); - cotaContraportada.linewidth = 2; - var cotaPortada = previewEC.makeDobleArrow( - origenEC.x + ((anchoCalle / 2) + sangradoValor), - origenEC.y - (altoLibro / 3), - origenEC.x + (anchoCalle / 2 + anchoLibro + sangradoValor), - 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 + anchoLibro/2 + anchoCalle/2 + sangradoValor + 15, - origenEC.y, - stylesEC - ); - previewEC.makeText("Contraportada", - origenEC.x - (anchoLibro/2 + anchoCalle/2 + sangradoValor), - origenEC.y, - stylesEC - ); - // Sangrados - let styleSangrado = {size: 10, family: 'Public Sans', style: 'italic', fill: 'red'}; - previewEC.makeText(sangradoTexto, origenEC.x + offsetCubierta, origenEC.y + (altoLibro / 2 + 13), styleSangrado); - previewEC.makeText(sangradoTexto, origenEC.x + offsetCubierta, origenEC.y - (altoLibro / 2 + 13), styleSangrado); - previewEC.makeText(sangradoTexto, origenEC.x - offsetCubierta, origenEC.y + (altoLibro / 2 + 13), styleSangrado); - previewEC.makeText(sangradoTexto, origenEC.x - offsetCubierta, origenEC.y - (altoLibro / 2 + 13), styleSangrado); - 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", - origenEC.x + (anchoSangrado / 2) + 30, - origenEC.y, - styleCotas - ).rotation = -Math.PI / 2; - previewEC.makeText((2 * pvObj.anchoLibro) + pvObj.lomoLibro + (2 * sangradoValor) + " mm", - origenEC.x, - origenEC.y + (altoLibro / 2) + 50, - styleCotas); - - previewEC.update(); - -} - -function portadaGrapado(lpTagName, isCosido, isTapaDura) { - - // 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 - - // Get the preview Object parameters - getObjetoLP(lpTagName, isCosido, isTapaDura); - - // Definicion de los parametros del Esquema de Cubierta (EC) - if (pvObj.anchoSolapa == 0) { - anchoSangrado = 600; // px - altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // 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 { - anchoSangrado = 600; // px - altoSangrado = (anchoSangrado * 0.418 > 350) ? anchoSangrado * 0.418 : 350; // 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 - $('#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; - - if (pvObj.anchoSolapa != 0) { - var solapas = previewEC.makeRectangle( - origenEC.x, - origenEC.y, - anchoCubierta, - altoLibro); - solapas.stroke = 'black'; - solapas.linewidth = 1; - - // Cotas Solapas - 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 - 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(pvObj.anchoLibro + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); - previewEC.makeText(pvObj.anchoLibro + " 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 + pvObj.offsetSolapa)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm", - origenEC.x, - origenEC.y + (altoLibro / 2) + 50, - styleCotas); - - previewEC.update(); - -} - -function getLomoLibro() { - const anchoLomoInputs = $("#tableLineasPresupuesto tbody tr:visible td input[id*='_lomo']"); - const anchoLomo = Array.from(anchoLomoInputs).reduce((sum, input) => sum + parseFloat($(input).val()), 0); - - return parseFloat(anchoLomo.toFixed(2)); -} - - -function getObjetoLP(lpName, _isCosido, _isTapaDura) { - - let rowData = null; - - $('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { - - let lineaPresupuestoId = this.data().row_id.replace('lp_', ''); - - switch (lpName) { - case 'bn': - case 'bnhq': - case 'color': - case 'colorhq': - case 'cubierta': - case 'rot_bn': - case 'rot_color': - case 'guardas': - case 'sobrecubierta': - if (lineaPresupuestoId === lpName) { - rowData = this.data(); - } - break; - case 'ec': - if (lineaPresupuestoId === 'cubierta') { - rowData = this.data(); - } - break; - default: - //console.log(lineaPresupuestoId); - break; - } - - }); - - - pvObj = { - idIndex: lpName, - tipoImpresion: parseInt($('#tipo_impresion_id').val()), - gramajeLibro: parseInt(rowData.gramaje), - manoLP: parseFloat(rowData.lomo), - lomoLibro: getLomoLibro(), - anchoSolapa: $('#solapas').is(':checked') ? parseFloat($('#solapas_ancho').val()) : parseFloat(0), - nFormas: parseInt(rowData.formas), - nFormasH: parseInt(rowData.formas_h), - nFormasV: parseInt(rowData.formas_v), - orientacionFormas: rowData.formas_orientacion, - altoMaquina: parseFloat(rowData.maquina_alto), - anchoMaquina: parseFloat(rowData.maquina_ancho), - altoImpresion: parseFloat(rowData.maquina_impresion_alto), - anchoImpresion: parseFloat(rowData.maquina_impresion_ancho), - altoLibro: getDimensionLibro().alto, - anchoLibro: getDimensionLibro().ancho, - offsetSolapa: 0 - }; - - //console.log(pvObj); - - // Printing shape definition - 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); - $(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + rowData.papel_impresion_id); - $(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + rowData.maquina_id); - - $(pvName + '_gramaje').text(pvObj.gramajeLibro); - $(pvName + '_mano').text(pvObj.manoLP); - $(pvName + '_solapas').text(pvObj.anchoSolapa); - $(pvName + '_maquina').text(pvObj.anchoMaquina + "x" + pvObj.altoMaquina); - $(pvName + '_maquina_impresion').text(pvObj.anchoImpresion + "x" + pvObj.altoImpresion); - $(pvName + '_libro').text(pvObj.anchoLibro + "x" + pvObj.altoLibro); - $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - $(pvName + '_nFormas').text(pvObj.nFormas); - - if (pvObj.anchoSolapa != 0) { - $('.pv-solapas').show(); - pvObj.offsetSolapa = parseFloat(3); // 3mm - - } - - // Custom overwrites - switch (pvObj.idIndex) { - case 'cubierta': - // 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); - } - // 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 + pvObj.offsetSolapa)) + (2 * sangre) + pvObj.lomoLibro); - pvObj.altoForma += (2 * sangre); - } - // Grapado - else if (pvObj.tipoImpresion === 21) { - let sangre = parseFloat(5); // mm - pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + pvObj.offsetSolapa)) + (2 * sangre)); - 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 sangre = parseFloat(20); // mm - pvObj.anchoForma = pvObj.anchoLibro; - } else { - // ? - } - - // Update labels - $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - break; - - case 'sobrecubierta': - sangre = parseFloat(5); // mm - let anchoSolapaSobrecubierta = $('#solapas_sobrecubierta').is(':checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : parseFloat(0); // mm - if (_isTapaDura) { - let anchoPliegue = parseFloat(7); // mm - let altoPliegue = parseFloat(7); // mm - pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaSobrecubierta + pvObj.offsetSolapa)) + (2 * sangre) + pvObj.lomoLibro); - pvObj.altoForma += altoPliegue + (2 * sangre); - } else { - pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * (anchoSolapaSobrecubierta + pvObj.offsetSolapa)) + (2 * sangre) + pvObj.lomoLibro); - pvObj.altoForma += (2 * sangre); - } - - // Update labels - $(pvName + '_solapas').text(anchoSolapaSobrecubierta); - anchoSolapaSobrecubierta != 0 ? $('.pv-solapas').show() : $('.pv-solapas').hide(); - $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - break; - case 'ec': - $(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + rowData.papel); - $(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + rowData.papel_impresion_id); - $(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + rowData.maquina_id); - $('#pv_ec_lomo').text(pvObj.lomoLibro); - break; - - case 'rot_bn': - case 'rot_color': - // Conditional assignements depending on rotation of the printing shape - if (pvObj.orientacionFormas == 'v') { - let auxReg = pvObj.altoForma; - pvObj.altoForma = pvObj.anchoForma; - pvObj.anchoForma = auxReg; - } - $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - 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; - - case 'bn': - case 'bnhq': - case 'color': - case 'colorhq': - // Conditional assignements depending on rotation of the printing shape - if (pvObj.orientacionFormas == 'v') { - let auxReg = pvObj.altoForma; - pvObj.altoForma = pvObj.anchoForma; - pvObj.anchoForma = auxReg; - } - $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - break; - case 'guardas': - // 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; - pvObj.altoForma = pvObj.anchoForma; - pvObj.anchoForma = auxReg; - } - $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); - break; - - default: - break; - } -} - - -function getVisibleTabs() { - const table = $('#tableLineasPresupuesto').DataTable(); - - // Clear all existing tabs - $('*[id*=tab-pv-]').hide().find('.active').removeClass('active'); - $('*[id*=pv_]').removeClass('active show'); - - // Enable active tabs - table.rows().every(function () { - const lpName = this.data().row_id.replace('lp_', ''); - const tabName = lpName.replace('_', '-'); - - if (['bn', 'bnhq', 'color', 'colorhq', 'rot_bn', 'rot_color', 'guardas', 'cubierta', 'sobrecubierta'].includes(lpName)) { - $(`#tab-pv-${tabName}`).show(); - - if (lpName === 'cubierta') { - $(`#tab-pv-${tabName}`).show(); - $(`#tab-pv-esquema-${tabName}`).show(); - } - } - - - }); -} \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 6ff810f6..f8ef50a5 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -6,7 +6,7 @@ section("content") ?> -
+

@@ -302,16 +302,7 @@ - - diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 2d061698..1c3b12f2 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -6,6 +6,7 @@ import DatosLibro from './sections/datosLibro.js'; import Comparador from './sections/comparador.js'; import LineasPresupuesto from './sections/lineasPresupuesto.js'; import PreviewFormasAdmin from './sections/previewFormasAdmin.js'; +import Servicios from './sections/servicios.js'; class PresupuestoAdminEdit { @@ -38,6 +39,7 @@ class PresupuestoAdminEdit { }); this.previewFormasAdmin = null; + this.servicios = new Servicios(); this.calcularPresupuesto = false; } @@ -80,6 +82,7 @@ class PresupuestoAdminEdit { } ); this.previewFormasAdmin.init(); + this.servicios.init(); if (window.location.href.includes("edit")) { @@ -121,6 +124,8 @@ class PresupuestoAdminEdit { self.datosLibro.cargarDatos(response.data.datosLibro); self.comparador.cargarDatos(response.data.comparador); self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto); + + self.servicios.cargar(); /*self.direcciones.handleChangeCliente(); self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index bd357b73..516727f3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -244,6 +244,8 @@ class Comparador { this.sobrecubierta.on('change', () => { if (this.sobrecubierta.val() == 1) { $('#solapas_sobrecubierta').prop('checked', true); + $('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); + $('#solapas_ancho_sobrecubierta').val(60); $('#compPapelSobrecubierta').prop('disabled', false); $('#compGramajeSobrecubierta').prop('disabled', false); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 44abc868..a406eb5b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -172,8 +172,6 @@ class DatosLibro { this.checkPaginasPresupuesto(); - $('.tamanio-personalizado').addClass('d-none'); - $(document).trigger('update-lineas-presupuesto'); // TO-DO @@ -211,10 +209,10 @@ class DatosLibro { changeSolapasCubierta() { if (this.solapasCubierta.prop('checked')) { - this.divSolapasCubierta.removeClass('d-none'); + $('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); } else { - this.divSolapasCubierta.addClass('d-none'); + $('#div_solapas_ancho_sobrecubierta').divSolapasCubierta.addClass('d-none'); this.anchoSolapasCubierta.val(0); } $('#serv_default').trigger('click'); @@ -388,12 +386,12 @@ class DatosLibro { if (datos.solapasCubierta) { this.solapasCubierta.prop('checked', true); this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho); - $('#div_solapas_ancho').removeClass('d-none'); + this.divSolapasSobrecubierta.removeClass('d-none'); } else{ this.solapasCubierta.prop('checked', false); this.anchoSolapasCubierta.val(0); - $('#div_solapas_ancho').addClass('d-none'); + this.divSolapasSobrecubierta.addClass('d-none'); } } if (datos.solapasSobrecubierta) { @@ -403,7 +401,7 @@ class DatosLibro { } else{ this.solapasSobrecubierta.prop('checked', false); - this.anchoSolapasSobrecubierta.val(0); + this.anchoSolapasSobrecubierta.val(60); $('#div_solapas_ancho_sobrecubierta').addClass('d-none'); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 8e68b1d6..092cdcda 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -674,7 +674,7 @@ class LineasPresupuesto {
` + - window.Presupuestos.errores.paginasLP + + window.language.Presupuestos.errores.paginasLP + `
`; @@ -1463,7 +1463,7 @@ class LineasPresupuesto { cliente_id: $('#clienteId').find(":selected").val(), }; - if(datos.ancho==0 || datos.alto==0){ + if(datos.ancho==0 || datos.alto==0 || datos.ancho=='' || datos.alto=='' || isNaN(datos.ancho) || isNaN(datos.alto)){ return; }