Ext.ns("feyaSoft.oilAccount.account.home");feyaSoft.oilAccount.account.home.TechnologyPanel=function(config){var selectBoxModel=new Ext.grid.CheckboxSelectionModel();selectBoxModel.on("selectionchange",function(sm){if(sm.getSelections().length==1){var record=sm.getSelected();if(record.data.userPermission=="reader"){Ext.getCmp("technology-delete-button").disable();Ext.getCmp("technology-edit-button").disable()}else{Ext.getCmp("technology-delete-button").enable();Ext.getCmp("technology-edit-button").enable()}}else{Ext.getCmp("technology-delete-button").disable();Ext.getCmp("technology-edit-button").disable()}},this);var cm=new Ext.grid.ColumnModel([{id:"id",header:"Identify",dataIndex:"id",width:100,hidden:true},{id:"title",header:"Title",dataIndex:"title",sortable:true,width:250},{header:"userPermission",dataIndex:"userPermission",hidden:true,width:100}]);this.dataStore=new Ext.data.JsonStore({autoDestroy:true,url:"accountTechnology/list",fields:[]});this.dataStore.setDefaultSort("lastModifiedDate","DESC");this.dataStore.load({params:{start:0,limit:10}});var template=new Ext.XTemplate('<div class="x-grid3-row open-news-item">	<div class="open-news-icon"> <img src="{imagepath}" /> &nbsp; </div>	<div class="open-news-text">		<div class="x-grid3-cell open-news-text-header">			<div class="open-news-text-title">{title} </div>					</div>		<div class="x-grid3-cell open-news-text-description">			{description}		</div>	</div>	<div style="clear: both;"></div></div>');this.menubar=[{text:"Add",tooltip:"Add Feature",iconCls:"addItem",handler:function(){new feyaSoft.oilAccount.account.home.CreateEditTechnology({myOwner:this})},scope:this},{text:"Edit",tooltip:"Edit the selected item",iconCls:"editItem",disabled:true,handler:function(){var record=this.getSelectionModel().getSelected();new feyaSoft.oilAccount.account.home.CreateEditTechnology({rd:record,myOwner:this})},scope:this},"-",{text:"Delete",tooltip:"Delete the selected item",iconCls:"remove",disabled:true,handler:function(){var record=this.getSelectionModel().getSelected();this.deleteItem(record)},scope:this}];if(USR_GLOBAL_INFO.myPermssion=="7"){feyaSoft.oilAccount.account.home.TechnologyPanel.superclass.constructor.call(this,{title:"Features",border:false,layout:"fit",cm:cm,sm:selectBoxModel,autoScroll:true,stripeRows:true,frame:true,store:this.dataStore,tbar:this.menubar,bbar:new Ext.PagingToolbar({pageSize:10,store:this.dataStore,displayInfo:true,displayMsg:"",plugins:new Ext.ux.SlidingPager()}),view:new Ext.ux.grid.ExplorerView({rowTemplate:template,forceFit:true})})}else{feyaSoft.oilAccount.account.home.TechnologyPanel.superclass.constructor.call(this,{title:"Features",border:false,layout:"fit",cm:cm,autoScroll:true,stripeRows:true,frame:true,store:this.dataStore,bbar:new Ext.PagingToolbar({pageSize:10,store:this.dataStore,displayInfo:true,displayMsg:"",plugins:new Ext.ux.SlidingPager()}),view:new Ext.ux.grid.ExplorerView({rowTemplate:template,forceFit:true})})}this.on("rowdblclick",this.onRowdblclick,this);this.on("rowclick",this.onRowclick,this)};Ext.extend(feyaSoft.oilAccount.account.home.TechnologyPanel,Ext.grid.GridPanel,{onRowdblclick:function(grid,rowIndex,e){var data=this.dataStore.getAt(rowIndex).data;this.showTab(data,false)},onRowclick:function(grid,rowIndex,e){var data=this.dataStore.getAt(rowIndex).data;this.showTab(data,true)},showTab:function(data,isHide){var uniqueId="technology-"+data.id;if(data.url=="blank"||data.url==null||data.url.trim().length==0){Ext.MessageBox.alert("Errors","This url is empty, can not open it.")}else{Ext.getCmp("oilaccount-account-mainPanel").loadSimpleUrl(data.url,data.title,uniqueId,isHide)}},reload:function(){this.dataStore.reload()},deleteItem:function(rd){Ext.Msg.show({title:"Confirm Delete",msg:"Do you really want to delete this technology: "+rd.data.title,icon:Ext.Msg.QUESTION,buttons:Ext.Msg.YESNO,fn:this.onDeleteConfirm,scope:this,record:rd})},onDeleteConfirm:function(button_id,text,options){if(button_id=="yes"){Ext.Ajax.request({url:"accountTechnology/archive",method:"POST",params:{id:options.record.data.id},success:function(result,request){var jsonData=Ext.util.JSON.decode(result.responseText);if(jsonData.success=="true"){this.dataStore.load()}else{Ext.MessageBox.alert("Error",jsonData.errorInfo)}},failure:function(result,request){Ext.MessageBox.alert("Failed","Internal Error, please try again")},scope:this})}}});
