Wtf.courseWithoutSession=function(A){Wtf.apply(this,A);this.cmodel=new Wtf.grid.ColumnModel([new Wtf.KWLRowNumberer(),{header:"Course Name",dataIndex:"modulename"},{header:"Code",dataIndex:"code"},{header:"CPD Hours",dataIndex:"credithrs"}]);this.cmodel.defaultSortable=true;this.gradStructRec=Wtf.data.Record.create([{name:"modulename",type:"string"},{name:"code",type:"string"},{name:"credithrs",type:"string"}]);this.gradStructReader=new Wtf.data.KwlJsonReader({root:"data",totalProperty:"count"},this.gradStructRec);this.gradStructStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/admin/acastructure.jsp"}),reader:this.gradStructReader});this.grid=new Wtf.grid.GridPanel({ds:this.gradStructStore,cm:this.cmodel,border:false,enableColumnHide:false,trackMouseOver:true,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}});Wtf.courseWithoutSession.superclass.constructor.call(this,{autoDestroy:true,border:false,layout:"fit",tbar:["Quick Search: ",this.quickPanelSearch=new Wtf.KWLTagSearch({width:200,field:"code"})],items:[this.grid],bbar:this.pg=new Wtf.PagingSearchToolbar({id:"pgTbar"+this.id,pageSize:20,searchField:this.quickPanelSearch,store:this.gradStructStore,displayInfo:true,displayMsg:"Displaying records {0} - {1} of {2}",emptyMsg:"No results to display",plugins:this.pP=new Wtf.common.pPageSize({})})});this.on("render",this.handleRender,this);this.gradStructStore.on("load",this.handleStoreLoad,this);this.gradStructStore.on("datachanged",function(){var B=this.pP.combo.value;this.quickPanelSearch.setPage(B)},this)};Wtf.extend(Wtf.courseWithoutSession,Wtf.Panel,{handleRender:function(A){this.gradStructStore.baseParams={type:133};this.gradStructStore.load({params:{start:0,limit:20}})},handleStoreLoad:function(A,C,B){this.quickPanelSearch.StorageChanged(A)}});Wtf.facultyNewCourse=function(A){Wtf.apply(this,A);this.delArray=[];this.addArray=[];Wtf.facultyNewCourse.superclass.constructor.call(this,A)};Wtf.extend(Wtf.facultyNewCourse,Wtf.Panel,{initComponent:function(){Wtf.facultyNewCourse.superclass.initComponent.call(this);this.moduleSM=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});this.moduleCM=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),this.moduleSM,{header:"Name",dataIndex:"name",renderer:function(value,css,record,row,column,store){return"<a href=javascript:void(0) onclick=\"courseProfile('"+record.get("id")+"')\">"+value+"</a>"}},{header:"Code",dataIndex:"code"},{header:"Program Name",dataIndex:"programname"},{header:"Start Date",dataIndex:"startdate",renderer:function(val){if(val=="1972-01-31"){return"N/A"}else{return val}}},{header:"CPD Hours",dataIndex:"credithrs"},{header:"Session Applicable",dataIndex:"gradtype",renderer:function(value){if(value=="1"){return"Yes"}else{if(value=="2"){return"No"}}}},{header:"Status",dataIndex:"status",renderer:function(value){if(value==-1){return"Not sent for approval"}else{if(value==0){return"Waiting for approval"}else{if(value==1){return"Approved"}else{if(value==2){return"Rejected"}else{if(value==3){return"Approved"}}}}}}}]);this.moduleCM.defaultSortable=true;this.moduleStore=new Wtf.data.Store({reader:new Wtf.data.KwlJsonReader({root:"data",totalProperty:"TotalCount"},["name","code","type","id","note","startdate","credithrs","gradtype","prereqmoduleid","appexam","appclass","auditper","specialgrade","programid","courseid","status","programname","programtype","plan","displan","schplan"]),autoLoad:false,url:"jspfiles/admin/LacaStructure.jsp",baseParams:{flag:74}});this.moduleStore.on("load",this.getCoursePlanmap,this);this.moduleGrid=new Wtf.grid.GridPanel({ds:this.moduleStore,cm:this.moduleCM,border:false,sm:this.moduleSM,loadMask:{msg:"Loading Modules..."},viewConfig:{forceFit:true}});this.moduleSM.on("selectionchange",function(sm){this.setHODBttn.disable();this.editModule.disable();this.rejectModule.disable();this.approveModule.disable();this.courseGradeMap.disable();this.deleteModBttn.disable();this.mapModule.disable();this.setPlanBttn.disable();this.sendApprovalModule.disable();if(sm.getSelected()){var status=sm.getSelected().get("status");this.courseGradeMap.enable();if(status==0){this.approveModule.enable();this.rejectModule.enable()}else{if(status==1){this.mapModule.enable()}else{if(status==-1){this.sendApprovalModule.enable()}}}this.deleteModBttn.enable();if(!(Wtf.realroles.indexOf("6")>-1&&(status==1||status==2||status==3))){this.setHODBttn.enable();this.setPlanBttn.enable();this.editModule.enable();this.courseGradeMap.enable()}}},this);this.accountscenter=new Wtf.Panel({id:"accPan"+this.id,layout:"fit",tbar:["Quick Search: ",this.quickPanelSearch=new Wtf.KWLTagSearch({width:100,field:"name"}),"-",this.newModule=new Wtf.Toolbar.Button({text:"New",scope:this,handler:function(){this.createModule(true,1)},hidden:(Wtf.realroles.indexOf("6")>-1)?true:false}),this.editModule=new Wtf.Toolbar.Button({text:"Edit",scope:this,disabled:true,handler:function(){this.createModule(false,this.moduleSM.getSelected().get("programtype"))}}),this.deleteModBttn=new Wtf.Toolbar.Button({text:"Delete",disabled:true,scope:this,handler:function(){this.deleteModule(1)},hidden:(Wtf.realroles.indexOf("6")>-1)?true:false}),this.approveModule=new Wtf.Toolbar.Button({text:"Approve",scope:this,disabled:true,handler:function(){Wtf.Ajax.requestEx({url:"jspfiles/newCourse.jsp",params:{moduleid:this.moduleSM.getSelected().get("id"),type:"approveCourse",status:1},method:"POST"},this,function(result,req){var retstatus=eval("("+result.trim()+")");if(retstatus.success){this.moduleStore.load({params:{start:0,limit:15}});msgBoxShow(["Update Status","Status updated successfully"],Wtf.MessageBox.INFO)}else{msgBoxShow(["Status","Error while updating status"],Wtf.MessageBox.INFO)}},function(result,req){msgBoxShow(["Status","Error while updating status"],Wtf.MessageBox.INFO)})},hidden:(Wtf.realroles.indexOf("46")>-1)?true:false}),this.rejectModule=new Wtf.Toolbar.Button({text:"Reject",disabled:true,scope:this,tooltip:"Click to reject",handler:function(){this.rejectReq()},hidden:(Wtf.realroles.indexOf("46")>-1)?true:false}),this.mapModule=new Wtf.Toolbar.Button({text:"Map Courses",scope:this,disabled:true,handler:this.mapModule,hidden:(Wtf.realroles.indexOf("6")>-1)?true:false}),this.setHODBttn=new Wtf.Toolbar.Button({text:"Assign Trainer",tooltip:"Click to Assign Trainer",id:"TrainerBttn"+this.id,disabled:true,scope:this,handler:this.handleFacCoClick}),this.setPlanBttn=new Wtf.Toolbar.Button({text:"Fee Plans",tooltip:"Click to open",disabled:true,id:"PlansBttn"+this.id,scope:this,menu:[{text:"Set Plan",handler:this.setPlan,scope:this},{text:"View Fee",handler:this.viewFee,scope:this}]}),this.sendApprovalModule=new Wtf.Toolbar.Button({text:"Send For Approval",scope:this,disabled:true,hidden:(Wtf.realroles.indexOf("6")>-1)?true:false,handler:function(){Wtf.Ajax.requestEx({url:"jspfiles/newCourse.jsp",params:{moduleid:this.moduleSM.getSelected().get("id"),type:"approveCourse",status:0},method:"POST"},this,function(result,req){var retstatus=eval("("+result.trim()+")");if(retstatus.success){this.moduleStore.load({params:{start:0,limit:15}});msgBoxShow(["Update Status","Status updated successfully"],Wtf.MessageBox.INFO)}else{if(retstatus.msg!=null){msgBoxShow([retstatus.title,retstatus.msg],Wtf.MessageBox.INFO)}else{msgBoxShow(["Status","Error while updating status"],Wtf.MessageBox.INFO)}}},function(result,req){msgBoxShow(["Status","Error while updating status"],Wtf.MessageBox.INFO)})}}),this.courseGradeMap=new Wtf.Toolbar.Button({text:"Map Grading Structure",disabled:true,scope:this,handler:function(){this.opencoursegrademap()}}),this.skillSet=new Wtf.Toolbar.Button({text:"Learning Outcomes",tooltip:"Learning Outcomes",id:"setskill",scope:this,disabled:false,handler:function(){this.editSkill()}})],bbar:this.pg=new Wtf.PagingSearchToolbar({pageSize:15,searchField:this.quickPanelSearch,store:this.moduleStore,displayInfo:true,displayMsg:"Displaying items {0} - {1} of {2}",emptyMsg:"No items to display",plugins:this.pP=new Wtf.common.pPageSize({})}),items:this.moduleGrid});this.add(this.accountscenter)},handleFacCoClick:function(E,D){var C=Wtf.data.Record.create([{name:"id"},{name:"name"}]);var A=new Wtf.data.JsonReader({root:"data"},C);this.configStore=new Wtf.data.Store({reader:A,url:"jspfiles/newCourse.jsp",baseParams:{type:"configtype",config:"Trainer Profile"}});this.configStore.load();this.config=new Wtf.form.ComboBox({editable:false,displayField:"name",valueField:"id",triggerAction:"all",mode:"local",store:this.configStore,emptyText:"Select Config...",blankText:"Select Config...",scope:this,multiSelect:true});this.multi=new Wtf.common.Select(Wtf.applyIf({multiSelect:true,allowBlank:false},this.config));for(var B=0;B<this.delArray.length;B++){this.delArray.remove(this.delArray[B])}for(var B=0;B<this.addArray.length;B++){this.addArray.remove(this.addArray[B])}this.creategrid();this.centerdiv=document.createElement("div");this.centerdiv.appendChild(this.movetoright);this.centerdiv.appendChild(this.movetoleft);this.centerdiv.style.padding="135px 10px 135px 10px";this.assignFacultyWin=new Wtf.Window({title:"Trainer ",closable:true,modal:true,iconCls:"win",width:600,height:525,resizable:false,buttonAlign:"right",buttons:[{text:"Update",scope:this,handler:this.assignfacsubmit},{text:"Cancel",scope:this,handler:function(){this.assignFacultyWin.close()}}],layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/createuser.gif","Assign Trainer ","Allocate Trainer to a course")},{region:"center",border:false,bodyStyle:"background:#f1f1f1;font-size : 10px;padding:20px 20px 20px 20px;",layout:"fit",tbar:[this.multi,"-","Trainer Search: ",this.trainerSearch=new Wtf.KWLComboSearch({width:150,field:"name"}),"-"],items:[{border:false,bodyStyle:"background:transparent;",layout:"border",items:[{region:"west",border:false,width:250,layout:"fit",items:[{xtype:"KWLListPanel",title:"Available Trainer ",border:false,paging:false,layout:"fit",autoLoad:false,items:this.availablegrid}]},{region:"center",border:false,contentEl:this.centerdiv},{region:"east",border:false,width:250,layout:"fit",items:[{xtype:"KWLListPanel",title:"Assigned  Trainer ",border:false,paging:false,layout:"fit",autoLoad:false,items:this.selectedgrid}]}]}]}]});this.assignFacultyWin.show();this.multi.on("select",function(){this.trainerSearch.setConfig(this.multi.getValue())},this)},creategrid:function(){this.availableds=new Wtf.data.Store({url:"jspfiles/admin/adminSeModFaculty.jsp",reader:new Wtf.data.JsonReader({root:"data"},["id","name"]),baseParams:{mode:13,type:"normal",moduleid:this.moduleSM.getSelected().get("id"),availfrom:"",availto:"",skill:"",level:"",costmin:"",costmax:"",location:""}});this.availableds.load({params:{start:0,limit:30}});this.availablesm=new Wtf.grid.CheckboxSelectionModel();this.availablecm=new Wtf.grid.ColumnModel([new Wtf.KWLRowNumberer(),this.availablesm,{header:"Name",dataIndex:"name",autoWidth:true,sortable:true,groupable:true}]);this.availablegrid=new Wtf.grid.GridPanel({store:this.availableds,cm:this.availablecm,sm:this.availablesm,border:false,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}});this.availableds.on("load",function(A,C,B){this.trainerSearch.StorageChanged(A)},this);this.selectedds=new Wtf.data.Store({url:"jspfiles/admin/adminSeModFaculty.jsp",reader:new Wtf.data.JsonReader({root:"data"},["id","name"]),autoLoad:false});this.selectedsm=new Wtf.grid.CheckboxSelectionModel();this.selectedcm=new Wtf.grid.ColumnModel([new Wtf.KWLRowNumberer(),this.selectedsm,{header:"Name",dataIndex:"name",autoWidth:true,sortable:true,groupable:true}]);this.selectedgrid=new Wtf.grid.GridPanel({store:this.selectedds,cm:this.selectedcm,sm:this.selectedsm,border:false,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}});this.selectedds.load({params:{moduleid:this.moduleSM.getSelected().get("id"),start:0,limit:30,mode:12,programid:this.moduleSM.getSelected().get("programid")}});this.movetoright=document.createElement("img");this.movetoright.src="images/arrowright.gif";this.movetoright.style.width="24px";this.movetoright.style.height="24px";this.movetoright.style.margin="5px 0px 5px 0px";this.movetoright.onclick=this.movetorightclicked.createDelegate(this,[]);this.movetoleft=document.createElement("img");this.movetoleft.src="images/arrowleft.gif";this.movetoleft.style.width="24px";this.movetoleft.style.height="24px";this.movetoleft.style.margin="5px 0px 5px 0px";this.movetoleft.onclick=this.movetoleftclicked.createDelegate(this,[])},assignfacsubmit:function(){var C="";var A="";for(var B=0;B<this.delArray.length;B++){C+=this.delArray[B];if(B<this.delArray.length-1){C+=","}}for(var B=0;B<this.addArray.length;B++){A+=this.addArray[B];if(B<this.addArray.length-1){A+=","}}for(var B=0;B<this.delArray.length;B++){this.delArray.remove(this.delArray[B])}for(var B=0;B<this.addArray.length;B++){this.addArray.remove(this.addArray[B])}Wtf.Ajax.request({url:"jspfiles/admin/adminSeModFaculty.jsp",params:{delid:C,addid:A,moduleid:this.moduleSM.getSelected().get("id"),mode:14},method:"POST",scope:this,success:function(){this.assignFacultyWin.close()}})},setPlan:function(){var A=this.moduleSM.getSelected().get("plan").split(",");displansel=this.moduleSM.getSelected().get("displan").split(",");schplansel=this.moduleSM.getSelected().get("schplan").split(",");var B=new Wtf.assignPlan({userid:this.moduleSM.getSelected().get("id"),programid:"",plansel:A,displansel:displansel,schplansel:schplansel,flag:1,defaultplan:1,typeflag:"course"});B.on("refreshgrid",this.getCoursePlanmap,this)},viewFee:function(){this.feeSM=new Wtf.grid.CheckboxSelectionModel({});this.feeRecord=Wtf.data.Record.create([{name:"feename"},{name:"fee",type:"int"},{name:"feedis",type:"int"}]);this.feeReader=new Wtf.data.KwlJsonReader({root:"data"},this.feeRecord);this.feeStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/admin/acastructure.jsp"}),reader:this.feeReader});this.feeCM=new Wtf.grid.ColumnModel([this.feeSM,{header:"Feetype",dataIndex:"feename"},{header:"Fee",dataIndex:"fee"},{header:"Fee(Discount)",dataIndex:"feedis"}]);this.feeGrid=new Wtf.grid.EditorGridPanel({ds:this.feeStore,cm:this.feeCM,sm:this.feeSM,autoScroll:true,trackMouseOver:true,collapsible:true,layout:"fit",clicksToEdit:1,viewConfig:{forceFit:true,autoFill:true}});this.feeStore.load({params:{type:39,userid:this.moduleSM.getSelected().get("id")}});var A=new Wtf.Window({title:"View Course Fee",closable:true,modal:true,iconCls:"win",width:340,height:400,resizable:false,buttonAlign:"right",layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/upload52.gif","Course Fee","View Course Fee.")},{region:"center",border:false,layout:"fit",items:[{border:false,bodyStyle:"background:transparent;",layout:"fit",labelWidth:50,items:this.feeGrid}]}]});A.show()},opencoursegrademap:function(){this.gradeSM=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});this.gradeRecord=Wtf.data.Record.create([{name:"gscode"},{name:"gsdesc"},{name:"mapped"}]);this.gradeReader=new Wtf.data.KwlJsonReader({root:"data"},this.gradeRecord);this.gradeStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/admin/gradeStructure.jsp"}),reader:this.gradeReader});this.gradeCM=new Wtf.grid.ColumnModel([this.gradeSM,{header:"Grading Structure",dataIndex:"gscode"},{header:"Description",dataIndex:"gsdesc"}]);this.gradeGrid=new Wtf.grid.GridPanel({ds:this.gradeStore,cm:this.gradeCM,sm:this.gradeSM,autoScroll:true,trackMouseOver:true,collapsible:true,layout:"fit",viewConfig:{forceFit:true,autoFill:true}});this.gradeStore.load({params:{type:1,flag:1,start:0,limit:20}});this.gradeWin=new Wtf.Window({title:"Select Grading Schemes",closable:true,modal:true,iconCls:"win",width:340,height:400,resizable:false,buttonAlign:"right",layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/upload52.gif","Grading Structures","Select a grading structure.")},{region:"center",border:false,layout:"fit",items:[{border:false,bodyStyle:"background:transparent;",layout:"fit",labelWidth:50,items:this.gradeGrid}]},{region:"south",buttons:[{text:"Select",scope:this,handler:function(){Wtf.Ajax.requestEx({url:"jspfiles/admin/acastructure.jsp?type=1&flag=4&",params:{gscode:this.gradeSM.getSelected().data["gscode"],moduleid:this.moduleSM.getSelected().data["id"]},method:"POST"},this,function(resp,req){if(eval("("+resp+")").success=="true"){msgBoxShow(["Success","Grading structure mapped successfully"],Wtf.MessageBox.INFO);this.gradeWin.close()}else{msgBoxShow(["Failure","Grading structure could not be mapped"],Wtf.MessageBox.INFO)}},function(resp,req){msgBoxShow(["Failure","Error occured while connecting to the server"],Wtf.MessageBox.INFO)})}},{text:"Cancel",scope:this,handler:function(){this.gradeWin.close()}}]}]});this.gradeWin.show()},getCoursePlanmap:function(){this.quickPanelSearch.StorageChanged(this.moduleStore);Wtf.Ajax.requestEx({url:"jspfiles/admin/acastructure.jsp",method:"POST",params:{type:37}},this,function(response,option){var resp=eval("("+response+")");if(resp.data!=null){for(var ctr=0;ctr<this.moduleStore.getCount();ctr++){this.moduleStore.getAt(ctr).set("plan","");this.moduleStore.getAt(ctr).set("displan","")}for(var ctr=0;ctr<resp.data.length;ctr++){var index=-1;for(var cnt=0;cnt<this.moduleStore.getCount();cnt++){if(this.moduleStore.getAt(cnt).get("id")==resp.data[ctr].courseid){index=cnt;break}}if(index>-1){if(resp.data[ctr].type==0){this.moduleStore.getAt(index).set("plan",resp.data[ctr].code)}if(resp.data[ctr].type==1){var planstr=this.moduleStore.getAt(index).get("displan");if(planstr!=null&&planstr!=""){planstr+=","}planstr+=resp.data[ctr].code;this.moduleStore.getAt(index).set("displan",planstr)}}}}},function(resp,req){})},rejectReq:function(){this.credithrwin=new Wtf.Window({width:400,height:230,layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/upload52.gif","Reason","Reason for rejecting new course request.")},{region:"center",border:false,layout:"form",labelWidth:50,bodyStyle:"padding: 13px; 13px; 13px;",items:this.reason=new Wtf.form.TextArea({fieldLabel:"Reason",height:70,width:290,maxLength:1024,maxLengthText:"Reason should be less than 1024 characters"})}],buttons:[{text:"Save",scope:this,handler:function(){Wtf.Ajax.requestEx({url:"jspfiles/newCourse.jsp",params:{moduleid:this.moduleSM.getSelected().get("id"),reason:this.reason.getValue(),type:"rejectCourse"},method:"POST"},this,function(result,req){var retstatus=eval("("+result.trim()+")");if(retstatus.success){this.moduleStore.load({params:{start:0,limit:15}});this.credithrwin.close();msgBoxShow(["Update Status","Status updated successfully"],Wtf.MessageBox.INFO)}else{msgBoxShow(["Status","Error while updating status"],Wtf.MessageBox.INFO)}},function(result,req){msgBoxShow(["Status","Error while updating status"],Wtf.MessageBox.INFO)})},scope:this},{text:"Cancel",scope:this,handler:function(){this.credithrwin.close()}}]});this.credithrwin.show()},mapModule:function(C,B){this.delArray=[];this.addArray=[];this.catStore=new Wtf.data.Store({url:"jspfiles/admin/LacaStructure.jsp",reader:new Wtf.data.KwlJsonReader({root:"data"},["courseid","coursename"]),baseParams:{flag:"81"}});this.catStore.load();for(var A=0;A<this.delArray.length;A++){this.delArray.remove(this.delArray[A])}for(var A=0;A<this.addArray.length;A++){this.addArray.remove(this.addArray[A])}this.creategrid1();this.centerdiv=document.createElement("div");this.centerdiv.appendChild(this.movetoright);this.centerdiv.appendChild(this.movetoleft);this.centerdiv.style.padding="135px 10px 135px 10px";this.assignFacultyWin=new Wtf.Window({title:"Map Course",closable:true,modal:true,iconCls:"win",width:600,height:525,resizable:false,buttonAlign:"right",buttons:[{text:"Update",scope:this,handler:this.assignfacsubmit1},{text:"Cancel",scope:this,handler:function(){this.assignFacultyWin.close()}}],layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/createuser.gif","Map new modules","Map new modules to selected category.")},{region:"center",border:false,bodyStyle:"background:#f1f1f1;font-size : 10px;padding:20px 20px 20px 20px;",layout:"fit",tbar:["Category:",this.categoryCombo=new Wtf.form.ComboBox({fieldLabel:"Category",mode:"local",triggerAction:"all",typeAhead:true,forceSelection:true,store:this.catStore,displayField:"coursename",valueField:"courseid",allowBlank:false})],items:[{border:false,bodyStyle:"background:transparent;",layout:"border",items:[{region:"west",border:false,width:250,layout:"fit",items:[{xtype:"KWLListPanel",title:"Available Courses",border:false,paging:false,layout:"fit",autoLoad:false,items:this.availablegrid}]},{region:"center",border:false,contentEl:this.centerdiv},{region:"east",border:false,width:250,layout:"fit",items:[{xtype:"KWLListPanel",title:"Mapped Courses",border:false,paging:false,layout:"fit",autoLoad:false,items:this.selectedgrid}]}]}]}]});this.categoryCombo.on("select",function(){this.selectedds.load({params:{categoryid:this.categoryCombo.getValue(),mode:17}})},this);this.assignFacultyWin.show()},creategrid1:function(){this.availableds=new Wtf.data.Store({url:"jspfiles/admin/adminSeModFaculty.jsp",reader:new Wtf.data.JsonReader({root:"data"},["id","name","code"]),autoLoad:false});this.availablesm=new Wtf.grid.CheckboxSelectionModel();this.availablecm=new Wtf.grid.ColumnModel([new Wtf.KWLRowNumberer(),this.availablesm,{header:"Name",dataIndex:"name",autoWidth:true,sortable:true,groupable:true},{header:"Code",dataIndex:"code",autoWidth:true,sortable:true,groupable:true}]);this.availablegrid=new Wtf.grid.GridPanel({store:this.availableds,cm:this.availablecm,sm:this.availablesm,border:false,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}});this.availableds.load({params:{mode:16}});this.selectedds=new Wtf.data.Store({url:"jspfiles/admin/adminSeModFaculty.jsp",reader:new Wtf.data.JsonReader({root:"data"},["id","name","code"]),autoLoad:false});this.selectedsm=new Wtf.grid.CheckboxSelectionModel();this.selectedcm=new Wtf.grid.ColumnModel([new Wtf.KWLRowNumberer(),this.selectedsm,{header:"Name",dataIndex:"name",autoWidth:true,sortable:true,groupable:true},{header:"Code",dataIndex:"code",autoWidth:true,sortable:true,groupable:true}]);this.selectedgrid=new Wtf.grid.GridPanel({store:this.selectedds,cm:this.selectedcm,sm:this.selectedsm,border:false,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}});this.selectedds.load({params:{categoryid:"",mode:17}});this.movetoright=document.createElement("img");this.movetoright.src="images/arrowright.gif";this.movetoright.style.width="24px";this.movetoright.style.height="24px";this.movetoright.style.margin="5px 0px 5px 0px";this.movetoright.onclick=this.movetorightclicked.createDelegate(this,[]);this.movetoleft=document.createElement("img");this.movetoleft.src="images/arrowleft.gif";this.movetoleft.style.width="24px";this.movetoleft.style.height="24px";this.movetoleft.style.margin="5px 0px 5px 0px";this.movetoleft.onclick=this.movetoleftclicked.createDelegate(this,[])},movetorightclicked:function(){var A=this.availablesm.getSelections();if(A.length>0){this.selectedds.add(A)}for(var B=0;B<A.length;B++){this.availableds.remove(A[B]);if(this.delArray.indexOf(A[B].data["id"])!=-1){this.delArray.remove(A[B].data["id"])}else{this.addArray.push(A[B].data["id"])}}},movetoleftclicked:function(){var A=this.selectedsm.getSelections();if(A.length>0){this.availableds.add(A)}for(var B=0;B<A.length;B++){this.selectedds.remove(A[B]);if(this.addArray.indexOf(A[B].data["id"])!=-1){this.addArray.remove(A[B].data["id"])}else{this.delArray.push(A[B].data["id"])}}},assignfacsubmit1:function(){var delid="";var addid="";for(var ctr=0;ctr<this.delArray.length;ctr++){delid+=this.delArray[ctr];if(ctr<this.delArray.length-1){delid+=","}}for(var ctr=0;ctr<this.addArray.length;ctr++){addid+=this.addArray[ctr];if(ctr<this.addArray.length-1){addid+=","}}for(var ctr=0;ctr<this.delArray.length;ctr++){this.delArray.remove(this.delArray[ctr])}for(var ctr=0;ctr<this.addArray.length;ctr++){this.addArray.remove(this.addArray[ctr])}Wtf.Ajax.request({url:"jspfiles/admin/adminSeModFaculty.jsp",params:{delid:delid,addid:addid,categoryid:this.categoryCombo.getValue(),mode:18},method:"POST",scope:this,success:function(result,req){var respobj=eval("("+result.responseText+")");if(respobj!=null){if(respobj.success!=null){if(respobj.success){msgBoxShow(["Map Course","Course map successfully with selected category"],Wtf.MessageBox.INFO);this.moduleStore.load({params:{start:0,limit:15}});this.assignFacultyWin.close()}else{msgBoxShow(["Map Course","Error while mapping course"],Wtf.MessageBox.ERROR)}}if(respobj.msg!=null){msgBoxShow(["Update Status",respobj.msg],Wtf.MessageBox.ERROR)}}}})},onRender:function(A){Wtf.facultyNewCourse.superclass.onRender.call(this,A);this.moduleStore.load({params:{start:0,limit:15}})},createModule:function(C,E){if(E==1){var F="Course";var B=false;var D=true}this.gradTypeStore=new Wtf.data.SimpleStore({fields:["no","type"],data:[["1","Yes"],["2","No"]]});this.gradtype=new Wtf.form.ComboBox({fieldLabel:"Session Applicable*",mode:"local",triggerAction:"all",typeAhead:true,editable:false,width:390,store:this.gradTypeStore,displayField:"type",valueField:"no",hiddenName:"gradtype",value:C?null:this.moduleSM.getSelected().get("gradtype")}),this.sdate=new Wtf.form.DateField({fieldLabel:"Start Date*",allowBlank:false,disabled:C?false:this.moduleSM.getSelected().get("gradtype")=="1"?true:false,width:390,name:"startdate",format:"m/d/y",value:C?null:this.moduleSM.getSelected().get("gradtype")=="1"?"":this.moduleSM.getSelected().get("startdate")});this.gradtype.on("select",function(I,H,G){if(I.getValue()=="1"){this.sdate.disable();this.sdate.setValue(null)}else{this.sdate.enable()}},this);var A=C?1:2;this.newModuleWin=new Wtf.Window({title:C?"Create New "+F:"Edit Selected "+F,closable:true,modal:true,iconCls:"win",width:550,height:550,buttonAlign:"right",buttons:[{text:C?"Create":"Update",scope:this,handler:function(){if(this.createModuleForm.form.isValid()){if(this.newModuleWin.buttons[0].getText()=="Create"||this.newModuleWin.buttons[0].getText()=="Update"){var G=true;if(G){this.h3.setValue("");this.newModuleWin.buttons[0].disable();this.newModuleWin.buttons[0].setText("OK");this.newModuleWin.buttons[1].hide();this.createModuleForm.form.submit({scope:this,success:function(I,H){if(H.result.success==true){this.modbar.reset();this.modbar.updateProgress(1,C?F+" Created":"Changes done successfully");this.moduleStore.load({params:{start:0,limit:15}})}else{this.modbar.reset();this.modbar.updateProgress(1,"Error : "+H.result.success)}this.newModuleWin.buttons[0].enable();this.newModuleWin.buttons[1].hide()},failure:function(I,H){this.modbar.reset();this.modbar.updateProgress(1,H.result.success);this.newModuleWin.buttons[0].enable();this.newModuleWin.buttons[1].hide()}});this.createModuleForm.hide();this.newModuleWin.setHeight(210);this.modbar.show();this.modbar.wait()}}else{this.newModuleWin.close()}}}},{text:"Cancel",scope:this,handler:function(){this.newModuleWin.close()}}],layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:C?getHeader("images/upload52.gif","Create New "+F,"Create a new "+F):getHeader("images/upload52.gif","Edit Selected "+F,"Edit Selected "+F)},{region:"center",border:false,bodyStyle:"background:#f1f1f1;font-size : 10px;padding:10px;",layout:"fit",items:[{border:false,bodyStyle:"background:transparent;",layout:"fit",items:[this.createModuleForm=new Wtf.form.FormPanel({url:"jspfiles/admin/LacaStructure.jsp?flag=6&mode="+A,fileUpload:true,waitMsgTarget:true,method:"POST",border:false,bodyStyle:"font-size:10px;",defaluts:{width:400},lableWidth:150,defaultType:"textfield",id:this.id+"createCourse",autoScroll:true,items:[this.cname=new Wtf.form.TextField({fieldLabel:F+" Name*",allowBlank:false,name:"name",width:390,maxLength:128,maxLengthText:"Course name should be less than 128 characters",value:C?null:this.moduleSM.getSelected().get("name")}),this.gradtype,this.sdate,this.credithrs=new Wtf.form.NumberField({fieldLabel:"CPD Hours*",width:390,allowNegative:false,name:"credithrs",allowBlank:false,value:C?3:this.moduleSM.getSelected().get("credithrs")}),this.cnote=new Wtf.form.TextArea({fieldLabel:"About",height:80,width:390,name:"note",maxLength:1024,maxLengthText:"Note should be less than 1024 characters",value:C?null:this.moduleSM.getSelected().get("note")}),this.uploadpath=new Wtf.form.TextField({inputType:"file",fieldLabel:"Image",name:"filepath",id:"filepath"}),this.h1=new Wtf.form.Hidden({name:"id",value:C?null:this.moduleSM.getSelected().get("id")}),this.h2=new Wtf.form.Hidden({name:"courseid",value:C?null:""}),this.h3=new Wtf.form.Hidden({name:"jsonstr"})]}),this.modbar=new Wtf.ProgressBar({text:C?"Creating "+F+" ...":"Editing "+F+" ...",hidden:true})]}]}]});this.attrPanel=new Wtf.attributeComponent({facId:loginid,widthValue:390,configType:"Course",layout:"form",border:false,refid:(C)?"":this.moduleSM.getSelected().get("id")});Wtf.getCmp(this.id+"createCourse").add(this.attrPanel);this.attrPanel.on("closeform",function(G){Wtf.getCmp(this.id+"createCourse").doLayout()},this);this.newModuleWin.show()},deleteModule:function(programtype){Wtf.Msg.show({title:programtype==0?"Module Deletion":"Course Deletioin",msg:programtype==0?"Are you sure you want to delete selected module?":"Are you sure you want to delete selected course?",buttons:Wtf.Msg.YESNO,fn:function(bttn){if(bttn=="yes"){Wtf.Ajax.requestEx({url:"jspfiles/admin/LacaStructure.jsp",params:{flag:"44",moduleid:this.moduleSM.getSelected().get("id")}},this,function(result,req){var suc=eval("("+result.trim()+")");if(suc.result=="success"){msgBoxShow(["Delete Status","Record deleted successfully."],Wtf.MessageBox.INFO);this.moduleStore.load({params:{start:0,limit:15}})}else{msgBoxShow(["Delete Status",suc.result],Wtf.MessageBox.ERROR)}},function(result,req){msgBoxShow(["Delete Status","Error while deleting record."],Wtf.MessageBox.ERROR)})}},scope:this,animEl:"elId",icon:Wtf.MessageBox.QUESTION})},editSkill:function(){if(this.moduleGrid.getSelectionModel().getSelections().length==1){this.skillRecord=Wtf.data.Record.create([{name:"configid"},{name:"name"}]);this.skillReader=new Wtf.data.KwlJsonReader({root:"data"},this.skillRecord);this.skillStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/admin/acastructure.jsp"}),reader:this.skillReader});this.comboType=new Wtf.form.ComboBox({hiddenName:"configid",triggerAction:"all",store:this.skillStore,mode:"local",displayField:"name",fieldLabel:"Select skill",valueField:"name",emptyText:"Select type",allowBlank:false,editable:false});this.feeSM=new Wtf.grid.CheckboxSelectionModel({});this.skillStore.load({params:{type:137,userid:"Employee Profile"}});this.otherRec=Wtf.data.Record.create([{name:"skill"},{name:"level"},{name:"id"}]);this.otherReader=new Wtf.data.JsonReader({root:"data"},this.otherRec);this.otherStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/newCourse.jsp"}),reader:this.otherReader});this.otherStore.load({params:{type:"getskillGrid",userid:this.moduleGrid.getSelectionModel().getSelected().get("id")}});this.otherStore.on("load",function(){},this);this.skillCM=new Wtf.grid.ColumnModel([{header:"Skill",editor:this.comboType,dataIndex:"skill",renderer:this.comboBoxRenderer(this.comboType)},{header:"Level",editor:new Wtf.form.NumberField({allowBlank:false,allowNegative:false,maxValue:100000}),dataIndex:"level"}]);this.skillGrid=new Wtf.grid.EditorGridPanel({ds:this.otherStore,cm:this.skillCM,sm:this.feeSM,autoScroll:true,trackMouseOver:true,collapsible:true,layout:"fit",clicksToEdit:1,viewConfig:{forceFit:true,autoFill:true}});this.skillGrid.on("afteredit",this.editHandler,this);this.viewFeeWin=new Wtf.Window({title:"Skillsets",closable:true,modal:true,iconCls:"win",width:340,height:400,resizable:false,buttonAlign:"right",buttons:[{text:"Save",scope:this,handler:this.saveSkill,disabled:this.view},{text:"Cancel",scope:this,handler:function(){this.viewFeeWin.close()}}],layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/upload52.gif","Edit Skill","Edit Skill.")},{region:"center",border:false,layout:"fit",items:[{border:false,bodyStyle:"background:transparent;",layout:"fit",labelWidth:50,items:this.skillGrid}]}]});this.viewFeeWin.show();this.mode="edit"}else{Wtf.MessageBox.alert("Error","Please select  record")}},comboBoxRenderer:function(A){return function(C){var B=A.store.find(A.displayField,C);if(B==-1){return""}var D=A.store.getAt(B);return D.get(A.displayField)}},saveSkill:function(){var jsondata="{data:[";var jsondata1="";for(var ptr=0;ptr<this.otherStore.getCount()-1;ptr++){var configid=this.otherStore.getAt(ptr).data["skill"];var name=this.otherStore.getAt(ptr).get("level");jsondata1+="{'name':'"+configid+"','level':'"+name+"'},"}jsondata1=jsondata1.substring(0,jsondata1.length-1);var json=jsondata+jsondata1+"]}";Wtf.Ajax.requestEx({url:"jspfiles/admin/acastructure.jsp",method:"POST",params:{type:138,userid:this.moduleGrid.getSelectionModel().getSelected().get("id"),jstr:json}},this,function(response,option){this.resp=eval("("+response+")");if(this.resp.success=="true"){this.viewFeeWin.close();msgBoxShow(["Skill Saved","Skill saved successfully."],Wtf.MessageBox.INFO)}},function(resp,req){})},addDataInGrid:function(){this.otherStore.removeAll();this.otherStore.insert(0,this.makeRecord())},makeRecord:function(){var A=new this.otherRec({skill:"",level:""});return A},editHandler:function(A){if(A.row==this.otherStore.getCount()-1){this.otherStore.add(this.makeRecord())}}});Wtf.moduleassign=function(A){Wtf.apply(this,A);this.quickSearchTF=new Wtf.KWLTagSearch({field:"tags",width:200});this.modulesm=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});this.modulesm1=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});Wtf.ux.comboBoxRenderer=function(B){return function(D){var C=B.store.find(B.valueField,D);if(C==-1){return""}var E=B.store.getAt(C);return E.get(B.displayField)}};this.statStore=new Wtf.data.SimpleStore({fields:["statid","statname"],data:[["0","Confirmation Pending"],["1","Active"]]});this.comboStatus=new Wtf.form.ComboBox({id:"cmbStat"+this.id,valueField:"statid",displayField:"statname",store:this.statStore,mode:"local",triggerAction:"all"});this.groupingView1=new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:true,hideGroupedColumn:true});this.groupingView=new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:true,hideGroupedColumn:true});this.cmodel1=new Wtf.grid.ColumnModel([this.modulesm,{header:"Course Name",width:150,sortable:true,dataIndex:"name"},{header:"Session Name",width:150,sortable:true,dataIndex:"sessionname"},{header:"Session Code",width:150,sortable:true,dataIndex:"sessioncode"},{header:"Start Date",width:150,sortable:true,dataIndex:"sdate"},{header:"End Date",width:150,sortable:true,dataIndex:"edate"},{header:"Min Capacity",width:150,sortable:true,dataIndex:"min"},{header:"Max Capacity",width:150,sortable:true,dataIndex:"max"}]);this.sessionRecord=Wtf.data.Record.create([{name:"id",type:"string"},{name:"name",type:"string"},{name:"code",type:"string"},{name:"sessionname",type:"string"},{name:"sessioncode",type:"string"},{name:"specialgrade",type:"string"},{name:"basemoduleid",type:"string"},{name:"sdate",type:"string"},{name:"edate",type:"string"},{name:"min",type:"string"},{name:"max",type:"string"}]);this.sessionReader=new Wtf.data.JsonReader({root:"data",totalProperty:"count"},this.sessionRecord);this.sessionds=new Wtf.data.GroupingStore({proxy:new Wtf.data.HttpProxy({url:"jspfiles/faculty/getModules.jsp"}),reader:this.sessionReader,sortInfo:{field:"name",direction:"DESC"},groupField:"name"});this.grid=new Wtf.grid.GridPanel({border:true,store:this.sessionds,sm:this.modulesm,cm:this.cmodel1,view:this.groupingView1,viewConfig:{forceFit:true},loadMask:{msg:"Loading Modules..."},tbar:["Quick Search: ",this.quickSearchTF]});this.cmodel2=new Wtf.grid.ColumnModel([this.modulesm1,{header:"Class Name",width:150,dataIndex:"name"},{header:"Venue",width:150,dataIndex:"venue"},{header:"Date",width:100,dataIndex:"date"},{header:"Start Time",width:100,dataIndex:"starttime"},{header:"End Time",width:100,dataIndex:"endtime"},{header:"Course",width:100,dataIndex:"modulename"}]);this.cmodel2.defaultSortable=true;this.sectionRecord=Wtf.data.Record.create([{name:"name",type:"string"},{name:"venue",type:"string"},{name:"tname",type:"string"},{name:"date",type:"string"},{name:"stype",type:"string"},{name:"id",type:"string"},{name:"facid",type:"string"},{name:"status",type:"string"},{name:"modulename",type:"string"},{name:"ctype",type:"string"},{name:"starttime",type:"string"},{name:"endtime",type:"string"},{name:"recurrence",type:"string"}]);this.sectionReader=new Wtf.data.KwlJsonReader({root:"data",totalProperty:"count"},this.sectionRecord);this.sectionStore=new Wtf.data.GroupingStore({proxy:new Wtf.data.HttpProxy({url:"jspfiles/newClass.jsp"}),reader:this.sectionReader,sortInfo:{field:"modulename",direction:"DESC"},groupField:"modulename"});this.quickSearchTF1=new Wtf.KWLTagSearch({field:"tags",width:200});this.grid1=new Wtf.grid.GridPanel({ds:this.sectionStore,cm:this.cmodel2,sm:this.modulesm1,border:false,view:this.groupingView,trackMouseOver:true,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true},tbar:["Quick Search: ",this.quickSearchTF1]});Wtf.moduleassign.superclass.constructor.call(this,{layout:"fit",items:[{layout:"border",border:false,items:[{title:"Modules",xtype:"KWLListPanel",paging:false,autoLoad:false,border:false,height:250,region:"north",layout:"fit",split:true,items:this.grid,bbar:new Wtf.PagingSearchToolbar({id:"pgTbar1"+this.id,pageSize:10,searchField:this.quickSearchTF,store:this.sessionds,displayInfo:true,displayMsg:"Displaying records {0} - {1} of {2}",emptyMsg:"No results to display",plugins:this.pP=new Wtf.common.pPageSize({}),buttons:["-",this.open=new Wtf.Button({id:"btnOpen"+this.id,text:"View Course",scope:this,handler:function(){var B=this.modulesm.getSelected();mainPanel.loadTab("modulePanel.html","   _"+B.data.id+"_"+B.data.name+"_"+B.data.specialgrade+"_"+B.data.basemoduleid,B.data.name,"navareadashboard",Wtf.etype.course)}}),"-"]})},{title:"Classes",xtype:"KWLListPanel",border:false,paging:false,autoLoad:false,region:"center",layout:"fit",items:this.grid1,bbar:new Wtf.PagingToolbar({id:"pgTbar11"+this.id,pageSize:10,store:this.sectionStore,displayInfo:true,displayMsg:"Displaying records {0} - {1} of {2}",emptyMsg:"No results to display",plugins:new Wtf.common.pPageSize({})})}]}]});this.open.disable();this.sessionds.load({params:{start:0,limit:10}});this.modulesm.on("selectionchange",function(){if(this.modulesm.getSelected()){this.open.enable()}else{this.open.disable()}},this);this.grid.on("rowdblclick",function(B,D,C){if(this.modulesm.getSelected().data.status==1){mainPanel.loadTab("modulePanel.html","   _"+this.sessionds.getAt(D).data["id"]+"_"+this.sessionds.getAt(D).data["name"]+"_"+this.sessionds.getAt(D).data["specialgrade"]+"_"+this.sessionds.getAt(D).data["basemoduleid"],this.sessionds.getAt(D).data["name"],"navareadashboard",Wtf.etype.course)}},this);this.on("render",this.handleRender,this);this.sessionds.on("load",this.handleStoreLoad,this);this.sessionds.on("datachanged",function(){var B=this.pP.combo.value;this.quickSearchTF.setPage(B)},this)};Wtf.extend(Wtf.moduleassign,Wtf.Panel,{handleRender:function(A){this.sectionStore.baseParams={type:"getfacclass",userid:loginid};this.sectionStore.load({params:{start:0,limit:10}});this.sectionStore.on("load",function(B,D,C){this.quickSearchTF1.StorageChanged(B)},this);this.sectionStore.on("datachanged",function(){var B=this.pP.combo.value;this.quickSearchTF1.setPage(B)},this);this.grid1.on("sortchange",function(B,C){this.grid1.getStore().groupBy(C.field)},this)},handleStoreLoad:function(A,C,B){this.quickSearchTF.StorageChanged(A);if(Wtf.isIE){this.addListener("activate",this.handleActivate,this);this.ownerCt.ownerCt.addListener("activate",this.handleActivate,this)}},handleActivate:function(A){A.doLayout();var B=(this.grid.ownerCt.getSize().height>100)?this.grid.ownerCt.getSize().height:250;this.grid.ownerCt.setHeight(B);A.doLayout()}});Wtf.courseIncomplete=function(A){Wtf.apply(this,A);this.modulesm=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});this.groupingView1=new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:true,hideGroupedColumn:true});this.cmodel1=new Wtf.grid.ColumnModel([this.modulesm,{header:"Trainee Name",width:150,dataIndex:"username"},{header:"Course Name",width:150,dataIndex:"modulename"},{header:"Program",width:150,dataIndex:"programname"},{header:"Session",width:150,dataIndex:"sessionname"}]);this.sessionRecord=Wtf.data.Record.create([{name:"userid",type:"string"},{name:"username",type:"string"},{name:"modulename",type:"string"},{name:"programname",type:"string"},{name:"moduleid",type:"string"},{name:"sessionid",type:"string"},{name:"sessionname",type:"string"}]);this.sessionReader=new Wtf.data.JsonReader({root:"data",totalProperty:"count"},this.sessionRecord);this.sessionds=new Wtf.data.GroupingStore({proxy:new Wtf.data.HttpProxy({url:"jspfiles/faculty/getFacMod.jsp"}),reader:this.sessionReader,baseParams:{userid:loginid,type:"getIncompleteMod"}});this.grid=new Wtf.grid.GridPanel({border:true,store:this.sessionds,sm:this.modulesm,cm:this.cmodel1,viewConfig:{forceFit:true},loadMask:{msg:"Loading Data..."}});this.assignMarkBttn=new Wtf.Toolbar.Button({text:"Assign Marks",tooltip:"Assign Marks For Selected Item",scope:this,handler:this.assignMarks,disabled:true});Wtf.courseIncomplete.superclass.constructor.call(this,{layout:"fit",items:[{layout:"border",border:false,items:[{autoLoad:false,border:false,region:"center",layout:"fit",items:this.grid}],tbar:["Quick Search: ",this.quickPanelSearch=new Wtf.KWLQuickSearch({width:200,field:"name"}),"|",this.assignMarkBttn]}]});this.grid.getSelectionModel().on("selectionchange",this.disableBttn,this)};Wtf.extend(Wtf.courseIncomplete,Wtf.Panel,{afterRender:function(A){Wtf.courseIncomplete.superclass.afterRender.call(this,A);this.sessionds.load({params:{start:0,limit:15}})},assignMarks:function(){var A="gradebk"+this.id+this.modulesm.getSelected().get("moduleid");this.openTab(A,Wtf.course.gradeBook,{title:"Grade Book",closable:true,modulerunid:this.modulesm.getSelected().get("moduleid"),id:"gradebk"+this.id+this.modulesm.getSelected().get("moduleid")})},disableBttn:function(A){if(A.getSelections().length==1){this.assignMarkBttn.enable()}else{this.assignMarkBttn.disable()}},openTab:function(C,D,A){var B=Wtf.getCmp(C);if(!B){B=new D(A);this.parent.add(B);this.parent.doLayout()}this.parent.setActiveTab(B)}});Wtf.facSab=function(A){Wtf.apply(this,A);this.expander=new Wtf.grid.RowExpander({tpl:new Wtf.Template("<br>","<p><b>Reason:</b> {reason}</p>")});this.colConfig=[{header:"From",width:50,dataIndex:"startdate",sortable:true,renderer:function(B){if(Wtf.isEmpty(B)){return B}else{return B.format(Wtf.getDateFormat())}}},{header:"To",width:50,dataIndex:"enddate",sortable:true,renderer:function(B){if(Wtf.isEmpty(B)){return B}else{return B.format(Wtf.getDateFormat())}}},{header:"Reason",width:300,dataIndex:"reason",sortable:true},{header:"Status",width:100,dataIndex:"status",sortable:true,renderer:function(F,D,E,G,C,B){if(F==0){return"Applied"}else{if(F==1){return"<label style = 'color : green;'>Approved</label>"}else{if(F==2){return"<label style = 'color : red;'>Rejected</label>"}}}}}];if((isRoleGroup("4")||Wtf.isHR())){this.colConfig.unshift({header:"Trainer Name",width:100,dataIndex:"name",sortable:true,groupable:true})}this.colConfig.unshift(new Wtf.grid.RowNumberer({}));this.colConfig.unshift(this.expander);this.cmodel=new Wtf.grid.ColumnModel(this.colConfig);this.record=Wtf.data.Record.create([{name:"sabid",type:"string"},{name:"startdate",type:"date",dateFormat:"Y-m-d"},{name:"enddate",type:"date",dateFormat:"Y-m-d"},{name:"reason",type:"string"},{name:"status",type:"string"},{name:"name",type:"string"},{name:"userid",type:"string"}]);this.reader=new Wtf.data.JsonReader({root:"data"},this.record);this.groupingView=new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:false,hideGroupedColumn:true});this.gridView=new Wtf.grid.GridView({forceFit:true});this.ds=new Wtf.data.GroupingStore({proxy:new Wtf.data.HttpProxy({url:"jspfiles/faculty/sabbatical.jsp"}),reader:this.reader,baseParams:{mode:(isRoleGroup("4")||Wtf.isHR())?2:1},sortInfo:{field:"name",direction:"ASC"},groupField:"name"});this.grid=new Wtf.grid.GridPanel({border:false,store:this.ds,cm:this.cmodel,plugins:this.expander,view:(isRoleGroup("4")||Wtf.isHR())?this.groupingView:this.gridView,loadMask:{msg:"Loading..."}});if((isRoleGroup("4")||Wtf.isHR())){this.bbarConfig=[this.approveBttn=new Wtf.Toolbar.Button({text:"Approve Application",scope:this,disabled:true,handler:function(){var C=this.grid.getSelectionModel().getSelected();var B={edit:true,mode:6,status:1,startdate:C.get("startdate"),enddate:C.get("enddate"),reason:C.get("reason"),sabid:C.get("sabid"),facid:C.get("userid")};this.createWin(B)}}),this.disBttn=new Wtf.Toolbar.Button({text:"Reject Application",scope:this,disabled:true,handler:function(){Wtf.MessageBox.confirm("Reject Application","Are you sure you want to reject the application?",function(C){if(C=="yes"){var E=this.grid.getSelectionModel().getSelected();var D=E.get("startdate");var B=E.get("enddate");Wtf.Ajax.requestEx({url:"jspfiles/faculty/sabbatical.jsp",method:"POST",params:{status:2,mode:6,stdate:E.get("startdate").format("Y-m-j"),enddate:E.get("enddate").format("Y-m-j"),sabid:E.get("sabid"),facid:E.get("userid"),reason:E.get("reason")}},this,function(){msgBoxShow(["Reject Application","The application has been rejected."],Wtf.MessageBox.INFO);this.ds.reload()},function(){msgBoxShow(["Error","Error occurred while updating status. Please try again later."],Wtf.MessageBox.ERROR)});this.ds.reload()}},this)}})]}else{this.bbarConfig=[this.addBttn=new Wtf.Toolbar.Button({text:"New Application",scope:this,handler:function(){var B={edit:false,mode:3,status:0};this.createWin(B)}}),this.editBttn=new Wtf.Toolbar.Button({text:"Edit Application",scope:this,disabled:true,handler:function(){var C=this.grid.getSelectionModel().getSelected();var B={edit:true,mode:4,status:0,startdate:C.get("startdate"),enddate:C.get("enddate"),reason:C.get("reason"),sabid:C.get("sabid")};this.createWin(B)}}),this.delBttn=new Wtf.Toolbar.Button({text:"Delete Application",scope:this,disabled:true,handler:function(){Wtf.MessageBox.confirm("Delete Application","Are you sure you want to delete your application for sabbatical?",function(B){if(B=="yes"){var C=this.grid.getSelectionModel().getSelected();Wtf.Ajax.request({url:"jspfiles/faculty/sabbatical.jsp",method:"POST",scope:this,params:{mode:5,sabid:C.get("sabid")},success:function(D,E){this.ds.reload()},failure:function(){msgBoxShow(["Error","Error occurred while deleting. Please try again later."],Wtf.MessageBox.ERROR)}})}},this)}})]}Wtf.facSab.superclass.constructor.call(this,{layout:"fit",items:[{layout:"border",border:false,items:[{border:false,region:"center",layout:"fit",items:this.grid}]}],bbar:this.bbarConfig});this.grid.getSelectionModel().on("selectionchange",this.selChange,this)};Wtf.extend(Wtf.facSab,Wtf.Panel,{onRender:function(A){Wtf.facSab.superclass.onRender.call(this,A);this.ds.load()},selChange:function(B){var A=B.getSelected();if(!B.hasSelection()){if((isRoleGroup("4")||Wtf.isHR())){this.approveBttn.disable();this.disBttn.disable()}else{this.editBttn.disable();this.delBttn.disable()}}else{if((isRoleGroup("4")||Wtf.isHR())){this.approveBttn.enable();if(B.getSelected().get("status")!=2){this.disBttn.enable()}else{this.disBttn.disable()}}else{if(A.get("status")==0){this.editBttn.enable();this.delBttn.enable()}}}},handleKey:function(D){if(this.fP.form.isValid()){var C=this.fromField.getRawValue();var B=this.toField.getRawValue();if(D.facid){var A=D.facid}else{var A=""}this.fP.form.submit({scope:this,params:{status:D.status,mode:D.mode,stdate:Wtf.modifyDateFmt(C,Wtf.getDateFormat(),"Y-m-j"),enddate:Wtf.modifyDateFmt(B,Wtf.getDateFormat(),"Y-m-j"),sabid:D.sabid,facid:A,reason:this.reasonField.getValue()},success:function(){this.win.close();this.ds.reload()},failure:function(){msgBoxShow(["Error","Error occurred while connecting to server. Please try again later."],Wtf.MessageBox.ERROR)}})}},createWin:function(A){if((isRoleGroup("4")||Wtf.isHR())){if(A.status==1){var B="Approve sabbatical application. You can edit the dates for this application"}else{if(A.status==2){var B="Reject sabbatical application. You can edit the dates for this application"}}}else{var B="Apply for sabbatical"}this.win=new Wtf.Window({iconCls:"winicon",resizable:false,width:350,modal:true,plain:true,height:280,title:"Application for Sabbatical",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/ack40.gif","Sabbatical Application",B)},{region:"center",layout:"fit",border:false,bodyStyle:"background:#f1f1f1;border-bottom:1px solid #bfbfbf;padding:10px",items:[this.fP=new Wtf.form.FormPanel({url:"jspfiles/faculty/sabbatical.jsp",waitMsgTarget:true,method:"POST",border:false,labelWidth:100,items:[this.fromField=new Wtf.form.DateField({fieldLabel:"From*",scope:this,allowBlank:false,format:Wtf.getDateFormat(),width:190,value:A.edit?A.startdate:null}),this.toField=new Wtf.form.DateField({fieldLabel:"To*",scope:this,allowBlank:false,format:Wtf.getDateFormat(),width:190,value:A.edit?A.enddate:null}),this.reasonField=new Wtf.form.TextArea({fieldLabel:"Reason*",scope:this,allowBlank:false,disabled:(isRoleGroup("4")||Wtf.isHR())?true:false,width:190,maxLength:1024,value:A.edit?A.reason:""})]})]}],buttons:[{text:"OK",scope:this,handler:function(){if(this.fromField.getValue()<=this.toField.getValue()){this.handleKey(A)}else{this.fromField.markInvalid("From date should be before To date");this.toField.markInvalid("From date should be before To date")}}},{text:"Cancel",scope:this,handler:function(){this.win.close()}}]});this.win.show()}})