Wtf.lms.appReq=function(A){Wtf.apply(this,A);this.sm=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});this.creatorRecord=Wtf.data.Record.create([{name:"user",type:"string"},{name:"id",type:"string"}]);this.creatorReader=new Wtf.data.JsonReader({root:"data"},this.creatorRecord);this.creatorStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/lms/contentrequest.jsp"}),reader:this.creatorReader});this.reader=new Wtf.data.JsonReader({root:"data",fields:[{name:"cname",type:"string"},{name:"reqdate",type:"string"},{name:"modify",type:"string"},{name:"status",type:"string"},{name:"id",type:"string"},{name:"inst",type:"string"},{name:"user",type:"string"},{name:"module",type:"string"},{name:"resp",type:"string"},{name:"actstatus",type:"int"},{name:"resp1",type:"string"}]});this.ds=new Wtf.data.GroupingStore({url:"jspfiles/lms/contentrequest.jsp",baseParams:{flag:4},reader:this.reader});this.groupingView=new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,hideGroupedColumn:false});this.expander=new Wtf.grid.RowExpander({tpl:new Wtf.Template("<br>","<p><b>Instruction:</b> {inst}</p>","<br>","<p><b>Response:</b> {resp}</p>","<br>","<p><b>Learning Object:</b> {resp1}</p>")});this.cm=new Wtf.grid.ColumnModel([this.expander,this.sm,{header:"Content Name",dataIndex:"cname",align:"left",width:0.4,sortable:true,groupable:true},{header:"Module Name",dataIndex:"module",align:"left",width:0.1,sortable:true,groupable:true},{header:"Requested by",dataIndex:"user",align:"center",width:0.1,sortable:true,groupable:true},{header:"Request Date",dataIndex:"reqdate",align:"center",width:0.15,sortable:true,groupable:true,renderer:function(B){return Wtf.modifyDateFmt(B,"Y-m-d g:i A",Wtf.getDateFormat())}},{header:"Modified Date",dataIndex:"modify",align:"center",width:0.15,sortable:true,groupable:true,renderer:function(B){return Wtf.modifyDateFmt(B,"Y-m-d g:i A",Wtf.getDateFormat())}},{header:"Status",dataIndex:"status",align:"center",width:0.1,sortable:true,groupable:true}]);this.cm.defaultSortable=true;Wtf.lms.appReq.superclass.constructor.call(this,{layout:"fit",items:[{layout:"border",border:false,autoWidth:true,items:[this.grid=new Wtf.grid.GridPanel({border:false,region:"center",store:this.ds,cm:this.cm,plugins:this.expander,sm:this.sm,trackMouseOver:true,viewConfig:{forceFit:true},loadMask:{msg:"Loading Request Status..."}})]}],bbar:[new Wtf.PagingToolbar({pageSize:15,id:"paggintoolbar"+this.id,store:this.ds,scope:this,plugins:new Wtf.common.pPageSize({id:"pPageSize_"+this.id}),items:["-",this.crtRequest=new Wtf.Toolbar.Button({text:"Acknowledge Request",scope:this,disabled:true,tooltip:{text:"Click to acknowledge request"},handler:this.approveRequest}),this.actRequst=new Wtf.Toolbar.Button({text:"Action Completed",scope:this,disabled:true,tooltip:{text:"Click to Complete due action"},handler:this.actionComplete})]})]})};Wtf.extend(Wtf.lms.appReq,Wtf.Panel,{editMeta:null,flag:false,onRender:function(A){Wtf.lms.appReq.superclass.onRender.call(this,A);this.addEvents({"ackReq":true});this.ds.load({params:{start:0,limit:15}});this.grid.on("sortchange",function(B,C){this.grid.getStore().groupBy(C.field)},this);this.sm.addListener("selectionchange",this.rowSelectionHandler,this);this.conType=new Wtf.data.SimpleStore({data:[["Quiz","1"],["Section","2"],["File","3"]],fields:["type","id"],reader:new Wtf.data.ArrayReader({},[{name:"type"},{name:"id"}]),autoLoad:true});this.creatorStore.load({params:{flag:"1"}})},approveRequest:function(){var B=this.sm.getSelections();var C="";for(var A=0;A<B.length;A++){C+=B[A].data.id+","}this.setStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/lms/contentrequest.jsp"}),reader:this.creatorReader});this.creatorStore.load({params:{flag:5,id:C}});this.ds.load();this.fireEvent("ackReq")},rowSelectionHandler:function(){var A=this.sm.getSelections();if(A.length==1){if(A[0].data.actstatus==2){this.crtRequest.disable();this.actRequst.disable()}else{if(A[0].data.actstatus==1){this.crtRequest.disable();this.actRequst.enable()}else{this.crtRequest.enable()}}}else{this.crtRequest.disable();this.actRequst.disable()}},actionComplete:function(){this.respReader=new Wtf.data.JsonReader({root:"data",fields:[{name:"objectid",type:"string"},{name:"objectname",type:"string"}]});this.respds=new Wtf.data.Store({url:"jspfiles/lms/contentrequest.jsp",baseParams:{flag:7},reader:this.respReader});this.respsm=new Wtf.grid.CheckboxSelectionModel();this.respcm=new Wtf.grid.ColumnModel([this.respsm,{header:"Object Name",dataIndex:"objectname",align:"left",width:1,sortable:true,groupable:true}]);this.actionWin=new Wtf.Window({title:"Response for requested content",closable:true,iconCls:"win",width:500,modal:true,height:450,scope:this,resizable:false,buttons:[{text:"Save",scope:this,handler:this.sendResp},{text:"Cancel",scope:this,handler:function(){this.actionWin.close()}}],items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/createuser.gif","Response for requested Content","Choose the learning objects you have created in response to the request along with any comments or information on the objects.")},{region:"center",height:120,border:false,bodyStyle:"background:#f1f1f1;",items:[this.reqform=new Wtf.form.FormPanel({waitMsgTarget:true,method:"POST",border:false,labelAlign:"top",bodyStyle:"margin: 10px 10px 0 10px;font-size:10px;",items:[this.respArea=new Wtf.form.TextArea({xtype:"textarea",fieldLabel:"Response",name:"instruction",anchor:"99%",height:75,width:300})]})]},{region:"south",height:190,layout:"fit",bodyStyle:"padding: 0 10px 10px 10px;background:#f1f1f1;",border:false,items:[this.respgrid=new Wtf.grid.GridPanel({region:"center",store:this.respds,autoScroll:true,cm:this.respcm,sm:this.respsm,trackMouseOver:true,viewConfig:{forceFit:true},loadMask:{msg:"Loading Request Status..."}})]}]});this.actionWin.show();this.respds.load()},sendResp:function(){var E=this.sm.getSelections();var F=E[0].data.id;var A=this.respsm.getSelections();var C="";var D="";for(var B=0;B<A.length;B++){C+="'"+A[B].data.objectid+"',";D+=(B+1)+": "+A[B].data.objectname+","}if(C.length>1){C=C.substring(0,C.length-1);D=D.substring(0,D.length-1);Wtf.Ajax.request({url:"jspfiles/lms/contentrequest.jsp",method:"POST",params:({flag:"6",id:F,objid:C,resp:this.respArea.getValue()})});this.actionWin.close();this.ds.load()}else{Wtf.Msg.alert("Error","Please select a learning object")}}})