dojo.provide("parus.balanceAbsentReportsDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("dojox.grid.DataGrid");dojo.require("parus.parus8");dojo.require("parus.gridData");dojo.require("parus.dialog");dojo.declare("parus.balanceAbsentReportsDialog",[parus.Dialog],{date:null,agentGroup:null,kind:null,postCreate:function(){this.inherited(arguments);this.reportsGrid.attr("store",this.gridStore());this.reportsPopupMenu.bindDomNode(this.reportsGrid.viewsNode);parus.balance._createActionsButton(this.reportsPopupMenu,this.headerPane);var a=parus.userdata.get(this.declaredClass);if(a){parus.gridSettingsDialog.mergeGridSettings(this.reportsGrid,a.gridSettings);parus.gridSettingsDialog.mergeColorConditions(this.reportsGrid,a.colorConditions);parus.gridSettingsDialog.mergeMenuSettings(this.reportsPopupMenu,a.actionSettings,a.userProcsActions,a.userReportsActions,a.userAppsActions);parus.gridSettingsDialog.mergeFilterBar(this.reportsGrid,a.showFilterBar,a.filterValues,a.sortInfo)}this.reportsGrid.setQuery(this.reportsGrid.query)},gridStore:function(){return parus.gridData({queryid:"AbsentReports",onGetConditions:dojo.hitch(this,function(a){return{KIND:this.kind,AGNGRP:this.agentGroup,BDATE:this.date}}),onComplete:dojo.hitch(this,function(b,a){dojo.forEach(a,dojo.hitch(this,function(d,c){if(parus.parus8.nodeField(d,"CREATEREPORT")=="1"){this.reportsGrid.selection.addToSelection(c)}}));this.gridChanged()})})},gridChanged:function(){dojo.forEach(this.reportsPopupMenu.getChildren(),dojo.hitch(this,function(a){if(a.itemAction){if(a.declaredClass!="dijit.MenuSeparator"){a.attr("disabled",!this.reportsGrid.selection.getSelectedCount())}}}));parus.parus8.checkMenuSeparators(this.reportsPopupMenu)},createReports:function(){var b=[];var a=this.reportsGrid.selection.getFirstSelected();for(var c=0;c<this.reportsGrid.selection.getSelectedCount();c++){b.push({RN:this.reportsGrid.store.getValue(a,"RN"),BDATE:this.reportsGrid.store.getValue(a,"BDATE")});a=this.reportsGrid.selection.getNextSelected(a)}if(!b.length){return}(new parus.confirmationDialog({message:"Создать все отмеченные несозданные отчеты?",onApply:dojo.hitch(this,function(){dojo.forEach(b,function(d){parus.database.execute("createAbsentReports",d)});parus.balance.refreshGrid(this.reportsGrid);return true})})).show()},sendMessages:function(){var c=[];var a=this.reportsGrid.selection.getFirstSelected();for(var b=0;b<this.reportsGrid.selection.getSelectedCount();b++){c.push(this.reportsGrid.store.getValue(a,"RN"));a=this.reportsGrid.selection.getNextSelected(a)}if(!c.length){return}(new parus.confirmationDialog({message:"Разослать предупредительные сообщения по выбранным несозданным отчетам?",onApply:dojo.hitch(this,function(){parus.database.execute("createAbsentReportsMessages",{RN:c.join(";")});return true})})).show()}});