dojo.provide("parus.balanceUserProcParamsDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.customEdit");dojo.declare("parus.balanceUserProcParamsDialog",[parus.Dialog],{useSavedValues:true,userproc:null,queryid:"userProcParams",_widgets:null,_blobsForValidation:null,_storeKey:null,onClose:function(){this.saveFormLastValues()},saveFormLastValues:function(){var b=this.paramValues()||{};for(var a in b){if(dojo.isObject(b[a])){delete b[a]}}dojo.mixin(b,{userSize:this.userSize});parus.userdata.set(this._storeKey+"-"+this.queryid+"-"+this.userproc,b,true)},restoreFormLastValues:function(){var c=parus.userdata.get(this._storeKey+"-"+this.queryid+"-"+this.userproc)||{};this.userSize=c.userSize||null;if(this.useSavedValues){for(var b in c){var a=this._widgets[b];if(a){if(a.declaredClass=="dijit.form.CheckBox"){a.attr("checked",c[b]=="1")}else{if(a.declaredClass=="dijit.form.DateTextBox"){a.attr("value",dojo.date.locale.parse(c[b],{selector:"date",datePattern:"dd.MM.yyyy"}))}else{a.attr("value",c[b])}}}}}},show:function(){if(this._widgets.length){this.restoreFormLastValues();this.inherited(arguments)}else{this._noParameters()}},_noParameters:function(){this.onApply(this)},paramValues:function(){var b={};for(var a in this._widgets){if(a!="length"){if(this._widgets[a].declaredClass=="dijit.form.CheckBox"){b[a]=this._widgets[a].checked?"1":"0"}else{if(this._widgets[a].declaredClass=="parus.parus8.blobEditor"){b[a]=this._widgets[a]}else{if(this._widgets[a].declaredClass=="parus.parus8.clobEditor"){b[a]=this._widgets[a]}else{b[a]=parus.parus8.valueToExternalString(parus._docPropsValueValueFromWidget(this._widgets[a]))}}}}}return b},postCreate:function(){this.inherited(arguments);this._storeKey=this.declaredClass;var a=parus.parus8.rowNodes(parus.database.query(this.queryid,{RN:this.userproc}));this._widgets={length:0};this._blobsForValidation=[];dojo.forEach(a,dojo.hitch(this,function(c){var g=this.paramsTable.insertRow(-1);var f=g.insertCell(-1);f.appendChild(document.createElement("b")).appendChild(document.createTextNode(parus.parus8.nodeField(c,"NAME")+":"));f.width="50%";var e=g.insertCell(-1);if(parus.parus8.nodeField(c,"DATATYPE")!="3"){e.align="right"}var d=parus.customEditProperties(parus.parus8.nodeField(c,"DICTIONARY"),parus.parus8.nodeField(c,"DATATYPE"),parus.parus8.nodeField(c,"SUBTYPE")||"0",parus.parus8.nodeField(c,"REQUIRE")=="1",null,null,null);if(parus.parus8.nodeField(c,"DATATYPE")=="3"){dojo.mixin(d.params,{checked:parus.parus8.nodeField(c,"VALUE")=="1"})}else{dojo.mixin(d.params,{value:parus.parus8.externalStringToValue(parus.parus8.nodeField(c,"VALUE"),parus.parus8.nodeField(c,"DATATYPE"))})}dojo.mixin(d.params,{multiselect:!!(parus.parus8.nodeField(c,"DATATYPE")=="0"),arbitrary:true});var b=new (d.constructor())(d.params,e.appendChild(document.createElement("div")));if(d.params.required&&(parus.parus8.nodeField(c,"DATATYPE")=="5"||parus.parus8.nodeField(c,"DATATYPE")=="6")){this._blobsForValidation.push(b);dojo.mixin(b,{onChange:dojo.hitch(this,function(){this.blobEditChange(b)})})}parus._docPropsValueValueForWidget(b,null,parus.parus8.nodeField(c,"DATATYPE"),parus.parus8.nodeField(c,"SUBTYPE")||"0");this._widgets["P"+parus.parus8.nodeField(c,"RN")]=b;this._widgets.length++}))},validate:function(){var a=this.inherited(arguments);dojo.forEach(this._blobsForValidation,dojo.hitch(this,function(b){if(a){a=this.blobValidate(b)}}));return a},close:function(){dojo.forEach(this._blobsForValidation,function(a){dijit.hideTooltip(a.domNode)});return this.inherited(arguments)},blobValidate:function(a){if(!a.domNode.value){dijit.showTooltip("Это обязательное значение",a.domNode);dojo.addClass(a.domNode,"dijitError");return false}else{dojo.removeClass(a.domNode,"dijitError");dijit.hideTooltip(a.domNode);return true}},blobEditChange:function(a){this.blobValidate(a)}});