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 efa33485..d4088b2f 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 @@ -114,7 +114,7 @@ function previewRotativa(lpTagName) { let nTopForms = (pvObj.altoImpresion / 2.0 - margenTop) / (LVo + guardaV); let yOffset = LVo * getDecimalPart(nTopForms); - console.log(yOffset); + //console.log(yOffset); // Clear the canvas element $('#pv_' + pvObj.idIndex + '_shape').empty(); @@ -371,7 +371,7 @@ function getObjetoLP(lpName) { pvObj = { idIndex: lpName, - gramajeLibro: parseFloat($('#lp_' + lpName + '_gramaje').val()), + gramajeLibro: parseInt($('#lp_' + lpName + '_gramaje').text()), manoLP: parseFloat($('#lp_' + lpName + '_lomo').val()), lomoLibro: getLomoLibro(), anchoSolapa: parseFloat($('#solapas_ancho').val()), @@ -391,13 +391,6 @@ function getObjetoLP(lpName) { pvObj.anchoForma = (_isCosido) ? 2 * pvObj.anchoLibro : pvObj.anchoLibro; pvObj.altoForma = pvObj.altoLibro; - // Conditional assignements depending on rotation of the printing shape - if (pvObj.orientacionFormas == 'v') { - let auxReg = pvObj.altoForma; - pvObj.altoForma = pvObj.anchoForma; - pvObj.anchoForma = auxReg; - } - // Update preview info fields let pvName = '#pv_' + lpName; $(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + $('#lp_' + lpName + '_papel').val()); @@ -437,8 +430,29 @@ function getObjetoLP(lpName) { case 'rot_bn': case 'rot_color': + if((pvObj.anchoImpresion / pvObj.altoForma) > (pvObj.anchoImpresion / pvObj.anchoForma)){ + let auxReg = pvObj.anchoForma; + pvObj.anchoForma = pvObj.altoForma; + pvObj.altoForma = auxReg; + } + $(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma); pvObj.altoClick = 305; //parseFloat($('#lp_' + lpName + '_alto_click').val()); - pvObj.nFormasV = Math.trunc(pvObj.altoImpresion / pvObj.altoForma); + pvObj.nFormasH = Math.trunc(pvObj.anchoImpresion / pvObj.anchoForma); + pvObj.nFormasV = Math.trunc((pvObj.altoImpresion - 3) / (pvObj.altoForma + 4)); + console.log( ) + 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; default: @@ -449,26 +463,60 @@ function getObjetoLP(lpName) { function getVisibleTabs() { - $("#tableLineasPresupuesto tbody tr:visible").each(function () { + $("#tableLineasPresupuesto tbody tr").each(function () { + let isVisible = $(this).is(":visible"); + let lpName = $(this).attr('id').replace('lp_', ''); + let tabName = lpName.replace('_', '-'); - //console.log("Visible: " + $(this).attr('id')); - if ($(this).attr('id').indexOf('cubierta') > -1) { - $("#" + $(this).attr('id').replace('lp_', 'tab-pv-')).show(); - $("#" + $(this).attr('id').replace('lp_', 'tab-pv-esquema-')).show(); - $("#pv_cubierta").addClass("active show"); - $("#pv_esquema-cubierta").addClass("active show"); - } else if ($(this).attr('id').indexOf('_data') > -1) { - // Do nothing here - } else if ($(this).attr('id').indexOf('_rot') > -1) { - $("#" + $(this).attr('id').replace('lp_rot_', 'tab-pv-rot-')).show(); - $("#" + $(this).attr('id').replace('lp_', '')).addClass("active show"); - } else { - $("#" + $(this).attr('id').replace('lp_', 'tab-pv-')).show(); - $("#" + $(this).attr('id').replace('lp_', '')).addClass("active show"); + switch (lpName){ + case 'bn': + case 'bnhq': + case 'color': + case 'colorhq': + case 'rot_bn': + case 'rot_color': + if(isVisible) { + $("#tab-pv-" + tabName).show(); + }else{ + $("#tab-pv-" + tabName).hide(); + $("#tab-pv-" + tabName).children('.active').each(function () { + $(this).removeClass('active'); + }); + $("#pv_" + lpName).removeClass("active show"); + } + break; + + + case 'cubierta': + if(isVisible) { + $("#tab-pv-" + tabName).show(); + $("#tab-pv-esquema-" + tabName).show(); + }else{ + $("#tab-pv-" + tabName).hide(); + $("#tab-pv-esquema-" + tabName).hide(); + $("#tab-pv-" + tabName).children('.active').each(function () { + $(this).removeClass('active'); + }); + $("#tab-pv-esquema-" + tabName).children('.active').each(function () { + $(this).removeClass('active'); + }); + $("#pv_" + lpName).removeClass("active show"); + $("#pv_esquema_" + lpName).removeClass("active show"); + } + break; + + default: + //console.log(tabType + " visible? " +isVisible ); + break; } + //console.log(tabType + " visible? " +isVisible ); + }); + + /* + $("#tableLineasPresupuesto tbody tr:hidden").each(function () { //console.log("Hidden: " + $(this).attr('id')); @@ -476,17 +524,19 @@ function getVisibleTabs() { $("#" + $(this).attr('id').replace('lp_', 'tab-pv-')).hide(); $("#" + $(this).attr('id').replace('lp_', 'tab-pv-esquema-')).hide(); $("#pv_cubierta").removeClass("active show"); - $("#pv_esquema-cubierta").removeClass("active show"); + $("#pv_esquema_cubierta").removeClass("active show"); } else if ($(this).attr('id').indexOf('_data') > -1) { // Do nothing here } else if ($(this).attr('id').indexOf('_rot') > -1) { $("#" + $(this).attr('id').replace('lp_rot_', 'tab-pv-rot-')).hide(); - $("#" + $(this).attr('id').replace('lp_', '')).removeClass("active show"); + $("#" + $(this).attr('id').replace('lp_', 'pv_')).removeClass("active show"); } else { $("#" + $(this).attr('id').replace('lp_', 'tab-pv-')).hide(); - $("#" + $(this).attr('id').replace('lp_', '')).removeClass("active show"); + $("#" + $(this).attr('id').replace('lp_', 'pv_')).removeClass("active show"); } }); + */ + }