From 02133bf0b968d7de113714517c1b5f9dfd324e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez=20Ortega?= Date: Tue, 7 Nov 2023 08:38:49 +0100 Subject: [PATCH 01/10] trabajando en meter los datos en las lineas de presupuesto --- .../_lineasPresupuestoItems.php | 61 +++++++++++++------ .../cosidotapablanda/comparador.js | 35 +++++++++-- .../viewCosidotapablandaForm.php | 2 +- 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index 34fa2795..9fa29c9e 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -35,7 +35,7 @@ - + @@ -75,10 +75,10 @@ - + - + @@ -118,10 +118,10 @@ - + - + @@ -161,10 +161,10 @@ - + - + @@ -204,10 +204,10 @@ - + - + @@ -247,9 +247,9 @@ - + - +
@@ -456,7 +456,7 @@ - + @@ -496,10 +496,10 @@ - + - +
@@ -704,7 +704,7 @@ - + @@ -744,10 +744,10 @@ - + - + @@ -787,7 +787,7 @@ - + @@ -1013,4 +1013,29 @@ function calcularPresupuesto_bn(){ }) } +// Delete row +$(document).on('click', '.btn-delete', function(e) { + const row_id = $(this).closest('tr')[0].id; + $(".btn-remove").attr('row-id', row_id); + +}); + + +$(document).on('click', '.btn-remove', function(e) { + const row_id = $(this).attr('row-id'); + switch(row_id) { + case 'lp_bn': + clear_lp_bn(true); + row = $('#' + row_id).css('display', 'none'); + break; + case 'lp_bn_hq': + // code block + break; + default: + // code block + } + $('#confirm2delete').modal('toggle'); +}); + + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 6194f0ec..fc8b1871 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -151,20 +151,47 @@ $('.accordion-button').on('click', function (e) { /******************************* * Metodos *******************************/ +function fill_lp_bn(row){ + $('#lp_bn_paginas').val(row['paginas']) + + $.when($('#lp_bn_papel').val('').change()) + .then(function(){ + $.when($('#lp_bn_papel').val(row['papelGenericoId']).change()) + .then(function() { + $.when($('#lp_bn_gramaje').val(1).change()) + .then(function() { + $('#lp_bn_maquina').val(row['maquinaId']).change(); + }) + + }) + }) + + /* + $('#lp_bn_gramaje').val(row['gramaje']).change(); + $('#lp_bn_papelImpresion').val(row['papelImpresionId']).change(); + $('#lp_bn_maquina').val(row['maquinaId']).change();*/ + $('#lp_bn').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} + + $('.insertarLinea').on("click", function (e) { if(e.target.id.includes("Plana")){ // Se borran todas las líneas que no sean cubierta y sobrecubierta - $('#tableLineasPresupuesto').DataTable() + /*$('#tableLineasPresupuesto').DataTable() .rows( function ( idx, data, node ) { return data[0] !== 'cubierta' && data[0] !== 'sobrecubierta'; } ) .remove() - .draw(); + .draw();*/ var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); - console.log(rows); for(row of rows){ + if(row['tipo'] =='bn'){ + fill_lp_bn(row); + + }/* $('#tableLineasPresupuesto').DataTable().row.add({ 'tipo': row['tipo'], 'paginas': row['paginas'], @@ -189,7 +216,7 @@ $('.insertarLinea').on("click", function (e) { 'papelGenericoId': row['papelGenericoId'], 'papelImpresionId': row['papelImpresionId'], } - ).draw(); + ).draw();*/ } } }); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index daf4ea2f..cbfc610c 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -358,7 +358,7 @@ }, }); - + $('.comp_negro_items').on('change', function (e) { From d9512293572cc3d4b6bb350020144a09fd61d46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 7 Nov 2023 14:48:49 +0100 Subject: [PATCH 02/10] finalizado lp bn bnhq color y colorhq en plana --- .../_lineasPresupuestoItems.php | 1008 +++++++++++++++-- .../cosidotapablanda/comparador.js | 71 -- .../viewCosidotapablandaForm.php | 2 + 3 files changed, 902 insertions(+), 179 deletions(-) diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index 9fa29c9e..04caf69b 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -35,7 +35,7 @@ - + @@ -78,9 +78,9 @@ - + - + + - - - - - - - - + + + + + + - - - - + + + + - + - + + - - - - - - - - + + + + + + - - - - + + + + - + - + + - - - - - - - - + + + + + + - - - - + + + + - + @@ -249,7 +249,7 @@ - +
@@ -456,7 +456,7 @@ - + @@ -499,7 +499,7 @@ - +
@@ -831,34 +831,85 @@ $('#lp_rot_bn_vercalculos').on("click", function () { }); -function clear_lp_bn(clear_selectors){ - let pags = $("#lp_bn_paginas" ).val() - $(".lp-bn-input" ).val("0") - $("#lp_bn_paginas" ).val(pags) - if(clear_selectors) - $( ".lp-bn-select").empty() -} +// Delete row +$(document).on('click', '.btn-delete', function(e) { + const row_id = $(this).closest('tr')[0].id; + $(".btn-remove").attr('row-id', row_id); + +}); -function fill_lp_bn(data){ - $('#lp_bn_tiempo').val(data.tiempo_maquina) - $('#lp_bn_numeroPliegos').val(isNaN(parseFloat(data.pliegos_libro)) ? "" : parseFloat(data.pliegos_libro).toFixed(2)) - $('#lp_bn_pliegosPedido').val(isNaN(parseFloat(data.pliegos_pedido)) ? "" : parseFloat(data.pliegos_pedido).toFixed(2)) - $('#lp_bn_precioPliego').val(isNaN(parseFloat(data.precios_pliegos)) ? "" : parseFloat(data.precios_pliegos).toFixed(6)) - $('#lp_bn_libro').val(isNaN(parseFloat(data.precio_libro)) ? "" : parseFloat(data.precio_libro).toFixed(2)) - $('#lp_bn_totalPapelPedido').val(isNaN(parseFloat(data.precio_pedido)) ? "" : parseFloat(data.precio_pedido).toFixed(2)) - $('#lp_bn_lomo').val(isNaN(parseFloat(data.mano)) ? "" : parseFloat(data.mano).toFixed(2)) - $('#lp_bn_peso').val(isNaN(parseFloat(data.peso)) ? "" : parseFloat(data.peso).toFixed(2)) - $('#lp_bn_click').val(isNaN(parseFloat(data.precio_click)) ? "" : parseFloat(data.precio_click).toFixed(6)) - $('#lp_bn_totalClicks').val(isNaN(parseFloat(data.precio_click_pedido)) ? "" : parseFloat(data.precio_click_pedido).toFixed(2)) + +$(document).on('click', '.btn-remove', function(e) { + const row_id = $(this).attr('row-id') + clear_interior(row_id) + $('#confirm2delete').modal('toggle') +}); + +function clear_interior(row_id = ''){ + switch(row_id) { + case 'lp_bn': + clear_lp_bn(true); + $('#' + row_id).css('display', 'none'); + break; + case 'lp_color': + clear_lp_color(true); + $('#' + row_id).css('display', 'none'); + break; + case 'lp_bnhq': + clear_lp_bnhq(true); + $('#' + row_id).css('display', 'none'); + break; + case 'lp_colorhq': + clear_lp_colorhq(true); + $('#' + row_id).css('display', 'none'); + break; + default: + clear_lp_bn(true); + clear_lp_color(true); + clear_lp_bnhq(true); + clear_lp_colorhq(true); + $('.lp-interior').css('display', 'none'); + break; + } } +$('.insertarLinea').on("click", function (e) { -$('#lp_bn_papel').on("change", function () { - clear_lp_bn(true) - $.ajax({ + if(e.target.id.includes("Plana")){ + + clear_interior(); + + var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + if(row['tipo'] =='bn'){ + fill_lp_bn(row, true); + } + else if(row['tipo'] =='bnhq'){ + fill_lp_bnhq(row, true); + } + else if(row['tipo'] =='color'){ + fill_lp_color(row, true); + } + else if(row['tipo'] =='colorhq'){ + fill_lp_colorhq(row, true); + } + } + } +}); +endSection() ?> + + + + +section("additionalInlineJs") ?> +async function set_lp_bn_gramaje(){ + await $.ajax({ type: 'post', url: '', + beforeSend: function() { + clear_lp_bn(true) + }, data: { tipo: 'gramajeLineasPresupuesto', uso: 'interior', @@ -876,16 +927,20 @@ $('#lp_bn_papel').on("change", function () { $('#lp_bn_gramaje').val('') } }); -}) +} -$('#lp_bn_gramaje').on("change", function () { - $('#lp_bn_papelImpresion').empty() - $('#lp_bn_maquina').empty() - clear_lp_bn(false) - $.ajax({ + + +async function set_lp_bn_papelImpresion(){ + await $.ajax({ type: 'post', url: '', + beforeSend: function() { + $('#lp_bn_papelImpresion').empty() + $('#lp_bn_maquina').empty() + clear_lp_bn(false) + }, data: { tipo: 'papelImpresion', uso: 'negro', @@ -904,23 +959,25 @@ $('#lp_bn_gramaje').on("change", function () { $('#lp_bn_papelImpresion').val('') } }); -}) +} -$('#lp_bn_papelImpresion').on("change", function () { - $('#lp_bn_maquina').empty() - clear_lp_bn(false) - const dimension = getDimensionLibro(); - $.ajax({ +async function set_lp_bn_maquina(){ + + await $.ajax({ type: 'post', url: '', + beforeSend: function() { + $('#lp_bn_maquina').empty() + clear_lp_bn(false) + }, data: { tipo: 'maquina', uso: 'negro', tipoLinea: "interior", is_rotativa: 0, - ancho: dimension.ancho, - alto: dimension.alto, + ancho: getDimensionLibro().ancho, + alto: getDimensionLibro().alto, datos: parseInt($('#tirada').val()) + parseInt($('#merma').val()), papel_impresion: $('#lp_bn_papelImpresion option:selected').val() , : v @@ -935,7 +992,23 @@ $('#lp_bn_papelImpresion').on("change", function () { $('#lp_bn_maquina').val('') } }); -}) +} + + +function clear_lp_bn(clear_selectors){ + let pags = $("#lp_bn_paginas" ).val() + $(".lp-bn-input" ).val("0") + $("#lp_bn_paginas" ).val(pags) + if(clear_selectors) + $( ".lp-bn-select").empty() +} + +$('#lp_bn_gramaje').bind("focus", set_lp_bn_gramaje); +$('#lp_bn_papelImpresion').focus("focus", set_lp_bn_papelImpresion); +$('#lp_bn_maquina').bind("focus", set_lp_bn_maquina); + + + $('#lp_bn_maquina').on("change", function () { @@ -945,6 +1018,7 @@ $('#lp_bn_maquina').on("change", function () { } }) + $('#lp_bn_paginas').on("change", function () { if( parseInt($('#lp_bn_paginas').val())>0 && @@ -976,8 +1050,6 @@ function calcularPresupuesto_bn(){ : v }; - console.log(datos) - $.ajax({ type: "POST", url: "/cosidotapablanda/datatable", @@ -1013,29 +1085,749 @@ function calcularPresupuesto_bn(){ }) } -// Delete row -$(document).on('click', '.btn-delete', function(e) { - const row_id = $(this).closest('tr')[0].id; - $(".btn-remove").attr('row-id', row_id); +function fill_lp_bn(row, fromComparator=false){ + + if(fromComparator){ + $('#lp_bn_paginas').val(row.paginas) + $('#lp_bn_papel').val(row.papelGenericoId) + $('#lp_bn_gramaje').empty() + $('#lp_bn_gramaje').append(``); + $('#lp_bn_papelImpresion').empty() + $('#lp_bn_papelImpresion').append(``); + $('#lp_bn_maquina').empty() + $('#lp_bn_maquina').append(``); + $('#lp_bn_tiempo').val(row.tiempoMaquina) + $('#lp_bn_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) + $('#lp_bn_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) + $('#lp_bn_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) + $('#lp_bn_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) + $('#lp_bn_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) + $('#lp_bn_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) + $('#lp_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_bn_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) + $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + } + else{ + // Si viene de hacerlo a mano... + $('#lp_bn_tiempo').val(row.tiempo_maquina) + $('#lp_bn_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_bn_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_bn_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_bn_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_bn_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_bn_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_bn_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + } + + + $('#lp_bn').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} +endSection() ?> + + + + +section("additionalInlineJs") ?> +async function set_lp_color_gramaje(){ + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_color(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'interior', + datos: $('#lp_color_papel option:selected').val() , + tipoLinea: "color", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('`); + $('#lp_color_papelImpresion').empty() + $('#lp_color_papelImpresion').append(``); + $('#lp_color_maquina').empty() + $('#lp_color_maquina').append(``); + $('#lp_color_tiempo').val(row.tiempoMaquina) + $('#lp_color_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) + $('#lp_color_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) + $('#lp_color_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) + $('#lp_color_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) + $('#lp_color_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) + $('#lp_color_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) + $('#lp_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_color_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) + $('#lp_color_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + } + else{ + // Si viene de hacerlo a mano... + $('#lp_color_tiempo').val(row.tiempo_maquina) + $('#lp_color_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_color_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_color_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_color_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_color_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_color_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_color_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_color_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + } + + + $('#lp_color').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} +endSection() ?> + + + + +section("additionalInlineJs") ?> +async function set_lp_bnhq_gramaje(){ + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_bnhq(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'interior', + datos: $('#lp_bnhq_papel option:selected').val() , + tipoLinea: "negrohq", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('`); + $('#lp_bnhq_papelImpresion').empty() + $('#lp_bnhq_papelImpresion').append(``); + $('#lp_bnhq_maquina').empty() + $('#lp_bnhq_maquina').append(``); + $('#lp_bnhq_tiempo').val(row.tiempoMaquina) + $('#lp_bnhq_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) + $('#lp_bnhq_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) + $('#lp_bnhq_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) + $('#lp_bnhq_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) + $('#lp_bnhq_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) + $('#lp_bnhq_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) + $('#lp_bnhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_bnhq_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) + $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + } + else{ + // Si viene de hacerlo a mano... + $('#lp_bnhq_tiempo').val(row.tiempo_maquina) + $('#lp_bnhq_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_bnhq_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_bnhq_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_bnhq_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_bnhq_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_bnhq_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_bnhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_bnhq_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + } + + + $('#lp_bnhq').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} +endSection() ?> + + + + +section("additionalInlineJs") ?> +async function set_lp_colorhq_gramaje(){ + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_colorhq(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'interior', + datos: $('#lp_colorhq_papel option:selected').val() , + tipoLinea: "colorhq", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('`); + $('#lp_colorhq_papelImpresion').empty() + $('#lp_colorhq_papelImpresion').append(``); + $('#lp_colorhq_maquina').empty() + $('#lp_colorhq_maquina').append(``); + $('#lp_colorhq_tiempo').val(row.tiempoMaquina) + $('#lp_colorhq_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) + $('#lp_colorhq_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) + $('#lp_colorhq_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) + $('#lp_colorhq_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) + $('#lp_colorhq_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) + $('#lp_colorhq_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) + $('#lp_colorhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_colorhq_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) + $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + } + else{ + // Si viene de hacerlo a mano... + $('#lp_colorhq_tiempo').val(row.tiempo_maquina) + $('#lp_colorhq_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_colorhq_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_colorhq_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_colorhq_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_colorhq_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_colorhq_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_colorhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_colorhq_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + } + + + $('#lp_colorhq').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index fc8b1871..17da355f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -151,77 +151,6 @@ $('.accordion-button').on('click', function (e) { /******************************* * Metodos *******************************/ -function fill_lp_bn(row){ - $('#lp_bn_paginas').val(row['paginas']) - - $.when($('#lp_bn_papel').val('').change()) - .then(function(){ - $.when($('#lp_bn_papel').val(row['papelGenericoId']).change()) - .then(function() { - $.when($('#lp_bn_gramaje').val(1).change()) - .then(function() { - $('#lp_bn_maquina').val(row['maquinaId']).change(); - }) - - }) - }) - - /* - $('#lp_bn_gramaje').val(row['gramaje']).change(); - $('#lp_bn_papelImpresion').val(row['papelImpresionId']).change(); - $('#lp_bn_maquina').val(row['maquinaId']).change();*/ - $('#lp_bn').css('display', '') - $("#tableLineasPresupuesto").DataTable().columns.adjust(); -} - - -$('.insertarLinea').on("click", function (e) { - - if(e.target.id.includes("Plana")){ - // Se borran todas las líneas que no sean cubierta y sobrecubierta - /*$('#tableLineasPresupuesto').DataTable() - .rows( function ( idx, data, node ) { - return data[0] !== 'cubierta' && data[0] !== 'sobrecubierta'; - } ) - .remove() - .draw();*/ - - var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if(row['tipo'] =='bn'){ - fill_lp_bn(row); - - }/* - $('#tableLineasPresupuesto').DataTable().row.add({ - 'tipo': row['tipo'], - 'paginas': row['paginas'], - 'papel': row['papel'], - 'gramaje': row['gramaje'], - 'marca': row['marca'], - 'maquina': row['maquina'], - 'tiempo': row['tiempoMaquina'], - 'numeroPliegos': row['numeroPliegos'], - 'pliegosPedido': row['pliegosPedido'], - 'precioPliego': row['precioPliego'], - 'libro': row['libro'], - 'totalPapelPedido': row['totalPapelPedido'], - 'chekPapel': true, - 'lomo': row['lomo'], - 'peso': row['peso'], - 'click': row['click'], - 'totalClicks': row['totalClicks'], - 'chekClicks': true, - 'maquinaId': row['maquinaId'], - 'maquinaVelocidad': row['maquinaVelocidad'], - 'papelGenericoId': row['papelGenericoId'], - 'papelImpresionId': row['papelImpresionId'], - } - ).draw();*/ - } - } -}); - - function getRowFromLineaInt(tipo, linea) { return { diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index cbfc610c..513daada 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -1071,6 +1071,8 @@ endSection() ?> + + section('css') ?> From 72d5673e37d268a40d4d81287b05d6278f7166d4 Mon Sep 17 00:00:00 2001 From: imnavajas Date: Wed, 8 Nov 2023 09:00:23 +0100 Subject: [PATCH 03/10] =?UTF-8?q?A=C3=B1adida=20funcionalidad=20de=20gener?= =?UTF-8?q?ar=20alertas=20en=20base=20al=20id=20de=20un=20contenedor=20esp?= =?UTF-8?q?ecifico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../themes/_commonPartialsBs/_alertBoxes.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php index ab60abcd..9c195cfb 100644 --- a/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php +++ b/ci4/app/Views/themes/_commonPartialsBs/_alertBoxes.php @@ -24,7 +24,7 @@ if (session()->has('error')) { section('additionalInlineJs') ?> -function popAlert(message, alertClass, alertIcon){ +function popAlert(message, alertClass, alertIcon, containerId = 'sk-alert'){ var htmlString = `
`; - $(window).scrollTop(0); - $('#sk-alert').hide().empty().html(htmlString).fadeIn("slow", function(){ + if(containerId == 'sk-alert'){ + $(window).scrollTop(0); + } + $('#' + containerId).hide().empty().html(htmlString).fadeIn("slow", function(){ setTimeout(function(){ - $('#sk-alert').fadeOut("slow"); + $('#' + containerId).fadeOut("slow"); }, 5000); }); } -function popSuccessAlert(successMsg){ - popAlert(successMsg, "alert-success", "ti-check"); +function popSuccessAlert(successMsg, containerId = 'sk-alert'){ + popAlert(successMsg, "alert-success", "ti-check", containerId); } -function popWarningAlert(warningMsg){ - popAlert(warningMsg, "alert-warning", "ti-bell"); +function popWarningAlert(warningMsg, containerId = 'sk-alert'){ + popAlert(warningMsg, "alert-warning", "ti-bell", containerId); } -function popErrorAlert(errorMsg){ - popAlert(errorMsg, "alert-danger", "ti-ban"); +function popErrorAlert(errorMsg, containerId = 'sk-alert'){ + popAlert(errorMsg, "alert-danger", "ti-ban", containerId); } From 397d69f823a38a1dc3018bea8979f3e76f930032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 8 Nov 2023 14:45:49 +0100 Subject: [PATCH 04/10] trabajando en los mensajes de error --- .../Presupuestos/Cosidotapablanda.php | 5 +++ ci4/app/Language/es/Presupuestos.php | 6 ++++ .../cosidotapablanda/_datosLibroItems.php | 12 +++---- .../_datosPresupuestoClienteItems.php | 3 ++ .../cosidotapablanda/comparador.js | 23 +++++++------ .../viewCosidotapablandaForm.php | 33 ++++++++++++++++--- 6 files changed, 59 insertions(+), 23 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index bda99c9d..c34ffbf5 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -632,6 +632,11 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController ->findTipologiasForPapelImpresion($papel->id, $parametrosRotativa->colorPages>0?'color':'negro') ->get()->getResultObject(); + + if(count($datosTipologias)==0){ + continue; + } + $parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro; $parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color; $parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro; diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index f7fbe29a..eacd0296 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -166,6 +166,12 @@ return [ 'max_length' => 'El campo {field} no puede exceder los {param} caracteres de longitud.', ], + 'errores' => [ + 'paginas' => 'El campo páginas tiene que ser mayor que cero', + 'tiradas' => 'El campo tiradas tiene que ser mayor que cero', + 'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm', + ], + /* '4x0' => '4x0', '4x4' => '4x4', diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index ac6a29b5..52a47e14 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -19,7 +19,7 @@ - +
@@ -29,7 +29,7 @@
- solapas == true ? 'checked' : ''; ?>> + solapas == true ? 'checked' : ''; ?>>
@@ -44,7 +44,7 @@ - +
@@ -55,7 +55,7 @@ * - @@ -95,7 +95,7 @@ - + @@ -104,7 +104,7 @@ - + diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php index e01eb3b1..a380239f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php @@ -9,6 +9,9 @@
+ +
+
diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 17da355f..729a2070 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -212,15 +212,6 @@ function getRowFromLineaRot(linea) { } -function checkDatosPedidoForComp() { - - if (parseInt($('#paginas').val()) > 0 && - parseInt($('#tirada').val()) > 0 && - ($('#papelFormatoId').select2('data').length > 0 || - (parseInt($('#papelFormatoAncho').val()) > 0 && parseInt($('#papelFormatoAlto').val()) > 0))) - return true; - return false; -} @@ -486,12 +477,20 @@ function getIDsComparador(is_color, is_hq){ function getDimensionLibro(){ var ancho = 0; var alto = 0; + if($('#papelFormatoId').select2('data').length > 0){ - ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]); - alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]); + if($('#papelFormatoId').select2('data')[0].id.length > 0){ + ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]); + alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]); + } + else if(document.getElementById('papelFormatoPersonalizado').checked){ + ancho = parseFloat(document.getElementById('papelFormatoAncho').value); + alto = parseFloat(document.getElementById('papelFormatoAlto').value); + } } - else{ + + else if(document.getElementById('papelFormatoPersonalizado').checked){ ancho = parseFloat(document.getElementById('papelFormatoAncho').value); alto = parseFloat(document.getElementById('papelFormatoAlto').value); } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 513daada..75b12f17 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -485,7 +485,6 @@ } return false; } - $('.comp_cubierta_items').on('change', function (){ @@ -591,7 +590,6 @@ if ($(''+ elementos.papel).select2('data').length > 0 && $(''+ elementos.gramaje).select2('data').length > 0 && - parseInt($(''+ elementos.paginas).val()) > 0 && checkDatosPedidoForComp()) { getLineasIntPlana(is_color, is_hq).then((result) =>{ @@ -835,10 +833,9 @@ function checkComparadorInt(is_color, is_hq) { elementos = getIDsComparador(is_color, is_hq) - + if ($(''+ elementos.papel).select2('data').length > 0 && $(''+ elementos.gramaje).select2('data').length > 0 && - parseInt($(''+ elementos.paginas).val()) > 0 && checkDatosPedidoForComp()) { getLineasIntPlana(is_color, is_hq).then((result) =>{ @@ -1069,6 +1066,33 @@ } }); + + function checkDatosPedidoForComp() { + + const dimension = getDimensionLibro(); + + if (parseInt($('#paginas').val()) <= 0){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + if (parseInt($('#tirada').val()) <= 0){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + if('ancho' in dimension && 'alto' in dimension){ + + if(dimension.alto < 60 || dimension.ancho < 60 || isNaN(dimension.alto) || isNaN(dimension.ancho) ){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + } + else{ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + return true; + } + endSection() ?> @@ -1090,5 +1114,4 @@ - endSection() ?> From 75eb95b04045c9187afbb7253d2d688447b56e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez=20Ortega?= Date: Fri, 10 Nov 2023 13:18:02 +0100 Subject: [PATCH 05/10] terminado lineas de presupuesto --- .../Presupuestos/Cosidotapablanda.php | 70 +- ci4/app/Language/en/Presupuestos.php | 11 + ci4/app/Language/es/Presupuestos.php | 5 + ci4/app/Models/Configuracion/MaquinaModel.php | 5 +- .../Configuracion/PapelGenericoModel.php | 33 +- .../Configuracion/PapelImpresionModel.php | 30 +- ci4/app/Services/PresupuestoService.php | 2 + .../_lineasPresupuestoItems.php | 1364 +++++++++++++++-- .../cosidotapablanda/comparador.js | 1 + .../viewCosidotapablandaForm.php | 50 +- 10 files changed, 1347 insertions(+), 224 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index c34ffbf5..baf1c877 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -145,6 +145,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ(); $this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta(); $this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta(); + $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); + $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); // Tarifas $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); @@ -440,6 +442,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController ]; $gramaje = $reqData['gramaje'] ?? 0; + + if ($type=='interior') { @@ -461,7 +465,21 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController 'color' => intval($reqData['paginas_color']) ?? 0, ); - $resourceData = $this->getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas); + $datosTipolog = $reqData['negro'] ?? null; + if(!is_null($datosTipolog)){ + $datosTipolog = []; + $data = (object)array( + 'negro' => intval($reqData['negro']) ?? 0, + 'cyan' => intval($reqData['cyan']) ?? 0, + 'magenta' => intval($reqData['magenta']) ?? 0, + 'amarillo' => intval($reqData['amarillo']) ?? 0, + 'gota_negro' => intval($reqData['gota_negro']) ?? 0, + 'gota_color' => intval($reqData['gota_color']) ?? 0, + ); + array_push($datosTipolog, $data); + } + + $resourceData = $this->getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $datosTipolog); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -551,6 +569,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto( is_rotativa: 0, tarifa_tipo: $tipo, + uso_tarifa: $uso, tirada: $datosPedido->tirada + $datosPedido->merma, papel_impresion_id: $papel->id, ); @@ -584,7 +603,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $lineas; } - public function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas) + public function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $datosTipolog = null) { $uso = 'interior'; @@ -628,13 +647,18 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController foreach ($papeles as $papel) { $papelImpresionTipologiaModel = new \App\Models\Configuracion\PapelImpresionTipologiaModel(); - $datosTipologias = $papelImpresionTipologiaModel - ->findTipologiasForPapelImpresion($papel->id, $parametrosRotativa->colorPages>0?'color':'negro') - ->get()->getResultObject(); + if(is_null($datosTipolog)){ + $datosTipologias = $papelImpresionTipologiaModel + ->findTipologiasForPapelImpresion($papel->id, $parametrosRotativa->colorPages>0?'color':'negro') + ->get()->getResultObject(); - - if(count($datosTipologias)==0){ - continue; + + if(count($datosTipologias)==0){ + continue; + } + } + else{ + $datosTipologias = $datosTipolog; } $parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro; @@ -649,6 +673,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto( is_rotativa: 1, tarifa_tipo: $tipo, + uso_tarifa: $uso, tirada: $datosPedido->tirada + $datosPedido->merma, papel_impresion_id: $papel->id, ); @@ -683,6 +708,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $linea['fields']['papel_impresion'] = $papel->nombre; $linea['fields']['papel_impresion_id'] = $papel->id; $linea['fields']['paginas'] = $datosPedido->paginas; + $linea['fields']['paginas_color'] = $paginas->color; $linea['fields']['gramaje'] = $gramaje; $linea['fields']['papel_generico_id'] = $papel_generico['id']; $linea['fields']['papel_generico'] = $papel_generico['nombre']; @@ -691,6 +717,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $linea['fields']['num_formas_horizontales'] = floor($linea['fields']['factor_anchura']); $linea['fields']['num_formas_verticales'] = floor($linea['fields']['factor_altura']); + $linea['fields']['datosTipologias'] = $datosTipologias[0]; + // impresion $linea['fields']['precio_click'] = $tarifa; $linea['fields']['precio_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click']; @@ -791,8 +819,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $alto = $reqData['alto'] ?? null; // Datos contiene la tirada // uso: negro, negrohq, color, colorhq, + $uso_tarifa = $reqData['uso_tarifa'] ?? 'interior'; $model = new MaquinaModel(); - $maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $datos, $papel_impresion ); + $maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $uso_tarifa ,$datos, $papel_impresion ); $menu = []; foreach ($maquinas as $maquina){ @@ -855,6 +884,29 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $data; } + + protected function getPapelGenericoRotativaNegro() + { + $model = model('App\Models\Configuracion\PapelGenericoModel'); + $data = $model->getPapelForComparador('negro', false, false, true); + array_unshift($data, (object)array( + "id" => 0, + "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) + )); + return $data; + } + + protected function getPapelGenericoRotativaColor() + { + $model = model('App\Models\Configuracion\PapelGenericoModel'); + $data = $model->getPapelForComparador('color', false, false, true); + array_unshift($data, (object)array( + "id" => 0, + "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) + )); + return $data; + } + protected function getPapelGenericoNegro() { $model = model('App\Models\Configuracion\PapelGenericoModel'); diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index dc64feb9..5805cb1c 100644 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -92,6 +92,8 @@ return [ 'color' => 'Colour', 'colorhq' => 'ColourHQ', 'rotativa' => 'Rotary', + 'rotativa_bn' => 'Rot. BW', + 'rotativa_color' => 'Rot. Colour', 'si' => 'Yes', 'no' => 'No', 'insertarLinea' => 'Insert Line', @@ -137,6 +139,15 @@ return [ 'totalCorte' => 'Total Cut', 'totalImpresion' => 'TOTAL PRINT', + 'addLineaPresupuesto' => 'Add line...', + + 'errores' => [ + 'paginas' => 'The field pages must be greater than zero', + 'tiradas' => 'The field print must be greater than zero', + 'dimension' => 'The book dimension must be greater than 60mm', + 'lineaDuplicada' => 'That type of line already exists in the budget.', + ], + /* '4x0' => '4x0', '4x4' => '4x4', 'aprobadoAt' => 'Aprobado At', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index eacd0296..1bb07df4 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -91,6 +91,8 @@ return [ 'color' => 'Color', 'colorhq' => 'ColorHQ', 'rotativa' => 'Rotativa', + 'rotativa_bn' => 'Rot. BN', + 'rotativa_color' => 'Rot. Color', 'si' => 'Si', 'no' => 'No', 'insertarLinea' => 'Insertar Línea', @@ -143,6 +145,8 @@ return [ 'gTintaMagentaPed' => 'G.T. Magenta Ped.', 'gTintaAmarilloPed' => 'G.T. Amarillo Ped.', + 'addLineaPresupuesto' => 'Añadir linea...', + 'servicioAcabado' => 'Servicio de acabado', 'servicioPreimpresion' => 'Servicio de preimpresión', 'servicioEncuadernado' => 'Servicio de encuadernado', @@ -170,6 +174,7 @@ return [ 'paginas' => 'El campo páginas tiene que ser mayor que cero', 'tiradas' => 'El campo tiradas tiene que ser mayor que cero', 'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm', + 'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto' ], diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index ac68b85a..d7988a1b 100644 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -336,7 +336,7 @@ class MaquinaModel extends \App\Models\GoBaseModel ->groupEnd(); } - public function getMaquinaImpresionForPresupuesto($is_rotativa, $tarifa_tipo, $tirada, $papel_impresion_id = -1) + public function getMaquinaImpresionForPresupuesto($is_rotativa, $tarifa_tipo, $uso_tarifa = 'interior', $tirada, $papel_impresion_id = -1) { /* 1.-> tarifa_Tipo impresion @@ -371,11 +371,12 @@ class MaquinaModel extends \App\Models\GoBaseModel if(is_array($tarifa_tipo)){ foreach($tarifa_tipo as $tarifa){ - $builder->where("EXISTS (SELECT * FROM lg_maquinas_tarifas_impresion t2 WHERE t1.id=t2.maquina_id AND t2.tipo='{$tarifa}' AND t2.is_deleted=0)"); + $builder->where("EXISTS (SELECT * FROM lg_maquinas_tarifas_impresion t2 WHERE t1.id=t2.maquina_id AND t2.tipo='{$tarifa}' AND t2.uso='{$uso_tarifa}' AND t2.is_deleted=0)"); } } else{ $builder->where("t2.tipo", $tarifa_tipo); + $builder->where("t2.uso", $uso_tarifa); } return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 17b68119..ce45bbfa 100644 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -93,7 +93,7 @@ class PapelGenericoModel extends \App\Models\GoBaseModel } - public function getPapelForComparador($tipo, $is_cubierta = null, $is_sobrecubierta = null) + public function getPapelForComparador($tipo, $is_cubierta = null, $is_sobrecubierta = null, $rotativa = null) { /* 1.-> Tipo impresion @@ -124,12 +124,19 @@ class PapelGenericoModel extends \App\Models\GoBaseModel $builder->where("t2.cubierta", 1); } } + if(!is_null($is_sobrecubierta)){ if($is_sobrecubierta==true){ $builder->where("t2.sobrecubierta", 1); } } + if(!is_null($rotativa)){ + if($rotativa==true){ + $builder->where("t2.rotativa", 1); + } + } + return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); } @@ -162,15 +169,23 @@ class PapelGenericoModel extends \App\Models\GoBaseModel ->where("t4.tipo", "impresion") ->where("t5.tipo", $tipo) ->where("t1.nombre", $papel_generico_nombre); + + $uso_tarifa = 'interior'; if($uso == 'bn' || $uso == 'bnhq') $builder->where("t2.bn", 1); else if ($uso == 'color' || $uso == 'colorhq') $builder->where("t2.color", 1); - else if ($uso == 'cubierta') + else if ($uso == 'cubierta'){ + $uso_tarifa = 'cubierta'; $builder->where("t2.cubierta", 1); - else if ($uso == 'sobrecubierta') + } + else if ($uso == 'sobrecubierta'){ + $uso_tarifa = 'sobrecubierta'; $builder->where("t2.sobrecubierta", 1); + } + + $builder->where("t5.uso", $uso_tarifa); $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); $id = 1; @@ -209,18 +224,26 @@ class PapelGenericoModel extends \App\Models\GoBaseModel ->where("t5.tipo", $tipo) ->where("t1.id", $papel_generico_id); + $uso_tarifa = 'interior'; + if($tipo == 'negro' || $tipo == 'negrohq') $builder->where("t2.bn", 1); else if ($tipo == 'color' || $tipo == 'colorhq') $builder->where("t2.color", 1); - if ($uso == 'cubierta') + if ($uso == 'cubierta'){ + $uso_tarifa = 'cubierta'; $builder->where("t2.cubierta", 1); - else if ($uso == 'sobrecubierta') + } + else if ($uso == 'sobrecubierta'){ + $uso_tarifa = 'sobrecubierta'; $builder->where("t2.sobrecubierta", 1); + } if($uso=='rotativa') $builder->where("t2.rotativa", 1); else $builder->where("t2.rotativa", 0); + + $builder->where("t5.uso", $uso_tarifa); $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index 4e53176b..f9474e97 100644 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -295,35 +295,7 @@ class PapelImpresionModel extends \App\Models\GoBaseModel $builder->where("t1.rotativa", 1); else $builder->where("t1.rotativa", 0); -/* - if($tipo=='negro' || $tipo=='negrohq'){ - $builder->where("t1.bn", 1); - $builder->where("t1.rotativa", 0); - } - elseif($tipo=='color' || $tipo=='colorhq'){ - $builder->where("t1.color", 1); - $builder->where("t1.rotativa", 0); - } - elseif($tipo=='cubierta'){ - $builder->where("t1.cubierta", 1); - $builder->where("t1.color", 1); - $builder->where("t1.rotativa", 0); - } - elseif($tipo=='sobrecubierta'){ - $builder->where("t1.sobrecubierta", 1); - $builder->where("t1.color", 1); - $builder->where("t1.rotativa", 0); - } - elseif($tipo=='rot_bn'){ - $builder->where("t1.bn", 1); - $builder->where("t1.rotativa", 1); - } - elseif($tipo=='rot_color'){ - $builder->where("t1.color", 1); - $builder->where("t1.rotativa", 1); - } -*/ - + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 81ddd6a3..3b51b4ad 100644 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -233,6 +233,8 @@ class PresupuestoService extends BaseService $data['precio_pagina_color'] = round($pag_color ? $data['precio_tinta'] / ($pag_color * ($datosPedido->tirada + $datosPedido->merma)) : 0, 6); // calculo de corte + $data['velocidad_corte'] = $maquina->velocidad_corte; + $data['precio_hora_corte'] = $maquina->precio_hora_corte; $data['tiempo_corte'] = $maquina->velocidad_corte > 0 ? round($metros_papel_total / $maquina->velocidad_corte, 2) : 0; $data['total_corte'] = round(($data['tiempo_corte'] / 60.0) * $maquina->precio_hora_corte, 2); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index 04caf69b..01476f71 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -9,6 +9,10 @@
+ +
+ + @@ -35,7 +39,7 @@ - + - + - + - + + - + - + - - - - - - + + + + + + - - - - + + + + - + + - + - - - - - - + + + + + + - - - - + + + + - + - + - + - - - - - - + + + + + + - - - - + + + + @@ -792,8 +806,27 @@
+ + +
+
+
+
+ + +
+
+
-
@@ -813,7 +846,9 @@ $('#lp_rot_bn_papel').val(''); $('#lp_rot_color_papel').val(''); $('#lp_cubierta_papel').val(''); $('#lp_sobrecubierta_papel').val(''); +$('#addLineasPresupuesto').val(''); + $('#lp_rot_color_vercalculos').on("click", function () { if($( ".calculos_rot_color" ).css('display') == 'none') $( ".calculos_rot_color" ).css('display', 'flex') @@ -841,10 +876,19 @@ $(document).on('click', '.btn-delete', function(e) { $(document).on('click', '.btn-remove', function(e) { const row_id = $(this).attr('row-id') - clear_interior(row_id) + if(row_id.includes('rot')){ + clear_rotativa(row_id) + } + else if(row_id.includes('cubierta')){ + clear_cubierta() + } + else{ + clear_interior(row_id) + } $('#confirm2delete').modal('toggle') }); + function clear_interior(row_id = ''){ switch(row_id) { case 'lp_bn': @@ -874,11 +918,38 @@ function clear_interior(row_id = ''){ } +function clear_rotativa(row_id = ''){ + switch(row_id) { + case 'lp_rot_bn': + clear_lp_rot_bn(true); + $('.lp_rot_bn').css('display', 'none'); + break; + case 'lp_rot_color': + clear_lp_rot_color(true); + $('.lp_rot_color').css('display', 'none'); + break; + default: + clear_lp_rot_bn(true); + clear_lp_rot_color(true); + $('.lp_rot_bn').css('display', 'none'); + $('.lp_rot_color').css('display', 'none'); + break; + } +} + + +function clear_cubierta(){ + clear_lp_cubierta(true); + $('#lp_cubierta').css('display', 'none'); +} + + $('.insertarLinea').on("click", function (e) { if(e.target.id.includes("Plana")){ clear_interior(); + clear_rotativa(); var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); for(row of rows){ @@ -896,7 +967,97 @@ $('.insertarLinea').on("click", function (e) { } } } + if(e.target.id.includes("Rotativa")){ + + clear_rotativa(); + clear_interior(); + + var rows = $("#tableCompIntRotativa").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + if(row['paginasColor'] ==0){ + fill_lp_rot_bn(row, true); + } + else if(row['paginasColor'] >0){ + fill_lp_rot_color(row, true); + } + } + } + + if(e.target.id.includes("Cubierta")){ + + clear_cubierta(); + + var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + fill_lp_cubierta(row, true); + } + } }); + + +$('#addLineasPresupuesto').on("change", function (e) { + switch($('#addLineasPresupuesto').val()){ + case 'lp_bn': + if($('#lp_bn').css('display') == 'none'){ + $('.lp_bn').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + case 'lp_bnhq': + if($('#lp_bnhq').css('display') == 'none'){ + $('.lp_bnhq').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + case 'lp_color': + if($('#lp_color').css('display') == 'none'){ + $('.lp_color').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + case 'lp_colorhq': + if($('#lp_colorhq').css('display') == 'none'){ + $('.lp_colorhq').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + case 'lp_rot_bn': + if($('#lp_rot_bn').css('display') == 'none'){ + $('.lp_rot_bn').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + case 'lp_rot_color': + if($('#lp_rot_color').css('display') == 'none'){ + $('.lp_rot_color').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + case 'lp_cubierta': + if($('#lp_cubierta').css('display') == 'none'){ + $('#lp_cubierta').css('display', 'flex') + } + else{ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); + } + break + default: + break + } +}) + endSection() ?> @@ -1003,14 +1164,13 @@ function clear_lp_bn(clear_selectors){ $( ".lp-bn-select").empty() } + +$('#lp_bn_papel').bind("focus", {clear_selectors: true}, clear_lp_bn); $('#lp_bn_gramaje').bind("focus", set_lp_bn_gramaje); $('#lp_bn_papelImpresion').focus("focus", set_lp_bn_papelImpresion); $('#lp_bn_maquina').bind("focus", set_lp_bn_maquina); - - - $('#lp_bn_maquina').on("change", function () { if(parseInt($('#lp_bn_paginas').val())>0){ @@ -1237,6 +1397,7 @@ function clear_lp_color(clear_selectors){ $( ".lp-color-select").empty() } +$('#lp_color_papel').bind("focus", {clear_selectors: true}, clear_lp_color); $('#lp_color_gramaje').bind("focus", set_lp_color_gramaje); $('#lp_color_papelImpresion').focus("focus", set_lp_color_papelImpresion); $('#lp_color_maquina').bind("focus", set_lp_color_maquina); @@ -1468,14 +1629,11 @@ function clear_lp_bnhq(clear_selectors){ $( ".lp-bnhq-select").empty() } +$('#lp_bnhq_papel').bind("focus", {clear_selectors: true}, clear_lp_bnhq); $('#lp_bnhq_gramaje').bind("focus", set_lp_bnhq_gramaje); $('#lp_bnhq_papelImpresion').focus("focus", set_lp_bnhq_papelImpresion); $('#lp_bnhq_maquina').bind("focus", set_lp_bnhq_maquina); - - - - $('#lp_bnhq_maquina').on("change", function () { if(parseInt($('#lp_bnhq_paginas').val())>0){ @@ -1702,14 +1860,13 @@ function clear_lp_colorhq(clear_selectors){ $( ".lp-colorhq-select").empty() } + +$('#lp_colorhq_papel').bind("focus", {clear_selectors: true}, clear_lp_colorhq); $('#lp_colorhq_gramaje').bind("focus", set_lp_colorhq_gramaje); $('#lp_colorhq_papelImpresion').focus("focus", set_lp_colorhq_papelImpresion); $('#lp_colorhq_maquina').bind("focus", set_lp_colorhq_maquina); - - - $('#lp_colorhq_maquina').on("change", function () { if(parseInt($('#lp_colorhq_paginas').val())>0){ @@ -1830,4 +1987,917 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq').css('display', '') $("#tableLineasPresupuesto").DataTable().columns.adjust(); } +endSection() ?> + + + + +section("additionalInlineJs") ?> +async function set_lp_rot_bn_gramaje(){ + + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_rot_bn(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'rotativa', + datos: $('#lp_rot_bn_papel option:selected').val() , + tipoLinea: "negro", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('`); + $('#lp_rot_bn_papelImpresion').empty() + $('#lp_rot_bn_papelImpresion').append(``); + $('#lp_rot_bn_maquina').empty() + $('#lp_rot_bn_maquina').append(``); + $('#lp_rot_bn_aFavorFibra').prop('checked', row.aFavorFibra=='si'?true:false) + calcularPresupuesto_rot_bn(false); + + } + else{ + // Si viene de hacerlo a mano... + $('#lp_rot_bn_tiempo').val(row.tiempo_maquina) + $('#lp_rot_bn_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_rot_bn_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_rot_bn_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_rot_bn_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_rot_bn_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_rot_bn_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_rot_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_rot_bn_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_rot_bn_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + $('#lp_rot_bn_totalLinea').val(isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2)) + $('#lp_rot_bn_aFavorFibra').prop('checked', row.a_favor_fibra==0?false:true) + + $('#lp_rot_bn_cobNegro').val(isNaN(parseFloat(row.datosTipologias.negro)) ? "" : parseFloat(row.datosTipologias.negro).toFixed(0)) + $('#lp_rot_bn_cobCyan').val(isNaN(parseFloat(row.datosTipologias.cyan)) ? "" : parseFloat(row.datosTipologias.cyan).toFixed(0)) + $('#lp_rot_bn_cobMagenta').val(isNaN(parseFloat(row.datosTipologias.magenta)) ? "" : parseFloat(row.datosTipologias.magenta).toFixed(0)) + $('#lp_rot_bn_cobAmarillo').val(isNaN(parseFloat(row.datosTipologias.amarillo)) ? "" : parseFloat(row.datosTipologias.amarillo).toFixed(0)) + $('#lp_rot_bn_gotaNegro').val(isNaN(parseFloat(row.datosTipologias.gota_negro)) ? "" : parseFloat(row.datosTipologias.gota_negro).toFixed(0)) + $('#lp_rot_bn_gotaColor').val(isNaN(parseFloat(row.datosTipologias.gota_color)) ? "" : parseFloat(row.datosTipologias.gota_color).toFixed(0)) + + $('#lp_rot_bn_metrosMinuto').val(isNaN(parseFloat(row.maquina_velocidad)) ? "" : parseFloat(row.maquina_velocidad).toFixed(2)) + $('#lp_rot_bn_resolucion').val(isNaN(parseFloat(row.resolucion)) ? "" : parseFloat(row.resolucion).toFixed(0)) + $('#lp_rot_bn_areaPaginas').val(isNaN(parseFloat(row.superficie)) ? "" : parseFloat(row.superficie).toFixed(2)) + $('#lp_rot_bn_gotasNegro').val(isNaN(parseFloat(row.num_gotas_negro)) ? "" : parseFloat(row.num_gotas_negro).toFixed(0)) + $('#lp_rot_bn_gotasCyan').val(isNaN(parseFloat(row.num_gotas_cyan)) ? "" : parseFloat(row.num_gotas_cyan).toFixed(0)) + $('#lp_rot_bn_gotasMagenta').val(isNaN(parseFloat(row.num_gotas_magenta)) ? "" : parseFloat(row.num_gotas_magenta).toFixed(0)) + $('#lp_rot_bn_gotasAmarillo').val(isNaN(parseFloat(row.num_gotas_amarillo)) ? "" : parseFloat(row.num_gotas_amarillo).toFixed(0)) + $('#lp_rot_bn_precioPagNegro').val(isNaN(parseFloat(row.precio_pagina_negro)) ? "" : parseFloat(row.precio_pagina_negro).toFixed(6)) + $('#lp_rot_bn_precioPagColor').val(isNaN(parseFloat(row.precio_pagina_color)) ? "" : parseFloat(row.precio_pagina_color).toFixed(6)) + $('#lp_rot_bn_factorAltura').val(isNaN(parseFloat(row.factor_altura)) ? "" : parseFloat(row.factor_altura).toFixed(2)) + $('#lp_rot_bn_factorAnchura').val(isNaN(parseFloat(row.factor_anchura)) ? "" : parseFloat(row.factor_anchura).toFixed(2)) + $('#lp_rot_bn_paginasPliego').val(isNaN(parseFloat(row.paginas_por_pliego)) ? "" : parseFloat(row.paginas_por_pliego).toFixed(2)) + + $('#lp_rot_bn_metrosPapelLibro').val(isNaN(parseFloat(row.metros_papel_libro)) ? "" : parseFloat(row.metros_papel_libro).toFixed(2)) + $('#lp_rot_bn_metrosPapelTotal').val(isNaN(parseFloat(row.metros_papel_total)) ? "" : parseFloat(row.metros_papel_total).toFixed(2)) + $('#lp_rot_bn_clicksLibro').val(isNaN(parseFloat(row.clicks_libro)) ? "" : parseFloat(row.clicks_libro).toFixed(0)) + $('#lp_rot_bn_gTintaNegro').val(isNaN(parseFloat(row.peso_gotas_negro)) ? "" : parseFloat(row.peso_gotas_negro).toFixed(2)) + $('#lp_rot_bn_gTintaCyan').val(isNaN(parseFloat(row.peso_gotas_cyan)) ? "" : parseFloat(row.peso_gotas_cyan).toFixed(2)) + $('#lp_rot_bn_gTintaMagenta').val(isNaN(parseFloat(row.peso_gotas_magenta)) ? "" : parseFloat(row.peso_gotas_magenta).toFixed(2)) + $('#lp_rot_bn_gTintaAmarillo').val(isNaN(parseFloat(row.peso_gotas_amarillo)) ? "" : parseFloat(row.peso_gotas_amarillo).toFixed(2)) + $('#lp_rot_bn_clicksPedido').val(isNaN(parseFloat(row.clicks_pedido)) ? "" : parseFloat(row.clicks_pedido).toFixed(0)) + $('#lp_rot_bn_totalClicksPedido').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + $('#lp_rot_bn_totalTinta').val(isNaN(parseFloat(row.precio_tinta)) ? "" : parseFloat(row.precio_tinta).toFixed(2)) + $('#lp_rot_bn_totalCorte').val(isNaN(parseFloat(row.total_corte)) ? "" : parseFloat(row.total_corte).toFixed(2)) + $('#lp_rot_bn_totalImpresion').val(isNaN(parseFloat(row.precio_click_pedido+row.precio_tinta+row.total_corte)) ? "" : parseFloat(row.precio_click_pedido+row.precio_tinta+row.total_corte).toFixed(2)) + + $('#lp_rot_bn_velocidadCorte').val(isNaN(parseFloat(row.velocidad_corte)) ? "" : parseFloat(row.velocidad_corte).toFixed(2)) + $('#lp_rot_bn_precioHoraCorte').val(isNaN(parseFloat(row.precio_hora_corte)) ? "" : parseFloat(row.precio_hora_corte).toFixed(2)) + $('#lp_rot_bn_tiempoCorte').val(isNaN(parseFloat(row.tiempo_corte)) ? "" : parseFloat(row.tiempo_corte).toFixed(2)) + $('#lp_rot_bn_gTintaNegroPed').val(isNaN(parseFloat(row.peso_gotas_negro_pedido)) ? "" : parseFloat(row.peso_gotas_negro_pedido).toFixed(2)) + $('#lp_rot_bn_gTintaCyanPed').val(isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)) + $('#lp_rot_bn_gTintaMagentaPed').val(isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)) + $('#lp_rot_bn_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) + } + + + $('.lp_rot_bn').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} +endSection() ?> + + + + + + +section("additionalInlineJs") ?> +async function set_lp_rot_color_gramaje(){ + + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_rot_color(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'rotativa', + datos: $('#lp_rot_color_papel option:selected').val() , + tipoLinea: "color", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('`); + $('#lp_rot_color_papelImpresion').empty() + $('#lp_rot_color_papelImpresion').append(``); + $('#lp_rot_color_maquina').empty() + $('#lp_rot_color_maquina').append(``); + $('#lp_rot_color_aFavorFibra').prop('checked', row.aFavorFibra=='si'?true:false) + $('#lp_rot_color_numPagColor').val(row.paginasColor) + calcularPresupuesto_rot_color(false); + + } + else{ + // Si viene de hacerlo a mano... + $('#lp_rot_color_tiempo').val(row.tiempo_maquina) + $('#lp_rot_color_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_rot_color_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_rot_color_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_rot_color_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_rot_color_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_rot_color_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_rot_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_rot_color_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_rot_color_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + $('#lp_rot_color_totalLinea').val(isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2)) + $('#lp_rot_color_aFavorFibra').prop('checked', row.a_favor_fibra==0?false:true) + + $('#lp_rot_color_cobNegro').val(isNaN(parseFloat(row.datosTipologias.negro)) ? "" : parseFloat(row.datosTipologias.negro).toFixed(0)) + $('#lp_rot_color_cobCyan').val(isNaN(parseFloat(row.datosTipologias.cyan)) ? "" : parseFloat(row.datosTipologias.cyan).toFixed(0)) + $('#lp_rot_color_cobMagenta').val(isNaN(parseFloat(row.datosTipologias.magenta)) ? "" : parseFloat(row.datosTipologias.magenta).toFixed(0)) + $('#lp_rot_color_cobAmarillo').val(isNaN(parseFloat(row.datosTipologias.amarillo)) ? "" : parseFloat(row.datosTipologias.amarillo).toFixed(0)) + $('#lp_rot_color_gotaNegro').val(isNaN(parseFloat(row.datosTipologias.gota_negro)) ? "" : parseFloat(row.datosTipologias.gota_negro).toFixed(0)) + $('#lp_rot_color_gotaColor').val(isNaN(parseFloat(row.datosTipologias.gota_color)) ? "" : parseFloat(row.datosTipologias.gota_color).toFixed(0)) + + $('#lp_rot_color_metrosMinuto').val(isNaN(parseFloat(row.maquina_velocidad)) ? "" : parseFloat(row.maquina_velocidad).toFixed(2)) + $('#lp_rot_color_resolucion').val(isNaN(parseFloat(row.resolucion)) ? "" : parseFloat(row.resolucion).toFixed(0)) + $('#lp_rot_color_areaPaginas').val(isNaN(parseFloat(row.superficie)) ? "" : parseFloat(row.superficie).toFixed(2)) + $('#lp_rot_color_gotasNegro').val(isNaN(parseFloat(row.num_gotas_negro)) ? "" : parseFloat(row.num_gotas_negro).toFixed(0)) + $('#lp_rot_color_gotasCyan').val(isNaN(parseFloat(row.num_gotas_cyan)) ? "" : parseFloat(row.num_gotas_cyan).toFixed(0)) + $('#lp_rot_color_gotasMagenta').val(isNaN(parseFloat(row.num_gotas_magenta)) ? "" : parseFloat(row.num_gotas_magenta).toFixed(0)) + $('#lp_rot_color_gotasAmarillo').val(isNaN(parseFloat(row.num_gotas_amarillo)) ? "" : parseFloat(row.num_gotas_amarillo).toFixed(0)) + $('#lp_rot_color_precioPagNegro').val(isNaN(parseFloat(row.precio_pagina_negro)) ? "" : parseFloat(row.precio_pagina_negro).toFixed(6)) + $('#lp_rot_color_precioPagColor').val(isNaN(parseFloat(row.precio_pagina_color)) ? "" : parseFloat(row.precio_pagina_color).toFixed(6)) + $('#lp_rot_color_factorAltura').val(isNaN(parseFloat(row.factor_altura)) ? "" : parseFloat(row.factor_altura).toFixed(2)) + $('#lp_rot_color_factorAnchura').val(isNaN(parseFloat(row.factor_anchura)) ? "" : parseFloat(row.factor_anchura).toFixed(2)) + $('#lp_rot_color_paginasPliego').val(isNaN(parseFloat(row.paginas_por_pliego)) ? "" : parseFloat(row.paginas_por_pliego).toFixed(2)) + + $('#lp_rot_color_metrosPapelLibro').val(isNaN(parseFloat(row.metros_papel_libro)) ? "" : parseFloat(row.metros_papel_libro).toFixed(2)) + $('#lp_rot_color_metrosPapelTotal').val(isNaN(parseFloat(row.metros_papel_total)) ? "" : parseFloat(row.metros_papel_total).toFixed(2)) + $('#lp_rot_color_clicksLibro').val(isNaN(parseFloat(row.clicks_libro)) ? "" : parseFloat(row.clicks_libro).toFixed(0)) + $('#lp_rot_color_gTintaNegro').val(isNaN(parseFloat(row.peso_gotas_negro)) ? "" : parseFloat(row.peso_gotas_negro).toFixed(2)) + $('#lp_rot_color_gTintaCyan').val(isNaN(parseFloat(row.peso_gotas_cyan)) ? "" : parseFloat(row.peso_gotas_cyan).toFixed(2)) + $('#lp_rot_color_gTintaMagenta').val(isNaN(parseFloat(row.peso_gotas_magenta)) ? "" : parseFloat(row.peso_gotas_magenta).toFixed(2)) + $('#lp_rot_color_gTintaAmarillo').val(isNaN(parseFloat(row.peso_gotas_amarillo)) ? "" : parseFloat(row.peso_gotas_amarillo).toFixed(2)) + $('#lp_rot_color_clicksPedido').val(isNaN(parseFloat(row.clicks_pedido)) ? "" : parseFloat(row.clicks_pedido).toFixed(0)) + $('#lp_rot_color_totalClicksPedido').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + $('#lp_rot_color_totalTinta').val(isNaN(parseFloat(row.precio_tinta)) ? "" : parseFloat(row.precio_tinta).toFixed(2)) + $('#lp_rot_color_totalCorte').val(isNaN(parseFloat(row.total_corte)) ? "" : parseFloat(row.total_corte).toFixed(2)) + $('#lp_rot_color_totalImpresion').val(isNaN(parseFloat(row.precio_click_pedido+row.precio_tinta+row.total_corte)) ? "" : parseFloat(row.precio_click_pedido+row.precio_tinta+row.total_corte).toFixed(2)) + + $('#lp_rot_color_velocidadCorte').val(isNaN(parseFloat(row.velocidad_corte)) ? "" : parseFloat(row.velocidad_corte).toFixed(2)) + $('#lp_rot_color_precioHoraCorte').val(isNaN(parseFloat(row.precio_hora_corte)) ? "" : parseFloat(row.precio_hora_corte).toFixed(2)) + $('#lp_rot_color_tiempoCorte').val(isNaN(parseFloat(row.tiempo_corte)) ? "" : parseFloat(row.tiempo_corte).toFixed(2)) + $('#lp_rot_color_gTintaNegroPed').val(isNaN(parseFloat(row.peso_gotas_negro_pedido)) ? "" : parseFloat(row.peso_gotas_negro_pedido).toFixed(2)) + $('#lp_rot_color_gTintaCyanPed').val(isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)) + $('#lp_rot_color_gTintaMagentaPed').val(isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)) + $('#lp_rot_color_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) + } + + + $('.lp_rot_color').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} +endSection() ?> + + + + + +section("additionalInlineJs") ?> +async function set_lp_cubierta_gramaje(){ + + await $.ajax({ + type: 'post', + url: '', + beforeSend: function() { + clear_lp_cubierta(true) + }, + data: { + tipo: 'gramajeLineasPresupuesto', + uso: 'cubierta', + datos: $('#lp_cubierta_papel option:selected').val() , + tipoLinea: "color", + : v + }, + dataType: 'json', + success: function (data) { + yeniden(data.); + $.each(data.menu, function(item){ + var option = $('`); + $('#lp_cubierta_papelImpresion').empty() + $('#lp_cubierta_papelImpresion').append(``); + $('#lp_cubierta_maquina').empty() + $('#lp_cubierta_maquina').append(``); + calcularPresupuesto_cubierta(false); + + } + else{ + // Si viene de hacerlo a mano... + $('#lp_cubierta_tiempo').val(row.tiempo_maquina) + $('#lp_cubierta_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) + $('#lp_cubierta_pliegosPedido').val(isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(2)) + $('#lp_cubierta_precioPliego').val(isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6)) + $('#lp_cubierta_libro').val(isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2)) + $('#lp_cubierta_totalPapelPedido').val(isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2)) + $('#lp_cubierta_lomo').val(isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2)) + $('#lp_cubierta_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) + $('#lp_cubierta_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) + $('#lp_cubierta_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + $('#lp_cubierta_totalLinea').val(isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2)) + + } + + + $('.lp_cubierta').css('display', '') + $("#tableLineasPresupuesto").DataTable().columns.adjust(); +} endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 729a2070..433e0d47 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -208,6 +208,7 @@ function getRowFromLineaRot(linea) { 'tiempoMaquina': linea.fields.tiempo_maquina, 'papelGenericoId': linea.fields.papel_generico_id, 'papelImpresionId': linea.fields.papel_impresion_id, + 'paginasColor': linea.fields.paginas_color, } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 75b12f17..830a4bfd 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -184,7 +184,7 @@ info: false, ordering: false, responsive: true, - select: true, + select: false, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, @@ -239,7 +239,7 @@ info: false, ordering: false, responsive: true, - select: true, + select: false, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, @@ -281,11 +281,12 @@ { 'data': 'maquinaVelocidad'}, { 'data': 'tiempoMaquina'}, { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} + { 'data': 'papelImpresionId'}, + { 'data': 'paginasColor'}, ], columnDefs: [ { - target: [21,22,23,24,25], + target: [21,22,23,24,25,26], visible: false, searchable: false }, @@ -299,7 +300,7 @@ info: false, ordering: false, responsive: true, - select: true, + select: false, language: { url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" }, @@ -549,38 +550,17 @@ $('#tipoImpresion').on("change", function () { updatePapelesComparador(); + $('#title_int_rot').html(''); $('#title_int_plana').html(''); $('#paginas').change(); + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); - if (($('#tipoImpresion').select2('data')[0].id == 'negro' || - $('#tipoImpresion').select2('data')[0].id == 'color')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && - $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - - } - else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || - $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - if($('#tableCompIntPlana').DataTable().rows().count() > 0 && - !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - } }); @@ -593,7 +573,13 @@ checkDatosPedidoForComp()) { getLineasIntPlana(is_color, is_hq).then((result) =>{ - getLineasIntRot(is_hq); + + // Para rotativa, si es color el papel y el gramaje tiene que ser igual + if(!is_color || ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && + $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) + { + getLineasIntRot(is_hq); + } }); } else{ From 894c4b6cb944833a8cea4532e1115b97cfc4b1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez=20Ortega?= Date: Sun, 12 Nov 2023 17:27:54 +0100 Subject: [PATCH 06/10] solucionados bugs (pe, cuando es cubierta o sobrecubierta no se necesita color=1) --- .../Presupuestos/Cosidotapablanda.php | 4 +- ci4/app/Language/en/Presupuestos.php | 1 + ci4/app/Language/es/Presupuestos.php | 3 +- .../Configuracion/PapelGenericoModel.php | 11 +-- .../Configuracion/PapelImpresionModel.php | 13 ++-- .../_datosPresupuestoClienteItems.php | 3 +- .../_lineasPresupuestoItems.php | 50 ++++++++----- .../cosidotapablanda/comparador.js | 17 ++++- .../viewCosidotapablandaForm.php | 70 ++++++++----------- 9 files changed, 98 insertions(+), 74 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index baf1c877..fa2e1b64 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -527,14 +527,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController if( $uso == 'cubierta' ){ $opciones_papel = array( 'cubierta' => 1, - 'color' => 1, + //'color' => 1, 'rotativa' => 0, ); } else if ( $uso == 'sobrecubierta' ){ $opciones_papel = array( 'sobrecubierta' => 1, - 'color' => 1, + //'color' => 1, 'rotativa' => 0, ); } diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 5805cb1c..a928c11a 100644 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -146,6 +146,7 @@ return [ 'tiradas' => 'The field print must be greater than zero', 'dimension' => 'The book dimension must be greater than 60mm', 'lineaDuplicada' => 'That type of line already exists in the budget.', + 'errorRotColor' => 'Papers and weights must be the same in color and BW', ], /* '4x0' => '4x0', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 1bb07df4..8339ceb2 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -174,7 +174,8 @@ return [ 'paginas' => 'El campo páginas tiene que ser mayor que cero', 'tiradas' => 'El campo tiradas tiene que ser mayor que cero', 'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm', - 'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto' + 'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto', + 'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN', ], diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index ce45bbfa..4d412398 100644 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -226,10 +226,6 @@ class PapelGenericoModel extends \App\Models\GoBaseModel $uso_tarifa = 'interior'; - if($tipo == 'negro' || $tipo == 'negrohq') - $builder->where("t2.bn", 1); - else if ($tipo == 'color' || $tipo == 'colorhq') - $builder->where("t2.color", 1); if ($uso == 'cubierta'){ $uso_tarifa = 'cubierta'; $builder->where("t2.cubierta", 1); @@ -238,6 +234,13 @@ class PapelGenericoModel extends \App\Models\GoBaseModel $uso_tarifa = 'sobrecubierta'; $builder->where("t2.sobrecubierta", 1); } + else{ + if($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); + } + if($uso=='rotativa') $builder->where("t2.rotativa", 1); else diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index f9474e97..7e0cacc9 100644 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -283,20 +283,21 @@ class PapelImpresionModel extends \App\Models\GoBaseModel $builder->where("t2.id", $papel_generico); $builder->where("t1.gramaje", $gramaje); - if($tipo == 'negro' || $tipo == 'negrohq') - $builder->where("t1.bn", 1); - else if ($tipo == 'color' || $tipo == 'colorhq') - $builder->where("t1.color", 1); if ($uso == 'cubierta') $builder->where("t1.cubierta", 1); else if ($uso == 'sobrecubierta') $builder->where("t1.sobrecubierta", 1); + else{ + if($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t1.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t1.color", 1); + } if($uso=='rotativa') $builder->where("t1.rotativa", 1); else $builder->where("t1.rotativa", 0); - - + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php index a380239f..d66cd0a2 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php @@ -345,7 +345,8 @@ - : + + : 0.00 diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index 01476f71..06493685 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -997,52 +997,66 @@ $('.insertarLinea').on("click", function (e) { $('#addLineasPresupuesto').on("change", function (e) { switch($('#addLineasPresupuesto').val()){ + // Se chequean todas las lineas de negro y todas las de color + // (solo una de cada en interior) case 'lp_bn': - if($('#lp_bn').css('display') == 'none'){ - $('.lp_bn').css('display', 'flex') + if($('#lp_bn').css('display') != 'none' || + $('#lp_bnhq').css('display') != 'none' || + $('#lp_rot_bn').css('display') != 'none'){ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); } else{ - popErrorAlert('', 'divAlarmasLineasPresupuesto'); + $('.lp_bn').css('display', 'flex') } break case 'lp_bnhq': - if($('#lp_bnhq').css('display') == 'none'){ - $('.lp_bnhq').css('display', 'flex') + if($('#lp_bn').css('display') != 'none' || + $('#lp_bnhq').css('display') != 'none' || + $('#lp_rot_bn').css('display') != 'none'){ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); } else{ - popErrorAlert('', 'divAlarmasLineasPresupuesto'); + $('.lp_bnhq').css('display', 'flex') } break case 'lp_color': - if($('#lp_color').css('display') == 'none'){ - $('.lp_color').css('display', 'flex') + if($('#lp_color').css('display') != 'none' || + $('#lp_colorhq').css('display') != 'none' || + $('#lp_rot_color').css('display') != 'none'){ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); } else{ - popErrorAlert('', 'divAlarmasLineasPresupuesto'); + $('.lp_color').css('display', 'flex') } break case 'lp_colorhq': - if($('#lp_colorhq').css('display') == 'none'){ - $('.lp_colorhq').css('display', 'flex') + if($('#lp_color').css('display') != 'none' || + $('#lp_colorhq').css('display') != 'none' || + $('#lp_rot_color').css('display') != 'none'){ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); } else{ - popErrorAlert('', 'divAlarmasLineasPresupuesto'); + $('.lp_colorhq').css('display', 'flex') } break case 'lp_rot_bn': - if($('#lp_rot_bn').css('display') == 'none'){ - $('.lp_rot_bn').css('display', 'flex') + if($('#lp_bn').css('display') != 'none' || + $('#lp_bnhq').css('display') != 'none' || + $('#lp_rot_bn').css('display') != 'none'){ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); } else{ - popErrorAlert('', 'divAlarmasLineasPresupuesto'); + $('.lp_rot_bn').css('display', 'flex') } break case 'lp_rot_color': - if($('#lp_rot_color').css('display') == 'none'){ - $('.lp_rot_color').css('display', 'flex') + if($('#lp_color').css('display') != 'none' || + $('#lp_colorhq').css('display') != 'none' || + $('#lp_rot_color').css('display') != 'none'){ + popErrorAlert('', 'divAlarmasLineasPresupuesto'); } else{ - popErrorAlert('', 'divAlarmasLineasPresupuesto'); + $('.lp_rot_color').css('display', 'flex') } break case 'lp_cubierta': diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 433e0d47..70093224 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -357,7 +357,7 @@ function clearNegro() { function clearIntLineas(is_color){ - $("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect(); + //$("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect(); var tabla = $('#tableCompIntPlana').DataTable(); tabla .rows( function ( idx, data, node ) { @@ -365,6 +365,7 @@ function clearIntLineas(is_color){ } ) .remove() .draw(); + //$('#tableCompIntPlana').DataTable().clear().draw(); $('#insertarPlanaBtn').css('display', 'none'); } @@ -372,12 +373,15 @@ function clearIntLineas(is_color){ function clearCubierta(){ $('#tableCompCubierta').DataTable().clear().draw(); + $('#insertarCubiertaBtn').css('display', 'none'); } function clearIntRot(){ + $('#errorComRot').html(''); $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#insertarRotativaBtn').css('display', 'none'); } @@ -568,3 +572,14 @@ function fillCubierta(data, is_color, is_hq){ .draw() }) } + +function clearCompTable(clearNegro=true,clearColor=false,clearCubierta=false){ + if(clearNegro){ + + } + + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') +} diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 5644cb26..5e9f843b 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -564,33 +564,6 @@ }); - function checkComparadorInt(is_color, is_hq) { - - elementos = getIDsComparador(is_color, is_hq) - - if ($(''+ elementos.papel).select2('data').length > 0 && - $(''+ elementos.gramaje).select2('data').length > 0 && - checkDatosPedidoForComp()) { - - getLineasIntPlana(is_color, is_hq).then((result) =>{ - - // Para rotativa, si es color el papel y el gramaje tiene que ser igual - if(!is_color || ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) - { - getLineasIntRot(is_hq); - } - }); - } - else{ - clearIntLineas(is_color); - clearIntRot(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - - } - } - $('.comp_negro_items').on('change', function (e) { checkComparadorInt(false,false); @@ -818,23 +791,38 @@ function checkComparadorInt(is_color, is_hq) { - elementos = getIDsComparador(is_color, is_hq) + clearIntLineas(is_color); + clearIntRot(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + elementos = getIDsComparador(is_color, is_hq) + if ($(''+ elementos.papel).select2('data').length > 0 && $(''+ elementos.gramaje).select2('data').length > 0 && + parseInt($(''+ elementos.paginas).val()) > 0 && checkDatosPedidoForComp()) { getLineasIntPlana(is_color, is_hq).then((result) =>{ - getLineasIntRot(is_hq); + // Para rotativa, si es color el papel y el gramaje tiene que ser igual + if(!is_color) + { + getLineasIntRot(is_hq); + } + else + { + if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && + $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) + { + getLineasIntRot(is_hq); + } + else + { + $('#errorComRot').html(''); + } + } }); } - else{ - clearIntLineas(is_color); - clearIntRot(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - - } } @@ -854,7 +842,7 @@ $('#compGramajeNegro').empty().trigger("change"); $('#compGramajeNegro').prop('disabled', false); $('#compGramajeNegro').select2({ - allowClear: true, + allowClear: false, minimumResultsForSearch: Infinity, ajax: { url: '', @@ -896,7 +884,7 @@ $('#compGramajeNegrohq').empty().trigger("change"); $('#compGramajeNegrohq').prop('disabled', false); $('#compGramajeNegrohq').select2({ - allowClear: true, + allowClear: false, minimumResultsForSearch: Infinity, ajax: { url: '', @@ -940,7 +928,7 @@ $('#compGramajeColor').prop('disabled', false); $('#compPapelColor').find('option[value="0"]').remove(); $('#compGramajeColor').select2({ - allowClear: true, + allowClear: false, minimumResultsForSearch: Infinity, ajax: { url: '', @@ -984,7 +972,7 @@ $('#compGramajeColorhq').prop('disabled', false); $('#compPapelColorhq').find('option[value="0"]').remove(); $('#compGramajeColorhq').select2({ - allowClear: true, + allowClear: false, minimumResultsForSearch: Infinity, ajax: { url: '', @@ -1024,7 +1012,7 @@ $('#compGramajeCubierta').prop('disabled', false); $('#compPapelCubierta').find('option[value="0"]').remove(); $('#compGramajeCubierta').select2({ - allowClear: true, + allowClear: false, minimumResultsForSearch: Infinity, ajax: { url: '', From 119505dfaf3c5edb007cf772242b3433a1974dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez=20Ortega?= Date: Mon, 13 Nov 2023 12:48:00 +0100 Subject: [PATCH 07/10] trabajando en el edit --- ci4/app/Controllers/Clientes/Cliente.php | 15 +- .../Controllers/GoBaseResourceController.php | 18 +- .../Presupuestos/Cosidotapablanda.php | 198 ++-- ci4/app/Language/en/Presupuestos.php | 11 +- ci4/app/Language/es/Presupuestos.php | 3 +- .../Models/Presupuestos/PresupuestoModel.php | 808 +------------ .../cosidotapablanda/_datosLibroItems.php | 30 +- .../_datosPresupuestoClienteItems.php | 886 +++++++++++++- .../_datosPresupuestoItems.php | 7 +- .../_lineasPresupuestoItems.php | 14 + .../viewCosidotapablandaForm.php | 1042 +---------------- 11 files changed, 1180 insertions(+), 1852 deletions(-) diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index dc4ac6cb..f91714e1 100644 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -312,11 +312,16 @@ class Cliente extends \App\Controllers\GoBaseResourceController $onlyActiveOnes = false; $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; $onlyActiveOnes = false; - $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); - $nonItem = new \stdClass; - $nonItem->id = ''; - $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; - array_unshift($menu, $nonItem); + try{ + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $nonItem = new \stdClass; + $nonItem->id = ''; + $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; + array_unshift($menu, $nonItem); + } + catch(Exception $e){ + $menu = []; + } $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); diff --git a/ci4/app/Controllers/GoBaseResourceController.php b/ci4/app/Controllers/GoBaseResourceController.php index 86433d87..8b210d98 100644 --- a/ci4/app/Controllers/GoBaseResourceController.php +++ b/ci4/app/Controllers/GoBaseResourceController.php @@ -255,18 +255,28 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon /** * Convenience method to validate form submission + * JJO: Se le añade las reglas y los mensajes custom * @return bool */ - protected function canValidate() + protected function canValidate($customValidationRules = null, $customValidationMessages = null) { - $validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null; - + if($customValidationRules == null){ + $validationRules = $this->model->validationRules ?? $this->formValidationRules ?? null; + } + else{ + $validationRules = $customValidationRules; + } if ($validationRules == null) { return true; } - $validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;; + if($customValidationMessages == null){ + $validationErrorMessages = $this->model->validationMessages ?? $this->formValidationErrorMessagess ?? null;; + } + else{ + $validationErrorMessages = $customValidationMessages; + } if ($validationErrorMessages != null) { $valid = $this->validate($validationRules, $validationErrorMessages); diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index fa2e1b64..8e98b6af 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -96,10 +96,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $sanitizedData['user_created_id'] = $session->id_user; $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - if ($this->canValidate()) : + if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { @@ -153,14 +152,13 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); + + $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO $this->viewData['formAction'] = route_to('createCosidotapablanda'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.addNewSuffix'); - /* TEST JS LOADER */ - //$this->viewData['global_js_variables'] = array('jsVarTest' => "'Hola Jaime'"); - return $this->displayForm(__METHOD__); } // end function add() @@ -312,19 +310,19 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['presupuestoEntity'] = $presupuestoEntity; $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); - $this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); - $this->viewData['tiposImpresionList'] = $this->getTiposImpresionListItems($presupuestoEntity->tipo_impresion_id ?? null); - $this->viewData['tipologiasLibroList'] = $this->getTipologiasLibroListItems($presupuestoEntity->tipologia_id ?? null); + //$this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); + //$this->viewData['tiposImpresionList'] = $this->getTiposImpresionListItems($presupuestoEntity->tipo_impresion_id ?? null); + //$this->viewData['tipologiasLibroList'] = $this->getTipologiasLibroListItems($presupuestoEntity->tipologia_id ?? null); $this->viewData['paisList'] = $this->getPaisListItems(); - $this->viewData['ubicacionLibroList'] = $this->getUbicacionLibroListItems($presupuestoEntity->ubicacion_id ?? null); - $this->viewData['presupuestoEstadoList'] = $this->getPresupuestoEstadoListItems($presupuestoEntity->estado_id ?? null); - $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - $this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($presupuestoEntity->paginas_negro_papel_id ?? null); - $this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($presupuestoEntity->paginas_negro_papel_impresion_id ?? null); - $this->viewData['maquinaList'] = $this->getMaquinaListItems($presupuestoEntity->paginas_negro_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList'] = $this->getMaquinasTarifasImpresionListItems($presupuestoEntity->paginas_negro_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList2'] = $this->getPapelGenericoListItems2($presupuestoEntity->paginas_color_papel_id ?? null); - $this->viewData['papelImpresionList2'] = $this->getPapelImpresionListItems2($presupuestoEntity->paginas_color_papel_impresion_id ?? null); + //$this->viewData['ubicacionLibroList'] = $this->getUbicacionLibroListItems($presupuestoEntity->ubicacion_id ?? null); + //$this->viewData['presupuestoEstadoList'] = $this->getPresupuestoEstadoListItems($presupuestoEntity->estado_id ?? null); + //$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); + //$this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($presupuestoEntity->paginas_negro_papel_id ?? null); + //$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($presupuestoEntity->paginas_negro_papel_impresion_id ?? null); + //$this->viewData['maquinaList'] = $this->getMaquinaListItems($presupuestoEntity->paginas_negro_maquina_id ?? null); + //$this->viewData['maquinasTarifasImpresionList'] = $this->getMaquinasTarifasImpresionListItems($presupuestoEntity->paginas_negro_tarifa_impresion_id ?? null); + //$this->viewData['papelGenericoList2'] = $this->getPapelGenericoListItems2($presupuestoEntity->paginas_color_papel_id ?? null); + /*$this->viewData['papelImpresionList2'] = $this->getPapelImpresionListItems2($presupuestoEntity->paginas_color_papel_impresion_id ?? null); $this->viewData['maquinaList2'] = $this->getMaquinaListItems2($presupuestoEntity->paginas_color_maquina_id ?? null); $this->viewData['maquinasTarifasImpresionList2'] = $this->getMaquinasTarifasImpresionListItems2($presupuestoEntity->paginas_color_tarifa_impresion_id ?? null); $this->viewData['papelGenericoList3'] = $this->getPapelGenericoListItems3($presupuestoEntity->paginas_portada_papel_id ?? null); @@ -339,16 +337,31 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['userList2'] = $this->getUserListItems2($presupuestoEntity->aprobado_user_id ?? null); $this->viewData['userList3'] = $this->getUserListItems3($presupuestoEntity->pedido_espera_user_id ?? null); $this->viewData['paginasCubiertaList'] = $this->getPaginasCubiertaOptions(); - $this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions(); + $this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions();*/ + $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')); + $this->viewData['paisList'] = $this->getPaisListItems(); + $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); $this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro(); $this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ(); $this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor(); $this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ(); $this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta(); $this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta(); + $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); + $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); - $this->viewData['formAction'] = route_to('updatePresupuesto', $id); + // Tarifas + $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); + $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); + $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); + $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); + + + $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO + + $this->viewData['formAction'] = route_to('updateCosidotapablanda', $id); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3'); @@ -767,86 +780,96 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController if ($this->request->isAJAX()) { $reqData = $this->request->getPost(); + try{ - $tipo = $reqData['tipo'] ?? null; - $uso = $reqData['uso'] ?? null; - $datos = $reqData['datos'] ?? null; - //$searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; + $tipo = $reqData['tipo'] ?? null; + $uso = $reqData['uso'] ?? null; + $datos = $reqData['datos'] ?? null; + //$searchStr = goSanitize($this->request->getPost('searchTerm'))[0]; - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); - if ($tipo == 'gramaje') { - // En este caso contiene el nombre del papel generico - $model = new PapelGenericoModel(); - $menu = $model->getGramajeComparador($datos, $uso ); + if ($tipo == 'gramaje') { + // En este caso contiene el nombre del papel generico + $model = new PapelGenericoModel(); + $menu = $model->getGramajeComparador($datos, $uso ); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } - elseif ($tipo == 'gramajeLineasPresupuesto') { - $tipoLinea = $reqData['tipoLinea'] ?? null; - // En este caso contiene el id del papel generico - $model = new PapelGenericoModel(); - $menu = $model->getGramajeLineasPresupuesto($datos, $tipoLinea, $uso ); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + } + elseif ($tipo == 'gramajeLineasPresupuesto') { + $tipoLinea = $reqData['tipoLinea'] ?? null; + // En este caso contiene el id del papel generico + $model = new PapelGenericoModel(); + $menu = $model->getGramajeLineasPresupuesto($datos, $tipoLinea, $uso ); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } - elseif ($tipo == 'papelImpresion') { - $gramaje = $reqData['gramaje'] ?? null; - $tipoLinea = $reqData['tipoLinea'] ?? null; - // En este caso contiene el nombre del papel generico - // Uso: negro, negrohq, color, colorhq, rot_bn, rot_color, - $model = new PapelImpresionModel(); - $menu = $model->getPapelesImpresionForMenu($datos, $gramaje, $tipoLinea, $uso ); + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + } + elseif ($tipo == 'papelImpresion') { + $gramaje = $reqData['gramaje'] ?? null; + $tipoLinea = $reqData['tipoLinea'] ?? null; + // En este caso contiene el nombre del papel generico + // Uso: negro, negrohq, color, colorhq, rot_bn, rot_color, + $model = new PapelImpresionModel(); + $menu = $model->getPapelesImpresionForMenu($datos, $gramaje, $tipoLinea, $uso ); - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } - - elseif ($tipo == 'maquina') { - $is_rotativa = $reqData['is_rotativa'] ?? null; - $papel_impresion = $reqData['papel_impresion'] ?? null; - $tipo_linea = $reqData['tipoLinea'] ?? null; - $ancho = $reqData['ancho'] ?? null; - $alto = $reqData['alto'] ?? null; - // Datos contiene la tirada - // uso: negro, negrohq, color, colorhq, - $uso_tarifa = $reqData['uso_tarifa'] ?? 'interior'; - $model = new MaquinaModel(); - $maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $uso_tarifa ,$datos, $papel_impresion ); - $menu = []; - foreach ($maquinas as $maquina){ - - $formas = PresupuestoService::getNumFormasPlana($tipo_linea, $maquina, floatval($ancho), floatval($alto), true); - - if($formas['num_formas'] != 'n/a'){ - array_push($menu, $maquina); - } + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; } - $data = [ - 'menu' => $menu, - $csrfTokenName => $newTokenHash - ]; - } + elseif ($tipo == 'maquina') { + $is_rotativa = $reqData['is_rotativa'] ?? null; + $papel_impresion = $reqData['papel_impresion'] ?? null; + $tipo_linea = $reqData['tipoLinea'] ?? null; + $ancho = $reqData['ancho'] ?? null; + $alto = $reqData['alto'] ?? null; + // Datos contiene la tirada + // uso: negro, negrohq, color, colorhq, + $uso_tarifa = $reqData['uso_tarifa'] ?? 'interior'; + $model = new MaquinaModel(); + $maquinas = $model->getMaquinaImpresionForPresupuesto($is_rotativa, $uso, $uso_tarifa ,$datos, $papel_impresion ); + $menu = []; + foreach ($maquinas as $maquina){ + + $formas = PresupuestoService::getNumFormasPlana($tipo_linea, $maquina, floatval($ancho), floatval($alto), true); + + if($formas['num_formas'] != 'n/a'){ + array_push($menu, $maquina); + } + } - else{ - + $data = [ + 'menu' => $menu, + $csrfTokenName => $newTokenHash + ]; + } + + else{ + + $data = [ + 'tipo' => $tipo, + $csrfTokenName => $newTokenHash + ]; + } + } + catch(Exception $e){ $data = [ - 'tipo' => $tipo, + 'error' => $e, $csrfTokenName => $newTokenHash ]; } - - return $this->respond($data); + finally{ + return $this->respond($data); + } + } else { return $this->failUnauthorized('Invalid request', 403); } @@ -880,6 +903,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController { $papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel'); $data = $papelFormatoModel->getElementsForMenu(); + array_shift($data); array_unshift($data, (object)['id' => '', 'tamanio' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papelFormatoId'))])]); return $data; } diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index a928c11a..571c6720 100644 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -141,6 +141,13 @@ return [ 'addLineaPresupuesto' => 'Add line...', + 'validation' => [ + 'decimal' => 'The {field} field must contain a decimal number.', + 'integer' => 'The {field} field must contain an integer.', + 'requerido' => 'The {field} field is required.', + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + ], + 'errores' => [ 'paginas' => 'The field pages must be greater than zero', 'tiradas' => 'The field print must be greater than zero', @@ -333,7 +340,9 @@ return [ 'catalogo_id' => [ 'integer' => 'The {field} field must contain an integer.', - + 'decimal' => 'The {field} field must contain a decimal number.', + 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'required' => 'The {field} field is required.', ], 'causa_cancelacion' => [ diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 8339ceb2..d3be5e1c 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -166,7 +166,8 @@ return [ 'validation' => [ 'decimal' => 'El campo {field} debe contener un número decimal.', - 'requerido' => 'El campo {field} esta requerido.', + 'integer' => 'El campo {field} debe contener un número entero.', + 'requerido' => 'El campo {field} es obligatorio.', 'max_length' => 'El campo {field} no puede exceder los {param} caracteres de longitud.', ], diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 3bdc5f1b..31fb0400 100644 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -206,810 +206,76 @@ class PresupuestoModel extends \App\Models\GoBaseModel public static $labelField = "titulo"; - protected $validationRules = [ - "aprobado_at" => [ - "label" => "Presupuestos.aprobadoAt", - "rules" => "valid_date|permit_empty", - ], - "aprobado_json_data" => [ - "label" => "Presupuestos.aprobadoJsonData", - "rules" => "trim|max_length[16313]", - ], + protected $validationRulesAdd = [ "autor" => [ "label" => "Presupuestos.autor", "rules" => "trim|required|max_length[150]", ], - "base_imponible" => [ - "label" => "Presupuestos.baseImponible", - "rules" => "decimal|permit_empty", - ], - "catalogo_id" => [ - "label" => "Presupuestos.catalogoId", - "rules" => "integer|permit_empty", - ], - "causa_cancelacion" => [ - "label" => "Presupuestos.causaCancelacion", - "rules" => "trim|max_length[16313]", - ], - "coleccion" => [ - "label" => "Presupuestos.coleccion", - "rules" => "trim|max_length[255]", - ], - "comentarios_cliente" => [ - "label" => "Presupuestos.comentarios_cliente", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_pdf" => [ - "label" => "Presupuestos.comentariosPdf", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_safekat" => [ - "label" => "Presupuestos.comentariosSafekat", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_tarifa" => [ - "label" => "Presupuestos.comentariosTarifa", - "rules" => "trim|required|max_length[16313]", - ], - "comentarios_produccion" => [ - "label" => "Presupuestos.comentariosProduccion", - "rules" => "trim|required|max_length[16313]", - ], - "comparador_json_data" => [ - "label" => "Presupuestos.comparadorJsonData", - "rules" => "trim|max_length[16313]", - ], - "sobrecubiertas_ancho" => [ - "label" => "Presupuestos.sobrecubiertasAncho", - "rules" => "required|decimal", - ], - "descuento" => [ - "label" => "Presupuestos.descuento", - "rules" => "required|decimal", - ], - "fecha_encuardenado_at" => [ - "label" => "Presupuestos.fechaEncuardenadoAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_entrega_real_at" => [ - "label" => "Presupuestos.fechaEntregaRealAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_externo_at" => [ - "label" => "Presupuestos.fechaExternoAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_ferro_subido_at" => [ - "label" => "Presupuestos.fechaFerroSubidoAt", - "rules" => "valid_date|permit_empty", - ], - "fecha_impresion_at" => [ - "label" => "Presupuestos.fechaImpresionAt", - "rules" => "valid_date|permit_empty", - ], - "forzar_total" => [ - "label" => "Presupuestos.forzarTotal", - "rules" => "required|decimal", + "titulo" => [ + "label" => "Presupuestos.titulo", + "rules" => "trim|required|max_length[30]", ], "inc_rei" => [ "label" => "Presupuestos.incRei", "rules" => "integer|permit_empty", ], - "is_deleted" => [ - "label" => "Presupuestos.isDeleted", - "rules" => "required|integer", - ], - "isbn" => [ - "label" => "Presupuestos.isbn", - "rules" => "trim|max_length[50]", - ], - "lomo" => [ - "label" => "Presupuestos.lomo", - "rules" => "integer|permit_empty", - ], - "margen" => [ - "label" => "Presupuestos.margen", - "rules" => "decimal|permit_empty", - ], - "margen_extra" => [ - "label" => "Presupuestos.margenExtra", - "rules" => "required|decimal", - ], - "margen_manual" => [ - "label" => "Presupuestos.margenManual", - "rules" => "decimal|permit_empty", - ], - "merma" => [ - "label" => "Presupuestos.merma", - "rules" => "required|decimal", - ], - "merma_portada" => [ - "label" => "Presupuestos.mermaPortada", - "rules" => "required|decimal", + "coleccion" => [ + "label" => "Presupuestos.incRei", + "rules" => "trim|max_length[255]", ], "numero_edicion" => [ "label" => "Presupuestos.numeroEdicion", "rules" => "trim|max_length[50]", ], - "paginas" => [ - "label" => "Presupuestos.paginas", - "rules" => "required|integer", + "isbn" => [ + "label" => "Presupuestos.isbn", + "rules" => "trim|max_length[50]", ], - "paginas_color" => [ - "label" => "Presupuestos.paginasColor", - "rules" => "integer|permit_empty", + "pais_id" => [ + "label" => "Presupuestos.paisId", + "rules" => "required|integer|greater_than[0]", ], - "paginas_color_click" => [ - "label" => "Presupuestos.paginasColorClick", - "rules" => "decimal|permit_empty", - ], - "paginas_color_forma_id" => [ - "label" => "Presupuestos.paginasColorFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_color_gramaje" => [ - "label" => "Presupuestos.paginasColorGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_color_libro" => [ - "label" => "Presupuestos.paginasColorLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_color_mano" => [ - "label" => "Presupuestos.paginasColorMano", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pedido" => [ - "label" => "Presupuestos.paginasColorPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_color_peso" => [ - "label" => "Presupuestos.paginasColorPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pliegos_libro" => [ - "label" => "Presupuestos.paginasColorPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pliegos_pedido" => [ - "label" => "Presupuestos.paginasColorPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_color_pliegos_precio" => [ - "label" => "Presupuestos.paginasColorPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_color_posicion" => [ - "label" => "Presupuestos.paginasColorPosicion", - "rules" => "trim|max_length[16313]", - ], - "paginas_color_precio" => [ - "label" => "Presupuestos.paginasColorPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta" => [ - "label" => "Presupuestos.paginasCubierta", - "rules" => "required|in_list[4x0,4x4]", - ], - "paginas_sobrecubierta_click" => [ - "label" => "Presupuestos.paginasCubiertaClick", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_forma_id" => [ - "label" => "Presupuestos.paginasCubiertaFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_sobrecubierta_gramaje" => [ - "label" => "Presupuestos.paginasCubiertaGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_libro" => [ - "label" => "Presupuestos.paginasCubiertaLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_mano" => [ - "label" => "Presupuestos.paginasCubiertaMano", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pedido" => [ - "label" => "Presupuestos.paginasCubiertaPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_peso" => [ - "label" => "Presupuestos.paginasCubiertaPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pliegos_libro" => [ - "label" => "Presupuestos.paginasCubiertaPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pliegos_pedido" => [ - "label" => "Presupuestos.paginasCubiertaPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_pliegos_precio" => [ - "label" => "Presupuestos.paginasCubiertaPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_sobrecubierta_precio" => [ - "label" => "Presupuestos.paginasCubiertaPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_negro" => [ - "label" => "Presupuestos.paginasNegro", - "rules" => "integer|permit_empty", - ], - "paginas_negro_click" => [ - "label" => "Presupuestos.paginasNegroClick", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_forma_id" => [ - "label" => "Presupuestos.paginasNegroFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_negro_gramaje" => [ - "label" => "Presupuestos.paginasNegroGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_libro" => [ - "label" => "Presupuestos.paginasNegroLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_mano" => [ - "label" => "Presupuestos.paginasNegroMano", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pedido" => [ - "label" => "Presupuestos.paginasNegroPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_peso" => [ - "label" => "Presupuestos.paginasNegroPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pliegos_libro" => [ - "label" => "Presupuestos.paginasNegroPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pliegos_pedido" => [ - "label" => "Presupuestos.paginasNegroPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_pliegos_precio" => [ - "label" => "Presupuestos.paginasNegroPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_negro_precio" => [ - "label" => "Presupuestos.paginasNegroPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta" => [ - "label" => "Presupuestos.paginasPortada", - "rules" => "required|in_list[4x0,4x4]", - ], - "paginas_cubierta_click" => [ - "label" => "Presupuestos.paginasPortadaClick", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_forma_id" => [ - "label" => "Presupuestos.paginasPortadaFormaId", - "rules" => "integer|permit_empty", - ], - "paginas_cubierta_gramaje" => [ - "label" => "Presupuestos.paginasPortadaGramaje", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_libro" => [ - "label" => "Presupuestos.paginasPortadaLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_mano" => [ - "label" => "Presupuestos.paginasPortadaMano", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pedido" => [ - "label" => "Presupuestos.paginasPortadaPedido", - "rules" => "required|decimal", - ], - "paginas_cubierta_peso" => [ - "label" => "Presupuestos.paginasPortadaPeso", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pliegos_libro" => [ - "label" => "Presupuestos.paginasPortadaPliegosLibro", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pliegos_pedido" => [ - "label" => "Presupuestos.paginasPortadaPliegosPedido", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_pliegos_precio" => [ - "label" => "Presupuestos.paginasPortadaPliegosPrecio", - "rules" => "decimal|permit_empty", - ], - "paginas_cubierta_precio" => [ - "label" => "Presupuestos.paginasPortadaPrecio", - "rules" => "decimal|permit_empty", - ], - "papel_formato_alto" => [ - "label" => "Presupuestos.papelFormatoAlto", - "rules" => "decimal|permit_empty", - ], - "papel_formato_ancho" => [ - "label" => "Presupuestos.papelFormatoAncho", - "rules" => "decimal|permit_empty", - ], - "pedido_espera_fecha" => [ - "label" => "Presupuestos.pedidoEsperaFecha", - "rules" => "valid_date|permit_empty", + "cliente_id" => [ + "label" => "Presupuestos.clienteId", + "rules" => "required|integer|greater_than[0]", ], "referencia_cliente" => [ "label" => "Presupuestos.referenciaCliente", - "rules" => "trim|required|max_length[100]", - ], - "responsable" => [ - "label" => "Presupuestos.responsable", - "rules" => "trim|max_length[32]", - ], - "serie_id" => [ - "label" => "Presupuestos.serieId", - "rules" => "integer|permit_empty", - ], - "solapas_ancho" => [ - "label" => "Presupuestos.solapasAncho", - "rules" => "required|decimal", - ], - "tarifa_cliente_id" => [ - "label" => "Presupuestos.tarifaClienteId", - "rules" => "integer|permit_empty", - ], - "tirada" => [ - "label" => "Presupuestos.tirada", - "rules" => "required|integer", - ], - "tirada_alternativa_json_data" => [ - "label" => "Presupuestos.tiradaAlternativaJsonData", - "rules" => "trim|max_length[16313]", - ], - "titulo" => [ - "label" => "Presupuestos.titulo", - "rules" => "trim|required|max_length[300]", - ], - "total" => [ - "label" => "Presupuestos.total", - "rules" => "decimal|permit_empty", - ], - "total_acabado" => [ - "label" => "Presupuestos.totalAcabado", - "rules" => "decimal|permit_empty", - ], - "total_calculado" => [ - "label" => "Presupuestos.totalCalculado", - "rules" => "decimal|permit_empty", - ], - "total_click" => [ - "label" => "Presupuestos.totalClick", - "rules" => "decimal|permit_empty", - ], - "total_confirmado" => [ - "label" => "Presupuestos.totalConfirmado", - "rules" => "decimal|permit_empty", - ], - "total_confirmado_update_at" => [ - "label" => "Presupuestos.totalConfirmadoUpdateAt", - "rules" => "valid_date|permit_empty", - ], - "total_descuento" => [ - "label" => "Presupuestos.totalDescuento", - "rules" => "decimal|permit_empty", - ], - "total_envios" => [ - "label" => "Presupuestos.totalEnvios", - "rules" => "decimal|permit_empty", - ], - "total_manipulado" => [ - "label" => "Presupuestos.totalManipulado", - "rules" => "decimal|permit_empty", - ], - "total_margen" => [ - "label" => "Presupuestos.totalMargen", - "rules" => "decimal|permit_empty", - ], - "total_margen_extra" => [ - "label" => "Presupuestos.totalMargenExtra", - "rules" => "decimal|permit_empty", - ], - "total_pedido" => [ - "label" => "Presupuestos.totalPedido", - "rules" => "decimal|permit_empty", - ], - "total_peso" => [ - "label" => "Presupuestos.totalPeso", - "rules" => "decimal|permit_empty", - ], - "total_preimpresion" => [ - "label" => "Presupuestos.totalPreimpresion", - "rules" => "decimal|permit_empty", - ], - "total_preimpresion_margen" => [ - "label" => "Presupuestos.totalPreimpresionMargen", - "rules" => "decimal|permit_empty", - ], - "total_presupuesto" => [ - "label" => "Presupuestos.totalPresupuesto", - "rules" => "decimal|permit_empty", - ], - "user_created_id" => [ - "label" => "Presupuestos.userCreatedId", - "rules" => "required|integer", - ], - "user_update_id" => [ - "label" => "Presupuestos.userUpdateId", - "rules" => "integer|permit_empty", - ], - "version" => [ - "label" => "Presupuestos.version", - "rules" => "required|integer", + "rules" => "trim|max_length[100]", ], ]; - protected $validationMessages = [ - "aprobado_at" => [ - "valid_date" => "Presupuestos.validation.aprobado_at.valid_date", - ], - "aprobado_json_data" => [ - "max_length" => "Presupuestos.validation.aprobado_json_data.max_length", - ], + protected $validationMessagesAdd = [ "autor" => [ - "max_length" => "Presupuestos.validation.autor.max_length", - "required" => "Presupuestos.validation.autor.required", - ], - "base_imponible" => [ - "decimal" => "Presupuestos.validation.base_imponible.decimal", - ], - "catalogo_id" => [ - "integer" => "Presupuestos.validation.catalogo_id.integer", - ], - "causa_cancelacion" => [ - "max_length" => "Presupuestos.validation.causa_cancelacion.max_length", - ], - "coleccion" => [ - "max_length" => "Presupuestos.validation.coleccion.max_length", - ], - "comentarios_cliente" => [ "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_pdf" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_safekat" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_tarifa" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comentarios_produccion" => [ - "max_length" => "Presupuestos.validation.max_length", - "required" => "Presupuestos.validation.required", - ], - "comparador_json_data" => [ - "max_length" => "Presupuestos.validation.comparador_json_data.max_length", - ], - "sobrecubiertas_ancho" => [ - "decimal" => "Presupuestos.validation.sobrecubiertas_ancho.decimal", - "required" => "Presupuestos.validation.sobrecubiertas_ancho.required", - ], - "descuento" => [ - "decimal" => "Presupuestos.validation.descuento.decimal", - "required" => "Presupuestos.validation.descuento.required", - ], - "fecha_encuardenado_at" => [ - "valid_date" => "Presupuestos.validation.fecha_encuardenado_at.valid_date", - ], - "fecha_entrega_real_at" => [ - "valid_date" => "Presupuestos.validation.fecha_entrega_real_at.valid_date", - ], - "fecha_externo_at" => [ - "valid_date" => "Presupuestos.validation.fecha_externo_at.valid_date", - ], - "fecha_ferro_subido_at" => [ - "valid_date" => "Presupuestos.validation.fecha_ferro_subido_at.valid_date", - ], - "fecha_impresion_at" => [ - "valid_date" => "Presupuestos.validation.fecha_impresion_at.valid_date", - ], - "forzar_total" => [ - "decimal" => "Presupuestos.validation.forzar_total.decimal", - "required" => "Presupuestos.validation.forzar_total.required", - ], - "inc_rei" => [ - "integer" => "Presupuestos.validation.inc_rei.integer", - ], - "is_deleted" => [ - "integer" => "Presupuestos.validation.is_deleted.integer", - "required" => "Presupuestos.validation.is_deleted.required", - ], - "isbn" => [ - "max_length" => "Presupuestos.validation.isbn.max_length", - ], - "lomo" => [ - "integer" => "Presupuestos.validation.lomo.integer", - ], - "margen" => [ - "decimal" => "Presupuestos.validation.margen.decimal", - ], - "margen_extra" => [ - "decimal" => "Presupuestos.validation.margen_extra.decimal", - "required" => "Presupuestos.validation.margen_extra.required", - ], - "margen_manual" => [ - "decimal" => "Presupuestos.validation.margen_manual.decimal", - ], - "merma" => [ - "decimal" => "Presupuestos.validation.merma.decimal", - "required" => "Presupuestos.validation.merma.required", - ], - "merma_portada" => [ - "decimal" => "Presupuestos.validation.merma_portada.decimal", - "required" => "Presupuestos.validation.merma_portada.required", - ], - "numero_edicion" => [ - "max_length" => "Presupuestos.validation.numero_edicion.max_length", - ], - "paginas" => [ - "integer" => "Presupuestos.validation.paginas.integer", - "required" => "Presupuestos.validation.paginas.required", - ], - "paginas_color" => [ - "integer" => "Presupuestos.validation.paginas_color.integer", - ], - "paginas_color_click" => [ - "decimal" => "Presupuestos.validation.paginas_color_click.decimal", - ], - "paginas_color_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_color_forma_id.integer", - ], - "paginas_color_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_color_gramaje.decimal", - ], - "paginas_color_libro" => [ - "decimal" => "Presupuestos.validation.paginas_color_libro.decimal", - ], - "paginas_color_mano" => [ - "decimal" => "Presupuestos.validation.paginas_color_mano.decimal", - ], - "paginas_color_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_color_pedido.decimal", - ], - "paginas_color_peso" => [ - "decimal" => "Presupuestos.validation.paginas_color_peso.decimal", - ], - "paginas_color_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_color_pliegos_libro.decimal", - ], - "paginas_color_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_color_pliegos_pedido.decimal", - ], - "paginas_color_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_color_pliegos_precio.decimal", - ], - "paginas_color_posicion" => [ - "max_length" => "Presupuestos.validation.paginas_color_posicion.max_length", - ], - "paginas_color_precio" => [ - "decimal" => "Presupuestos.validation.paginas_color_precio.decimal", - ], - "paginas_sobrecubierta" => [ - "in_list" => "Presupuestos.validation.paginas_sobrecubierta.in_list", - "required" => "Presupuestos.validation.paginas_sobrecubierta.required", - ], - "paginas_sobrecubierta_click" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_click.decimal", - ], - "paginas_sobrecubierta_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_sobrecubierta_forma_id.integer", - ], - "paginas_sobrecubierta_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_gramaje.decimal", - ], - "paginas_sobrecubierta_libro" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_libro.decimal", - ], - "paginas_sobrecubierta_mano" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_mano.decimal", - ], - "paginas_sobrecubierta_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pedido.decimal", - ], - "paginas_sobrecubierta_peso" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_peso.decimal", - ], - "paginas_sobrecubierta_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pliegos_libro.decimal", - ], - "paginas_sobrecubierta_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pliegos_pedido.decimal", - ], - "paginas_sobrecubierta_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_pliegos_precio.decimal", - ], - "paginas_sobrecubierta_precio" => [ - "decimal" => "Presupuestos.validation.paginas_sobrecubierta_precio.decimal", - ], - "paginas_negro" => [ - "integer" => "Presupuestos.validation.paginas_negro.integer", - ], - "paginas_negro_click" => [ - "decimal" => "Presupuestos.validation.paginas_negro_click.decimal", - ], - "paginas_negro_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_negro_forma_id.integer", - ], - "paginas_negro_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_negro_gramaje.decimal", - ], - "paginas_negro_libro" => [ - "decimal" => "Presupuestos.validation.paginas_negro_libro.decimal", - ], - "paginas_negro_mano" => [ - "decimal" => "Presupuestos.validation.paginas_negro_mano.decimal", - ], - "paginas_negro_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pedido.decimal", - ], - "paginas_negro_peso" => [ - "decimal" => "Presupuestos.validation.paginas_negro_peso.decimal", - ], - "paginas_negro_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pliegos_libro.decimal", - ], - "paginas_negro_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pliegos_pedido.decimal", - ], - "paginas_negro_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_negro_pliegos_precio.decimal", - ], - "paginas_negro_precio" => [ - "decimal" => "Presupuestos.validation.paginas_negro_precio.decimal", - ], - "paginas_cubierta" => [ - "in_list" => "Presupuestos.validation.paginas_cubierta.in_list", - "required" => "Presupuestos.validation.paginas_cubierta.required", - ], - "paginas_cubierta_click" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_click.decimal", - ], - "paginas_cubierta_forma_id" => [ - "integer" => "Presupuestos.validation.paginas_cubierta_forma_id.integer", - ], - "paginas_cubierta_gramaje" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_gramaje.decimal", - ], - "paginas_cubierta_libro" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_libro.decimal", - ], - "paginas_cubierta_mano" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_mano.decimal", - ], - "paginas_cubierta_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pedido.decimal", - "required" => "Presupuestos.validation.paginas_cubierta_pedido.required", - ], - "paginas_cubierta_peso" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_peso.decimal", - ], - "paginas_cubierta_pliegos_libro" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pliegos_libro.decimal", - ], - "paginas_cubierta_pliegos_pedido" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pliegos_pedido.decimal", - ], - "paginas_cubierta_pliegos_precio" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_pliegos_precio.decimal", - ], - "paginas_cubierta_precio" => [ - "decimal" => "Presupuestos.validation.paginas_cubierta_precio.decimal", - ], - "papel_formato_alto" => [ - "decimal" => "Presupuestos.validation.papel_formato_alto.decimal", - ], - "papel_formato_ancho" => [ - "decimal" => "Presupuestos.validation.papel_formato_ancho.decimal", - ], - "pedido_espera_fecha" => [ - "valid_date" => "Presupuestos.validation.pedido_espera_fecha.valid_date", - ], - "referencia_cliente" => [ - "max_length" => "Presupuestos.validation.referencia_cliente.max_length", - "required" => "Presupuestos.validation.referencia_cliente.required", - ], - "responsable" => [ - "max_length" => "Presupuestos.validation.responsable.max_length", - ], - "serie_id" => [ - "integer" => "Presupuestos.validation.serie_id.integer", - ], - "solapas_ancho" => [ - "decimal" => "Presupuestos.validation.solapas_ancho.decimal", - "required" => "Presupuestos.validation.solapas_ancho.required", - ], - "tarifa_cliente_id" => [ - "integer" => "Presupuestos.validation.tarifa_cliente_id.integer", - ], - "tirada" => [ - "integer" => "Presupuestos.validation.tirada.integer", - "required" => "Presupuestos.validation.tirada.required", - ], - "tirada_alternativa_json_data" => [ - "max_length" => "Presupuestos.validation.tirada_alternativa_json_data.max_length", + "required" => "Presupuestos.validation.requerido", ], "titulo" => [ - "max_length" => "Presupuestos.validation.titulo.max_length", - "required" => "Presupuestos.validation.titulo.required", + "max_length" => "Presupuestos.validation.max_length", + "required" => "Presupuestos.validation.requerido", ], - "total" => [ - "decimal" => "Presupuestos.validation.total.decimal", + "inc_rei" => [ + "integer" => "Presupuestos.validation.integer", + ], - "total_acabado" => [ - "decimal" => "Presupuestos.validation.total_acabado.decimal", + "coleccion" => [ + "max_length" => "Presupuestos.validation.max_length", ], - "total_calculado" => [ - "decimal" => "Presupuestos.validation.total_calculado.decimal", + "numero_edicion" => [ + "max_length" => "Presupuestos.validation.max_length", ], - "total_click" => [ - "decimal" => "Presupuestos.validation.total_click.decimal", + "isbn" => [ + "max_length" => "Presupuestos.validation.max_length", ], - "total_confirmado" => [ - "decimal" => "Presupuestos.validation.total_confirmado.decimal", + "pais_id" => [ + "required" => "Presupuestos.validation.requerido", ], - "total_confirmado_update_at" => [ - "valid_date" => "Presupuestos.validation.total_confirmado_update_at.valid_date", - ], - "total_descuento" => [ - "decimal" => "Presupuestos.validation.total_descuento.decimal", - ], - "total_envios" => [ - "decimal" => "Presupuestos.validation.total_envios.decimal", - ], - "total_manipulado" => [ - "decimal" => "Presupuestos.validation.total_manipulado.decimal", - ], - "total_margen" => [ - "decimal" => "Presupuestos.validation.total_margen.decimal", - ], - "total_margen_extra" => [ - "decimal" => "Presupuestos.validation.total_margen_extra.decimal", - ], - "total_pedido" => [ - "decimal" => "Presupuestos.validation.total_pedido.decimal", - ], - "total_peso" => [ - "decimal" => "Presupuestos.validation.total_peso.decimal", - ], - "total_preimpresion" => [ - "decimal" => "Presupuestos.validation.total_preimpresion.decimal", - ], - "total_preimpresion_margen" => [ - "decimal" => "Presupuestos.validation.total_preimpresion_margen.decimal", - ], - "total_presupuesto" => [ - "decimal" => "Presupuestos.validation.total_presupuesto.decimal", - ], - "user_created_id" => [ - "integer" => "Presupuestos.validation.user_created_id.integer", - "required" => "Presupuestos.validation.user_created_id.required", - ], - "user_update_id" => [ - "integer" => "Presupuestos.validation.user_update_id.integer", - ], - "version" => [ - "integer" => "Presupuestos.validation.version.integer", - "required" => "Presupuestos.validation.version.required", + "cliente_id" => [ + "required" => "Presupuestos.validation.requerido", ], + "referencia_cliente" => [ + "max_length" => "Presupuestos.validation.max_length", + ], ]; public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) { diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 52a47e14..9ddbda84 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -259,4 +259,32 @@
- \ No newline at end of file + + + + + +section("additionalInlineJs") ?> +$('#papelFormatoPersonalizado').on("click",function(){ + var checkbox = document.getElementById('papelFormatoPersonalizado'); + if(checkbox.checked == true){ + document.getElementById("papelFormatoAncho").style.display = "block"; + document.getElementById("papelFormatoAlto").style.display = "block"; + $('#papelFormatoId').next(".select2-container").hide(); + $('#papelFormatoId').val('').change(); + document.getElementById("label_papelFormatoId").innerHTML = + " (" + + " x )*"; + } + else{ + document.getElementById("papelFormatoAncho").value= ""; + document.getElementById("papelFormatoAlto").value= ""; + document.getElementById("papelFormatoAncho").style.display = "none"; + document.getElementById("papelFormatoAlto").style.display = "none"; + $('#papelFormatoId').next(".select2-container").show(); + document.getElementById("label_papelFormatoId").innerHTML = + "*"; + } +}); + +endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php index d66cd0a2..1279ae52 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php @@ -425,4 +425,888 @@ - \ No newline at end of file + + + + + + +section("additionalInlineJs") ?> + + autosize($('#compCalPaginasColor')); + + init_comparador(); + + var tableCompIntPlana = new DataTable('#tableCompIntPlana',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='bn') + return ''; + else if(data=='bnhq') + return ''; + else if(data=='color') + return ''; + else if(data=='colorhq') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'} + ], + columnDefs: [ + { + target: [16,17,18,19,20], + visible: false, + searchable: false + }, + ] + }); + + + var tableCompIntRotativa = new DataTable('#tableCompIntRotativa',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='rotativa') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'aFavorFibra', + 'render': function(data, type, row, meta){ + if(data=='si') + return ''; + else if(data=='no') + return ''; + } + }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'precioPagNegro' }, + { 'data': 'precioPagColor' }, + { 'data': 'totalTinta' }, + { 'data': 'totalCorte' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'}, + { 'data': 'paginasColor'}, + ], + columnDefs: [ + { + target: [21,22,23,24,25,26], + visible: false, + searchable: false + }, + ] + }); + + var tableCompCubierta = new DataTable('#tableCompCubierta',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + columns: [ + { 'data': 'tipo', + 'render': function ( data, type, row, meta ) { + if(data=='cubierta') + return ''; + else if(data=='sobrecubierta') + return ''; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'click' }, + { 'data': 'totalClicks' }, + { 'data': 'total' }, + { 'data': 'maquinaId'}, + { 'data': 'maquinaVelocidad'}, + { 'data': 'tiempoMaquina'}, + { 'data': 'papelGenericoId'}, + { 'data': 'papelImpresionId'} + ], + columnDefs: [ + { + target: [16,17,18,19,20], + visible: false, + searchable: false + }, + ] + }); + + $('.comp_negro_items').on('change', function (e) { + + checkComparadorInt(false,false); + }); + + $('.comp_negrohq_items').on('change', function (e) { + + checkComparadorInt(false, true); + }); + + $('.comp_color_items').on('change', function (e) { + + checkComparadorInt(true, false); + }); + + $('.comp_colorhq_items').on('change', function (e) { + checkComparadorInt(true, true); + }); + + async function getLineasIntPlana(is_color, is_hq){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'interior', + color: is_color?1:0, + hq: is_hq?1:0, + paginas: parseInt($(''+ elementos.paginas).val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, + papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), + gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntLineas(is_color); + + if(data.lineas.length >0){ + + fillIntPlana(data, is_color, is_hq); + selectIntLineas(); + $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none') + } + else{ + $('#title_int_plana').html(''); + $('#insertarPlanaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00'); + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + return false; + } + + async function getLineasIntRot(is_hq){ + + const dimension = getDimensionLibro(); + + // Rotativa solo negro o color (no hq) + if ( is_hq==false){ + + if(checkInputsForRotativa()){ + + let datos = { + type: 'interior_rot', + paginas: parseInt($('#paginas').val()), + paginas_negro: parseInt($('#compPaginasNegro').val()), + paginas_color: parseInt($('#compPaginasColor').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + // el papel y el gramaje se coge del negro (siempre estará) + papel_generico_id: $('#compPapelNegro').select2('data')[0].id, + papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), + gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntRot(); + + if(data.lineas.length >0){ + + fillIntRot(data); + selectIntRotLineas(); + $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); + $('#insertarRotativaBtn').removeClass('d-none') + } + else{ + $('#title_int_rot').html(''); + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_rot').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + } + return false; + } + + $('.comp_cubierta_items').on('change', function (){ + + if ($('#compCarasCubierta').select2('data').length > 0 && + $('#compPapelCubierta').select2('data').length > 0 && + $('#compGramajeCubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'cubierta', + paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: parseInt($('#solapas_ancho').val()), + papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, + papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearCubierta(); + + if(data.lineas.length >0){ + + fillCubierta(data); + selectCubiertaLineas(); + $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); + $('#insertarCubiertaBtn').removeClass('d-none') + + } + else{ + $('#title_cubierta').html(''); + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearCubierta(); + } + }); + + + $('#tipoImpresion').on("change", function () { + updatePapelesComparador(); + + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + $('#paginas').change(); + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + + }); + + + $('.comp_negro_items').on('change', function (e) { + + checkComparadorInt(false,false); + }); + + $('.comp_negrohq_items').on('change', function (e) { + + checkComparadorInt(false, true); + }); + + $('.comp_color_items').on('change', function (e) { + + checkComparadorInt(true, false); + }); + + $('.comp_colorhq_items').on('change', function (e) { + checkComparadorInt(true, true); + }); + + async function getLineasIntPlana(is_color, is_hq){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'interior', + color: is_color?1:0, + hq: is_hq?1:0, + paginas: parseInt($(''+ elementos.paginas).val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, + papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), + gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntLineas(is_color); + + if(data.lineas.length >0){ + + fillIntPlana(data, is_color, is_hq); + selectIntLineas(); + $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none') + } + else{ + $('#title_int_plana').html(''); + $('#insertarPlanaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00'); + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + return false; + } + + async function getLineasIntRot(is_hq){ + + const dimension = getDimensionLibro(); + + // Rotativa solo negro o color (no hq) + if ( is_hq==false){ + + if(checkInputsForRotativa()){ + + let datos = { + type: 'interior_rot', + paginas: parseInt($('#paginas').val()), + paginas_negro: parseInt($('#compPaginasNegro').val()), + paginas_color: parseInt($('#compPaginasColor').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + // el papel y el gramaje se coge del negro (siempre estará) + papel_generico_id: $('#compPapelNegro').select2('data')[0].id, + papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), + gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearIntRot(); + + if(data.lineas.length >0){ + + fillIntRot(data); + selectIntRotLineas(); + $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); + $('#insertarRotativaBtn').removeClass('d-none') + } + else{ + $('#title_int_rot').html(''); + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_rot').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + } + return false; + } + + + $('.comp_cubierta_items').on('change', function (){ + + if ($('#compCarasCubierta').select2('data').length > 0 && + $('#compPapelCubierta').select2('data').length > 0 && + $('#compGramajeCubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + type: 'cubierta', + paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: parseInt($('#solapas_ancho').val()), + papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, + papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , + : v + }; + + $.ajax({ + type: "POST", + url: "/cosidotapablanda/datatable", + data: datos, + success: function (data) { + + clearCubierta(); + + if(data.lineas.length >0){ + + fillCubierta(data); + selectCubiertaLineas(); + $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); + $('#insertarCubiertaBtn').removeClass('d-none') + + } + else{ + $('#title_cubierta').html(''); + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearCubierta(); + } + }); + + + $('#tipoImpresion').on("change", function () { + updatePapelesComparador(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + $('#paginas').change(); + + + if (($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color')){ + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && + $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + + } + else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + if($('#tableCompIntPlana').DataTable().rows().count() > 0 && + !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + } + }); + + + function checkComparadorInt(is_color, is_hq) { + + clearIntLineas(is_color); + clearIntRot(); + $('#title_int_rot').html(''); + $('#title_int_plana').html(''); + + elementos = getIDsComparador(is_color, is_hq) + + if ($(''+ elementos.papel).select2('data').length > 0 && + $(''+ elementos.gramaje).select2('data').length > 0 && + parseInt($(''+ elementos.paginas).val()) > 0 && + checkDatosPedidoForComp()) { + + getLineasIntPlana(is_color, is_hq).then((result) =>{ + // Para rotativa, si es color el papel y el gramaje tiene que ser igual + if(!is_color) + { + getLineasIntRot(is_hq); + } + else + { + if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && + $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) + { + getLineasIntRot(is_hq); + } + else + { + $('#errorComRot').html(''); + } + } + }); + } + } + + + $('#compPapelNegro').on('select2:select', function (e){ + + if($('#compPapelNegro').select2('data')[0].id=='0'){ + $('#compGramajeNegro').val('').change(); + $('#compGramajeNegro').prop('disabled', true); + } + + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeNegro').val('').change(); + $('#compGramajeNegro').empty().trigger("change"); + $('#compGramajeNegro').prop('disabled', false); + $('#compGramajeNegro').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'bn', + datos: $('#compPapelNegro').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + $('#compPapelNegrohq').on('select2:select', function (e){ + + if($('#compPapelNegrohq').select2('data')[0].id=='0'){ + $('#compGramajeNegrohq').val('').change(); + $('#compGramajeNegrohq').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeNegrohq').empty().trigger("change"); + $('#compGramajeNegrohq').prop('disabled', false); + $('#compGramajeNegrohq').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'bnhq', + datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + + $('#compPapelColor').on('select2:select', function (e){ + + if($('#compPapelColor').select2('data')[0].id=='0'){ + $('#compGramajeColor').val('').change(); + $('#compGramajeColor').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeColor').empty().trigger("change"); + $('#compGramajeColor').prop('disabled', false); + $('#compPapelColor').find('option[value="0"]').remove(); + $('#compGramajeColor').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'color', + datos: $('#compPapelColor').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + + $('#compPapelColorhq').on('select2:select', function (e){ + + if($('#compPapelColorhq').select2('data')[0].id=='0'){ + $('#compGramajeColorhq').val('').change(); + $('#compGramajeColorhq').prop('disabled', true); + } + else{ + $('#insertarPlanaBtn').addClass('d-none') + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00') + $('#total_comp_rot').html('0.00') + $('#compGramajeColorhq').empty().trigger("change"); + $('#compGramajeColorhq').prop('disabled', false); + $('#compPapelColorhq').find('option[value="0"]').remove(); + $('#compGramajeColorhq').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'colorhq', + datos: $('#compPapelColorhq').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + $('#compPapelCubierta').on('select2:select', function (e){ + if($('#compPapelCubierta').select2('data')[0].id=='0'){ + $('#compGramajeCubierta').val('').change(); + $('#compGramajeCubierta').prop('disabled', true); + } + else{ + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + $('#compGramajeCubierta').val('').trigger('change'); + $('#compGramajeCubierta').prop('disabled', false); + $('#compPapelCubierta').find('option[value="0"]').remove(); + $('#compGramajeCubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + ajax: { + url: '', + type: 'post', + dataType: 'json', + + data: function (params) { + return { + tipo: 'gramaje', + uso: 'cubierta', + datos: $('#compPapelCubierta').select2('data')[0].text.trim() , + : v + }; + }, + delay: 60, + processResults: function (response) { + yeniden(response.); + return { + results: response.menu + }; + }, + cache: true + } + }); + } + }); + + + function checkDatosPedidoForComp() { + + const dimension = getDimensionLibro(); + + if (parseInt($('#paginas').val()) <= 0){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + if (parseInt($('#tirada').val()) <= 0){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + if('ancho' in dimension && 'alto' in dimension){ + + if(dimension.alto < 60 || dimension.ancho < 60 || isNaN(dimension.alto) || isNaN(dimension.ancho) ){ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + } + else{ + popErrorAlert('', 'divAlarmasComparador'); + return false; + } + return true; + } + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php index 8429d740..b61e1d61 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php @@ -34,7 +34,10 @@ - + @@ -47,7 +50,7 @@ $v) : ?> - section("additionalInlineJs") ?> +var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" + }, + +}); + async function set_lp_cubierta_gramaje(){ await $.ajax({ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 5e9f843b..7d20aa28 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -16,21 +16,26 @@ getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + - - - - - - + + + + + + + +
" /> - "btn btn-dark float-start me-sm-3 me-1",]) ?> - "btn btn-info float-start me-sm-3 me-1",]) ?> + + "btn btn-dark float-start me-sm-3 me-1",]) ?> + "btn btn-info float-start me-sm-3 me-1",]) ?> + "btn btn-secondary float-start",]) ?>
@@ -84,993 +89,70 @@ allowClear: false, }); - $('#papelFormatoId').select2({ - allowClear: false, - }); + + + $('#papelFormatoId').select2({ + allowClear: false, + }); - $('#tipoImpresion').select2({ - allowClear: false, - }); + $('#tipoImpresion').select2({ + allowClear: false, + }); - $('#compPapelNegro').select2({ - allowClear: false, - }); + $('#compPapelNegro').select2({ + allowClear: false, + }); - $('#compGramajeNegro').select2({ - allowClear: false, - }); + $('#compGramajeNegro').select2({ + allowClear: false, + }); - $('#compPapelNegrohq').select2({ - allowClear: false, - }); + $('#compPapelNegrohq').select2({ + allowClear: false, + }); - $('#compGramajeNegrohq').select2({ - allowClear: false, - }); + $('#compGramajeNegrohq').select2({ + allowClear: false, + }); - $('#compPapelColor').select2({ - allowClear: false, - }); + $('#compPapelColor').select2({ + allowClear: false, + }); - $('#compPapelColorhq').select2({ - allowClear: false, - }); + $('#compPapelColorhq').select2({ + allowClear: false, + }); - $('#compGramajeColor').select2({ - allowClear: false, - }); + $('#compGramajeColor').select2({ + allowClear: false, + }); - $('#compGramajeColorhq').select2({ - allowClear: false, - }); + $('#compGramajeColorhq').select2({ + allowClear: false, + }); - $('#compPapelCubierta').select2({ - allowClear: false, - }); + $('#compPapelCubierta').select2({ + allowClear: false, + }); - $('#compGramajeCubierta').select2({ - allowClear: false, - }); + $('#compGramajeCubierta').select2({ + allowClear: false, + }); - $('#encuadernacion').select2({ - allowClear: false, - }); + $('#encuadernacion').select2({ + allowClear: false, + }); - $('#compCarasCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); + $('#compCarasCubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + + //const papelGenericoNegroList = ; endSection() ?> - - - -section("additionalInlineJs") ?> - - autosize($('#compCalPaginasColor')); - - $('#papelFormatoPersonalizado').on("click",function(){ - var checkbox = document.getElementById('papelFormatoPersonalizado'); - if(checkbox.checked == true){ - document.getElementById("papelFormatoAncho").style.display = "block"; - document.getElementById("papelFormatoAlto").style.display = "block"; - $('#papelFormatoId').next(".select2-container").hide(); - $('#papelFormatoId').val('').change(); - document.getElementById("label_papelFormatoId").innerHTML = - " (" + - " x )*"; - } - else{ - document.getElementById("papelFormatoAncho").value= ""; - document.getElementById("papelFormatoAlto").value= ""; - document.getElementById("papelFormatoAncho").style.display = "none"; - document.getElementById("papelFormatoAlto").style.display = "none"; - $('#papelFormatoId').next(".select2-container").show(); - document.getElementById("label_papelFormatoId").innerHTML = - "*"; - } - }); - - - init_comparador(); - - - var tableCompIntPlana = new DataTable('#tableCompIntPlana',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='bn') - return ''; - else if(data=='bnhq') - return ''; - else if(data=='color') - return ''; - else if(data=='colorhq') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'click' }, - { 'data': 'totalClicks' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} - ], - columnDefs: [ - { - target: [16,17,18,19,20], - visible: false, - searchable: false - }, - ] - }); - - - var tableCompIntRotativa = new DataTable('#tableCompIntRotativa',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='rotativa') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'aFavorFibra', - 'render': function(data, type, row, meta){ - if(data=='si') - return ''; - else if(data=='no') - return ''; - } - }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'click' }, - { 'data': 'totalClicks' }, - { 'data': 'precioPagNegro' }, - { 'data': 'precioPagColor' }, - { 'data': 'totalTinta' }, - { 'data': 'totalCorte' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'}, - { 'data': 'paginasColor'}, - ], - columnDefs: [ - { - target: [21,22,23,24,25,26], - visible: false, - searchable: false - }, - ] - }); - - var tableCompCubierta = new DataTable('#tableCompCubierta',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='cubierta') - return ''; - else if(data=='sobrecubierta') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'click' }, - { 'data': 'totalClicks' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} - ], - columnDefs: [ - { - target: [16,17,18,19,20], - visible: false, - searchable: false - }, - ] - }); - - const papelGenericoNegroList = ; - - - var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/i18n ?>.json" - }, - - }); - - - $('.comp_negro_items').on('change', function (e) { - - checkComparadorInt(false,false); - }); - - $('.comp_negrohq_items').on('change', function (e) { - - checkComparadorInt(false, true); - }); - - $('.comp_color_items').on('change', function (e) { - - checkComparadorInt(true, false); - }); - - $('.comp_colorhq_items').on('change', function (e) { - checkComparadorInt(true, true); - }); - - async function getLineasIntPlana(is_color, is_hq){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'interior', - color: is_color?1:0, - hq: is_hq?1:0, - paginas: parseInt($(''+ elementos.paginas).val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, - papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), - gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntLineas(is_color); - - if(data.lineas.length >0){ - - fillIntPlana(data, is_color, is_hq); - selectIntLineas(); - $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); - $('#insertarPlanaBtn').removeClass('d-none') - } - else{ - $('#title_int_plana').html(''); - $('#insertarPlanaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00'); - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - return false; - } - - async function getLineasIntRot(is_hq){ - - const dimension = getDimensionLibro(); - - // Rotativa solo negro o color (no hq) - if ( is_hq==false){ - - if(checkInputsForRotativa()){ - - let datos = { - type: 'interior_rot', - paginas: parseInt($('#paginas').val()), - paginas_negro: parseInt($('#compPaginasNegro').val()), - paginas_color: parseInt($('#compPaginasColor').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - // el papel y el gramaje se coge del negro (siempre estará) - papel_generico_id: $('#compPapelNegro').select2('data')[0].id, - papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), - gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntRot(); - - if(data.lineas.length >0){ - - fillIntRot(data); - selectIntRotLineas(); - $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); - $('#insertarRotativaBtn').removeClass('d-none') - } - else{ - $('#title_int_rot').html(''); - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_rot').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - } - return false; - } - - $('.comp_cubierta_items').on('change', function (){ - - if ($('#compCarasCubierta').select2('data').length > 0 && - $('#compPapelCubierta').select2('data').length > 0 && - $('#compGramajeCubierta').select2('data').length > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'cubierta', - paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - solapas: $('#solapas').is(':checked')?1:0, - solapas_ancho: parseInt($('#solapas_ancho').val()), - papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, - papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearCubierta(); - - if(data.lineas.length >0){ - - fillCubierta(data); - selectCubiertaLineas(); - $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); - $('#insertarCubiertaBtn').removeClass('d-none') - - } - else{ - $('#title_cubierta').html(''); - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearCubierta(); - } - }); - - - $('#tipoImpresion').on("change", function () { - updatePapelesComparador(); - - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - $('#paginas').change(); - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - - }); - - - $('.comp_negro_items').on('change', function (e) { - - checkComparadorInt(false,false); - }); - - $('.comp_negrohq_items').on('change', function (e) { - - checkComparadorInt(false, true); - }); - - $('.comp_color_items').on('change', function (e) { - - checkComparadorInt(true, false); - }); - - $('.comp_colorhq_items').on('change', function (e) { - checkComparadorInt(true, true); - }); - - async function getLineasIntPlana(is_color, is_hq){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'interior', - color: is_color?1:0, - hq: is_hq?1:0, - paginas: parseInt($(''+ elementos.paginas).val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, - papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), - gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntLineas(is_color); - - if(data.lineas.length >0){ - - fillIntPlana(data, is_color, is_hq); - selectIntLineas(); - $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); - $('#insertarPlanaBtn').removeClass('d-none') - } - else{ - $('#title_int_plana').html(''); - $('#insertarPlanaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00'); - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - return false; - } - - async function getLineasIntRot(is_hq){ - - const dimension = getDimensionLibro(); - - // Rotativa solo negro o color (no hq) - if ( is_hq==false){ - - if(checkInputsForRotativa()){ - - let datos = { - type: 'interior_rot', - paginas: parseInt($('#paginas').val()), - paginas_negro: parseInt($('#compPaginasNegro').val()), - paginas_color: parseInt($('#compPaginasColor').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - // el papel y el gramaje se coge del negro (siempre estará) - papel_generico_id: $('#compPapelNegro').select2('data')[0].id, - papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), - gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearIntRot(); - - if(data.lineas.length >0){ - - fillIntRot(data); - selectIntRotLineas(); - $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); - $('#insertarRotativaBtn').removeClass('d-none') - } - else{ - $('#title_int_rot').html(''); - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_rot').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - } - return false; - } - - - $('.comp_cubierta_items').on('change', function (){ - - if ($('#compCarasCubierta').select2('data').length > 0 && - $('#compPapelCubierta').select2('data').length > 0 && - $('#compGramajeCubierta').select2('data').length > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - type: 'cubierta', - paginas: parseInt($('#compCarasCubierta').select2('data')[0].id), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - solapas: $('#solapas').is(':checked')?1:0, - solapas_ancho: parseInt($('#solapas_ancho').val()), - papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, - papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , - : v - }; - - $.ajax({ - type: "POST", - url: "/cosidotapablanda/datatable", - data: datos, - success: function (data) { - - clearCubierta(); - - if(data.lineas.length >0){ - - fillCubierta(data); - selectCubiertaLineas(); - $('#title_cubierta').html('' + ' (' + tableCompCubierta.rows().count() + ')'); - $('#insertarCubiertaBtn').removeClass('d-none') - - } - else{ - $('#title_cubierta').html(''); - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearCubierta(); - } - }); - - - $('#tipoImpresion').on("change", function () { - updatePapelesComparador(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - $('#paginas').change(); - - - if (($('#tipoImpresion').select2('data')[0].id == 'negro' || - $('#tipoImpresion').select2('data')[0].id == 'color')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && - $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - - } - else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || - $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - if($('#tableCompIntPlana').DataTable().rows().count() > 0 && - !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - } - }); - - - function checkComparadorInt(is_color, is_hq) { - - clearIntLineas(is_color); - clearIntRot(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - - elementos = getIDsComparador(is_color, is_hq) - - if ($(''+ elementos.papel).select2('data').length > 0 && - $(''+ elementos.gramaje).select2('data').length > 0 && - parseInt($(''+ elementos.paginas).val()) > 0 && - checkDatosPedidoForComp()) { - - getLineasIntPlana(is_color, is_hq).then((result) =>{ - // Para rotativa, si es color el papel y el gramaje tiene que ser igual - if(!is_color) - { - getLineasIntRot(is_hq); - } - else - { - if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) - { - getLineasIntRot(is_hq); - } - else - { - $('#errorComRot').html(''); - } - } - }); - } - } - - - $('#compPapelNegro').on('select2:select', function (e){ - - if($('#compPapelNegro').select2('data')[0].id=='0'){ - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').prop('disabled', true); - } - - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').empty().trigger("change"); - $('#compGramajeNegro').prop('disabled', false); - $('#compGramajeNegro').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bn', - datos: $('#compPapelNegro').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelNegrohq').on('select2:select', function (e){ - - if($('#compPapelNegrohq').select2('data')[0].id=='0'){ - $('#compGramajeNegrohq').val('').change(); - $('#compGramajeNegrohq').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeNegrohq').empty().trigger("change"); - $('#compGramajeNegrohq').prop('disabled', false); - $('#compGramajeNegrohq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bnhq', - datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - $('#compPapelColor').on('select2:select', function (e){ - - if($('#compPapelColor').select2('data')[0].id=='0'){ - $('#compGramajeColor').val('').change(); - $('#compGramajeColor').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeColor').empty().trigger("change"); - $('#compGramajeColor').prop('disabled', false); - $('#compPapelColor').find('option[value="0"]').remove(); - $('#compGramajeColor').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'color', - datos: $('#compPapelColor').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - $('#compPapelColorhq').on('select2:select', function (e){ - - if($('#compPapelColorhq').select2('data')[0].id=='0'){ - $('#compGramajeColorhq').val('').change(); - $('#compGramajeColorhq').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeColorhq').empty().trigger("change"); - $('#compGramajeColorhq').prop('disabled', false); - $('#compPapelColorhq').find('option[value="0"]').remove(); - $('#compGramajeColorhq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'colorhq', - datos: $('#compPapelColorhq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelCubierta').on('select2:select', function (e){ - if($('#compPapelCubierta').select2('data')[0].id=='0'){ - $('#compGramajeCubierta').val('').change(); - $('#compGramajeCubierta').prop('disabled', true); - } - else{ - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - $('#compGramajeCubierta').val('').trigger('change'); - $('#compGramajeCubierta').prop('disabled', false); - $('#compPapelCubierta').find('option[value="0"]').remove(); - $('#compGramajeCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'cubierta', - datos: $('#compPapelCubierta').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - function checkDatosPedidoForComp() { - - const dimension = getDimensionLibro(); - - if (parseInt($('#paginas').val()) <= 0){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - if (parseInt($('#tirada').val()) <= 0){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - if('ancho' in dimension && 'alto' in dimension){ - - if(dimension.alto < 60 || dimension.ancho < 60 || isNaN(dimension.alto) || isNaN(dimension.ancho) ){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - } - else{ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - return true; - } - -endSection() ?> - - - section('css') ?> @@ -1087,5 +169,7 @@ - + + + endSection() ?> From 2f38df48860541ca64846c7fc2266ee06910bd00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 13 Nov 2023 15:05:45 +0100 Subject: [PATCH 08/10] leyendo lp y pasandolas a las tablas --- .../Presupuestos/Cosidotapablanda.php | 55 +-- ci4/app/Controllers/Test.php | 26 +- .../Presupuestos/PresupuestoLineaEntity.php | 123 +++++++ ci4/app/Language/en/Presupuestos.php | 3 +- ci4/app/Language/es/Presupuestos.php | 3 +- .../Presupuestos/PresupuestoLineaModel.php | 332 ++++++++++++++++++ .../Models/Presupuestos/PresupuestoModel.php | 4 +- .../_datosPresupuestoItems.php | 2 +- .../_lineasPresupuestoItems.php | 90 ++++- .../viewCosidotapablandaForm.php | 7 +- .../viewCosidotapablandaList.php | 13 +- 11 files changed, 604 insertions(+), 54 deletions(-) create mode 100644 ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php create mode 100644 ci4/app/Models/Presupuestos/PresupuestoLineaModel.php diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 8e98b6af..68206afd 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -116,6 +116,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $id = $this->model->db->insertID(); + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $lp_model->createForPresupuesto($id); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : @@ -137,21 +140,6 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $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')); $this->viewData['paisList'] = $this->getPaisListItems(); - $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - $this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro(); - $this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ(); - $this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor(); - $this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ(); - $this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta(); - $this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta(); - $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); - $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); - - // Tarifas - $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); - $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); - $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); - $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO @@ -310,34 +298,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['presupuestoEntity'] = $presupuestoEntity; $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); - //$this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); - //$this->viewData['tiposImpresionList'] = $this->getTiposImpresionListItems($presupuestoEntity->tipo_impresion_id ?? null); - //$this->viewData['tipologiasLibroList'] = $this->getTipologiasLibroListItems($presupuestoEntity->tipologia_id ?? null); $this->viewData['paisList'] = $this->getPaisListItems(); - //$this->viewData['ubicacionLibroList'] = $this->getUbicacionLibroListItems($presupuestoEntity->ubicacion_id ?? null); - //$this->viewData['presupuestoEstadoList'] = $this->getPresupuestoEstadoListItems($presupuestoEntity->estado_id ?? null); - //$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - //$this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($presupuestoEntity->paginas_negro_papel_id ?? null); - //$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($presupuestoEntity->paginas_negro_papel_impresion_id ?? null); - //$this->viewData['maquinaList'] = $this->getMaquinaListItems($presupuestoEntity->paginas_negro_maquina_id ?? null); - //$this->viewData['maquinasTarifasImpresionList'] = $this->getMaquinasTarifasImpresionListItems($presupuestoEntity->paginas_negro_tarifa_impresion_id ?? null); - //$this->viewData['papelGenericoList2'] = $this->getPapelGenericoListItems2($presupuestoEntity->paginas_color_papel_id ?? null); - /*$this->viewData['papelImpresionList2'] = $this->getPapelImpresionListItems2($presupuestoEntity->paginas_color_papel_impresion_id ?? null); - $this->viewData['maquinaList2'] = $this->getMaquinaListItems2($presupuestoEntity->paginas_color_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList2'] = $this->getMaquinasTarifasImpresionListItems2($presupuestoEntity->paginas_color_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList3'] = $this->getPapelGenericoListItems3($presupuestoEntity->paginas_portada_papel_id ?? null); - $this->viewData['papelImpresionList3'] = $this->getPapelImpresionListItems3($presupuestoEntity->paginas_portada_papel_impresion_id ?? null); - $this->viewData['maquinaList3'] = $this->getMaquinaListItems3($presupuestoEntity->paginas_portada_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList3'] = $this->getMaquinasTarifasImpresionListItems3($presupuestoEntity->paginas_portada_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList4'] = $this->getPapelGenericoListItems4($presupuestoEntity->paginas_cubierta_papel_id ?? null); - $this->viewData['papelImpresionList4'] = $this->getPapelImpresionListItems4($presupuestoEntity->paginas_cubierta_papel_impresion_id ?? null); - $this->viewData['maquinaList4'] = $this->getMaquinaListItems4($presupuestoEntity->paginas_cubierta_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList4'] = $this->getMaquinasTarifasImpresionListItems4($presupuestoEntity->paginas_cubierta_tarifa_impresion_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($presupuestoEntity->total_confirmado_user_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($presupuestoEntity->aprobado_user_id ?? null); - $this->viewData['userList3'] = $this->getUserListItems3($presupuestoEntity->pedido_espera_user_id ?? null); - $this->viewData['paginasCubiertaList'] = $this->getPaginasCubiertaOptions(); - $this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions();*/ $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')); @@ -352,12 +313,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); + // Lineas Presupuesto + $this->viewData['lineasPresupuesto'] = $this->getLineasPresupuestoActivas($id); + // Tarifas $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); - $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO @@ -1041,7 +1004,11 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $data; } - + protected function getLineasPresupuestoActivas($presupuesto_id) + { + $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + return $model->getLineasPresupuesto($presupuesto_id); + } } diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index f6f20f20..5e9404a0 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -17,7 +17,31 @@ class Test extends BaseController public function index() { - $this->testLineasIntPlana(); + $time = '99:59:59'; + + $time_parts = explode(":", $time); + $seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600; + echo "Time in seconds: " . $seconds; + } + + public function timeToSeconds(){ + $time = '99:59:59'; + + $time_parts = explode(":", $time); + $seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600; + echo "Time in seconds: " . $seconds; + } + + public function getLP(){ + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $data = $lp_model->getLineasPresupuesto(8); + foreach($data as $linea) + var_dump($linea->tipo); + } + + public function createLP(){ + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $lp_model->createForPresupuesto(8); } public function getPapelesHQ(){ diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php new file mode 100644 index 00000000..8fcc6c21 --- /dev/null +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -0,0 +1,123 @@ + null, + "presupuesto_id" => null, + "tipo" => null, + "paginas" => 0, + "paginas_color_posicion" => null, + "solapas_ancho" => 0.0, + "papel_id" => null, + "papel_impresion_id" => null, + "formas" => null, + "gramaje" => null, + "pliegos_libro" => null, + "pliegos_pedido" => null, + "pliegos_precio" => null, + "libro" => null, + "pedido" => null, + "mano" => null, + "peso" => null, + "maquina_id" => null, + "tarifa_impresion_id" => null, + "click" => null, + "precio" => null, + "rotativa_impresion" => null, + "rotativa_pag_color" => 0, + "rotativa_set_values" => false, + "rotativa_negro" => 0.0, + "rotativa_cyan" => 0.0, + "rotativa_magenta" => 0.0, + "rotativa_amarillo" => 0.0, + "rotativa_gota_negro" => 0.0, + "rotativa_gota_color" => 0.0, + "rotativa_saturacion" => 100.0, + "rotativa_a_favor_fibra" => true, + "rotativa_mxm" => null, + "rotativa_area_paginas" => null, + "rotativa_num_gotas_negro" => 0, + "rotativa_num_gotas_cyan" => 0, + "rotativa_num_gotas_magenta" => 0, + "rotativa_num_gotas_amarillo" => 0, + "rotativa_peso_gotas_negro" => 0, + "rotativa_peso_gotas_cyan" => 0, + "rotativa_peso_gotas_magenta" => 0, + "rotativa_peso_gotas_amarillo" => 0, + "rotativa_precio_pag_negro" => null, + "rotativa_precio_pag_color" => null, + "rotativa_factor_altura" => null, + "rotativa_factor_anchura" => null, + "rotativa_pag_por_pliego" => null, + "rotativa_metros_libro" => null, + "rotativa_metros_total" => null, + "rotativa_clicks_libro" => null, + "rotativa_clicks_total" => null, + "rotativa_precio_tinta" => null, + "rotativa_total_impresion" => null, + "rotativa_velocidad_corte" => 0, + "rotativa_tiempo_corte" => 0, + "rotativa_precio_hora_corte" => 0, + "rotativa_total_corte" => 0, + "isActiva" => false, + ]; + protected $casts = [ + "presupuesto_id" => "int", + "paginas" => "int", + "solapas_ancho" => "float", + "papel_id" => "?int", + "papel_impresion_id" => "?int", + "gramaje" => "?float", + "pliegos_libro" => "?float", + "pliegos_pedido" => "?float", + "pliegos_precio" => "?float", + "libro" => "?float", + "pedido" => "?float", + "mano" => "?float", + "peso" => "?float", + "maquina_id" => "?int", + "tarifa_impresion_id" => "?int", + "click" => "?float", + "precio" => "?float", + "rotativa_pag_color" => "int", + "rotativa_set_values" => "boolean", + "rotativa_negro" => "float", + "rotativa_cyan" => "float", + "rotativa_magenta" => "float", + "rotativa_amarillo" => "float", + "rotativa_gota_negro" => "float", + "rotativa_gota_color" => "float", + "rotativa_saturacion" => "float", + "rotativa_a_favor_fibra" => "boolean", + "rotativa_mxm" => "?float", + "rotativa_area_paginas" => "float", + "rotativa_num_gotas_negro" => "float", + "rotativa_num_gotas_cyan" => "float", + "rotativa_num_gotas_magenta" => "float", + "rotativa_num_gotas_amarillo" => "float", + "rotativa_peso_gotas_negro" => "float", + "rotativa_peso_gotas_cyan" => "float", + "rotativa_peso_gotas_magenta" => "float", + "rotativa_peso_gotas_amarillo" => "float", + "rotativa_precio_pag_negro" => "float", + "rotativa_precio_pag_color" => "float", + "rotativa_factor_altura" => "float", + "rotativa_factor_anchura" => "float", + "rotativa_pag_por_pliego" => "float", + "rotativa_metros_libro" => "float", + "rotativa_metros_total" => "float", + "rotativa_clicks_libro" => "float", + "rotativa_clicks_total" => "float", + "rotativa_precio_tinta" => "float", + "rotativa_total_impresion" => "float", + "rotativa_velocidad_corte" => "float", + "rotativa_tiempo_corte" => "float", + "rotativa_precio_hora_corte" => "float", + "rotativa_total_corte" => "float", + "isActiva" => "boolean", + ]; +} diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 571c6720..aa954702 100644 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -22,7 +22,8 @@ return [ 'incRei' => 'Incident \ Reprint', 'paginas' => 'Pages', 'tirada' => 'Print', - 'totalPapelPedido' => 'Total paper budget', + 'totalPedido' => 'Total paper budget', + 'totalPresupuesto' => 'Total Budget', 'presupuestoEstado' => 'State', 'presupuestoEstadoBorrador' => 'Draft', 'presupuestoEstadoAceptado' => 'Acepted', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index d3be5e1c..b71dd428 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -21,7 +21,8 @@ return [ 'incRei' => 'Incidencia \ Reimpresión', 'paginas' => 'Paginas', 'tirada' => 'Tirada', - 'totalPedido' => 'Total Presupuesto', + 'totalPedido' => 'Total Pedido', + 'totalPresupuesto' => 'Total Presupuesto', 'presupuestoEstado' => 'Estado', 'presupuestoEstadoBorrador' => 'Borrador', 'presupuestoEstadoAceptado' => 'Aceptado', diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php new file mode 100644 index 00000000..fabf40a5 --- /dev/null +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -0,0 +1,332 @@ + [ + "label" => "PresupuestoLineas.click", + "rules" => "decimal|permit_empty", + ], + "formas" => [ + "label" => "PresupuestoLineas.formas", + "rules" => "trim|max_length[16313]", + ], + "gramaje" => [ + "label" => "PresupuestoLineas.gramaje", + "rules" => "decimal|permit_empty", + ], + "libro" => [ + "label" => "PresupuestoLineas.libro", + "rules" => "decimal|permit_empty", + ], + "mano" => [ + "label" => "PresupuestoLineas.mano", + "rules" => "decimal|permit_empty", + ], + "paginas" => [ + "label" => "PresupuestoLineas.paginas", + "rules" => "required|integer", + ], + "paginas_color_posicion" => [ + "label" => "PresupuestoLineas.paginasColorPosicion", + "rules" => "trim|max_length[16313]", + ], + "pedido" => [ + "label" => "PresupuestoLineas.pedido", + "rules" => "decimal|permit_empty", + ], + "peso" => [ + "label" => "PresupuestoLineas.peso", + "rules" => "decimal|permit_empty", + ], + "pliegos_libro" => [ + "label" => "PresupuestoLineas.pliegosLibro", + "rules" => "decimal|permit_empty", + ], + "pliegos_pedido" => [ + "label" => "PresupuestoLineas.pliegosPedido", + "rules" => "decimal|permit_empty", + ], + "pliegos_precio" => [ + "label" => "PresupuestoLineas.pliegosPrecio", + "rules" => "decimal|permit_empty", + ], + "precio" => [ + "label" => "PresupuestoLineas.precio", + "rules" => "decimal|permit_empty", + ], + "rotativa_amarillo" => [ + "label" => "PresupuestoLineas.rotativaAmarillo", + "rules" => "required|decimal", + ], + "rotativa_area_paginas" => [ + "label" => "PresupuestoLineas.rotativaAreaPaginas", + "rules" => "required|decimal", + ], + "rotativa_clicks_libro" => [ + "label" => "PresupuestoLineas.rotativaClicksLibro", + "rules" => "required|decimal", + ], + "rotativa_clicks_total" => [ + "label" => "PresupuestoLineas.rotativaClicksTotal", + "rules" => "required|decimal", + ], + "rotativa_cyan" => [ + "label" => "PresupuestoLineas.rotativaCyan", + "rules" => "required|decimal", + ], + "rotativa_factor_altura" => [ + "label" => "PresupuestoLineas.rotativaFactorAltura", + "rules" => "required|decimal", + ], + "rotativa_factor_anchura" => [ + "label" => "PresupuestoLineas.rotativaFactorAnchura", + "rules" => "required|decimal", + ], + "rotativa_gota_color" => [ + "label" => "PresupuestoLineas.rotativaGotaColor", + "rules" => "required|decimal", + ], + "rotativa_gota_negro" => [ + "label" => "PresupuestoLineas.rotativaGotaNegro", + "rules" => "required|decimal", + ], + "rotativa_impresion" => [ + "label" => "PresupuestoLineas.rotativaImpresion", + "rules" => "required|in_list[negro,color]", + ], + "rotativa_magenta" => [ + "label" => "PresupuestoLineas.rotativaMagenta", + "rules" => "required|decimal", + ], + "rotativa_metros_libro" => [ + "label" => "PresupuestoLineas.rotativaMetrosLibro", + "rules" => "required|decimal", + ], + "rotativa_metros_total" => [ + "label" => "PresupuestoLineas.rotativaMetrosTotal", + "rules" => "required|decimal", + ], + "rotativa_mxm" => [ + "label" => "PresupuestoLineas.rotativaMxm", + "rules" => "decimal|permit_empty", + ], + "rotativa_negro" => [ + "label" => "PresupuestoLineas.rotativaNegro", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_amarillo" => [ + "label" => "PresupuestoLineas.rotativaNumGotasAmarillo", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_cyan" => [ + "label" => "PresupuestoLineas.rotativaNumGotasCyan", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_magenta" => [ + "label" => "PresupuestoLineas.rotativaNumGotasMagenta", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_negro" => [ + "label" => "PresupuestoLineas.rotativaNumGotasNegro", + "rules" => "required|decimal", + ], + "rotativa_pag_color" => [ + "label" => "PresupuestoLineas.rotativaPagColor", + "rules" => "required|integer", + ], + "rotativa_pag_por_pliego" => [ + "label" => "PresupuestoLineas.rotativaPagPorPliego", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_amarillo" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasAmarillo", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_cyan" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasCyan", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_magenta" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasMagenta", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_negro" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasNegro", + "rules" => "required|decimal", + ], + "rotativa_precio_hora_corte" => [ + "label" => "PresupuestoLineas.rotativaPrecioHoraCorte", + "rules" => "required|decimal", + ], + "rotativa_precio_pag_color" => [ + "label" => "PresupuestoLineas.rotativaPrecioPagColor", + "rules" => "required|decimal", + ], + "rotativa_precio_pag_negro" => [ + "label" => "PresupuestoLineas.rotativaPrecioPagNegro", + "rules" => "required|decimal", + ], + "rotativa_precio_tinta" => [ + "label" => "PresupuestoLineas.rotativaPrecioTinta", + "rules" => "required|decimal", + ], + "rotativa_saturacion" => [ + "label" => "PresupuestoLineas.rotativaSaturacion", + "rules" => "required|decimal", + ], + "rotativa_tiempo_corte" => [ + "label" => "PresupuestoLineas.rotativaTiempoCorte", + "rules" => "required|decimal", + ], + "rotativa_total_corte" => [ + "label" => "PresupuestoLineas.rotativaTotalCorte", + "rules" => "required|decimal", + ], + "rotativa_total_impresion" => [ + "label" => "PresupuestoLineas.rotativaTotalImpresion", + "rules" => "required|decimal", + ], + "rotativa_velocidad_corte" => [ + "label" => "PresupuestoLineas.rotativaVelocidadCorte", + "rules" => "required|decimal", + ], + "solapas_ancho" => [ + "label" => "PresupuestoLineas.solapasAncho", + "rules" => "required|decimal", + ], + "tipo" => [ + "label" => "PresupuestoLineas.tipo", + "rules" => "required|in_list[bn,bnhq,color,colorhq,cubierta,sobrecubierta,rot_bn,rot_color]", + ], + ]; + + + public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.id AS presupuesto, t3.nombre AS papel, t4.nombre AS papel_impresion, t5.nombre AS maquina, t6.tipo AS tarifa_impresion FROM " . + $this->table . + " t1 LEFT JOIN presupuestos t2 ON t1.presupuesto_id = t2.id LEFT JOIN lg_papel_generico t3 ON t1.papel_id = t3.id LEFT JOIN lg_papel_impresion t4 ON t1.papel_impresion_id = t4.id LEFT JOIN lg_maquinas t5 ON t1.maquina_id = t5.id LEFT JOIN lg_maquinas_tarifas_impresion t6 ON t1.tarifa_impresion_id = t6.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . intval($limit); + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . intval($offset); + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + public function createForPresupuesto($presupuesto_id){ + + $tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color']; + foreach($tipos as $tipo){ + $builder = $this->db + ->table($this->table . " t1"); + $data = [ + 'presupuesto_id' => $presupuesto_id, + 'tipo' => $tipo, + ]; + + $builder->insert($data); + } + } + + public function getLineasPresupuesto($presupuesto_id = -1) + { + /* + Todos los servicios de manipulado activas que se pueden usar en presupuestos + */ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "*" + ) + ->where("t1.presupuesto_id", $presupuesto_id) + ->where("t1.isActiva", 1); + + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + } +} + + diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 31fb0400..e31afc8b 100644 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -313,13 +313,15 @@ class PresupuestoModel extends \App\Models\GoBaseModel "t1.id AS id, t1.created_at AS fecha, t2.nombre AS cliente, CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo, t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada, - t1.total_pedido AS total_pedido, t6.estado AS estado" + t1.total_pedido AS total_pedido, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado" ); $builder->join("clientes t2", "t1.cliente_id = t2.id", "left"); $builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left"); $builder->join("lg_paises t5", "t1.pais_id = t5.id", "left"); $builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left"); + $builder->where("t1.is_deleted", 0); + return empty($search) ? $builder : $builder diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php index b61e1d61..6b0f405a 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php @@ -34,7 +34,7 @@ - diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index da35d90b..418809c3 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -2924,8 +2924,96 @@ function fill_lp_cubierta(row, fromComparador=false){ } - $('.lp_cubierta').css('display', '') $("#tableLineasPresupuesto").DataTable().columns.adjust(); } + + +fill_lp_from_bbdd() + +function fill_lp_from_bbdd(){ + + const lineasPresupuestoList = ; + lineasPresupuestoList.forEach(function(lp) { + console.log(lp.tipo) + $('#lp_' + lp.tipo + '_paginas').val(lp.paginas) + + var date = new Date(0); + date.setSeconds(lp.tiempo_maquina); // specify value for SECONDS here + var timeString = date.toISOString().substring(11, 19); + $('#lp_' + lp.tipo + '_tiempo').val(timeString) + + $('#lp_' + lp.tipo + '_numeroPliegos').val(isNaN(parseFloat(lp.pliegos_libro)) ? "" : parseFloat(lp.pliegos_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_pliegosPedido').val(isNaN(parseFloat(lp.pliegos_pedido)) ? "" : parseFloat(lp.pliegos_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_precioPliego').val(isNaN(parseFloat(lp.pliegos_precio)) ? "" : parseFloat(lp.pliegos_precio).toFixed(6)) + $('#lp_' + lp.tipo + '_libro').val(isNaN(parseFloat(lp.libro)) ? "" : parseFloat(lp.libro).toFixed(2)) + $('#lp_' + lp.tipo + '_totalPapelPedido').val(isNaN(parseFloat(lp.total_papel_pedido)) ? "" : parseFloat(lp.total_papel_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_lomo').val(isNaN(parseFloat(lp.mano)) ? "" : parseFloat(lp.mano).toFixed(2)) + $('#lp_' + lp.tipo + '_peso').val(isNaN(parseFloat(lp.peso)) ? "" : parseFloat(lp.peso).toFixed(2)) + $('#lp_' + lp.tipo + '_click').val(isNaN(parseFloat(lp.precio_click)) ? "" : parseFloat(lp.precio_click).toFixed(6)) + $('#lp_' + lp.tipo + '_totalClicks').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + + $('#lp_' + lp.tipo + '_checkPapel').prop('checked', lp.check_papel_total==0?false:true) + $('#lp_' + lp.tipo + '_checkClicks').prop('checked', lp.check_impresion_total==0?false:true) + + + /* + + + + + $('#lp_' + lp.tipo + '_totalLinea').val(isNaN(parseFloat(lp.total_impresion)) ? "" : parseFloat(lp.total_impresion).toFixed(2)) + $('#lp_' + lp.tipo + '_aFavorFibra').prop('checked', lp.a_favor_fibra==0?false:true) + + $('#lp_' + lp.tipo + '_cobNegro').val(isNaN(parseFloat(lp.datosTipologias.negro)) ? "" : parseFloat(lp.datosTipologias.negro).toFixed(0)) + $('#lp_' + lp.tipo + '_cobCyan').val(isNaN(parseFloat(lp.datosTipologias.cyan)) ? "" : parseFloat(lp.datosTipologias.cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_cobMagenta').val(isNaN(parseFloat(lp.datosTipologias.magenta)) ? "" : parseFloat(lp.datosTipologias.magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_cobAmarillo').val(isNaN(parseFloat(lp.datosTipologias.amarillo)) ? "" : parseFloat(lp.datosTipologias.amarillo).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaNegro').val(isNaN(parseFloat(lp.datosTipologias.gota_negro)) ? "" : parseFloat(lp.datosTipologias.gota_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaColor').val(isNaN(parseFloat(lp.datosTipologias.gota_color)) ? "" : parseFloat(lp.datosTipologias.gota_color).toFixed(0)) + + $('#lp_' + lp.tipo + '_metrosMinuto').val(isNaN(parseFloat(lp.maquina_velocidad)) ? "" : parseFloat(lp.maquina_velocidad).toFixed(2)) + $('#lp_' + lp.tipo + '_resolucion').val(isNaN(parseFloat(lp.resolucion)) ? "" : parseFloat(lp.resolucion).toFixed(0)) + $('#lp_' + lp.tipo + '_areaPaginas').val(isNaN(parseFloat(lp.superficie)) ? "" : parseFloat(lp.superficie).toFixed(2)) + $('#lp_' + lp.tipo + '_gotasNegro').val(isNaN(parseFloat(lp.num_gotas_negro)) ? "" : parseFloat(lp.num_gotas_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasCyan').val(isNaN(parseFloat(lp.num_gotas_cyan)) ? "" : parseFloat(lp.num_gotas_cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasMagenta').val(isNaN(parseFloat(lp.num_gotas_magenta)) ? "" : parseFloat(lp.num_gotas_magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasAmarillo').val(isNaN(parseFloat(lp.num_gotas_amarillo)) ? "" : parseFloat(lp.num_gotas_amarillo).toFixed(0)) + $('#lp_' + lp.tipo + '_precioPagNegro').val(isNaN(parseFloat(lp.precio_pagina_negro)) ? "" : parseFloat(lp.precio_pagina_negro).toFixed(6)) + $('#lp_' + lp.tipo + '_precioPagColor').val(isNaN(parseFloat(lp.precio_pagina_color)) ? "" : parseFloat(lp.precio_pagina_color).toFixed(6)) + $('#lp_' + lp.tipo + '_factorAltura').val(isNaN(parseFloat(lp.factor_altura)) ? "" : parseFloat(lp.factor_altura).toFixed(2)) + $('#lp_' + lp.tipo + '_factorAnchura').val(isNaN(parseFloat(lp.factor_anchura)) ? "" : parseFloat(lp.factor_anchura).toFixed(2)) + $('#lp_' + lp.tipo + '_paginasPliego').val(isNaN(parseFloat(lp.paginas_por_pliego)) ? "" : parseFloat(lp.paginas_por_pliego).toFixed(2)) + + $('#lp_' + lp.tipo + '_metrosPapelLibro').val(isNaN(parseFloat(lp.metros_papel_libro)) ? "" : parseFloat(lp.metros_papel_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_metrosPapelTotal').val(isNaN(parseFloat(lp.metros_papel_total)) ? "" : parseFloat(lp.metros_papel_total).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksLibro').val(isNaN(parseFloat(lp.clicks_libro)) ? "" : parseFloat(lp.clicks_libro).toFixed(0)) + $('#lp_' + lp.tipo + '_gTintaNegro').val(isNaN(parseFloat(lp.peso_gotas_negro)) ? "" : parseFloat(lp.peso_gotas_negro).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyan').val(isNaN(parseFloat(lp.peso_gotas_cyan)) ? "" : parseFloat(lp.peso_gotas_cyan).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagenta').val(isNaN(parseFloat(lp.peso_gotas_magenta)) ? "" : parseFloat(lp.peso_gotas_magenta).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarillo').val(isNaN(parseFloat(lp.peso_gotas_amarillo)) ? "" : parseFloat(lp.peso_gotas_amarillo).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksPedido').val(isNaN(parseFloat(lp.clicks_pedido)) ? "" : parseFloat(lp.clicks_pedido).toFixed(0)) + $('#lp_' + lp.tipo + '_totalClicksPedido').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_totalTinta').val(isNaN(parseFloat(lp.precio_tinta)) ? "" : parseFloat(lp.precio_tinta).toFixed(2)) + $('#lp_' + lp.tipo + '_totalCorte').val(isNaN(parseFloat(lp.total_corte)) ? "" : parseFloat(lp.total_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_totalImpresion').val(isNaN(parseFloat(lp.precio_click_pedido+lp.precio_tinta+lp.total_corte)) ? "" : parseFloat(lp.precio_click_pedido+lp.precio_tinta+lp.total_corte).toFixed(2)) + + $('#lp_' + lp.tipo + '_velocidadCorte').val(isNaN(parseFloat(lp.velocidad_corte)) ? "" : parseFloat(lp.velocidad_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_precioHoraCorte').val(isNaN(parseFloat(lp.precio_hora_corte)) ? "" : parseFloat(lp.precio_hora_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_tiempoCorte').val(isNaN(parseFloat(lp.tiempo_corte)) ? "" : parseFloat(lp.tiempo_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaNegroPed').val(isNaN(parseFloat(lp.peso_gotas_negro_pedido)) ? "" : parseFloat(lp.peso_gotas_negro_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyanPed').val(isNaN(parseFloat(lp.peso_gotas_cyan_pedido)) ? "" : parseFloat(lp.peso_gotas_cyan_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagentaPed').val(isNaN(parseFloat(lp.peso_gotas_magenta_pedido)) ? "" : parseFloat(lp.peso_gotas_magenta_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarilloPed').val(isNaN(parseFloat(lp.peso_gotas_amarillo_pedido)) ? "" : parseFloat(lp.peso_gotas_amarillo_pedido).toFixed(2)) + */ + $('.lp_' + lp.tipo).css('display', '') + + }) + + $("#tableLineasPresupuesto").DataTable().draw(); + //$("#tableLineasPresupuesto").DataTable().columns.adjust(); +} + + + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 7d20aa28..b73d397e 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -25,6 +25,8 @@ + +
; + - //const papelGenericoNegroList = ; + endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php index 0deb4f39..ea91cb8f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php @@ -27,7 +27,7 @@ - + @@ -104,8 +104,15 @@ { 'data': 'inc_rei' }, { 'data': 'paginas' }, { 'data': 'tirada' }, - { 'data': 'total_pedido' }, - { 'data': 'estado' }, + { 'data': 'total_presupuesto' }, + { 'data': 'estado' , + 'render': function ( data, type, row, meta ) { + if(data=='borrador') + return ''; + else if(data=='aceptado') + return ''; + } + }, { 'data': actionBtns } ] }); From e12913c2a0ce9dd755aa38db4a87ca2785ce2bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez=20Ortega?= Date: Tue, 14 Nov 2023 08:21:34 +0100 Subject: [PATCH 09/10] lp en edit terminadas --- ci4/app/Config/Routes.php | 3 +- .../Presupuestos/Cosidotapablanda.php | 69 +++- ci4/app/Controllers/Test.php | 17 +- .../Presupuestos/PresupuestoLineaEntity.php | 4 + ci4/app/Models/Configuracion/MaquinaModel.php | 12 + .../MaquinasTarifasImpresionModel.php | 4 +- .../Configuracion/PapelImpresionModel.php | 11 + .../Presupuestos/PresupuestoLineaModel.php | 18 +- .../cosidotapablanda/_comentariosItems.php | 6 +- .../_datosPresupuestoClienteItems.php | 31 +- .../_lineasPresupuestoItems.php | 305 ++++++++++++------ .../cosidotapablanda/comparador.js | 14 +- .../viewCosidotapablandaForm.php | 40 ++- 13 files changed, 394 insertions(+), 140 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 47312296..a64fb69b 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -471,8 +471,9 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos $routes->post('add', 'Cosidotapablanda::add', ['as' => 'createCosidotapablanda']); $routes->post('create', 'Cosidotapablanda::create', ['as' => 'ajaxCreateCosidotapablanda']); $routes->put('(:num)/update', 'Cosidotapablanda::update/$1', ['as' => 'ajaxUpdateCosidotapablanda']); - $routes->post('(:num)/edit', 'Cosidotapablanda::edit/$1', ['as' => 'updateCosidotapablanda']); + $routes->post('edit/(:num)', 'Cosidotapablanda::edit/$1', ['as' => 'updateCosidotapablanda']); $routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'dataTableOfCosidotapablanda']); + $routes->post('datatable_2', 'Cosidotapablanda::datatable_2', ['as' => 'updateDataOfCosidotapablanda']); $routes->post('allmenuitems', 'Cosidotapablanda::allItemsSelect', ['as' => 'select2ItemsOfCosidotapablanda']); $routes->post('menuitems', 'Cosidotapablanda::menuItems', ['as' => 'menuItemsOfCosidotapablanda']); }); diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 68206afd..fa349d13 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -496,6 +496,50 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController } } + + public function datatable_2() + { + if ($this->request->isAJAX()) { + $reqData = $this->request->getPost(); + + $tipo = $reqData['tipo'] ?? ''; + + if($tipo=='lineasPresupuesto'){ + + $datos = $reqData['datos'] ?? null; + $presupuesto_id = $reqData['presupuesto_id'] ?? -1; + + /*foreach($datos as $key=>$linea){ + $datos[$key]['papel_id'] = $datos[$key]['papel_id'] ?? -1; + }*/ + + + if($datos != null){ + $this->updateLineasPresupuestoActivas($presupuesto_id, $datos); + } + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function getCompIntData($uso, $datosPedido, $papel_generico, $gramaje, $isColor, $isHq) { $tipo = $isColor? ($isHq?'colorhq':'color'): ($isHq?'negrohq':'negro'); @@ -554,11 +598,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController foreach ($maquinas as $maquina) { $tarifamodel = new MaquinasTarifasImpresionModel(); - $tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo); + [$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo); if(!is_float($tarifa)){ continue; } $linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa); + $linea['fields']['tarifa_impresion_id'] = $tarifaId; $linea['fields']['maquina'] = $maquina->maquina; $linea['fields']['maquina_id'] = $maquina->maquina_id; $linea['fields']['maquina_velocidad'] = $maquina->velocidad; @@ -662,7 +707,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $parametrosRotativa->a_favor_fibra = $i; $tarifamodel = new MaquinasTarifasImpresionModel(); - $tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo); + [$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo); if(!is_float($tarifa)){ continue; } @@ -671,6 +716,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa); $precio_pliego_impresion = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas); + + $linea['fields']['tarifa_impresion_id'] = $tarifaId; + $linea['fields']['precios_pliegos'] = $precio_pliego_impresion; $linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $precio_pliego_impresion; @@ -1007,7 +1055,22 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController protected function getLineasPresupuestoActivas($presupuesto_id) { $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); - return $model->getLineasPresupuesto($presupuesto_id); + $data = $model->getLineasPresupuesto($presupuesto_id); + + $papel_imp_model = model('App\Models\Configuracion\PapelImpresionModel'); + $maquina_model = model('App\Models\Configuracion\MaquinaModel'); + + foreach($data as $linea){ + $linea->papel_impresion_nombre = $papel_imp_model->getNombre($linea->papel_impresion_id)[0]->text; + $linea->maquina_nombre = $maquina_model->getNombre($linea->maquina_id)[0]->text; + } + return $data; + } + + protected function updateLineasPresupuestoActivas($presupuesto_id, $datos) + { + $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + return $model->updateLineasPresupuesto($presupuesto_id, $datos); } diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 5e9404a0..66a1e000 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -17,11 +17,7 @@ class Test extends BaseController public function index() { - $time = '99:59:59'; - - $time_parts = explode(":", $time); - $seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600; - echo "Time in seconds: " . $seconds; + $this->getLP(); } public function timeToSeconds(){ @@ -35,8 +31,15 @@ class Test extends BaseController public function getLP(){ $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); $data = $lp_model->getLineasPresupuesto(8); - foreach($data as $linea) - var_dump($linea->tipo); + $papel_imp_model = model('App\Models\Configuracion\PapelImpresionModel'); + $maquina_model = model('App\Models\Configuracion\MaquinaModel'); + foreach($data as $linea){ + $linea->papel_impresion_id = $papel_imp_model->getValue_Nombre($linea->papel_impresion_id)[0]; + $linea->maquina_id = $maquina_model->getValue_Nombre($linea->maquina_id)[0]; + var_dump($linea->papel_impresion_id); + var_dump($linea->maquina_id); + } + } public function createLP(){ diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php index 8fcc6c21..603cd868 100644 --- a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -64,6 +64,8 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity "rotativa_precio_hora_corte" => 0, "rotativa_total_corte" => 0, "isActiva" => false, + "check_impresion_total" => false, + "check_papel_total" => false, ]; protected $casts = [ "presupuesto_id" => "int", @@ -119,5 +121,7 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity "rotativa_precio_hora_corte" => "float", "rotativa_total_corte" => "float", "isActiva" => "boolean", + "check_impresion_total" => "boolean", + "check_papel_total" => "boolean", ]; } diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index d7988a1b..e43752b4 100644 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -380,5 +380,17 @@ class MaquinaModel extends \App\Models\GoBaseModel } return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + + } + + public function getNombre($id){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.nombre AS text"); + + $builder->where("t1.id", $id); + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } } diff --git a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php index 2dc1c9f7..cde4df78 100644 --- a/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php +++ b/ci4/app/Models/Configuracion/MaquinasTarifasImpresionModel.php @@ -124,7 +124,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "t1.precio AS precio" + "t1.id AS id, t1.precio AS precio" ); //JJO @@ -135,7 +135,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel $tarifas = $builder->get()->getResultArray(); if (count($tarifas)>0){ - return floatval($tarifas[0]['precio']); + return [$tarifas[0]['id'], floatval($tarifas[0]['precio'])]; } return $tarifas; } diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index 7e0cacc9..44ef9a8d 100644 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -300,4 +300,15 @@ class PapelImpresionModel extends \App\Models\GoBaseModel return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } + + public function getNombre($id){ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "t1.nombre AS text"); + + $builder->where("t1.id", $id); + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + } } diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php index fabf40a5..96fd96ba 100644 --- a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -69,6 +69,8 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel "rotativa_tiempo_corte", "rotativa_precio_hora_corte", "rotativa_total_corte", + 'check_impresion_total', + 'check_papel_total', "isActiva", ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoLineaEntity"; @@ -313,9 +315,6 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel public function getLineasPresupuesto($presupuesto_id = -1) { - /* - Todos los servicios de manipulado activas que se pueden usar en presupuestos - */ $builder = $this->db ->table($this->table . " t1") ->select( @@ -327,6 +326,19 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } + + public function updateLineasPresupuesto($presupuesto_id = -1, $datos=[]) + { + foreach($datos as $linea){ + + $this->db + ->table($this->table . " t1") + ->where("t1.presupuesto_id", $presupuesto_id) + ->where("t1.tipo", $linea["tipo"]) + ->update($linea); + } + + } } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php index 53970be9..7a765f42 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_comentariosItems.php @@ -95,7 +95,7 @@ rows="3" id="comentariosCliente" name="comentarios_cliente" - required style="height: 10em;" + style="height: 10em;" class="form-control">comentarios_cliente) ?>
@@ -110,7 +110,6 @@ rows="3" id="comentariosSafekat" name="comentarios_safekat" - required style="height: 10em;" class="form-control">comentarios_safekat) ?> @@ -127,7 +126,7 @@ rows="3" id="comentariosPdf" name="comentarios_pdf" - required style="height: 10em;" + style="height: 10em;" class="form-control">comentarios_pdf) ?> @@ -143,7 +142,6 @@ rows="3" id="comentariosProduccion" name="comentarios_produccion" - required style="height: 10em;" class="form-control">comentarios_produccion) ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php index 1279ae52..a993fe8b 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems.php @@ -480,11 +480,12 @@ { 'data': 'maquinaVelocidad'}, { 'data': 'tiempoMaquina'}, { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} + { 'data': 'papelImpresionId'}, + { 'data': 'tarifa_impresion_id'} ], columnDefs: [ { - target: [16,17,18,19,20], + target: [16,17,18,19,20,21], visible: false, searchable: false }, @@ -543,10 +544,11 @@ { 'data': 'papelGenericoId'}, { 'data': 'papelImpresionId'}, { 'data': 'paginasColor'}, + { 'data': 'tarifa_impresion_id'} ], columnDefs: [ { - target: [21,22,23,24,25,26], + target: [21,22,23,24,25,26,27], visible: false, searchable: false }, @@ -592,11 +594,12 @@ { 'data': 'maquinaVelocidad'}, { 'data': 'tiempoMaquina'}, { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'} + { 'data': 'papelImpresionId'}, + { 'data': 'tarifa_impresion_id'} ], columnDefs: [ { - target: [16,17,18,19,20], + target: [16,17,18,19,20,21], visible: false, searchable: false }, @@ -1053,14 +1056,16 @@ } else { - if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) - { - getLineasIntRot(is_hq); - } - else - { - $('#errorComRot').html(''); + if(!is_hq){ + if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && + $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) + { + getLineasIntRot(is_hq); + } + else + { + $('#errorComRot').html(''); + } } } }); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index 418809c3..c5880211 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -40,6 +40,7 @@ + @@ -83,6 +84,7 @@ + @@ -126,6 +128,7 @@ + @@ -170,6 +173,7 @@ + @@ -213,6 +217,7 @@ + @@ -263,7 +268,7 @@
- +
@@ -462,6 +467,7 @@ + @@ -513,7 +519,7 @@
- +
@@ -710,6 +716,7 @@ + @@ -1276,16 +1284,8 @@ function fill_lp_bn(row, fromComparator=false){ $('#lp_bn_maquina').append(``); - $('#lp_bn_tiempo').val(row.tiempoMaquina) - $('#lp_bn_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_bn_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_bn_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_bn_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_bn_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_bn_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_bn_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_bn(false) } else{ // Si viene de hacerlo a mano... @@ -1299,6 +1299,8 @@ function fill_lp_bn(row, fromComparator=false){ $('#lp_bn_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_bn_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_bn_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -1508,16 +1510,8 @@ function fill_lp_color(row, fromComparator=false){ $('#lp_color_maquina').append(``); - $('#lp_color_tiempo').val(row.tiempoMaquina) - $('#lp_color_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_color_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_color_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_color_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_color_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_color_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_color_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_color_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_color(false) } else{ // Si viene de hacerlo a mano... @@ -1531,6 +1525,8 @@ function fill_lp_color(row, fromComparator=false){ $('#lp_color_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_color_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_color_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_color_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -1739,16 +1735,8 @@ function fill_lp_bnhq(row, fromComparator=false){ $('#lp_bnhq_maquina').append(``); - $('#lp_bnhq_tiempo').val(row.tiempoMaquina) - $('#lp_bnhq_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_bnhq_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_bnhq_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_bnhq_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_bnhq_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_bnhq_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_bnhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_bnhq_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_bnhq(false) } else{ // Si viene de hacerlo a mano... @@ -1762,6 +1750,8 @@ function fill_lp_bnhq(row, fromComparator=false){ $('#lp_bnhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_bnhq_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_bnhq_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -1972,16 +1962,8 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq_maquina').append(``); - $('#lp_colorhq_tiempo').val(row.tiempoMaquina) - $('#lp_colorhq_numeroPliegos').val(isNaN(parseFloat(row.numeroPliegos)) ? "" : parseFloat(row.numeroPliegos).toFixed(2)) - $('#lp_colorhq_pliegosPedido').val(isNaN(parseFloat(row.pliegosPedido)) ? "" : parseFloat(row.pliegosPedido).toFixed(2)) - $('#lp_colorhq_precioPliego').val(isNaN(parseFloat(row.precioPliego)) ? "" : parseFloat(row.precioPliego).toFixed(6)) - $('#lp_colorhq_libro').val(isNaN(parseFloat(row.libro)) ? "" : parseFloat(row.libro).toFixed(2)) - $('#lp_colorhq_totalPapelPedido').val(isNaN(parseFloat(row.totalPapelPedido)) ? "" : parseFloat(row.totalPapelPedido).toFixed(2)) - $('#lp_colorhq_lomo').val(isNaN(parseFloat(row.lomo)) ? "" : parseFloat(row.lomo).toFixed(2)) - $('#lp_colorhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) - $('#lp_colorhq_click').val(isNaN(parseFloat(row.click)) ? "" : parseFloat(row.click).toFixed(6)) - $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.totalClicks)) ? "" : parseFloat(row.totalClicks).toFixed(2)) + + calcularPresupuesto_colorhq(row, false) } else{ // Si viene de hacerlo a mano... @@ -1995,6 +1977,8 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq_peso').val(isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2)) $('#lp_colorhq_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) + + $('#lp_colorhq_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -2326,6 +2310,8 @@ function fill_lp_rot_bn(row, fromComparador=false){ $('#lp_rot_bn_gTintaCyanPed').val(isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)) $('#lp_rot_bn_gTintaMagentaPed').val(isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)) $('#lp_rot_bn_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) + + $('#lp_rot_bn_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -2665,6 +2651,10 @@ function fill_lp_rot_color(row, fromComparador=false){ $('#lp_rot_color_gTintaCyanPed').val(isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)) $('#lp_rot_color_gTintaMagentaPed').val(isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2)) $('#lp_rot_color_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) + + $('#lp_rot_color_numPagColor').val(row.paginas_color) + + $('#lp_rot_color_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } @@ -2921,7 +2911,9 @@ function fill_lp_cubierta(row, fromComparador=false){ $('#lp_cubierta_click').val(isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6)) $('#lp_cubierta_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) $('#lp_cubierta_totalLinea').val(isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2)) - + $('#lp_cubierta_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id))) ? "" : parseInt(row.tarifa_impresion_id) + + $('#lp_cubierta_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) } $('.lp_cubierta').css('display', '') @@ -2935,9 +2927,16 @@ function fill_lp_from_bbdd(){ const lineasPresupuestoList = ; lineasPresupuestoList.forEach(function(lp) { - console.log(lp.tipo) + $('#lp_' + lp.tipo + '_paginas').val(lp.paginas) + $( '#lp_' + lp.tipo + '_papel').val(lp.papel_id) + $( '#lp_' + lp.tipo + '_gramaje').html(lp.gramaje); + $( '#lp_' + lp.tipo + '_gramaje').append(new Option(parseFloat(lp.gramaje).toFixed(0), lp.gramaje)) + $( '#lp_' + lp.tipo + '_papelImpresion').append(new Option(lp.papel_impresion_nombre, lp.papel_impresion_id)) + $( '#lp_' + lp.tipo + '_maquina').append(new Option(lp.maquina_nombre, lp.maquina_id)) + + var date = new Date(0); date.setSeconds(lp.tiempo_maquina); // specify value for SECONDS here var timeString = date.toISOString().substring(11, 19); @@ -2955,63 +2954,183 @@ function fill_lp_from_bbdd(){ $('#lp_' + lp.tipo + '_checkPapel').prop('checked', lp.check_papel_total==0?false:true) $('#lp_' + lp.tipo + '_checkClicks').prop('checked', lp.check_impresion_total==0?false:true) - - - /* - - - - - $('#lp_' + lp.tipo + '_totalLinea').val(isNaN(parseFloat(lp.total_impresion)) ? "" : parseFloat(lp.total_impresion).toFixed(2)) - $('#lp_' + lp.tipo + '_aFavorFibra').prop('checked', lp.a_favor_fibra==0?false:true) - $('#lp_' + lp.tipo + '_cobNegro').val(isNaN(parseFloat(lp.datosTipologias.negro)) ? "" : parseFloat(lp.datosTipologias.negro).toFixed(0)) - $('#lp_' + lp.tipo + '_cobCyan').val(isNaN(parseFloat(lp.datosTipologias.cyan)) ? "" : parseFloat(lp.datosTipologias.cyan).toFixed(0)) - $('#lp_' + lp.tipo + '_cobMagenta').val(isNaN(parseFloat(lp.datosTipologias.magenta)) ? "" : parseFloat(lp.datosTipologias.magenta).toFixed(0)) - $('#lp_' + lp.tipo + '_cobAmarillo').val(isNaN(parseFloat(lp.datosTipologias.amarillo)) ? "" : parseFloat(lp.datosTipologias.amarillo).toFixed(0)) - $('#lp_' + lp.tipo + '_gotaNegro').val(isNaN(parseFloat(lp.datosTipologias.gota_negro)) ? "" : parseFloat(lp.datosTipologias.gota_negro).toFixed(0)) - $('#lp_' + lp.tipo + '_gotaColor').val(isNaN(parseFloat(lp.datosTipologias.gota_color)) ? "" : parseFloat(lp.datosTipologias.gota_color).toFixed(0)) + $('#lp_' + lp.tipo + '_tarifa_impresion_id').val(isNaN(parseInt(lp.tarifa_impresion_id)) ? "" : parseInt(lp.tarifa_impresion_id)) + + if(lp.tipo == 'rot_bn' ||lp.tipo == 'rot_color'){ - $('#lp_' + lp.tipo + '_metrosMinuto').val(isNaN(parseFloat(lp.maquina_velocidad)) ? "" : parseFloat(lp.maquina_velocidad).toFixed(2)) - $('#lp_' + lp.tipo + '_resolucion').val(isNaN(parseFloat(lp.resolucion)) ? "" : parseFloat(lp.resolucion).toFixed(0)) - $('#lp_' + lp.tipo + '_areaPaginas').val(isNaN(parseFloat(lp.superficie)) ? "" : parseFloat(lp.superficie).toFixed(2)) - $('#lp_' + lp.tipo + '_gotasNegro').val(isNaN(parseFloat(lp.num_gotas_negro)) ? "" : parseFloat(lp.num_gotas_negro).toFixed(0)) - $('#lp_' + lp.tipo + '_gotasCyan').val(isNaN(parseFloat(lp.num_gotas_cyan)) ? "" : parseFloat(lp.num_gotas_cyan).toFixed(0)) - $('#lp_' + lp.tipo + '_gotasMagenta').val(isNaN(parseFloat(lp.num_gotas_magenta)) ? "" : parseFloat(lp.num_gotas_magenta).toFixed(0)) - $('#lp_' + lp.tipo + '_gotasAmarillo').val(isNaN(parseFloat(lp.num_gotas_amarillo)) ? "" : parseFloat(lp.num_gotas_amarillo).toFixed(0)) - $('#lp_' + lp.tipo + '_precioPagNegro').val(isNaN(parseFloat(lp.precio_pagina_negro)) ? "" : parseFloat(lp.precio_pagina_negro).toFixed(6)) - $('#lp_' + lp.tipo + '_precioPagColor').val(isNaN(parseFloat(lp.precio_pagina_color)) ? "" : parseFloat(lp.precio_pagina_color).toFixed(6)) - $('#lp_' + lp.tipo + '_factorAltura').val(isNaN(parseFloat(lp.factor_altura)) ? "" : parseFloat(lp.factor_altura).toFixed(2)) - $('#lp_' + lp.tipo + '_factorAnchura').val(isNaN(parseFloat(lp.factor_anchura)) ? "" : parseFloat(lp.factor_anchura).toFixed(2)) - $('#lp_' + lp.tipo + '_paginasPliego').val(isNaN(parseFloat(lp.paginas_por_pliego)) ? "" : parseFloat(lp.paginas_por_pliego).toFixed(2)) + console.log(lp) + $('#lp_' + lp.tipo + '_numPagColor').val(isNaN(parseFloat(lp.rotativa_pag_color)) ? "" : parseFloat(lp.rotativa_pag_color).toFixed(0)) + $('#lp_' + lp.tipo + '_totalLinea').val(isNaN(parseFloat(lp.rotativa_total_impresion)) ? "" : parseFloat(lp.rotativa_total_impresion).toFixed(2)) + $('#lp_' + lp.tipo + '_aFavorFibra').prop('checked', lp.rotativa_a_favor_fibra==0?false:true) + + $('#lp_' + lp.tipo + '_cobNegro').val(isNaN(parseFloat(lp.rotativa_negro)) ? "" : parseFloat(lp.rotativa_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_cobCyan').val(isNaN(parseFloat(lp.rotativa_cyan)) ? "" : parseFloat(lp.rotativa_cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_cobMagenta').val(isNaN(parseFloat(lp.rotativa_magenta)) ? "" : parseFloat(lp.rotativa_magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_cobAmarillo').val(isNaN(parseFloat(lp.rotativa_amarillo)) ? "" : parseFloat(lp.rotativa_amarillo).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaNegro').val(isNaN(parseFloat(lp.rotativa_gota_negro)) ? "" : parseFloat(lp.rotativa_gota_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaColor').val(isNaN(parseFloat(lp.rotativa_gota_color)) ? "" : parseFloat(lp.rotativa_gota_color).toFixed(0)) + + $('#lp_' + lp.tipo + '_metrosMinuto').val(isNaN(parseFloat(lp.rotativa_mxm)) ? "" : parseFloat(lp.rotativa_mxm).toFixed(2)) + $('#lp_' + lp.tipo + '_resolucion').val(isNaN(parseFloat(lp.rotativa_resolucion)) ? "" : parseFloat(lp.rotativa_resolucion).toFixed(0)) + $('#lp_' + lp.tipo + '_areaPaginas').val(isNaN(parseFloat(lp.rotativa_area_paginas)) ? "" : parseFloat(lp.rotativa_area_paginas).toFixed(2)) + + $('#lp_' + lp.tipo + '_gotasNegro').val(isNaN(parseFloat(lp.rotativa_num_gotas_negro)) ? "" : parseFloat(lp.rotativa_num_gotas_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasCyan').val(isNaN(parseFloat(lp.rotativa_num_gotas_cyan)) ? "" : parseFloat(lp.rotativa_num_gotas_cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasMagenta').val(isNaN(parseFloat(lp.rotativa_num_gotas_magenta)) ? "" : parseFloat(lp.rotativa_num_gotas_magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasAmarillo').val(isNaN(parseFloat(lp.rotativa_num_gotas_amarillo)) ? "" : parseFloat(lp.rotativa_num_gotas_amarillo).toFixed(0)) + + $('#lp_' + lp.tipo + '_precioPagNegro').val(isNaN(parseFloat(lp.rotativa_precio_pag_negro)) ? "" : parseFloat(lp.rotativa_precio_pag_negro).toFixed(6)) + $('#lp_' + lp.tipo + '_precioPagColor').val(isNaN(parseFloat(lp.rotativa_precio_pag_color)) ? "" : parseFloat(lp.rotativa_precio_pag_color).toFixed(6)) + $('#lp_' + lp.tipo + '_factorAltura').val(isNaN(parseFloat(lp.rotativa_factor_altura)) ? "" : parseFloat(lp.rotativa_factor_altura).toFixed(2)) + $('#lp_' + lp.tipo + '_factorAnchura').val(isNaN(parseFloat(lp.rotativa_factor_anchura)) ? "" : parseFloat(lp.rotativa_factor_anchura).toFixed(2)) + $('#lp_' + lp.tipo + '_paginasPliego').val(isNaN(parseFloat(lp.rotativa_pag_por_pliego)) ? "" : parseFloat(lp.rotativa_pag_por_pliego).toFixed(2)) + + $('#lp_' + lp.tipo + '_metrosPapelLibro').val(isNaN(parseFloat(lp.rotativa_metros_libro)) ? "" : parseFloat(lp.rotativa_metros_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_metrosPapelTotal').val(isNaN(parseFloat(lp.rotativa_metros_total)) ? "" : parseFloat(lp.rotativa_metros_total).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksLibro').val(isNaN(parseFloat(lp.rotativa_clicks_libro)) ? "" : parseFloat(lp.rotativa_clicks_libro).toFixed(0)) + $('#lp_' + lp.tipo + '_gTintaNegro').val(isNaN(parseFloat(lp.rotativa_peso_gotas_negro)) ? "" : parseFloat(lp.rotativa_peso_gotas_negro).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyan').val(isNaN(parseFloat(lp.rotativa_peso_gotas_cyan)) ? "" : parseFloat(lp.rotativa_peso_gotas_cyan).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagenta').val(isNaN(parseFloat(lp.rotativa_peso_gotas_magenta)) ? "" : parseFloat(lp.rotativa_peso_gotas_magenta).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarillo').val(isNaN(parseFloat(lp.rotativa_peso_gotas_amarillo)) ? "" : parseFloat(lp.rotativa_peso_gotas_amarillo).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksPedido').val(isNaN(parseFloat(lp.rotativa_clicks_total)) ? "" : parseFloat(lp.rotativa_clicks_total).toFixed(0)) + $('#lp_' + lp.tipo + '_totalClicksPedido').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_totalTinta').val(isNaN(parseFloat(lp.rotativa_precio_tinta)) ? "" : parseFloat(lp.rotativa_precio_tinta).toFixed(2)) + $('#lp_' + lp.tipo + '_totalCorte').val(isNaN(parseFloat(lp.rotativa_total_corte)) ? "" : parseFloat(lp.rotativa_total_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_totalImpresion').val(isNaN(parseFloat(lp.rotativa_total_impresion)) ? "" : parseFloat(lp.rotativa_total_impresion).toFixed(2)) + + $('#lp_' + lp.tipo + '_velocidadCorte').val(isNaN(parseFloat(lp.rotativa_velocidad_corte)) ? "" : parseFloat(lp.rotativa_velocidad_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_precioHoraCorte').val(isNaN(parseFloat(lp.rotativa_precio_hora_corte)) ? "" : parseFloat(lp.rotativa_precio_hora_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_tiempoCorte').val(isNaN(parseFloat(lp.rotativa_tiempo_corte)) ? "" : parseFloat(lp.rotativa_tiempo_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaNegroPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_negro_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_negro_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyanPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_cyan_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_cyan_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagentaPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_magenta_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_magenta_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarilloPed').val(isNaN(parseFloat(lp.rotativa_peso_gotas_amarillo_pedido)) ? "" : parseFloat(lp.rotativa_peso_gotas_amarillo_pedido).toFixed(2)) + } - $('#lp_' + lp.tipo + '_metrosPapelLibro').val(isNaN(parseFloat(lp.metros_papel_libro)) ? "" : parseFloat(lp.metros_papel_libro).toFixed(2)) - $('#lp_' + lp.tipo + '_metrosPapelTotal').val(isNaN(parseFloat(lp.metros_papel_total)) ? "" : parseFloat(lp.metros_papel_total).toFixed(2)) - $('#lp_' + lp.tipo + '_clicksLibro').val(isNaN(parseFloat(lp.clicks_libro)) ? "" : parseFloat(lp.clicks_libro).toFixed(0)) - $('#lp_' + lp.tipo + '_gTintaNegro').val(isNaN(parseFloat(lp.peso_gotas_negro)) ? "" : parseFloat(lp.peso_gotas_negro).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaCyan').val(isNaN(parseFloat(lp.peso_gotas_cyan)) ? "" : parseFloat(lp.peso_gotas_cyan).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaMagenta').val(isNaN(parseFloat(lp.peso_gotas_magenta)) ? "" : parseFloat(lp.peso_gotas_magenta).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaAmarillo').val(isNaN(parseFloat(lp.peso_gotas_amarillo)) ? "" : parseFloat(lp.peso_gotas_amarillo).toFixed(2)) - $('#lp_' + lp.tipo + '_clicksPedido').val(isNaN(parseFloat(lp.clicks_pedido)) ? "" : parseFloat(lp.clicks_pedido).toFixed(0)) - $('#lp_' + lp.tipo + '_totalClicksPedido').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) - $('#lp_' + lp.tipo + '_totalTinta').val(isNaN(parseFloat(lp.precio_tinta)) ? "" : parseFloat(lp.precio_tinta).toFixed(2)) - $('#lp_' + lp.tipo + '_totalCorte').val(isNaN(parseFloat(lp.total_corte)) ? "" : parseFloat(lp.total_corte).toFixed(2)) - $('#lp_' + lp.tipo + '_totalImpresion').val(isNaN(parseFloat(lp.precio_click_pedido+lp.precio_tinta+lp.total_corte)) ? "" : parseFloat(lp.precio_click_pedido+lp.precio_tinta+lp.total_corte).toFixed(2)) - - $('#lp_' + lp.tipo + '_velocidadCorte').val(isNaN(parseFloat(lp.velocidad_corte)) ? "" : parseFloat(lp.velocidad_corte).toFixed(2)) - $('#lp_' + lp.tipo + '_precioHoraCorte').val(isNaN(parseFloat(lp.precio_hora_corte)) ? "" : parseFloat(lp.precio_hora_corte).toFixed(2)) - $('#lp_' + lp.tipo + '_tiempoCorte').val(isNaN(parseFloat(lp.tiempo_corte)) ? "" : parseFloat(lp.tiempo_corte).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaNegroPed').val(isNaN(parseFloat(lp.peso_gotas_negro_pedido)) ? "" : parseFloat(lp.peso_gotas_negro_pedido).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaCyanPed').val(isNaN(parseFloat(lp.peso_gotas_cyan_pedido)) ? "" : parseFloat(lp.peso_gotas_cyan_pedido).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaMagentaPed').val(isNaN(parseFloat(lp.peso_gotas_magenta_pedido)) ? "" : parseFloat(lp.peso_gotas_magenta_pedido).toFixed(2)) - $('#lp_' + lp.tipo + '_gTintaAmarilloPed').val(isNaN(parseFloat(lp.peso_gotas_amarillo_pedido)) ? "" : parseFloat(lp.peso_gotas_amarillo_pedido).toFixed(2)) - */ $('.lp_' + lp.tipo).css('display', '') }) $("#tableLineasPresupuesto").DataTable().draw(); - //$("#tableLineasPresupuesto").DataTable().columns.adjust(); +} + + +async function fill_bbdd_from_lp(presupuesto_id){ + + const tiposLineas = ['bn','bnhq','color','colorhq','cubierta','rot_bn','rot_color']; + data=[]; + tiposLineas.forEach(function(tipo_lp) { + + if($('#lp_' + tipo_lp).css('display') != 'none'){ + + + let t_maq_str = $('#lp_' + tipo_lp + '_tiempo').val().split(':'); // split it at the colons + let t_maq = 0 + if(t_maq_str.length == 3) + t_maq = (+t_maq_str[0]) * 3600 + (+t_maq_str[1]) * 60 + (+t_maq_str[2]); + + linea_data = { + presupuesto_id: presupuesto_id, + tipo: tipo_lp, + paginas: $('#lp_' + tipo_lp + '_paginas').val(), + papel_id: $( '#lp_' + tipo_lp + '_papel').val(), + gramaje: $( '#lp_' + tipo_lp + '_gramaje option:selected' ).text().trim(), + papel_impresion_id: $( '#lp_' + tipo_lp + '_papelImpresion').val(), + maquina_id: $( '#lp_' + tipo_lp + '_maquina').val(), + tiempo_maquina: t_maq, + pliegos_libro: $('#lp_' + tipo_lp + '_numeroPliegos').val(), + pliegos_pedido: $('#lp_' + tipo_lp + '_pliegosPedido').val(), + pliegos_precio: $('#lp_' + tipo_lp + '_precioPliego').val(), + libro: $('#lp_' + tipo_lp + '_libro').val(), + total_papel_pedido: $('#lp_' + tipo_lp + '_totalPapelPedido').val(), + mano: $('#lp_' + tipo_lp + '_lomo').val(), + peso: $('#lp_' + tipo_lp + '_peso').val(), + precio_click: $('#lp_' + tipo_lp + '_click').val(), + precio_click_pedido: $('#lp_' + tipo_lp + '_totalClicks').val(), + check_papel_total: $('#lp_' + tipo_lp + '_checkPapel').is(":checked")?1:0, + check_impresion_total: $('#lp_' + tipo_lp + '_checkClicks').is(":checked")?1:0, + tarifa_impresion_id: $('#lp_' + tipo_lp + '_tarifa_impresion_id').val(), + isActiva: 1, + } + + if(tipo_lp == 'rot_bn' || tipo_lp == 'rot_color'){ + + linea_data.rotativa_pag_color = $('#lp_' + tipo_lp +'_numPagColor').val() + linea_data.rotativa_total_impresion = $('#lp_' + tipo_lp + '_totalLinea').val() + linea_data.rotativa_a_favor_fibra = $('#lp_' + tipo_lp + '_aFavorFibra').is(":checked")?1:0 + linea_data.rotativa_negro = $('#lp_' + tipo_lp + '_cobNegro').val() + linea_data.rotativa_cyan = $('#lp_' + tipo_lp + '_cobCyan').val() + linea_data.rotativa_magenta = $('#lp_' + tipo_lp + '_cobMagenta').val() + linea_data.rotativa_amarillo = $('#lp_' + tipo_lp + '_cobAmarillo').val() + linea_data.rotativa_gota_negro = $('#lp_' + tipo_lp + '_gotaNegro').val() + linea_data.rotativa_gota_color = $('#lp_' + tipo_lp + '_gotaColor').val() + + linea_data.rotativa_mxm = $('#lp_' + tipo_lp + '_metrosMinuto').val() + linea_data.rotativa_resolucion = $('#lp_' + tipo_lp + '_resolucion').val() + linea_data.rotativa_area_paginas = $('#lp_' + tipo_lp + '_areaPaginas').val() + + linea_data.rotativa_num_gotas_negro = $('#lp_' + tipo_lp + '_gotasNegro').val() + linea_data.rotativa_num_gotas_cyan = $('#lp_' + tipo_lp + '_gotasCyan').val() + linea_data.rotativa_num_gotas_magenta = $('#lp_' + tipo_lp + '_gotasMagenta').val() + linea_data.rotativa_num_gotas_amarillo = $('#lp_' + tipo_lp + '_gotasAmarillo').val() + + linea_data.rotativa_precio_pag_negro = $('#lp_' + tipo_lp + '_precioPagNegro').val() + linea_data.rotativa_precio_pag_color = $('#lp_' + tipo_lp + '_precioPagColor').val() + linea_data.rotativa_factor_altura = $('#lp_' + tipo_lp + '_factorAltura').val() + linea_data.rotativa_factor_anchura = $('#lp_' + tipo_lp + '_factorAnchura').val() + linea_data.rotativa_pag_por_pliego = $('#lp_' + tipo_lp + '_paginasPliego').val() + + linea_data.rotativa_metros_libro = $('#lp_' + tipo_lp + '_metrosPapelLibro').val() + linea_data.rotativa_metros_total = $('#lp_' + tipo_lp + '_metrosPapelTotal').val() + linea_data.rotativa_clicks_libro = $('#lp_' + tipo_lp + '_clicksLibro').val() + linea_data.rotativa_peso_gotas_negro = $('#lp_' + tipo_lp + '_gTintaNegro').val() + linea_data.rotativa_peso_gotas_cyan = $('#lp_' + tipo_lp + '_gTintaCyan').val() + linea_data.rotativa_peso_gotas_magenta = $('#lp_' + tipo_lp + '_gTintaMagenta').val() + linea_data.rotativa_peso_gotas_amarillo = $('#lp_' + tipo_lp + '_gTintaAmarillo').val() + linea_data.rotativa_clicks_total = $('#lp_' + tipo_lp + '_clicksPedido').val() + linea_data.precio_click_pedido = $('#lp_' + tipo_lp + '_totalClicksPedido').val() + linea_data.rotativa_precio_tinta = $('#lp_' + tipo_lp + '_totalTinta').val() + linea_data.rotativa_total_corte = $('#lp_' + tipo_lp + '_totalCorte').val() + linea_data.rotativa_total_impresion = $('#lp_' + tipo_lp + '_totalImpresion').val() + + linea_data.rotativa_velocidad_corte = $('#lp_' + tipo_lp + '_velocidadCorte').val() + linea_data.rotativa_precio_hora_corte = $('#lp_' + tipo_lp + '_precioHoraCorte').val() + linea_data.rotativa_tiempo_corte = $('#lp_' + tipo_lp + '_tiempoCorte').val() + linea_data.rotativa_peso_gotas_negro_pedido = $('#lp_' + tipo_lp + '_gTintaNegroPed').val() + linea_data.rotativa_peso_gotas_cyan_pedido = $('#lp_' + tipo_lp + '_gTintaCyanPed').val() + linea_data.rotativa_peso_gotas_magenta_pedido = $('#lp_' + tipo_lp + '_gTintaMagentaPed').val() + linea_data.rotativa_peso_gotas_amarillo_pedido = $('#lp_' + tipo_lp + '_gTintaAmarilloPed').val() + + } + data.push(linea_data) + } + else{ + data.push({ + presupuesto_id: presupuesto_id, + tipo: tipo_lp, + isActiva: 0, + }) + } + }) + + await $.ajax({ + type: 'post', + url: '', + + data: { + tipo: 'lineasPresupuesto', + datos: data, + presupuesto_id: presupuesto_id, + : v + }, + dataType: 'json', + success:function(response){ + + token=response.; + yeniden(token); + } + }); } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js index 70093224..b7435406 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/comparador.js @@ -176,6 +176,7 @@ function getRowFromLineaInt(tipo, linea) { 'tiempoMaquina': linea.fields.tiempo_maquina, 'papelGenericoId': linea.fields.papel_generico_id, 'papelImpresionId': linea.fields.papel_impresion_id, + 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, } } @@ -209,6 +210,7 @@ function getRowFromLineaRot(linea) { 'papelGenericoId': linea.fields.papel_generico_id, 'papelImpresionId': linea.fields.papel_impresion_id, 'paginasColor': linea.fields.paginas_color, + 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, } } @@ -294,7 +296,6 @@ function updatePapelesComparador() { Array.from(elements_colorhq).forEach(element => { element.style.display = "none"; }); - clearNegro(); break; case "negrohq": @@ -348,12 +349,6 @@ function updatePapelesComparador() { } } -function clearNegro() { - document.getElementById('compPaginasNegro').value = 0; - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').prop('disabled', true); - $('#compPapelNegro').val('data', { id: '0' }); -} function clearIntLineas(is_color){ @@ -573,10 +568,7 @@ function fillCubierta(data, is_color, is_hq){ }) } -function clearCompTable(clearNegro=true,clearColor=false,clearCubierta=false){ - if(clearNegro){ - - } +function clearCompTable(){ $('#insertarPlanaBtn').addClass('d-none') $('#insertarRotativaBtn').addClass('d-none') diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index b73d397e..2aea5ec6 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -149,15 +149,49 @@ allowClear: false, minimumResultsForSearch: Infinity, }); - - //const papelGenericoNegroList = ; - endSection() ?> + + + + + +section("additionalInlineJs") ?> + +if(url_parts[url_parts.length-2] == 'edit'){ + id = url_parts[url_parts.length-1]; +} +else{ + id = -1; +} + +$('#presupuestoForm').on( "submit", function( event ) { + event.preventDefault(); + $.when(fill_bbdd_from_lp(id).then(function (data, textStatus, jqXHR){ + form = $('#presupuestoForm').serialize() + /*$.ajax({ + type: "POST", + url: "", + data: form, + done: function (data) { + yeniden(data.); + console.log(data); + } + });*/ + })) + + return false; //stop the actual form post !important! +}); + +endSection() ?> + + + + section('css') ?> From 149e9f64eb40a0f294d2bea012106df137f43221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 14 Nov 2023 12:58:24 +0100 Subject: [PATCH 10/10] terminado edit --- .../Presupuestos/Cosidotapablanda.php | 237 +++++++---------- .../Presupuestos/PresupuestoEntity.php | 2 + .../Models/Presupuestos/PresupuestoModel.php | 2 + .../cosidotapablanda/_datosLibroItems.php | 6 +- .../_datosPresupuestoClienteItems.php | 239 +++++++++++++++--- .../_datosPresupuestoItems.php | 6 +- .../_lineasPresupuestoItems.php | 4 +- .../cosidotapablanda/comparador.js | 103 +++++++- .../viewCosidotapablandaForm.php | 73 +----- 9 files changed, 415 insertions(+), 257 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index fa349d13..33f3924f 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -14,7 +14,7 @@ use App\Services\PresupuestoService; use App\Models\Configuracion\PapelImpresionModel; use App\Models\Configuracion\MaquinaModel; use App\Models\Configuracion\MaquinasTarifasImpresionModel; - +use Exception; class Cosidotapablanda extends \App\Controllers\GoBaseResourceController { @@ -153,150 +153,107 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController public function edit($requestedId = null) { - // JJO - $session = session(); + // JJO + $session = session(); - if ($requestedId == null) : - return $this->redirect2listView(); - endif; - $id = filter_var($requestedId, FILTER_SANITIZE_URL); - $presupuestoEntity = $this->model->find($id); - - if ($presupuestoEntity == false) : - $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]); - return $this->redirect2listView('sweet-error', $message); - endif; - - $requestMethod = $this->request->getMethod(); - - if ($requestMethod === 'post') : - - $nullIfEmpty = true; // !(phpversion() >= '8.1'); - - $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); - if ($this->request->getPost('recoger_en_taller') == null) { - $sanitizedData['recoger_en_taller'] = false; - } - if ($this->request->getPost('ferro') == null) { - $sanitizedData['ferro'] = false; - } - if ($this->request->getPost('ferro_digital') == null) { - $sanitizedData['ferro_digital'] = false; - } - if ($this->request->getPost('marcapaginas') == null) { - $sanitizedData['marcapaginas'] = false; - } - if ($this->request->getPost('papel_formato_personalizado') == null) { - $sanitizedData['papel_formato_personalizado'] = false; - } - if ($this->request->getPost('solapas') == null) { - $sanitizedData['solapas'] = false; - } - if ($this->request->getPost('cosido') == null) { - $sanitizedData['cosido'] = false; - } - if ($this->request->getPost('cubiertas') == null) { - $sanitizedData['cubiertas'] = false; - } - if ($this->request->getPost('imagenes_bn_interior') == null) { - $sanitizedData['imagenes_bn_interior'] = false; - } - if ($this->request->getPost('en_produccion') == null) { - $sanitizedData['en_produccion'] = false; - } - if ($this->request->getPost('en_espera') == null) { - $sanitizedData['en_espera'] = false; - } - if ($this->request->getPost('modo_comparador') == null) { - $sanitizedData['modo_comparador'] = false; - } - if ($this->request->getPost('paginas_negro_hq') == null) { - $sanitizedData['paginas_negro_hq'] = false; - } - if ($this->request->getPost('paginas_negro_check_papel_total') == null) { - $sanitizedData['paginas_negro_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_negro_check_impresion_total') == null) { - $sanitizedData['paginas_negro_check_impresion_total'] = false; - } - if ($this->request->getPost('paginas_color_check_papel_total') == null) { - $sanitizedData['paginas_color_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_color_check_impresion_total') == null) { - $sanitizedData['paginas_color_check_impresion_total'] = false; - } - if ($this->request->getPost('paginas_portada_check_papel_total') == null) { - $sanitizedData['paginas_portada_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_portada_check_impresion_total') == null) { - $sanitizedData['paginas_portada_check_impresion_total'] = false; - } - if ($this->request->getPost('paginas_cubierta_papel_impresion_id') == null) { - $sanitizedData['paginas_cubierta_papel_impresion_id'] = false; - } - if ($this->request->getPost('paginas_cubierta_check_papel_total') == null) { - $sanitizedData['paginas_cubierta_check_papel_total'] = false; - } - if ($this->request->getPost('paginas_cubierta_check_impresion_total') == null) { - $sanitizedData['paginas_cubierta_check_impresion_total'] = false; - } - if ($this->request->getPost('isDig') == null) { - $sanitizedData['isDig'] = false; - } - if ($this->request->getPost('envios_recoge_cliente') == null) { - $sanitizedData['envios_recoge_cliente'] = false; - } - if ($this->request->getPost('fecha_entrega_real_aviso') == null) { - $sanitizedData['fecha_entrega_real_aviso'] = false; - } - - // JJO - $sanitizedData['user_updated_id'] = $session->id_user; - - $noException = true; - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - - - - if ($this->canValidate()) : - try { - $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); - } catch (\Exception $e) { - $noException = false; - $this->dealWithException($e); - } - else : - $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]); - $this->session->setFlashdata('formErrors', $this->model->errors()); - - endif; - - $presupuestoEntity->fill($sanitizedData); - - $thenRedirect = true; + if ($requestedId == null) : + return $this->redirect2listView(); endif; - if ($noException && $successfulResult) : - $id = $presupuestoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.'; - $message .= anchor("admin/presupuestos/{$id}/edit", lang('Basic.global.continueEditing') . '?'); - $message = ucfirst(str_replace("'", "\'", $message)); + $id = filter_var($requestedId, FILTER_SANITIZE_URL); + $presupuestoEntity = $this->model->find($id); - if ($thenRedirect) : - if (!empty($this->indexRoute)) : - return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + if ($presupuestoEntity == false) : + $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]); + return $this->redirect2listView('sweet-error', $message); + endif; + + $requestMethod = $this->request->getMethod(); + + if ($requestMethod === 'post') : + + $nullIfEmpty = true; // !(phpversion() >= '8.1'); + + $postData = $this->request->getPost(); + + $postData['updated_at'] = gmdate('Y-m-d H:m:s', time()); + + $sanitizedData = $this->sanitized($postData, $nullIfEmpty); + + // JJO + $sanitizedData['user_updated_id'] = $session->id_user; + + $noException = true; + if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + + + + if ($this->canValidate()) : + try { + $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); + } catch (\Exception $e) { + $noException = false; + $this->dealWithException($e); + } else : - return $this->redirect2listView('sweet-success', $message); - endif; - else : - $this->session->setFlashData('sweet-success', $message); - endif; + $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]); + $this->session->setFlashdata('formErrors', $this->model->errors()); + + endif; + + $presupuestoEntity->fill($sanitizedData); + + $thenRedirect = false; + endif; + if ($noException && $successfulResult) : + $id = $presupuestoEntity->id ?? $id; + $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.'; + // $message .= anchor("admin/presupuestos/{$id}/edit", lang('Basic.global.continueEditing') . '?'); + //$message = ucfirst(str_replace("'", "\'", $message)); + + if ($thenRedirect) : + if (!empty($this->indexRoute)) : + return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); + else : + if ($this->request->isAJAX()) { + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'mensaje' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else{ + return $this->redirect2listView('sweet-success', $message); + } + + endif; + else : + if ($this->request->isAJAX()) { + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'mensaje' => $message, + $csrfTokenName => $newTokenHash + ]; + return $this->respond($data); + } + else{ + $this->session->setFlashData('sweet-success', $message); + } + endif; + + endif; // $noException && $successfulResult + endif; // ($requestMethod === 'post') - endif; // $noException && $successfulResult - endif; // ($requestMethod === 'post') $this->viewData['presupuestoEntity'] = $presupuestoEntity; + + if(!is_null($presupuestoEntity->comparador_json_data)) + $this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data); + else + $this->viewData['comp_data'] = ""; + $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['paisList'] = $this->getPaisListItems(); @@ -326,7 +283,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['formAction'] = route_to('updateCosidotapablanda', $id); - $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3'); + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitleCosidoTB') . ' ' . lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); @@ -603,6 +560,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController continue; } $linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa); + if(array_key_exists('error', $linea)) + continue; $linea['fields']['tarifa_impresion_id'] = $tarifaId; $linea['fields']['maquina'] = $maquina->maquina; $linea['fields']['maquina_id'] = $maquina->maquina_id; diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index bbe09e43..9d29fe8d 100644 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -176,6 +176,8 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "deleted_at" => null, "created_at" => null, "updated_at" => null, + "comp_tipo_impresion" => null, + "comp_pos_paginas_color" => null, ]; protected $casts = [ "version" => "int", diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index e31afc8b..285ef003 100644 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -194,6 +194,8 @@ class PresupuestoModel extends \App\Models\GoBaseModel "pedido_espera_fecha", "pedido_espera_user_id", "is_deleted", + "comp_tipo_impresion", + "comp_pos_paginas_color", ]; protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity"; diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 9ddbda84..d53937ef 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -116,7 +116,11 @@
-