diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 04ca3d8b..1a9ddab1 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -313,15 +313,39 @@ id = -1; "type": "readonly"}, { name: "tiempo_min", - + attr: { + type: "text", + name : "tiempo_min", + class :"autonumeric" + } }, { - name: "tiempo_max" + name: "tiempo_max", + attr: { + type: "text", + name : "tiempo_max", + class :"autonumeric" + } }, { - name: "precio_hora" + name: "precio_hora", + attr: { + type: "text", + name : "precio_hora", + class :"autonumeric" + } }, { - name: "total_min" + name: "total_min", + attr: { + type: "text", + name : "total_min", + class :"autonumeric" + } }, { - name: "margen" + name: "margen", + attr: { + type: "text", + name : "margen", + class :"autonumeric" + } }, { "name": "tirada_encuadernacion_id", "type": "hidden" @@ -334,7 +358,37 @@ id = -1; }, ] } ); + 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'){ d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; @@ -385,11 +439,11 @@ id = -1; }), columns: [ { 'data': 'id' }, - { 'data': 'tiempo_min' }, - { 'data': 'tiempo_max' }, - { 'data': 'precio_hora' }, - { 'data': 'total_min' }, - { 'data': 'margen' }, + { 'data': 'tiempo_min',render : (d) => `${d}` }, + { 'data': 'tiempo_max',render : (d) => `${d}` }, + { 'data': 'precio_hora',render : (d) => `${d}` }, + { 'data': 'total_min',render : (d) => `${d}` }, + { 'data': 'margen',render : (d) => `${d}` }, { data: actionBtns, className: 'row-edit dt-center'