dojo.provide("parus.signDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("dojox.grid.DataGrid");dojo.require("dojo.data.ItemFileReadStore");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.digitalSignature");dojo.declare("parus.signDialog",[parus.Dialog],{rn:null,unitCode:null,showNote:true,allowSimpleSign:true,checkPluginVersion:false,requiredVersion:{major:0,minor:0,build:0},isUserCertificatesUsed:false,postCreate:function(){this.inherited(arguments);this.noteEdit.attr("value",null);if(!this.showNote){this.notePanel.domNode.style.display="none"}if(!this.allowSimpleSign){this.simpleSignPane.domNode.style.display="none"}parus.balance._createActionsButton(this.popupMenu,this.headerPane);this.popupMenu.bindDomNode(this.certificateGrid.viewsNode);var a=parus.userdata.get(this.declaredClass);if(a){parus.gridSettingsDialog.mergeGridSettings(this.certificateGrid,a.gridSettings);parus.gridSettingsDialog.mergeColorConditions(this.certificateGrid,a.colorConditions)}},show:function(){var a=this;this.inherited(arguments).then(dojo.hitch(this,function(){parus.digitalSignature.checkPlugin().then(dojo.hitch(this,function(){if(!this.checkPluginVersion||(this.checkPluginVersion&&parus.digitalSignature.checkPluginVersion(this.requiredVersion))){parus.digitalSignature.certificatesStore(this.getAllowedUserCerts()).then(dojo.hitch(this,function(b){this.certificateGrid.attr("store",b);this.certificateGrid.setQuery(this.certificateGrid.query);this.certificateGrid.selection.select(0)}),function(b){parus.parus8.errorMessage(b)})}}),function(b){a.close();parus.parus8.errorMessage(b)})}))},onSimpleSignCheckBoxClicked:function(){this.certificateGrid.domNode.style.display=this.simpleSign.checked?"none":""},getAllowedUserCerts:function(){this.isUserCertificatesUsed=false;var a=parus.database.execute("GetContextUserCertificates",{RN:this.rn.join(";"),UNITCODE:this.unitCode});if(!a){return[]}this.isUserCertificatesUsed=parus.parus8.nodeField(parus.parus8.rowNodes(a)[0],"UseUserCertificates")=="1";if(this.isUserCertificatesUsed){return(parus.parus8.nodeField(parus.parus8.rowNodes(a)[0],"sTHUMBPRINTS")||"").split(",")}else{return null}},getNote:function(){return this.noteEdit.value},getIsSimpleSign:function(){return this.simpleSign.checked},getCertificateAttribute:function(b){if(this.simpleSign.checked){return null}var a=this.certificateGrid;return a.store.getValue(a.getItem(a.selection.getSelectedIndex()),b)},getSerialNumber:function(){return this.getCertificateAttribute("SERIALNUMBER")},getThumbprint:function(){return this.getCertificateAttribute("THUMBPRINT")},getIssuedTo:function(){return this.getCertificateAttribute("ISSUEDTO")},getIssuedBy:function(){return this.getCertificateAttribute("ISSUER")},getValidFrom:function(){return this.getCertificateAttribute("VALIDFROMDATE")},getValidTo:function(){return this.getCertificateAttribute("VALIDTODATE")},getGOSTVersion:function(){return this.getCertificateAttribute("GOST_VERSION")},getGOSTKeySize:function(){return this.getCertificateAttribute("GOST_KEYSIZE")}});