dojo.provide("parus.balanceAdvReportSelectDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("dijit.TitlePane");dojo.require("dijit.form.DateTextBox");dojo.require("dijit.form.CheckBox");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.database");dojo.require("parus.groupBox");dojo.require("parus.dictEdit");dojo.require("parus.balanceAdvReportCompareDialog");dojo.declare("parus.balanceAdvReportSelectDialog",[parus.Dialog],{_lastValues:null,_canCheckCriteria:true,protocol:"",applyProgressLabel:"Выполняется подбор строк...",postCreate:function(){this.inherited(arguments);this.criteriaTreeView._createTreeNode=function(a){return new parus.balanceAdvReportCompareCriteriaTreeNode(a)};this.criteriaTreeView.model=new parus.catalogTreeModel({queryid:"BalanceCompareReportRuleCriteriaHier",onGetConditions:dojo.hitch(this,function(b,a){return{RULE_CODE:this._lastValues.rule,CRN:(a?b.getIdentity(a)||"-1":"!*")}})})},onShow:function(){parus.catalogActions.refreshCatalogTree(this.criteriaTreeView);this.restoreFormLastValues()},saveFormLastValues:function(){this._lastValues={};this._lastValues.groups=this.groupsEdit.attr("value");this._lastValues.params=this.buildParams();this._lastValues.userSize=this.userSize;parus.userdata.set(this.declaredClass+this.protocol,this._lastValues)},restoreFormLastValues:function(){var a=parus.userdata.get(this.declaredClass+this.protocol)||{};dojo.mixin(this._lastValues,a);this.userSize=this._lastValues.userSize||null;setTimeout(dojo.hitch(this,function(){this.groupsEdit.attr("value",this._lastValues.groups||null)}),300);this.criteriaTreeView.model.fetchAll(dojo.hitch(this,function(){var c=this._lastValues.params;if(c){c=c.Conditions}if(c){c=c.Criteria}if(c){if(c.length){var b=[];dojo.forEach(c,function(d){for(key in d){b.push(d[key])}});setTimeout(dojo.hitch(this,function(){(function(d){if(!d){return}d._checkBox.attr("checked",dojo.indexOf(b,parus.parus8.nodeField(d.item,"ID"))!=-1);dojo.forEach(d.getChildren()||[],arguments.callee)})(this.criteriaTreeView.rootNode)}),300)}}}))},onApply:function(){this.saveFormLastValues();return true},getSectionGroupsCondition:function(){return{RULE_CODE:this._lastValues.rule||parus.parus8.CLASS_EmptyData}},buildParams:function(){var a=[];this.criteriaTreeView.model.fetchAll();(function(b){if(!b){return}if(b._checkBox.checked){a.push({"Сriterion":parus.parus8.nodeField(b.item,"ID")})}dojo.forEach(b.getChildren()||[],arguments.callee)})(this.criteriaTreeView.rootNode);if(!a.length){parus.parus8.errorMessage("Не выбраны критерии сравнения.");throw new Error("Dialog element is not defined for class "+this.declaredClass+".")}return{Conditions:{SectionGroups:this.groupsEdit.value||"",Criteria:a}}}});