Wtf.DepartmentPanel=function(A){Wtf.apply(this,A);this.createFacultyWindow=null;this.column1=null;this.column2=null;this.expander=new Wtf.grid.RowExpander({tpl:new Wtf.XTemplate("<p><b>Active Course:</b> </p><br>",'<table border="0">',"<tr>","<td>",'<table border="0">',"<tr>","<th><b>Session</b></th>","</tr>",'<tpl for="Asession">',"<tr>","<td>","{.}","</td>","</tr>","</tpl>","</table>","</td>","<td>",'<table border="0">',"<tr>","<th><b>Module</b></th>","</tr>",'<tpl for="Amodule">',"<tr>","<td>","{.}","</td>","</tr>","</tpl>","</table>","</td>","</tr>","</table>","<p><b>Past Course:</b> </p><br>",'<table border="0">',"<tr>","<td>",'<table border="0">',"<tr>","<th><b>Session</b></th>","</tr>",'<tpl for="Psession">',"<tr>","<td>","{.}","</td>","</tr>","</tpl>","</table>","</td>","<td>",'<table border="0">',"<tr>","<th><b>Module</b></th>","</tr>",'<tpl for="Pmodule">',"<tr>","<td>","{.}","</td>","</tr>","</tpl>","</table>","</td>","</tr>","</table>")});this.groupingView=new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:true,hideGroupedColumn:false});this.sm=new Wtf.grid.CheckboxSelectionModel({singleSelect:true});this.cmodel=new Wtf.grid.ColumnModel([this.expander,this.sm,{header:"Name",width:220,dataIndex:"Name"},{header:"Age",width:50,dataIndex:"Age"},{header:"Designation",width:120,dataIndex:"Designation"},{header:"No. of years with INCEIF",width:130,renderer:function(D,B,C){if(D==-1){return"<lable style = 'color : blue;'>Not on INCEIF Payroll</lable>"}else{return D}},dataIndex:"Noyears"},{header:"Department",width:120,dataIndex:"Department"},{header:"Type",width:100,dataIndex:"Type",renderer:this.typeRenderer},{header:"Payroll",width:100,dataIndex:"Payroll",renderer:this.payrollRenderer},{header:"Location",width:100,dataIndex:"Location"},{header:"Qualification",width:100,dataIndex:"Qualification"},{header:"Skills",width:100,dataIndex:"Skills"},{header:"StartDate",width:100,dataIndex:"StartDate",renderer:this.expirDate},{header:"EndDate",width:100,dataIndex:"EndDate",renderer:this.expirDate},{header:"Contract Download",width:80,renderer:this.DownloadLink1}]);this.cmodel.defaultSortable=true;this.departmentRecord=Wtf.data.Record.create([{name:"Id",type:"string"},{name:"Name",type:"string"},{name:"Type",type:"string"},{name:"Age",type:"string"},{name:"Designation",type:"string"},{name:"Noyears",type:"string"},{name:"Department",type:"string"},{name:"Payroll",type:"string"},{name:"Location",type:"string"},{name:"Qualification",type:"string"},{name:"Skills",type:"string"},{name:"Rating",type:"string"},{name:"Acourse",type:"string"},{name:"Pcourse",type:"string"},{name:"Asession"},{name:"Amodule"},{name:"Psession"},{name:"Pmodule"},{name:"roleid",type:"string"},{name:"StartDate"},{name:"EndDate"},{name:"FileName"},{name:"contExp"}]);this.departmentReader=new Wtf.data.KwlJsonReader({root:"data",totalProperty:"count"},this.departmentRecord);this.departmentStore=new Wtf.data.GroupingStore({proxy:new Wtf.data.HttpProxy({url:"jspfiles/schclass.jsp"}),reader:this.departmentReader,sortInfo:{field:"Name",direction:"DESC"}});this.grid=new Wtf.grid.GridPanel({ds:this.departmentStore,cm:this.cmodel,border:false,enableColumnHide:false,view:this.groupingView,plugins:this.expander,sm:this.sm,trackMouseOver:true,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}});this.defferBttn=new Wtf.Toolbar.Button({text:"New Faculty",tooltip:"Submit",id:"BtnNew"+this.id,scope:this});this.defferBttn.on("click",this.handleDeferClick,this);this.facltBtn=new Wtf.Toolbar.Button({text:"Master Setup",scope:this,menu:[{text:"Qualification",tooltip:{title:"Qualification",text:"Click to view Qualification Master"},handler:this.openQualMaster,scope:this},{text:"Skills",tooltip:{title:"Skills",text:"Click to view Skill Master"},handler:this.openSkillMaster,scope:this},{text:"Levels",tooltip:{title:"Levels",text:"Click to view Level Master"},handler:this.openLevelMaster,scope:this},{text:"Department",tooltip:{title:"Departments",text:"Click to view Department Master"},handler:this.openDeptMaster,scope:this},{text:"Designation",tooltip:{title:"Designations",text:"Click to view Designation Master"},handler:this.openDesigMaster,scope:this}]});Wtf.DepartmentPanel.superclass.constructor.call(this,{autoDestroy:true,border:false,layout:"fit",tbar:["Quick Search: ",this.quickPanelSearch=new Wtf.KWLTagSearch({width:200,field:"Name"}),this.facltBtn,{text:"Manage Faculty Profile",tooltip:{title:"Faculty Profile Management",text:"Click to Manage Faculty Profile"},handler:function(){if(this.sm.getSelected()){this.handleDeferClick()}else{msgBoxShow(["Manage Faculty Profile","Please select a faculty"])}},scope:this},{text:"Manage Contract",tooltip:{title:"Manage Contract",text:"Click to upload new contract"},handler:this.openContract,scope:this},{text:"Send Contract Expiry Notification",id:"SCEN",tooltip:{title:"Send Notification",text:"Click to send notification for expired contract"},disabled:true,handler:this.sendNotification,scope:this}],items:[this.grid],bbar:this.pg=new Wtf.PagingSearchToolbar({id:"pgTbardep"+this.id,pageSize:25,searchField:this.quickPanelSearch,store:this.departmentStore,displayInfo:true,displayMsg:"Displaying records {0} - {1} of {2}",emptyMsg:"No results to display",plugins:this.pP=new Wtf.common.pPageSize({})})});this.grid.on("cellclick",this.onClickHandle,this);this.grid.on("rowdblclick",this.showProfile,this);this.sm.on("selectionchange",this.selectionchange,this);this.sm.on("rowdeselect",function(){Wtf.getCmp("SCEN").disable()},this);this.departmentStore.on("load",this.handleStoreLoad,this);this.addEvents={"refreshfacgrid":true};this.departmentStore.on("datachanged",function(){var B=this.pP.combo.value;this.quickPanelSearch.setPage(B)},this);this.on("refreshfacgrid",function(){this.departmentStore.reload()},this)};Wtf.extend(Wtf.DepartmentPanel,Wtf.Panel,{onRender:function(A){Wtf.DepartmentPanel.superclass.onRender.call(this,A);this.departmentStore.baseParams={type:"getDetFac"};this.departmentStore.load({params:{start:0,limit:25}})},expirDate:function(B,A,F,E,D,C){if(F.data.contExp==0){return"<label style='color:red;'>"+Wtf.modifyDateFmt(B,"Y-m-j",Wtf.getDateFormat())+"</label>"}else{return Wtf.modifyDateFmt(B,"Y-m-j",Wtf.getDateFormat())}},DownloadLink1:function(B,A,F,E,D,C){if(F.data.FileName!=""){return"<a href='#' title='Download' onclick='setDldUrl(\"fileDownload.jsp?url="+F.data.FileName+"&type=contract&dtype=attachment\")'><div class='pwnd dldiconwt' style='height:16px; width:16px;'></div></a>"}else{return }},handleStoreLoad:function(A,C,B){this.quickPanelSearch.StorageChanged(A)},selectionchange:function(){var A=this.sm.getSelections();if(A.length==1){if(A[0].data["contExp"]==0){Wtf.getCmp("SCEN").enable()}else{Wtf.getCmp("SCEN").disable()}}},sendNotification:function(){var A=this.grid.getSelectionModel().selections.items[0].data["Id"];Wtf.Ajax.requestEx({method:"GET",url:"jspfiles/schclass.jsp?",params:({type:"notification",uid:A,edate:this.grid.getSelectionModel().selections.items[0].data["EndDate"]})},this,function(B,C){msgBoxShow(["Success","Contract expiry notification sent successfully to "+this.grid.getSelectionModel().selections.items[0].data["Name"]],Wtf.MessageBox.INFO)},function(B,C){msgBoxShow(["Error","Error Occur While Sending Message"],Wtf.MessageBox.ERROR)})},openContract:function(){if(this.grid.getSelectionModel().getCount()==1){var C=this.grid.getSelectionModel().selections.items[0].data["Id"];var A=this.grid.getSelectionModel().selections.items[0].data["StartDate"];var B=this.grid.getSelectionModel().selections.items[0].data["EndDate"];this.ContractPanel=new Wtf.FormPanel({frame:true,method:"POST",fileUpload:true,waitMsgTarget:true,url:"FileUpload.jsp?flag=4&id="+C,items:[this.stDt=new Wtf.form.DateField({id:"contractStartDate",fieldLabel:"Start Date*",width:150,value:A,format:Wtf.getDateFormat(),allowBlank:false}),this.edDt=new Wtf.form.DateField({id:"contractEndDate",fieldLabel:"End Date*",width:150,value:B,format:Wtf.getDateFormat(),allowBlank:false}),new Wtf.form.TextField({id:"contractUpload",inputType:"file",fieldLabel:"Contract*",allowBlank:false,name:"contract"})]});this.contractWindow=new Wtf.Window({iconCls:"winicon",resizable:false,id:"contractWin",width:400,height:170,title:"Upload New Contract",scope:this,layout:"fit",items:[this.ContractPanel],buttons:[{text:"Upload",type:"submit",scope:this,handler:function(){if(this.ContractPanel.form.isValid()){var D=this.stDt.getRawValue();var E=this.edDt.getRawValue();if(D>E){this.stDt.markInvalid("Start date cannot be after end date.")}else{this.ContractPanel.form.submit({scope:this,waitMsg:"Loading...",params:{startdate:Wtf.modifyDateFmt(D,Wtf.getDateFormat(),"m/d/y"),enddate:Wtf.modifyDateFmt(E,Wtf.getDateFormat(),"m/d/y")},success:function(F,G){msgBoxShow(["Upload Successful","File Uploaded Successfully "],Wtf.MessageBox.INFO);this.departmentStore.reload();this.contractWindow.close()},failure:function(F,G){msgBoxShow(["ERROR","A problem occurred while uploading"],Wtf.MessageBox.ERROR);this.contractWindow.close()}})}}}},{text:"Cancel",scope:this,handler:function(){this.contractWindow.close()}}]});this.contractWindow.show()}else{if(this.grid.getSelectionModel().getCount()>1){msgBoxShow(["ERROR","Select only one record"],Wtf.MessageBox.ERROR)}else{msgBoxShow(["ERROR","Select at least one record"],Wtf.MessageBox.ERROR)}}},handleDeferClick:function(A,B){this.facultyProfileWin=new Wtf.common.myProfile({facId:this.sm.getSelected().data.Id,parentid:this.id,id:loginid});this.facultyProfileWin.show();this.facultyProfileWin.on("close",function(){this.departmentStore.reload();Wtf.getCmp("SCEN").disable()},this)},typeRenderer:function(E,C,A,F,D,B){if(!E){return"<lable ></lable>"}else{if(E==0){return"<lable >Regular</lable>"}else{if(E==1){return"<lable >Adjunct</lable>"}}}},payrollRenderer:function(E,C,A,F,D,B){if(!E){return"<lable ></lable>"}else{if(E==0){return"<lable >INCEIF</lable>"}else{if(E==1){return"<lable >Other</lable>"}}}},onClickHandle:function(C,F,A,E){var D=E.target;if(D.id.match("rating")){if(D.src.match("images/star.png")){for(var B=D.id.substring(6);B<6;B++){D.parentNode.childNodes[B-1].src="images/star1.png"}}else{if(D.src.match("images/star1.png")){for(var B=D.id.substring(6);B>0;B--){D.parentNode.childNodes[B-1].src="images/star.png"}}}}},createLevelObj:function(){this.levelcm=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),{header:"Levels",dataIndex:"levelname",editor:new Wtf.form.TextField({allowBlank:false})}]);this.levelStore=new Wtf.data.JsonStore({url:"CountryList.jsp?mode=level",root:"data",fields:["levelid","levelname"]});this.levelStore.load()},createSkillObj:function(){this.skillcm=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),{header:"Skills",dataIndex:"skillname",editor:new Wtf.form.TextField({allowBlank:false})}]);this.skillStore=new Wtf.data.JsonStore({url:"CountryList.jsp?mode=skill",root:"data",fields:["skillid","skillname"]});this.skillStore.load()},createQualObj:function(){this.qualcm=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),{header:"Qualification",dataIndex:"qualname",editor:new Wtf.form.TextField({allowBlank:false})}]);this.qualStore=new Wtf.data.JsonStore({url:"CountryList.jsp?mode=qual",root:"data",fields:["qualid","qualname"]});this.qualStore.load()},createDeptObj:function(){this.deptcm=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),{header:"Department",dataIndex:"departmentname",editor:new Wtf.form.TextField({allowBlank:false})}]);this.deptStore=new Wtf.data.JsonStore({url:"CountryList.jsp?mode=dept",root:"data",fields:["departmentid","departmentname"]});this.deptStore.load()},createDesigObj:function(){this.desigcm=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),{header:"Designation",dataIndex:"designame",editor:new Wtf.form.TextField({allowBlank:false})}]);this.desigStore=new Wtf.data.JsonStore({url:"CountryList.jsp?mode=designation",root:"data",fields:["desigid","designame"]});this.desigStore.load()},openLevelMaster:function(){this.createLevelObj();this.levelMaster=new Wtf.Window({id:"levelmaster"+this.id,title:"Faculty Level Master",layout:"fit",iconCls:"winicon",modal:true,height:400,width:550,scope:this,items:[this.levelPanel=new Wtf.Panel({id:"levelpanel"+this.id,layout:"fit",cls:"backcolor",border:false,tbar:["-","New Faculty Level: ",this.levelText=new Wtf.form.TextField({anchor:"95%",id:this.id+"levelMasterText"}),"-",{text:"Add",tooltip:{title:"Add",text:"Click to add Faculty Levels"},handler:function(){this.addLevel()},scope:this},"-"],items:[this.addLevelPanel=new Wtf.Panel({id:"addLevel"+this.id,layout:"fit",border:false,items:[this.levelGrid=new Wtf.grid.EditorGridPanel({id:"levelgrid"+this.id,store:this.levelStore,cm:this.levelcm,border:false,loadMask:{msg:"Loading Faculty Levels..."},clicksToEdit:1,viewConfig:{forceFit:true}})]})]})]});this.levelMaster.show();this.levelMaster.on("close",function(){this.levelGrid.destroy();this.levelMaster.remove(this.levelGrid,true);this.levelMaster.destroy()},this);this.levelGrid.on("afteredit",this.levelAfterEdit,this)},openSkillMaster:function(){this.createSkillObj();this.skillMaster=new Wtf.Window({id:"skillmaster"+this.id,title:"Faculty Skill Master",layout:"fit",iconCls:"winicon",modal:true,height:400,width:550,scope:this,items:[this.skillPanel=new Wtf.Panel({id:"skillpanel"+this.id,layout:"fit",cls:"backcolor",border:false,tbar:["-","New Faculty Skill: ",this.skillText=new Wtf.form.TextField({anchor:"95%",id:this.id+"skillMasterText"}),"-",{text:"Add",tooltip:{title:"Add",text:"Click to add Faculty Skills"},handler:function(){this.addSkill()},scope:this},"-"],items:[this.addSkillPanel=new Wtf.Panel({id:"addSkill"+this.id,layout:"fit",border:false,items:[this.skillGrid=new Wtf.grid.EditorGridPanel({id:"skillgrid"+this.id,store:this.skillStore,cm:this.skillcm,border:false,loadMask:{msg:"Loading Faculty Skills..."},clicksToEdit:1,viewConfig:{forceFit:true}})]})]})]});this.skillMaster.show();this.skillMaster.on("close",function(){this.skillGrid.destroy();this.skillMaster.remove(this.skillGrid,true);this.skillMaster.destroy()},this);this.skillGrid.on("afteredit",this.skillAfterEdit,this)},openQualMaster:function(){this.createQualObj();this.qualMaster=new Wtf.Window({id:"qualmaster"+this.id,title:"Faculty Qualification Master",layout:"fit",iconCls:"winicon",modal:true,height:400,width:550,scope:this,items:[this.qualPanel=new Wtf.Panel({id:"qualpanel"+this.id,layout:"fit",cls:"backcolor",border:false,tbar:["-","New Faculty Qualification: ",this.qualText=new Wtf.form.TextField({anchor:"95%",id:this.id+"qualMasterText"}),"-",{text:"Add",tooltip:{title:"Add",text:"Click to add Faculty Qualification"},handler:function(){this.addQualification()},scope:this},"-"],items:[this.addQualPanel=new Wtf.Panel({id:"addQualification"+this.id,layout:"fit",border:false,items:[this.qualGrid=new Wtf.grid.EditorGridPanel({id:"qualgrid"+this.id,store:this.qualStore,cm:this.qualcm,loadMask:{msg:"Loading Qualification list..."},border:false,clicksToEdit:1,viewConfig:{forceFit:true}})]})]})]});this.qualMaster.show();this.qualMaster.on("close",function(){this.qualGrid.destroy();this.qualMaster.remove(this.qualGrid,true);this.qualMaster.destroy()},this);this.qualGrid.on("afteredit",this.qualAfterEdit,this)},openDeptMaster:function(){this.createDeptObj();this.deptMaster=new Wtf.Window({id:"deptmaster"+this.id,title:"Faculty Department Master",layout:"fit",iconCls:"winicon",modal:true,height:400,width:550,scope:this,items:[this.deptPanel=new Wtf.Panel({id:"deptpanel"+this.id,layout:"fit",cls:"backcolor",border:false,tbar:["-","New Faculty Department: ",this.deptText=new Wtf.form.TextField({anchor:"95%",id:this.id+"deptMasterText"}),"-",{text:"Add",tooltip:{title:"Add",text:"Click to add Faculty Department"},handler:function(){this.addDepartment()},scope:this},"-"],items:[this.addDeptPanel=new Wtf.Panel({id:"addDepartment"+this.id,layout:"fit",border:false,items:[this.deptGrid=new Wtf.grid.EditorGridPanel({id:"deptgrid"+this.id,store:this.deptStore,cm:this.deptcm,loadMask:{msg:"Loading Department list..."},border:false,clicksToEdit:1,viewConfig:{forceFit:true}})]})]})]});this.deptMaster.show();this.deptMaster.on("close",function(){this.deptGrid.destroy();this.deptMaster.remove(this.deptGrid,true);this.deptMaster.destroy()},this);this.deptGrid.on("afteredit",this.deptAfterEdit,this)},openDesigMaster:function(){this.createDesigObj();this.desigMaster=new Wtf.Window({id:"desigmaster"+this.id,title:"Faculty Designation Master",layout:"fit",iconCls:"winicon",modal:true,height:400,width:550,scope:this,items:[this.desigPanel=new Wtf.Panel({id:"desigpanel"+this.id,layout:"fit",cls:"backcolor",border:false,tbar:["-","New Faculty Designation: ",this.desigText=new Wtf.form.TextField({anchor:"95%",id:this.id+"desigMasterText"}),"-",{text:"Add",tooltip:{title:"Add",text:"Click to add Faculty Designation"},handler:function(){this.addDesignation()},scope:this},"-"],items:[this.addDesigPanel=new Wtf.Panel({id:"addDesignation"+this.id,layout:"fit",border:false,items:[this.desigGrid=new Wtf.grid.EditorGridPanel({id:"desiggrid"+this.id,store:this.desigStore,cm:this.desigcm,loadMask:{msg:"Loading Designation list..."},border:false,clicksToEdit:1,viewConfig:{forceFit:true}})]})]})]});this.desigMaster.show();this.desigMaster.on("close",function(){this.desigGrid.destroy();this.desigMaster.remove(this.desigGrid,true);this.desigMaster.destroy()},this);this.desigGrid.on("afteredit",this.desigAfterEdit,this)},levelAfterEdit:function(A){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"edit",type:"level",id:A.record.data.levelid,name:A.value},success:function(){},scope:this})},skillAfterEdit:function(A){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"edit",type:"skill",id:A.record.data.skillid,name:A.value},success:function(){},scope:this})},qualAfterEdit:function(A){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"edit",type:"qualification",id:A.record.data.qualid,name:A.value},success:function(){},scope:this})},deptAfterEdit:function(A){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"edit",type:"department",id:A.record.data.departmentid,name:A.value},success:function(){},scope:this})},desigAfterEdit:function(A){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"edit",type:"designation",id:A.record.data.desigid,name:A.value},success:function(){},scope:this})},addLevel:function(){if(this.levelText.getValue()){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"add",type:"level",name:this.levelText.getValue()},success:function(A,B){this.levelStore.reload()},scope:this});this.levelText.setValue("")}else{msgBoxShow(["Add Faculty Level","Please enter some text"])}},addSkill:function(){if(this.skillText.getValue()){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"add",type:"skill",name:this.skillText.getValue()},success:function(A,B){this.skillStore.reload()},scope:this});this.skillText.setValue("")}else{msgBoxShow(["Add Faculty Skill-Sets","Please enter some text"])}},addQualification:function(){if(this.qualText.getValue()){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"add",type:"qualification",name:this.qualText.getValue()},success:function(A,B){this.qualStore.reload()},scope:this});this.qualText.setValue("")}else{msgBoxShow(["Add Faculty Qualification","Please enter some text"])}},addDepartment:function(){if(this.deptText.getValue()){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"add",type:"department",name:this.deptText.getValue()},success:function(A,B){this.deptStore.reload()},scope:this});this.deptText.setValue("")}else{msgBoxShow(["Add Faculty Department","Please enter some text"])}},addDesignation:function(){if(this.desigText.getValue()){Wtf.Ajax.request({url:"jspfiles/admin/getMasterData.jsp",method:"POST",params:{action:"add",type:"designation",name:this.desigText.getValue()},success:function(A,B){this.desigStore.reload()},scope:this});this.desigText.setValue("")}else{msgBoxShow(["Add Faculty Designation","Please enter some text"])}},showProfile:function(B,C){var D=B.getStore().data.items[C].data["Id"];var A=B.getStore().data.items[C].data["Name"];mainPanel.loadTab("userProfile.html","mainuserProfile_"+D+"_disp",A,"navareadashboard",Wtf.etype.user)}});Wtf.onReady(function(){var A=hrTabs[0];hrTabs.remove(A);var B=new Wtf.TabPanel({id:hrTabs.id,deferredRender:false,activeTab:0,enableTabScroll:true,bodyStyle:"background:transparent;",items:[{layout:"fit",title:"Faculty List",iconCls:"facultyListIcon",items:new Wtf.DepartmentPanel({})},new Wtf.facSab({title:"Sabbatical Request"})]});A.add(B);A.doLayout()})