
var pType=Runner.pages.constants.PAGE_ADD;Runner.pages.PageSettings.addPageEvent("gasto",pType,"afterPageReady",function(pageObj,proxy,pageid,inlineRow,inlineObject){var pageObj=this;$(".runner-message, .message").hide();var limpiar=function(v){if(!v)return 0;return parseInt(v.toString().replace(/\./g,"").replace(/\D/g,""))||0;};var fMil=function(n){return n.toString().replace(/\D/g,"").replace(/\B(?=(\d{3})+(?!\d))/g,".");};setInterval(function(){var totalGasto=0;$("[id^='value_importe_']").each(function(){totalGasto+=limpiar($(this).val());});var $totalField=$("#value_total_1");if($totalField.length&&$totalField.val()!==fMil(totalGasto)){$totalField.val(fMil(totalGasto));}},500);$(document).on('keyup',"[id^='value_importe_']",function(){var val=$(this).val();$(this).val(fMil(limpiar(val)));});pageObj.on('beforeSave',function(formObj,fieldControlsArr,pageObj){var totalActual=limpiar($("#value_total_1").val());if(totalActual<=0){alert("⚠️ ¡RESTRICCIÓN!\n\nDebe indicar el detalle del Gasto!");return false;}
return true;});pageObj.on('afterSave',function(respObj,formObj,fieldControlsArr,pageObj){$(".runner-message, .message").html('').hide();window.location.href='gasto_add.php?status=success';});;});