
Runner.pages.fieldsEvents["start_date_event"]=function(pageObj,pageid,row){if(row){row=new Runner.AjaxRow(pageObj,row);}
var ret,reqParams,ctrl=this,fieldsData={},params={},ajax=new Runner.form.Button({id:'start_date_event',btnName:'start_date_event'}),before=function(){var startCtrl=ctrl;var periodCtrl=ctrl.getPeer('loan_period');var endCtrl=ctrl.getPeer('end_date');var startVal=startCtrl.getValue();var period=parseInt(periodCtrl.getValue())||0;if(startVal){var d=new Date(startVal);d.setDate(d.getDate()+period);var yyyy=d.getFullYear();var mm=('0'+(d.getMonth()+1)).slice(-2);var dd=('0'+d.getDate()).slice(-2);var formatted=yyyy+'-'+mm+'-'+dd;endCtrl.setValue(formatted);}
return false;},after=function(result){ctrl.setValue(result["upper"]);},submit=function(){params["table"]="loans";params["field"]=ctrl.fieldName;(Runner.controls.ControlStorage.byId(pageid)||[]).forEach(function(ctrl){if(!(ctrl instanceof Runner.controls.MultiUploadField)&&!(ctrl instanceof Runner.controls.FileControl)){fieldsData[ctrl.fieldName]=ctrl.getStringValue();}});reqParams={params:JSON.stringify(params),event:"start_date_event",pageType:pageObj.pageType,keys:JSON.stringify(pageObj.keys?pageObj.keys:(row&&row.getKeys())),masterTable:pageObj.masterTable,fieldsData:JSON.stringify(fieldsData)};$.post(Runner.getPageUrl("buttonhandler"),reqParams,function(result){var _result;try{_result=JSON.parse(result);}catch(e){Runner.displayGenericAjaxError(result);}
after.call(ctrl,_result);}).fail(function(jqXHR,textStatus,errorThrown){Runner.displayGenericAjaxError(jqXHR.responseText||textStatus+' '+errorThrown);});submit=function(){};};ajax.submitHandler=submit;ajax.submit=submit;ret=before.call(this);if(ret===false){return;}
submit();};