/*
 * JSMin
 * Javascript Compressor
 * http://www.crockford.com/
 * http://www.smallsharptools.com/Projects/Packer/
*/

// V:\1.1.007\js\form\Ext.ux.Namirial.GestioneLock.js

Ext.ux.Namirial.GestioneLock=Ext.extend(Ext.Window,{constructor:function(){this.storeLocks=new Ext.ux.Namirial.data.ArrayStore({url:JSONDATAURL,remoteSort:false,sortInfo:{field:'CFISC',direction:'ASC'},sql:"SELECT * FROM _sys_LOCKS WHERE UTENTE = '"+session.userLogged+"'",fields:locks_fields});this.storeLocks.on({'beforeload':{fn:function(){this.gridFooter.showBusy();},scope:this},'load':{fn:function(){this.gridFooter.setStatus("Dichiarazioni in uso: "+this.storeLocks.getCount())},scope:this}})
this.searchField=new Ext.form.TwinTriggerField({name:'ricercaLock',fieldLabel:getText['CERCA'],width:320,enableKeyEvents:true,selectOnFocus:true,trigger1Class:'x-form-clear-trigger',trigger2Class:'x-form-search-trigger'})
this.searchField.onTrigger1Click=function(){this.setValue('')};this.searchField.onTrigger2Click=this.cerca.createDelegate(this);this.searchField.on({'specialkey':{fn:function(f,e){if(e.getKey()==Ext.EventObject.ENTER){this.searchField.onTrigger2Click.call(this);}},scope:this}})
this.gridFooter=new Ext.StatusBar({id:'basic-statusbar',defaultText:''})
this.sm=new Ext.grid.RowSelectionModel({singleSelect:true})
this.gridLocks=new Ext.grid.GridPanel({stripeRows:true,store:this.storeLocks,border:false,autoScroll:true,loadMask:true,sm:this.sm,bbar:this.gridFooter,columns:locks_headers})
this.btn_ok=new Ext.Button({iconCls:'x-btn-text-icon',text:'Sblocca',icon:IMG_OK,minWidth:80,handler:this.sblocca,scope:this})
this.btn_annulla=new Ext.Button({iconCls:'x-btn-text-icon',text:'Annulla',icon:IMG_CANCEL,minWidth:80,handler:this.close,scope:this})
Ext.ux.Namirial.GestioneLock.superclass.constructor.call(this,{id:WINDOW_LOCKS,title:"Gestione codici fiscali in uso",width:506,height:350,layout:'fit',tbar:[{xtype:'label',html:'<table height="30" cellspadding="0" cellspacing="0"><tr><td style="padding-left: 15px; padding-right: 10px;" valign="middle">'+getText['CERCA']+':</td></tr></table>'},this.searchField],buttonAlign:'right',buttons:[this.btn_ok,this.btn_annulla],items:this.gridLocks})},showWin:function(){if(Ext.isEmpty(Ext.WindowMgr.get(WINDOW_LOCKS))){this.storeLocks.load();this.show()}},cerca:function(){var value=this.searchField.getValue();this.storeLocks.filter('CFISC',value);},sblocca:function(){var rec=this.sm.getSelected();if(!Ext.isEmpty(rec)){Ext.Msg.show({title:"ATTENZIONE!",msg:"<div class=\"errore\"><b>Sbloccando questo codice fiscale renderai inattendibili i dati sulla postazione in cui risulta in uso, sei sicuro di voler continuare?</b></div>",icon:Ext.MessageBox.WARNING,buttons:{yes:"Si",no:"No"},fn:function(btn){if(btn=='yes'){showLoading(null,null,null,unlockDichiarazione.createDelegate(this,[rec.get('CFISC'),function(){hideLoading()
this.close()},function(){hideLoading()
Toast("Errore","Errore nel tentativo di sbloccare "+rec.get('CFISC'))}]),this)}},scope:this})}}})

