dojo.provide("parus.balanceCustomLoadReportsDialog");dojo.require("dojo.io.iframe");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("dijit.form.RadioButton");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.dictEdit");dojo.declare("parus.balanceCustomLoadReportsDialog",[parus.Dialog],{catalogTree:null,kind:null,_lastValues:null,onShow:function(){this.restoreFormLastValues()},onClose:function(){this.saveFormLastValues()},performLoad:function(){if(!this.validate()){return}if(!this.fileData.value){return}var a=this.catalogTree;(new parus.treeDialog({model:parus.balance.catalogTreeStoreModel(),key:"BalanceReports",onDefaultNeeded:function(){var b=parus.database.execute("findAvailableCatalog",{UNITCODE:"BalanceReports"});return b?parus.parus8.nodeField(parus.parus8.rowNodes(b)[0],"PATH"):null},onSingle:function(){if(a.hiddenMode){return parus.parus8.nodeField(parus.parus8.rowNodes(parus.database.execute("singleCatalog",{UNITCODE:"BalanceReports",ACTION_CODE:"BLREPORTS_CUSTOM_IMPORT"}))[0],"CATALOG")}else{var b=a.path;return a.model.getIdentity(b[b.length-1])}},onPerform:dojo.hitch(this,function(b){this._performLoad(b);return true})})).show()},_performLoad:function(b){var a=new parus.progressDialog({message:"Загружаются отчеты в пользовательском формате..."});a.show();this.catalogInput.value=b;this.kindInput.value=this.kind;this.postForm.action=parus.database.getLoadReportsUrl();this.postForm.method="POST";this.postForm.encoding="multipart/form-data";this.postForm.canOverWrite.value=this.canOverWrite.attr("value");this.postForm.recalcReports.value=this.recalcReports.checked?"on":"off";this.postForm.logKind.value=(this.showReport.value=="2"?1:0);dojo.io.iframe.send({method:"POST",form:this.postForm,handleAs:"html",handle:dojo.hitch(this,function(h,f){if(this.showReport.value!="0"){if(parus.parus8._embeddedMode){var c=["customDownloadReport"].join("_");var d="T"+(+(new Date));var l="Протокол загрузки отчетов в пользовательском формате";mill.session.setValue(d,h.body.innerHTML,false);var k=dojo.moduleUrl("parus","embeddedContent.html")+"?loggedUserHandler="+parus.database.connected+"&params="+parus.parus8.hexEncodeParams([d,l,"1",""]);parus.embeddedMode.openTab((+(new Date)),l,k)}else{var j;var i=new dijit.layout.BorderContainer({design:"headline",gutters:false,"class":"balanceTemplateContentPane",style:"height:100%;width:100%;padding:0"});var g=parus.balance._createHeadingPane("Протокол загрузки отчетов в пользовательском формате");i.addChild(g);var e=new dijit.layout.ContentPane({region:"center",content:h.body.innerHTML});i.addChild(e);j=new dijit.layout.ContentPane({title:parus.balance.formatPageTitle("Протокол загрузки отчетов<br/>в пользовательском формате"),closable:true,"class":"balanceTemplateContentPane",onClose:dojo.hitch(this,function(){parus.balance.TabContainer.selectChild(this.kind?parus.balance.consolidatedPage:parus.balance.primaryPage);return true})});e.parentPane=j;j.setContent(i);parus.balance.TabContainer.addChild(j);parus.balance.TabContainer.selectChild(j)}}else{parus.parus8.notificationMessage("Загрузка выполнена.")}this.apply();a.close();a.destroyRecursive()})})},saveFormLastValues:function(){this._lastValues.encodingType=this.encodingType.value;this._lastValues.reportDate=dojo.date.locale.format(this.reportDate.value,{selector:"date",datePattern:"dd.MM.yyyy"});this._lastValues.agentCode=this.agentCode.value;this._lastValues.formatCode=this.formatCode.value;this._lastValues.canOverWrite=this.canOverWrite.attr("value");this._lastValues.recalcReports=this.recalcReports.checked;this._lastValues.showReport=this.showReport.value;this._lastValues.userSize=this.userSize;parus.userdata.set(this.declaredClass,this._lastValues)},restoreFormLastValues:function(){this._lastValues=parus.userdata.get(this.declaredClass)||{};this.encodingType.attr("value",this._lastValues.encodingType);this.reportDate.attr("value",this._lastValues.reportDate?dojo.date.locale.parse(this._lastValues.reportDate,{datePattern:"dd.MM.yyyy",selector:"date"}):null);this.agentCode.attr("value",this._lastValues.agentCode);this.formatCode.attr("value",this._lastValues.formatCode);this.canOverWrite.attr("value",this._lastValues.canOverWrite);this.recalcReports.attr("checked",this._lastValues.recalcReports);this.showReport.attr("value",this._lastValues.showReport);this.userSize=this._lastValues.userSize||null}});