dojo.provide("parus.balanceReportDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.customEdit");dojo.declare("parus.balanceReportDialog",[parus.Dialog],{_agentCodeLoaded:false,_agentNameLoaded:false,_dateIsSet:false,_docprops:null,postCreate:function(){this.inherited(arguments);this.noteEdit.attr("value",null);this._docprops={};if(parus.balance._docprops.length){this.requsitesPane.domNode.style.margin="0";var c=new dijit.layout.TabContainer({region:"center","class":"balanceInternalPages"});c.addChild(this.requsitesPane);var b=new dijit.layout.ContentPane({title:"Свойства","class":"dialogContentPane",style:"overflow-y:scroll"});var a=document.createElement("table");a.cellSpacing="5";a.width="100%";dojo.forEach(parus.balance._docprops,dojo.hitch(this,function(i){var h=a.insertRow(-1);var g=h.insertCell(-1);g.appendChild(document.createElement("b")).appendChild(document.createTextNode(parus.parus8.nodeField(i,"PROMPT")+":"));var f=h.insertCell(-1);f.align="right";var e=parus.customEditProperties(parus.parus8.nodeField(i,"DICTIONARY"),parus.parus8.nodeField(i,"DATATYPE")=="3"?"4":parus.parus8.nodeField(i,"DATATYPE"),parus.parus8.nodeField(i,"SUBTYPE"),parus.parus8.nodeField(i,"REQUIRE")=="1",parus.parus8.nodeField(i,"STRLEN"),parus.parus8.nodeField(i,"INTPART"),parus.parus8.nodeField(i,"FRACPART"));dojo.mixin(e.params,{disabled:parus.parus8.nodeField(i,"READONLY")=="1"});var d=new (e.constructor())(e.params,f.appendChild(document.createElement("div")));this._docprops[parus.parus8.nodeField(i,"RN")]=d}));b.containerNode.appendChild(a);c.addChild(b);this.mainContainer.addChild(c);dojo.style(this.mainContainer.domNode,{height:(parus.parus8.styleSize(this.mainContainer.domNode.style.height)+30)+"px"})}if(parus.balance._masterUserCalcs.length){this.userCalcsButton.domNode.style.display=""}},agentsChanged:function(a){if(a){if(a.disabled){return}}if((this.agentCodeEdit.value=="")&&(this.agentNameEdit.value=="")){this.agentCodeEdit.attr("disabled",false);this.agentNameEdit.attr("disabled",false)}else{if((this.agentCodeEdit.value!="")&&(a.dojoAttachPoint=="agentCodeEdit")){if(this._agentCodeLoaded){this._agentCodeLoaded=false}else{this.agentNameEdit.attr("disabled",true);this.agentNameEdit.attr("value",null)}}else{if((this.agentNameEdit.value!="")&&(a.dojoAttachPoint=="agentNameEdit")){if(this._agentNameLoaded){this._agentNameLoaded=false}else{this.agentCodeEdit.attr("disabled",true);this.agentCodeEdit.attr("value",null)}}}}setTimeout(dojo.hitch(this,function(){var b=parus.parus8.rowNodes(parus.database.execute("getAgentInfo",{AGENT_CODE:this.agentCodeEdit.disabled?"":this.agentCodeEdit.value,AGENT_NAME:this.agentNameEdit.disabled?"":this.agentNameEdit.value}))[0];if(this.agentCodeEdit.disabled){this.agentCodeEdit.attr("value",parus.parus8.nodeField(b,"RAGNABBR"))}if(this.agentNameEdit.disabled){this.agentNameEdit.attr("value",parus.parus8.nodeField(b,"RAGNNAME"))}if(this.agentHeadEdit.disabled){this.agentHeadEdit.attr("value",parus.parus8.nodeField(b,"RHEAD"))}if((this.agentCodeEdit.value=="")&&(this.agentNameEdit.value=="")){this.agentCodeEdit.attr("disabled",false);this.agentNameEdit.attr("disabled",false)}}),100)},formChanged:function(){if(this._dateIsSet){this._dateIsSet=false;return}if(this.formCodeEdit.value!=""){var a=parus.database.execute("findNearestPeriodDate",{SFORM:this.formCodeEdit.value});if(a){this.reportDateEdit.attr("value",parus.parus8.nodeField(parus.parus8.rowNodes(a)[0],"RESULT"))}}},getDatesCondition:function(){return{FORM_CODE:this.formCodeEdit.value||parus.parus8.CLASS_EmptyData}},propValues:function(){var b={};for(var a in this._docprops){b["P"+a]=parus._docPropsValueValueFromWidget(this._docprops[a])}return{DOCPROPS:b}},_userCalcParams:null,paramsForUserCalc:function(){var a=this._userCalcParams||{};dojo.mixin(a,{SAGENT_CODE:this.agentCodeEdit.value,SAGENT_NAME:this.agentNameEdit.value,DBDATE:this.reportDateEdit.value,SNOTE:this.noteEdit.value,SFORM_CODE:this.formCodeEdit.value,NUSE_HISTORY:this.historySelect.value,NONLY_LAST_HISTORY:(this.historyLastCheckBox.checked?1:0)});return a},paramsFromUserCalc:function(a){if(a.SAGENT_CODE){this.agentCodeEdit.attr("value",a.SAGENT_CODE);this.agentsChanged(this.agentCodeEdit)}if(a.SAGENT_NAME){this.agentNameEdit.attr("value",a.SAGENT_NAME);this.agentsChanged(this.agentNameEdit)}if(a.DBDATE){this.reportDateEdit.attr("value",a.DBDATE)}if(a.SNOTE){this.noteEdit.attr("value",a.SNOTE)}if(a.SFORM_CODE){this.formCodeEdit.attr("value",a.SFORM_CODE);this.formChanged()}if(a.NUSE_HISTORY){this.historySelect.attr("value",a.NUSE_HISTORY)}if(a.NONLY_LAST_HISTORY){this.historyLastCheckBox.attr("checked",a.NONLY_LAST_HISTORY="1")}},userCalcs:function(){parus.balance.executeUserCalcs(parus.balance._masterUserCalcs,true,true,dojo.hitch(this,this.paramsForUserCalc),dojo.hitch(this,this.paramsFromUserCalc))}});