dojo.provide("parus.balanceReportsFileImportDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.xml");dojo.require("parus.balanceUserProcParamsDialog");dojo.declare("parus.balanceReportsFileImportDialog",[parus.Dialog],{_lastValues:null,onShow:function(){this.restoreFormLastValues()},onClose:function(){this.saveFormLastValues()},saveFormLastValues:function(){this._lastValues.userProcEdit=this.userProcEdit.value;this._lastValues.binaryDataCheckBox=this.binaryDataCheckBox.attr("checked");this._lastValues.userSize=this.userSize;parus.userdata.set(this.declaredClass,this._lastValues)},restoreFormLastValues:function(){this._lastValues=parus.userdata.get(this.declaredClass)||{};this.userProcEdit.attr("value",this._lastValues.userProcEdit);this.binaryDataCheckBox.attr("checked",this._lastValues.binaryDataCheckBox);this.userSize=this._lastValues.userSize||null},performLoad:function(){if(!this.validate()){return}if(!this.fileData.value){return}var b=parus.database.execute("FindUserProcedure",{CODE:this.userProcEdit.value});if(!b){return false}this.OKButton.attr("disabled",true);this.CancelButton.attr("disabled",true);var a=new parus.balanceUserProcParamsDialog({useSavedValues:parus.parus8.optionValue("StoreUserProcsParams")!="0",userproc:parus.parus8.nodeField(parus.parus8.rowNodes(b)[0],"NRN"),onApply:dojo.hitch(this,function(){this.impparams.value=parus.xml.toXml({PARAMS:{PARAMS:a.paramValues()}});this.unitcode.value="BalanceReports";this.userprocValue.value=a.userproc;this.postForm.action=parus.database.getFileImportUrl();this.postForm.method="POST";this.postForm.encoding="multipart/form-data";var c=new parus.progressDialog({message:"Выполняется загрузка"});c.show();dojo.io.iframe.send({method:"POST",form:this.postForm,handleAs:(dojo.isIE>=10)?"html":"xml",handle:dojo.hitch(this,function(e,d){c.close();c.destroyRecursive();this.OKButton.attr("disabled",false);this.CancelButton.attr("disabled",false);if(e.documentElement.nodeName=="error"){parus.parus8.errorMessage(parus.parus8.nodeField(e.documentElement,"message"))}else{(new dojo.DeferredList([this.dialog.hide()])).then(dojo.hitch(this,function(){this.apply();if(parus.parus8.nodeField(parus.parus8.rowNodes(e.documentElement)[0],"HASJOURNAL")=="1"){var f=parus.dictionaries.MessagesJournal;dojo.mixin(f,{dictionary:f,hideCancel:true,gridConditions:{IDENT:parus.parus8.nodeField(parus.parus8.rowNodes(e.documentElement)[0],"IDENT")},onApply:dojo.hitch(this,function(g){return true})});new parus.dictionaryDialog(f).show()}else{parus.parus8.notificationMessage("Загрузка выполнена.")}}))}})});return true}),onClose:dojo.hitch(this,function(){a.saveFormLastValues();this.OKButton.attr("disabled",false);this.CancelButton.attr("disabled",false)})});a.show()}});