From 9b7c6c4ec1fee9e64252412967d54642dde2b647 Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sun, 9 Feb 2025 13:12:37 +0100 Subject: [PATCH] add autonumeric format & fix editor btn in tarifa impresion maquina --- .../maquinas/viewMaquinaForm.php | 99 ++++++++++++++++--- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/viewMaquinaForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/viewMaquinaForm.php index 13ac995d..ed374a00 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/viewMaquinaForm.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/viewMaquinaForm.php @@ -389,13 +389,17 @@ }, { name: "precio", attr: { - type: "number" - } + type: "text", + name : "precio", + class :"autonumeric" + } }, { name: "margen", attr: { - type: "number" - } + type: "text", + name : "margen", + class :"autonumeric" + } }, { "name": "maquina_id", "type": "hidden" @@ -409,8 +413,37 @@ ] } ); + editor.on('open', (event) => { + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + autoNumericInstance.remove() + + } + new AutoNumeric(this, { + decimalCharacter: ",", + digitGroupSeparator: ".", + allowDecimalPadding : 'floats', + decimalPlaces: 2, + unformatOnSubmit: true, + }); + }) + }) editor.on( 'preSubmit', function ( e, d, type ) { + if (d.data) { + Object.keys(d.data).forEach(function (key) { + // Find all elements with class .autonumeric + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + // Get raw value and update the corresponding field + let rawValue = autoNumericInstance.getNumericString(); + d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used + } + }); + }); + } if ( type === 'create'){ d.data[0]['maquina_id'] = id; } @@ -511,9 +544,9 @@ return ''; } }, - { 'data': 'precio' }, - { 'data': 'margen' }, - { 'data': 'is_deleted',}, + { 'data': 'precio',render : (d) => `${d}` }, + { 'data': 'margen',render : (d) => `${d}` }, + { 'data': 'is_deleted'}, { data: actionBtns, className: 'row-edit dt-center' @@ -523,7 +556,7 @@ columnDefs: [ { target: 4, - visible: false + visible: true }, { orderable: false, @@ -585,7 +618,7 @@ }, { 'data': 'papel_generico'}, { 'data': 'papel_impresion'}, - { 'data': 'gramaje'}, + { 'data': 'gramaje',render : (d) => `${d}`}, { 'data': 'bn'}, { 'data': 'color'}, { 'data': 'cubierta'}, @@ -731,9 +764,19 @@ fields: [ { name: "formas" }, { - name: "internas" + name: "internas", + attr: { + type: "text", + name : "internas", + class :"autonumeric" + } }, { - name: "externas" + name: "externas", + attr: { + type: "text", + name : "externas", + class :"autonumeric" + } }, { "name": "maquina_id", "type": "hidden" @@ -746,7 +789,37 @@ }, ] } ); + editor3.on('open', (event) => { + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + autoNumericInstance.remove() + } + new AutoNumeric(this, { + decimalCharacter: ",", + digitGroupSeparator: ".", + allowDecimalPadding : 'floats', + decimalPlaces: 2, + unformatOnSubmit: true, + }); + }) + }) + editor3.on('preSubmit', (e, d, type) => { + if (d.data) { + Object.keys(d.data).forEach(function (key) { + // Find all elements with class .autonumeric + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + // Get raw value and update the corresponding field + let rawValue = autoNumericInstance.getNumericString(); + d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used + } + }); + }); + } + }) editor3.on( 'preSubmit', function ( e, d, type ) { if ( type === 'create'){ @@ -799,8 +872,8 @@ }), columns : [ { 'data': 'formas' }, - { 'data': 'internas' }, - { 'data': 'externas' }, + { 'data': 'internas',render : (d) => `${d}` }, + { 'data': 'externas',render : (d) => `${d}` }, { data: actionBtns, className: 'row-edit dt-center'} ],