From 231a0c7cb2ee768759365008b0842e3cb103789e Mon Sep 17 00:00:00 2001 From: 75134972k <75134972k@csic.es> Date: Wed, 13 Mar 2024 14:29:39 +0100 Subject: [PATCH] corregido bug que no permitia guardar presupuesto --- .../Configuracion/Maquinascalles.php | 4 ++ .../clientes/cliente/_clienteFormItems.php | 9 +--- .../viewClienteplantillapreciosForm.php | 5 +-- .../maquinas/viewMaquinaForm.php | 4 +- .../papel/viewPapelGenericoForm.php | 3 +- .../papel/viewPapelImpresionForm.php | 4 +- .../cosidotapablanda/_datosEnvios.js | 7 ++- .../cosidotapablanda/_datosEnvios.test.js | 44 ------------------- .../cosidotapablanda/_datosLibroItems.js | 19 ++++---- .../cosidotapablanda/_datosLibroItems.php | 19 ++++---- .../cosidotapablanda/_datosServiciosItems.js | 36 +++++---------- .../_lineasPresupuestoItems.js | 15 +++++-- .../_tiradasAlternativasItems.js | 10 +++-- .../viewCosidotapablandaForm.php | 15 +++---- .../tarifas/acabado/viewTarifaAcabadoForm.php | 4 +- .../manipulado/viewTarifaManipuladoForm.php | 4 +- 16 files changed, 71 insertions(+), 131 deletions(-) delete mode 100644 ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.test.js diff --git a/ci4/app/Controllers/Configuracion/Maquinascalles.php b/ci4/app/Controllers/Configuracion/Maquinascalles.php index 9c46a46c..97f7756e 100755 --- a/ci4/app/Controllers/Configuracion/Maquinascalles.php +++ b/ci4/app/Controllers/Configuracion/Maquinascalles.php @@ -60,14 +60,18 @@ class Maquinascalles extends \App\Controllers\GoBaseResourceController 'message' => lang('MaquinasCalles.validation.formas.required')) ), Field::inst('internas') + ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->validator('Validate::numeric', array( + "decimal" => ',', 'message' => lang('MaquinasCalles.validation.internas.decimal')) ) ->validator('Validate::notEmpty', array( 'message' => lang('MaquinasCalles.validation.internas.required')) ), Field::inst('externas') + ->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar') ->validator('Validate::numeric', array( + "decimal" => ',', 'message' => lang('MaquinasCalles.validation.externas.decimal')) ) ->validator('Validate::notEmpty', array( diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php index f9565261..66c48389 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/cliente/_clienteFormItems.php @@ -718,14 +718,7 @@ $(document).on('click', '.btn-remove', function(e) { } }); -const url = window.location.href; -const url_parts = url.split('/'); -if(url_parts[url_parts.length-2] == 'edit'){ - id = url_parts[url_parts.length-1]; -} -else{ - id = -1; -} + endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php index 3f681b8d..b2701eb0 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php @@ -79,12 +79,11 @@ const url = window.location.href; const url_parts = url.split('/'); + + let id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } - else{ - id = -1; - } const actionBtns_lineas = function(data) { return ` diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php index dae3a262..fa5f3943 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/maquinas/viewMaquinaForm.php @@ -313,12 +313,10 @@ const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1; const url = window.location.href; const url_parts = url.split('/'); + let id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } - else{ - id = -1; - } const actionBtns = function(data) { return ` diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php index 7707855a..d229bab6 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelGenericoForm.php @@ -66,11 +66,10 @@ // JJO const url = window.location.href; const url_parts = url.split('/'); + let id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } - else - id = -1; const lastColNr = $('#tableOfPapelesimpresion').find("tr:first th").length - 1; const actionBtns = function(data) { return ` diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php index 4b2e5e7a..2ebdb9cb 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php @@ -148,12 +148,10 @@ const url = window.location.href; const url_parts = url.split('/'); + let id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } - else{ - id = -1; - } $('#papelGenericoId').select2({ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js index a353a6c8..9557bf8c 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js @@ -279,7 +279,7 @@ $('#recoger_en_taller').change(function(){ }) -var tableEnvios = $('#tableOfDireccionesEnvio').DataTable( { +let tableEnvios = $('#tableOfDireccionesEnvio').DataTable( { draw:5, serverSide: false, processing: true, @@ -346,11 +346,14 @@ var tableEnvios = $('#tableOfDireccionesEnvio').DataTable( { function save_datos_envios(){ + + var id = $('#presupuesto_id').val() + $.post( window.routes_envios.dataTableOfPresupuestoDirecciones, Object.assign({tipo: "clear_lineas", presupuesto_id: id}, window.token_ajax)) .done(function( data ) { - tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) { + $('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) { var data = this.data(); $.post( '/presupuestos/presupuestodirecciones/add', Object.assign({ diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.test.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.test.js deleted file mode 100644 index c9224499..00000000 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.test.js +++ /dev/null @@ -1,44 +0,0 @@ -// Test case 1: Valid inputs -const peso = 10; -const paisId = 1; -const cp = "12345"; -const tipo_envio = "express"; - -get_precio_envio(peso, paisId, cp, tipo_envio) - .then(data => { - console.log("Test case 1 - Result:", data); - // Add your assertions here - }) - .catch(error => { - console.error("Test case 1 - Error:", error); - }); - -// Test case 2: Invalid inputs -const peso = -5; -const paisId = 0; -const cp = ""; -const tipo_envio = "standard"; - -get_precio_envio(peso, paisId, cp, tipo_envio) - .then(data => { - console.log("Test case 2 - Result:", data); - // Add your assertions here - }) - .catch(error => { - console.error("Test case 2 - Error:", error); - }); - -// Test case 3: Network error -const peso = 20; -const paisId = 2; -const cp = "54321"; -const tipo_envio = "priority"; - -get_precio_envio(peso, paisId, cp, tipo_envio) - .then(data => { - console.log("Test case 3 - Result:", data); - // Add your assertions here - }) - .catch(error => { - console.error("Test case 3 - Error:", error); - }); \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js index 242f1035..9ec619f3 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.js @@ -28,7 +28,7 @@ $('#paginas').on("change", function () { update_envios: true, update_resumen: true, update_tiradas_alternativas: true - }) + }) } }); @@ -103,7 +103,9 @@ function calcular_mermas(){
-
+
` + + window.Presupuestos.validation.no_lp_for_merma + + `
`; @@ -119,10 +121,6 @@ function calcular_mermas(){ } -$('#papelFormatoId').select2({ - allowClear: false, -}); - $('#papelFormatoPersonalizado').on("click",function(){ var checkbox = document.getElementById('papelFormatoPersonalizado'); if(checkbox.checked == true){ @@ -131,8 +129,8 @@ $('#papelFormatoPersonalizado').on("click",function(){ $('#papelFormatoId').next(".select2-container").hide(); $('#papelFormatoId').val(0).change(); document.getElementById("label_papelFormatoId").innerHTML = - " (" + - " x )*"; + window.Presupuestos.papelFormatoId + " (" + + window.Presupuestos.papelFormatoAncho + " x " + window.Presupuestos.papelFormatoAncho + ")*"; } else{ document.getElementById("papelFormatoAncho").value= ""; @@ -141,6 +139,7 @@ $('#papelFormatoPersonalizado').on("click",function(){ document.getElementById("papelFormatoAlto").style.display = "none"; $('#papelFormatoId').next(".select2-container").show(); document.getElementById("label_papelFormatoId").innerHTML = - "*"; + window.Presupuestos.papelFormatoId + '*'; } -}); \ No newline at end of file +}); + 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 96d02451..d1d9ebb3 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -327,15 +327,9 @@ section("additionalInlineJs") ?> - -let initTamanioPersonalizado = papel_formato_personalizado==true?1:0); ?>; -if(initTamanioPersonalizado != null){ - if ( initTamanioPersonalizado){ - $('#papelFormatoId').next(".select2-container").hide(); - } -} - - +$('#papelFormatoId').select2({ + allowClear: false, +}); var ancho_libro = getDimensionLibro().ancho; @@ -431,4 +425,11 @@ $("#solapas_sobrecubierta").on("click", function () { $('#serv_default').click() }); + +let initTamanioPersonalizado = papel_formato_personalizado==true?1:0); ?>; +if(initTamanioPersonalizado != null){ + if ( initTamanioPersonalizado){ + $('#papelFormatoId').next(".select2-container").hide(); + } +} endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js index 00c5b624..38ffc232 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js @@ -82,11 +82,9 @@ function save_servicios(){ const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ - const id = url_parts[url_parts.length-1]; - } - else{ - const id = -1; + id = url_parts[url_parts.length-1]; } fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , { @@ -424,11 +422,9 @@ async function get_servAcabados_tiradasAlternativas(tirada){ const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ - const id = url_parts[url_parts.length-1]; - } - else{ - const id = -1; + id = url_parts[url_parts.length-1]; } var serviciosAcabados ={ @@ -822,11 +818,9 @@ async function get_servEncuadernacion_tiradasAlternativas(tirada, paginas, ancho const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ - const id = url_parts[url_parts.length-1]; - } - else{ - const id = -1; + id = url_parts[url_parts.length-1]; } var serviciosEncuadernacion ={ @@ -1083,11 +1077,9 @@ async function get_servManipulado_tiradasAlternativas(tirada){ const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ - const id = url_parts[url_parts.length-1]; - } - else{ - const id = -1; + id = url_parts[url_parts.length-1]; } var serviciosManipulado ={ @@ -1342,11 +1334,9 @@ async function get_servPreimpresion_tiradasAlternativas(){ const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ - const id = url_parts[url_parts.length-1]; - } - else{ - const id = -1; + id = url_parts[url_parts.length-1]; } var serviciosPreimpresion ={ @@ -1388,11 +1378,9 @@ async function actualizar_servicios(update_preimpresion=false){ const domain = window.location.origin const url = window.location.href; const url_parts = url.split('/'); + var id = -1; if(url_parts[url_parts.length-2] == 'edit'){ - const id = url_parts[url_parts.length-1]; - } - else{ - const id = -1; + id = url_parts[url_parts.length-1]; } const dimension = getDimensionLibro(); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js index 1b46bc0f..22ed5382 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.js @@ -309,7 +309,9 @@ function checkPaginasPresupuesto(){
-
+
` + + window.Presupuestos.errores.paginasLP + + `
`; } @@ -1257,7 +1259,7 @@ $('.insertarLinea').on("click", function (e) { if(row.tipo == 'cubierta'){ fill_lp_cubierta(row, true); if($('#acabado_cubierta_id').val() > 0) - insertar_acabado_exterior($('#acabado_cubierta_id').val(), '') + insertar_acabado_exterior($('#acabado_cubierta_id').val(), window.Presupuestos.cubierta) } } @@ -1267,7 +1269,7 @@ $('.insertarLinea').on("click", function (e) { if(row.tipo == 'sobrecubierta'){ fill_lp_sobrecubierta(row, true); if($('#acabado_sobrecubierta_id').val() > 0) - insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), '') + insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), window.Presupuestos.sobrecubierta) } } } @@ -1284,7 +1286,12 @@ $('.insertarLinea').on("click", function (e) { } - update_servicios() + updatePresupuesto({ + update_lineas: false, + update_servicios: true, + update_envios: false, + update_resumen: true, + update_tiradas_alternativas: true}) }); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js index 859b1e5a..8cbaa4e5 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js @@ -177,19 +177,23 @@ async function add_tirada_alternativa(tirada_alt) {
-
+
` + + window.Presupuestos.errores.tirada_alt_duplicada + + `
`; } - else{ + else{ htmlString = ` `; } 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 c9d2cec4..5970f92a 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -13,6 +13,8 @@ getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + -const url = window.location.href; -const url_parts = url.split('/'); - -if (url_parts[url_parts.length - 2] == 'edit') { - id = url_parts[url_parts.length - 1]; -} else { - id = -1; -} - section("additionalInlineJs") ?> @@ -263,7 +256,9 @@ if (url_parts[url_parts.length - 2] == 'edit') { save_servicios(); save_datos_envios(); - $.when(fill_bbdd_from_lp(id).then(function(data, textStatus, jqXHR) { + var presupuesto_id = $('#presupuesto_id').val() + + $.when(fill_bbdd_from_lp(presupuesto_id).then(function(data, textStatus, jqXHR) { generateCompJSON() generate_json_tiradas() form = $('#presupuestoForm').serialize() diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index 8c8330c8..1dd04021 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -71,12 +71,10 @@ const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1; const url = window.location.href; const url_parts = url.split('/'); + let id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } - else{ - id = -1; - } const actionBtns = function(data) { return ` diff --git a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index 37bdb532..0cbaf6c7 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -71,12 +71,10 @@ const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1; const url = window.location.href; const url_parts = url.split('/'); + let id = -1; if(url_parts[url_parts.length-2] == 'edit'){ id = url_parts[url_parts.length-1]; } - else{ - id = -1; - } const actionBtns = function(data) { return `