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