Ext.define("sessionusage.controller.Main",{extend:"Ext.app.Controller",refs:[{selector:"newUtilities",ref:"newUtilities"},{selector:"main",ref:"main"},{selector:"nomeasurepanel",ref:"nomeasurepanel"},{selector:"ReporterSettings",ref:"ReporterSettings"}],foregroundJspUrl:"/final/reporter/ErCtxSessionUsageReportJson.jsp",foregroundControllerUrl:"../servlet/com.eg.ErCtxSessionUsageReportC",backgroundControllerUrl:"../servlet/com.eg.ErStartBackGroundReportC",isNewFav:false,init:function(){this.control({"main":{"afterrender":this.boxready},"mainform":{"afterrender":this.loadForm},"newUtilities":{"render":this.loadTools},"sessionusagesettings":{"afterrender":this.loadSettings},'sessionusageform combo[name="er_type"]':{"select":this.onReportChange},'sessionusageform combo[name="select_farm"]':{"select":this.onZoneChange},'sessionusagesettings combo[name="reportGeneration"]':{"select":this.onChangeReportGeneration},'sessionusagesettings button[id="moreOptionCloseId"]':{"click":this.validateAndCloseSettings},'sessionusagesettings button[id="submitViaSetting"]':{"click":this.closeSettingAndSubmit},'sessionusageform combo[name="er_compType"]':{"select":this.onComponentTypeChange},'sessionusageform combo[name="erOsMachine_type"]':{"select":this.onMachineTypeChange},'sessionusageform button[name="submit"]':{"click":this.showResult},'egcomponent button[id="compExpand"]':{"click":this.expandMe},'egcomponent multiselect[id="er_component"]':{"change":this.onChangeComponent},'egcomponent trigger[id="compSearch"]':{"change":this.filterMultiselect},'application button[id="appExpand"]':{"click":this.expandMe},'application trigger[id="appSearch"]':{"change":this.filterMultiselect},"newUtilities > #printTool > button":{"click":this.printFile},"newUtilities > #saveTool > button":{"click":this.saveReportAsPDF},"newUtilities > #csvTool > button":{"click":this.saveCsv},"newUtilities > #mailTool > button":{"click":this.sendMail},"newUtilities > #favoriteTool > button":{"click":this.saveFavorite},"newUtilities > #scheduleTool > button":{"click":this.saveSchedule},'sessionusageform button[name="save"]':{"click":this.goTo},'mainform button[id="panelinsidetoggle"]':{"click":this.toggleForm},'mainform combo[id="er_option"]':{"select":this.onSelectAnalysisBy},'mainform combo[id="er_site"]':{"select":this.er_siteOnChange}});
},onChangeComponent:function(g,f,a){if(a==undefined||a=="undefined"){return;}var e=Ext.getCmp("er_option").getValue();var h="er_option="+e+"&er_type=No"+"&er_compType="+Ext.getCmp("er_compType").getValue();h+="&erOsMachine_type="+Ext.getCmp("erOsMachine_type").getValue();if(e=="Zone"){h+="&select_farm="+Ext.getCmp("select_farm").getValue();
}else{if(e=="Segment"||e=="Segment"){h+="&er_site="+Ext.getCmp("er_site").getValue();}}var d=g.getValue();for(var b in d){h+="&er_component="+d[b];}h+="&er_RmDispName="+appConstants.er_RmDispName;var c=this;Ext.Ajax.request({url:this.foregroundJspUrl,params:h,scope:this,success:function(i){appConstants.publicJsonData=Ext.decode(i.responseText);
c.loadApplications();}});},onSelectAnalysisBy:function(b){var a=b.getValue();var c="er_option="+a+"&er_type=No";this.getAjaxData(this.foregroundJspUrl,c);this.loadComboField("er_compType","componentTypeCombo","componentTypeLabel","componentTypeSelected",appConstants.publicJsonData,false,null,true);this.loadComboField("erOsMachine_type","MachineTypeTypeArry","machineTypeLabel","selectedMachineType",appConstants.publicJsonData,false,null,true);
if(a=="Component"){Ext.getCmp("select_farm").hide();Ext.getCmp("er_site").hide();}else{if(a=="Zone"){Ext.getCmp("select_farm").show();Ext.getCmp("er_site").hide();this.loadComboField("select_farm","zoneCombo","zoneLabel","zoneSelected",appConstants.publicJsonData,false,null,true);}else{Ext.getCmp("select_farm").hide();
this.loadComboField("er_site","siteCombo","siteComboLabel","selectedSiteCombo",appConstants.publicJsonData,false,null,true);}}this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",false);this.loadDataForReportChange();
this.loadApplications();},er_siteOnChange:function(a){var c=a.getValue();var b="er_option="+Ext.getCmp("er_option").getValue()+"&er_site="+Ext.getCmp("er_site").getValue()+"&er_type=No";this.getAjaxData(this.foregroundJspUrl,b);this.loadComboField("er_compType","componentTypeCombo","componentTypeLabel","componentTypeSelected",appConstants.publicJsonData,false,null,true);
this.loadComboField("erOsMachine_type","MachineTypeTypeArry","machineTypeLabel","selectedMachineType",appConstants.publicJsonData,false,null,true);this.loadDataForReportChange();this.loadApplications();},goTo:function(a){if(appConstants.frmSchModify=="Yes"){this.saveSchedule(a);}else{this.saveFavorite(a);
}},saveSchedule:function(d){if(Ext.getCmp("er_timeline").getValue()=="Any"){Ext.MessageBox.show({title:"Session Usage",msg:"Chosen timeline not allowed",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}else{if(!this.validateMainForm(false)){return false;}}var c="/final/reporter/ErSaveSchedule.jsp?"+this.getQueryString(true,true,true)+"&com.eg.CSRF_NONCE="+csrfToken;
if(d.getId()=="save"){if(c!=undefined&&c.indexOf("schedule_id")==-1){c+="&schedule_id="+appConstants.schedule_id;}c+="&showSchWindow=no";var b=c.substr(0,c.indexOf("?"));var e=c.substr(c.indexOf("?")+1,c.length-1);var a=Ext.create("Ext.form.Panel");a.submit({url:b,params:e,standardSubmit:true,method:"POST"});
}else{parent.scheduleWindowFn(c);}},saveFavorite:function(d){if(!this.validateMainForm(false)){return false;}var c="";if(d.getId()=="save"){this.isNewFav=false;c="/final/reporter/ErSaveFavorite.jsp?"+this.getQueryString(true,true,true)+"&er_view=GRAPH&cmd=client&fromFavoriteModify=Yes"+"&er_RmDispName="+appConstants.er_RmDispName+"&com.eg.CSRF_NONCE="+csrfToken;
if(c!=undefined&&c.indexOf("FavoriteId")==-1){c+="&FavoriteId="+appConstants.favorite_id;}c+="&showSchWindow=no";var b=c.substr(0,c.indexOf("?"));var e=c.substr(c.indexOf("?")+1,c.length-1);var a=Ext.create("Ext.form.Panel");a.submit({url:b,params:e,standardSubmit:true,method:"POST"});}else{this.isNewFav=true;
c="../servlet/com.eg.ErFavoriteC?"+this.getQueryString(true,true,true)+"&er_view=GRAPH&cmd=client"+"&er_RmDispName="+appConstants.er_RmDispName+"&com.eg.CSRF_NONCE="+csrfToken;parent.favouriteWindowFn(c);}},saveReportAsPDF:function(){var a="../reporter/ErHtmlToSavePdf.jsp?"+appConstants.publicJsonData.urlFields.saveQueryString;
if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");}appConstants.erUtils.savePDF(a);},bookletQuery:function(b){var a=appConstants.publicJsonData.urlFields.saveQueryString;return a;},bookletScheduleQuery:function(b){var a=this.getQueryString(true,true,true);return a;},bookletPreview:function(){this.printFile();
},printFile:function(){var a="/final/reporter/ErCtxSessionUsageReportPrint.jsp?"+appConstants.publicJsonData.urlFields.saveQueryString+"&er_view=PRINT&pdfPrint=yes";parent.printWindowFn(a);},sendMail:function(){Ext.widget("sendmail").show();},saveCsv:function(){window.location=this.foregroundControllerUrl+"?optionType=CSV";
},filterMultiselect:function(a){a.toggleTriggger();if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");}if(a.getId()=="compSearch"){appConstants.erUtils.filterComboStore(a,Ext.getCmp("er_component"),appConstants.publicJsonData.combo.componentCombo);}else{if(a.getId()=="appSearch"){appConstants.erUtils.filterComboStore(a,Ext.getCmp("er_application"),appConstants.publicJsonData.combo.applicationCombo);
}}},expandMe:function(a){if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");}if(a.getId()=="compExpand"){appConstants.erUtils.expandMultiComboButton(Ext.getCmp("er_component"),"Components",a);}else{if(a.getId()=="appExpand"){appConstants.erUtils.expandMultiComboButton(Ext.getCmp("er_application"),"Application",a);
}}},loadReportData:function(){var d=Ext.getCmp("resultContainer");var g=appConstants.publicJsonData.selectedFields.reportGenerationSelected;this.hideResults();var i=Ext.getCmp("er_stdate").getValue();i.setHours(Ext.getCmp("er_sthr").getValue());var o=Ext.getCmp("er_enddate").getValue();o.setHours(Ext.getCmp("er_endhr").getValue());
var k=checkDateTime(i,o);if(!k){return;}if(g=="foreground"){Ext.getCmp("panelinsidetoggle").setDisabled(false);d.removeAll();var a=appConstants.publicJsonData.isDataAvailable;if(a){Ext.getCmp("panelinsidetoggle").show();this.enableTools();Ext.getCmp("selectionDetails").setSelectionDetailsData(appConstants.publicJsonData.selectionDetails);
var m=appConstants.publicJsonData.stateDataObj;var j=appConstants.publicJsonData.overViewJson;var u='<table align="center" style="width:100%;"><tr><td width="16%">'+'<table  width="100%" align="center" cellspacing="0" cellpadding="0" border="0" style="align:center;margin:0px 5px 5px 5px;"><tr><td colspan="1" rowspan="1"><table align="center"><tr><td align="right" style="padding-right:5px"><div class="iconTotalSessions"></div></td><td class="newFont_bold28">'+j["totalSession"]+'</td></tr></table></td></tr><tr style="text-align: center;"><td colspan="1" rowspan="1" class="newFont_normal13">Total Sessions</td></tr></table></td><td width="22%">'+'<table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"><tr><td colspan="1" rowspan="1"><table align="center" style="align:center;margin:auto;"><tr><td align="right" style="padding-right:5px"><div class="iconUniquePools"></div></td><td class="newFont_bold28">'+j["uniquePool"]+'</td></tr></table></td></tr><tr style="text-align: center;"><td colspan="1" rowspan="1" class="newFont_normal13">Unique Delivery Groups</td></tr></table></td><td width="16%">'+'<table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"><tr><td colspan="1" rowspan="1"><table align="center" style="align:center;margin:auto;"><tr><td align="right" style="padding-right:5px"><div class="iconUniqueUsers"></div></td><td class="newFont_bold28">'+j["uniqueUser"]+'</td>	</tr></table></td></tr><tr style="text-align: center;"><td colspan="1" rowspan="1" class="newFont_normal13">Unique Users</td></tr></table></td>'+'<td width="23%"><table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"><tr><td colspan="1" rowspan="1"><table align="center" style="align:center;margin:auto;"><tr><td align="right" style="padding-right:5px"><div class="iconDuration"></div></td><td class="newFont_bold28">'+j["maxDuration"]+'</td>	</tr></table></td></tr><tr style="text-align: center;"><td colspan="1" rowspan="1" class="newFont_normal13">Max Duration</td></tr></table></td>'+'<td width="23%"><table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"><tr><td colspan="1" rowspan="1"><table align="center" style="align:center;margin:auto;"><tr><td align="right" style="padding-right:5px"><div class="iconDuration"></div></td><td class="newFont_bold28">'+j["avgDuration"]+'</td></td></tr></table></td></tr><tr style="text-align: center;"><td colspan="1" rowspan="1" class="newFont_normal13">Avg Duration</td></tr></table></td>'+"</tr></table>";
d.add({xtype:"panel",ui:"newGraphPanel",height:100,margin:"10 10 5 10",title:"Overview",items:[{xtype:"container",html:u,}]});var f=20;d.add({xtype:"panel",id:"sessionChart2",layout:"column",style:{"border":"0px !important",},height:290});var s=appConstants.publicJsonData["deliveryGrpSessChart"];titleStr=s["title"];
s["title"]="";var v='<div id="poolChartBar" style="height:95%;width:100%;overflowY:hidden;padding-right:10px;"></div>';Ext.getCmp("sessionChart2").add({xtype:"panel",title:titleStr,ui:"newGraphPanel",layout:"column",columnWidth:0.5,margin:"5 5 0 10",height:275,html:v,listeners:{"boxready":function(){var y={};
y=jQuery.extend(true,{},getHighChartsBarInstance("poolChartBar",s.chartHeight+f,s.chartWidth),y);y.setData(s,"<%=currentDateFormat%>","");y.drawChart();}}});var c=appConstants.publicJsonData["deliveryGrpUserChart"];titleStr=c["title"];c["title"]="";var t='<div id="poolUser" style="height:95%;width:100%;overflowY:hidden;padding-right:10px;"></div>';
Ext.getCmp("sessionChart2").add({xtype:"panel",title:titleStr,ui:"newGraphPanel",layout:"column",margin:"5 10 0 5",columnWidth:0.5,height:275,html:t,listeners:{"boxready":function(){var y={};y=jQuery.extend(true,{},getHighChartsBarInstance("poolUser",c.chartHeight+f,c.chartWidth),y);y.setData(c,"<%=currentDateFormat%>","");
y.drawChart();}}});var e=appConstants.publicJsonData["stateTrendChart"];titleStr=e["title"];e["title"]="";var b='<div id="stateTrend" style="height:95%;width:100% !important;overflowY:hidden;padding-top:10px"></div>';d.add({xtype:"panel",ui:"newGraphPanel",title:titleStr,margin:"0 10 10 10",height:350,html:b,listeners:{"boxready":function(){var y={};
y=jQuery.extend(true,{},getHighChartsBarInstance("stateTrend",300,1020),y);y.setData(e,"<%=currentDateFormat%>","");y.drawChart();}}});var r=appConstants.publicJsonData.gridData;if(r.length>0){this.loadGrid(appConstants.publicJsonData,r);}d.show();}else{Ext.getCmp("panelinsidetoggle").hide();this.disableTools();
this.getNomeasurepanel().show();}}else{if(g=="background"){var n=Ext.getCmp("backGroundPanel");var q=appConstants.publicJsonData.labelFields.bgStatus;Ext.getCmp("selectionDetails").setSelectionDetailsData(appConstants.publicJsonData.selectionDetails);if(q=="success"){var w=appConstants.publicJsonData.labelFields.bgResponseText;
var p=appConstants.publicJsonData.labelFields.bgAnchor;var l=appConstants.publicJsonData.urlFields.bgUrl;var h=p;n.update('<table border="0px" width="100%" height="100%"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconSuccess"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+w+".</br>"+'<a class="backgroundMsgLink" href='+l+">"+h+"</a></div></td></tr></table></td></tr></table>");
}else{if(q=="duplicate"){var w=appConstants.publicJsonData.labelFields.bgResponseText;var p=appConstants.publicJsonData.labelFields.bgAnchor;var l=appConstants.publicJsonData.urlFields.bgUrl;var h=p;n.update('<table border="0px" width="100%" height="100%" align="center"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconExclamation"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+w+".</br>"+'<a class="backgroundMsgLink" href='+l+">"+h+"</a></div></td></tr></table></td></tr></table>");
}else{var w=appConstants.publicJsonData.labelFields.bgResponseText;n.update('<table border="0px" width="100%" height="100%"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconExclamation"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+w+"</div></td></tr></table></td></tr></table>");
}}n.show();}else{if(g=="background-csv"){var n=Ext.getCmp("backGroundPanel");var x=Ext.getCmp("bgReportName").getValue();x=checkFileName(x);var q=appConstants.publicJsonData.labelFields.bgStatus;if(q!="undefined"){if(q=="success"){var w=appConstants.publicJsonData.labelFields.bgResponseText;var p=appConstants.publicJsonData.labelFields.bgAnchor;
var l=appConstants.publicJsonData.urlFields.bgUrl;var h=p;n.update('<table border="0px" width="100%" height="100%"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconSuccess"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+w+".</br>"+'<a class="backgroundMsgLink" href='+l+">"+h+"</a></div></td></tr></table></td></tr></table>");
}else{if(q=="duplicate"){var w=appConstants.publicJsonData.labelFields.bgResponseText;var p=appConstants.publicJsonData.labelFields.bgAnchor;var l=appConstants.publicJsonData.urlFields.bgUrl;var h=p;n.update('<table border="0px" width="100%" height="100%"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconExclamation"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+w+".</br>"+'<a class="backgroundMsgLink" href='+l+">"+h+"</a></div></td></tr></table></td></tr></table>");
}else{var w=appConstants.publicJsonData.labelFields.bgResponseText;n.update('<table border="0px" width="100%" height="100%"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconExclamation"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+w+"</div></td></tr></table></td></tr></table>");
}}}else{n.update('<table border="0px" width="100%" height="100%"><tr><td align="center" valign="middle"><table style="width:480px;"border="0px"><tr><td><div style="margin:0px 10px 0px 0px;display:block;width:32px;height:32px;float:right;" class="iconExclamation"></div></td><td><div style="line-height:1.5em" class="font_bold11">Error In BackGround Generation</div></td></tr></table></td></tr></table>');
}n.show();}else{console.log("No data found for report generation in json");}}}},loadGrid:function(f,p){var s=this;var m=Ext.getCmp("resultContainer");var a=f.gridCol;var b=new Array();var j=new Array();var i=f.subGridCol;var v="Session Details";var k=appConstants.publicJsonData.selectedFields.userDomainSelected;
var q="../servlet/com.eg.ErCtxUserLogonReportC";var e=120;if(k!=undefined&&(k=="Yes")){e=230;}for(var u in a){var n="left";var c=a[u];var r=100;if(c!=undefined&&(c==" ")){r=40;}if(c!=undefined&&(c=="Username")){r=e;}if(c!=undefined&&(c=="Client Name"||c=="Logon Duration (Sec)"||c=="Client Address"||c=="Application Name"||c=="Client version")){r=130;
}if(c!=undefined&&(c=="Machine Name"||c=="End Time"||c=="Start Time"||c=="Delivery Group")){r=150;}j.push(c);if(c=="Logon Duration (Sec)"){c="Logon Duration (Sec)";n="center";}else{if(c=="Duration"){n="center";}}b.push({header:c,sortable:true,width:r,align:n,dataIndex:c,renderer:function(H,y,E,J,A,I,w){if((H!=undefined&&H.indexOf("~logonDetail")>-1)){var C=E.data["Logon Duration (Sec)"];
var F=E.data["End Time"];if(C!="-"||true){var B=H.substring(0,H.indexOf("~"));var z=H.substring(H.indexOf("&"));var D=appConstants.publicJsonData.hiddenFields["inidate"];var G=Ext.getCmp("er_compType").getValue();if(F=="<center>-</center>"){F="-";}var x=q+"?reportFor=Citrix&sessionKey="+B+"&view=ui&userFormat="+D+"&logonDuration="+C+"&sessionEndTime="+F+z;
H='<div align="center" style="margin-top:-2px;"><img src="/final/images/spacer.gif" onClick="javascript:loadUsersSessionView(\''+x+'\')"  class="iconReportDetails" /></div>';}else{H="<center>-</center>";}y.tdAttr="data-qtip=Details";}else{y.tdAttr='data-qtip="'+H+'"';}return H;},doSort:function(x){var w=this.up("grid").store;
var y=this.getSortParam();if(y=="Duration"){y="durationMilli";}w.sort({property:y,direction:x,sorterFn:function(G,E){G=G.get(y);E=E.get(y);if(y=="End Time"){var z=new Date();var F=appConstants.publicJsonData.hiddenFields["inidate"];var A=Ext.Date.dateFormat(z,getExtjsDateFormat(F));A+=" "+new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds();
if(G=="<center>-</center>"){G=A;}else{if(E=="<center>-</center>"){E=A;}}}if(G.indexOf(".")>-1&&G.indexOf(" ")>-1){var C=G.substring(0,G.lastIndexOf(" "));var D=new Date(Ext.Date.parse(C,mgrDateFormat));var B=Ext.Date.dateFormat(D,getExtjsDateFormat("MMM-dd-yyyy"));G=B+G.substring(G.lastIndexOf(" "),G.length);
}if(E.indexOf(".")>-1&&E.indexOf(" ")>-1){var C=E.substring(0,E.lastIndexOf(" "));var D=new Date(Ext.Date.parse(C,mgrDateFormat));var B=Ext.Date.dateFormat(D,getExtjsDateFormat("MMM-dd-yyyy"));E=B+E.substring(E.lastIndexOf(" "),E.length);}if(!isNaN(G)&&!isNaN(E)){G=Ext.isNumber(G)?G:parseFloat(String(G),10);
E=Ext.isNumber(E)?E:parseFloat(String(E),10);if(x=="ASC"){G=isNaN(G)?999999:G;E=isNaN(E)?999999:E;}else{G=isNaN(G)?0:G;E=isNaN(E)?0:E;}}else{if(!isNaN(new Date(G))&&!isNaN(new Date(E))){E=new Date(E).getTime();G=new Date(G).getTime();}}return G>E?1:(G<E?-1:0);}});},});}var l=15;var g=false;if(p!=undefined&&p.length<l){g=true;
}j.push("app");j.push("durationMilli");var d=Ext.create("Ext.data.Store",{fields:j,proxy:{type:"pagingmemory",reader:{type:"json",root:"data",totalProperty:"total"}},data:p,pageSize:l,autoLoad:true,});var o=1;var t=new Array();var h=true;if(a.length>6){h=false;}t.push({columnWidth:1,margin:"10 10 10 10",xtype:"customgridwithsearch",gridTitle:'<span class="newFont_bold14">'+v+"</span>",gridData:p,fieldsToStore:j,pageLimit:15,jsonType:"json",columnVal:b,sortIndex:7,sortOrder:"DESC",forceFit:h,isPagingHidden:g,gridScroll:true,gridAutoScroll:true,});
m.add({xtype:"panel",margin:"10 10 10 10",padding:"0 0 0 0",ui:"newGraphPanel",layout:{type:"column",align:"stretch",},items:t});m.show();},showResult:function(a){var b;if(isSettingsEnabled){b=Ext.getCmp("reportGeneration").getValue();}else{b=appConstants.publicJsonData.selectedFields.reportGenerationSelected;
}if(b=="foreground"&&this.validateMainForm(true)){this.getAjaxDataForSubmit(this.foregroundControllerUrl,this.getQueryString(true,true,true));}else{if(b=="background-csv"&&this.validateMainForm(true)){this.getAjaxDataForSubmit("../servlet/com.eg.ErStartBackGroundReportC?isSubmit=true&SaveFormat=CSV",this.getQueryString(true,true,true));
}else{if(b=="background"&&this.validateMainForm(true)){this.getAjaxDataForSubmit(this.backgroundControllerUrl,this.getQueryString(true,true,true));}}}},typewatch:function(b,a){this.searchTask.delay(1000);},doFilter:function(){var h=Ext.getCmp("livesearch");var a=Ext.getCmp("mainGrid").dataArray;var c=Ext.getCmp("mainGrid").dummyArray;
if(Ext.String.trim(h.value).length>0&&(Ext.String.trim(h.value)!=""||Ext.String.trim(h.value)!=null)){Ext.getCmp("mainGrid").getStore().removeAll();var b=h.value;b=b.replace("\\","\\\\");var f=RegExp(b,"i");a.splice(0,a.length);for(var e in c){var d=false;var g=c[e];Ext.Object.each(g,function(j,i){d=d||f.test(String(i));
});if(d){a.push(g);}}Ext.getCmp("mainGrid").getStore().load();}else{Ext.getCmp("mainGrid").getStore().removeAll();a.splice(0,a.length);for(var e in c){var g=c[e];a.push(g);}Ext.getCmp("mainGrid").getStore().loadRawData(a);Ext.getCmp("mainGrid").getStore().load();}h.focus();h.toggleTriggger();},disableTools:function(){Ext.getCmp("saveTool").setDisabled(true);
Ext.getCmp("bookletTool").setDisabled(true);Ext.getCmp("printTool").setDisabled(true);Ext.getCmp("mailTool").setDisabled(true);Ext.getCmp("csvTool").setDisabled(true);},enableTools:function(){Ext.getCmp("saveTool").setDisabled(false);Ext.getCmp("bookletTool").setDisabled(false);Ext.getCmp("printTool").setDisabled(false);
Ext.getCmp("mailTool").setDisabled(false);Ext.getCmp("csvTool").setDisabled(false);},hideResults:function(){Ext.getCmp("resultContainer").hide();Ext.getCmp("backGroundPanel").hide();this.getNomeasurepanel().hide();},onChangeReportGeneration:function(a){this.hideResults();this.disableTools();Ext.getCmp("submitViaSetting").show();
Ext.getCmp("moreOptionCloseId").hide();if(a.getValue()=="background"){Ext.getCmp("bgReportName").setValue("");Ext.getCmp("bgReportName").show();}else{if(a.getValue()=="background-csv"){Ext.getCmp("bgReportName").setValue("");Ext.getCmp("bgReportName").show();}else{Ext.getCmp("bgReportName").hide();Ext.getCmp("submitViaSetting").hide();
Ext.getCmp("moreOptionCloseId").show();}}},onComponentTypeChange:function(b){this.hideResults();this.getAjaxData(this.foregroundJspUrl,this.getQueryString(true,false,false));var a=Ext.getCmp("er_compType").getValue();this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",true);
Ext.getCmp("componentpane").show();this.loadApplications();},onMachineTypeChange:function(b){this.hideResults();this.getAjaxData(this.foregroundJspUrl,this.getQueryString(true,false,false));var a=Ext.getCmp("er_compType").getValue();this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",true);
Ext.getCmp("componentpane").show();this.loadApplications();},onZoneChange:function(b){this.hideResults();var c="er_option="+Ext.getCmp("er_option").getValue()+"&select_farm="+Ext.getCmp("select_farm").getValue()+"&er_type=No";var a=Ext.getCmp("er_compType").getValue();this.getAjaxData(this.foregroundJspUrl,c);
this.loadComboField("er_compType","componentTypeCombo","componentTypeLabel","componentTypeSelected",appConstants.publicJsonData,false,null,true);this.loadComboField("erOsMachine_type","MachineTypeTypeArry","machineTypeLabel","selectedMachineType",appConstants.publicJsonData,false,null,true);var a=Ext.getCmp("er_compType").getValue();
this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",true);Ext.getCmp("componentpane").show();this.loadApplications();},loadDataForReportChange:function(){var a=Ext.getCmp("er_compType").getValue();this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",true);
Ext.getCmp("componentpane").show();},onReportChange:function(c){this.hideResults();var b=Ext.getCmp("er_option").getValue();var d="er_option="+b+"&er_type=No";if(b=="Zone"){d+="&select_farm="+Ext.getCmp("select_farm").getValue();}else{if(b=="Segment"||b=="Service"){d+="&er_site="+Ext.getCmp("er_site").getValue();
}}var a=Ext.getCmp("er_compType").getValue();this.getAjaxData(this.foregroundJspUrl,d);this.loadComboField("er_compType","componentTypeCombo","componentTypeLabel","componentTypeSelected",appConstants.publicJsonData,false,null,true);this.loadComboField("erOsMachine_type","MachineTypeTypeArry","machineTypeLabel","selectedMachineType",appConstants.publicJsonData,false,null,true);
this.loadDataForReportChange();this.loadApplications();},getAjaxData:function(a,b){Ext.Ajax.request({url:a,params:b,async:false,scope:this,success:function(c){appConstants.publicJsonData=Ext.decode(c.responseText);}});},getAjaxDataForSubmit:function(a,c){var b=this;Ext.Ajax.request({url:a,params:c,scope:this,success:function(d){appConstants.publicJsonData=Ext.decode(d.responseText);
b.loadReportData();}});},getQueryString:function(k,i,q){var e;var o,v,f,t,w,c,y,j,s,d;if(isSettingsEnabled){o=Ext.getCmp("timefrom").getValue();v=Ext.getCmp("minfrom").getValue();f=Ext.getCmp("timeto").getValue();t=Ext.getCmp("minto").getValue();w=Ext.getCmp("er_excwe").getValue();d=Ext.getCmp("er_userDomain").getValue();
c=Ext.getCmp("reportGeneration").getValue();y=Ext.getCmp("bgReportName").getValue();s=Ext.getCmp("er_groupBy").getValue();}else{var n=appConstants.publicJsonData.selectedFields;o=n.selectedTimeFrom;v=n.selectedMinsFrom;f=n.selectedTimeTo;t=n.selectedMinsTo;w=n.excludeWeekendsSelected;d=n.userDomainSelected;
c=n.reportGenerationSelected;y=n.reportNameSelected;s=n.groupBySelected;}var u=Ext.getCmp("er_option").getValue();e="er_type=No";if(u=="Zone"){e+="&select_farm="+Ext.getCmp("select_farm").getValue();}else{if(u=="Segment"||u=="Service"){e+="&er_site="+Ext.getCmp("er_site").getValue();}}if(k){e+="&er_compType="+Ext.getCmp("er_compType").getValue()+"&er_option="+Ext.getCmp("er_option").getValue();
}e+="&erOsMachine_type="+Ext.getCmp("erOsMachine_type").getValue();if(q){var p=Ext.getCmp("er_stdate").dataArray;var a=Ext.getCmp("er_enddate").dataArray;var h=Ext.getCmp("er_sthr").dataArray;e+="&er_timeline="+Ext.getCmp("er_timeline").getValue()+"&startdate="+p+"&enddate="+a+"&starthr="+Ext.getCmp("er_sthr").dataArray+"&endhr="+Ext.getCmp("er_endhr").dataArray+"&startmin="+mgr_stmin+"&endmin="+mgr_enmin;
e+="&timefrom="+o+"&minfrom="+v+"&timeto="+f+"&minto="+t;e+="&er_excwe="+w+"&isUserDomain="+d;if(c=="foreground"){e+="&er_reportgenration="+c+"&isSubmit=true&responseType=json";}else{y=checkFileName(y);e+="&er_reportgenration="+c+"&bg_reportname="+y+"&isSubmit=true";}}if(i){var b=new Array();b=Ext.getCmp("er_application").getValue();
for(var x in b){e+="&er_application="+encodeURIComponent(b[x]);}if(appConstants.publicJsonData.hasOwnProperty("hiddenFields")){var m=appConstants.publicJsonData.hiddenFields;for(var g in m){if(this.isNewFav!=undefined&&this.isNewFav){if(g!=undefined&&g=="ID"){continue;}if(g!=undefined&&g=="FavoriteId"){continue;
}}e+="&"+g+"="+m[g];}}}e+="&er_RmDispName="+appConstants.er_RmDispName;e+="&chartType="+appConstants.chartType;if(i){var b=new Array();b=Ext.getCmp("er_component").getValue();for(var x in b){e+="&er_component="+b[x];}var r=Ext.getCmp("er_compType").getValue();}var r=Ext.getCmp("er_compType").getValue();
e+="&er_groupBy=User&er_detailsBasedOn=user";var l=appConstants.vmComponentListEntry.indexOf(r);if(l>=0){e+="&isVmComp=true";}return e;},boxready:function(){registerAjaxEvents();var a=this;if(!appConstants.hideBackButton){Ext.getCmp("mainform").add({xtype:"hidden",id:"ID",name:"ID",value:appConstants.publicJsonData["ID"]});
}this.getMain().setTitle(appConstants.er_RmDispName);if(appConstants.frmFavModify!=undefined&&appConstants.frmFavModify=="Yes"){return;}if(appConstants.frmSchModify!=undefined&&appConstants.frmSchModify=="Yes"){return;}if(appConstants.isForceSubmit=="true"){this.loadReportData(appConstants.publicjsonData);
}else{if(appConstants.isSubmit=="true"){this.loadReportData(appConstants.publicjsonData);}}},loadForm:function(){this.loadFormFields();var d=appConstants.frmSchModify;var a=appConstants.frmFavModify;if(d=="Yes"||a=="Yes"){Ext.getCmp("submit").hide();Ext.getCmp("save").show();Ext.getCmp("favoriteTool").setDisabled(true);
Ext.getCmp("scheduleTool").setDisabled(true);}else{Ext.getCmp("submit").show();Ext.getCmp("save").hide();}var c=appConstants.publicJsonData.selectedFields.startDateForDisplay;var b=Ext.getCmp("er_stdate");b.setValue(c);b.dataArray=c;c=appConstants.publicJsonData.selectedFields.endDateForDisplay;b=Ext.getCmp("er_enddate");
b.setValue(c);b.dataArray=c;Ext.getCmp("er_sthr").setValue(appConstants.publicJsonData.selectedFields.startHourForDisplay);Ext.getCmp("er_endhr").setValue(appConstants.publicJsonData.selectedFields.endHourForDisplay);Ext.getCmp("er_sthr").dataArray=appConstants.publicJsonData.selectedFields.startHour;
Ext.getCmp("er_endhr").dataArray=appConstants.publicJsonData.selectedFields.endHour;stmin=appConstants.publicJsonData.selectedFields.startMinForDisplay;enmin=appConstants.publicJsonData.selectedFields.endMinForDisplay;mgr_stmin=appConstants.publicJsonData.selectedFields.startmin;mgr_enmin=appConstants.publicJsonData.selectedFields.endmin;
},loadFormFields:function(){this.loadComboField("er_option","analysisByCombo","","selectedAnalysisByCombo",appConstants.publicJsonData,false,null,true);this.loadComboField("select_farm","zoneCombo","zoneLabel","zoneSelected",appConstants.publicJsonData,false,null,true);this.loadComboField("er_compType","componentTypeCombo","componentTypeLabel","componentTypeSelected",appConstants.publicJsonData,false,null,true);
this.loadComboField("erOsMachine_type","MachineTypeTypeArry","machineTypeLabel","selectedMachineType",appConstants.publicJsonData,false,null,true);this.loadComboField("er_timeline","timelineCombo","","selectedTimeline",appConstants.publicJsonData,false,null,false);this.loadComboField("er_site","siteCombo","siteComboLabel","selectedSiteCombo",appConstants.publicJsonData,false,null,true);
var a=Ext.getCmp("er_compType").getValue();this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",true);Ext.getCmp("componentpane").show();this.loadComboField("er_application","applicationCombo","applicationLabel","applicationSelected",appConstants.publicJsonData,true,"applicationpane",true);
this.loadApplications();},loadApplications:function(){this.loadComboField("er_application","applicationCombo","applicationLabel","applicationSelected",appConstants.publicJsonData,true,"applicationpane",true);},loadSettings:function(){var c=appConstants.publicJsonData.hiddenFields;var b=c["FavoriteId"];
if(!Ext.isEmpty(b)){Ext.getCmp("reportGeneration").setDisabled(true);}this.loadComboField("er_excwe","excludeWeekendsCombo","excludeWeekendsLabel","excludeWeekendsSelected",appConstants.publicJsonData,false,null,true);this.loadComboField("reportGeneration","reportGenerationCombo","reportGenerationLabel","reportGenerationSelected",appConstants.publicJsonData,false,null,true);
this.loadComboField("er_userDomain","userDomainCombo","userDomainLabel","userDomainSelected",appConstants.publicJsonData,false,null,true);var a=appConstants.publicJsonData.selectedFields;Ext.getCmp("timefrom").setValue(a.selectedTimeFrom);Ext.getCmp("minfrom").setValue(a.selectedMinsFrom);Ext.getCmp("timeto").setValue(a.selectedTimeTo);
Ext.getCmp("minto").setValue(a.selectedMinsTo);if(a.hasOwnProperty("reportNameSelected")){Ext.getCmp("bgReportName").setValue(a.reportNameSelected);}a=null;delete a;},showConfigDropdown:function(){Ext.widget("configform");isSettingsEnabled=true;var a=this;Ext.get("closeSettings").on("click",function(){a.validateAndCloseSettings();
});},validateAndCloseSettings:function(){if(this.validateSettings()){Ext.get("configMod").animate({duration:500,to:{y:-500}});return true;}return false;},closeSettingAndSubmit:function(){if(this.validateAndCloseSettings()){this.showResult();}},loadComboField:function(c,f,g,i,e,b,j,k){var h=Ext.ComponentManager.get(c);
if(e.combo.hasOwnProperty(f)){var a=e.combo[f];h.getStore().clearFilter(true);h.getStore().loadRawData(a);if(e.selectedFields.hasOwnProperty(i)){h.setValue(e.selectedFields[i]);}else{h.setValue(a[0].valueField);}if(k){if(e.labelFields.hasOwnProperty(g)){if(!b){h.setFieldLabel(e.labelFields[g]);}else{Ext.ComponentManager.get(j).setFieldLabel(e.labelFields[g]);
}}}if(!b){if(h.isHidden()){h.show();}}else{var d=Ext.ComponentManager.get(j);if(d.isHidden()){d.show();}}}else{if(!b){if(!h.isHidden()){h.hide();}}else{var d=Ext.ComponentManager.get(j);if(!d.isHidden()){d.hide();}}}},loadTools:function(){this.getNewUtilities().loadIcon(true,true,true,false,true,true,true,false,false,false,true);
Ext.getCmp("favoriteTool").setDisabled(false);Ext.getCmp("scheduleTool").setDisabled(false);},toggleForm:function(b){Ext.getCmp("panelinsidetoggle").show();var a=Ext.getCmp("mainform");if(a.isHidden()){a.show();Ext.getCmp("selectionDetails").hide();}else{a.hide();Ext.getCmp("selectionDetails").show();
}},getMessageBox:function(b,a){Ext.MessageBox.show({title:b,msg:a,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;},validateMainForm:function(l){var b=appConstants.publicJsonData.hiddenFields;var f=b.getMaxDaysInMonth;var g=b.userTimeline;var i=Ext.getCmp("er_timeline").getValue();
var m=Ext.getCmp("er_stdate").getValue();var a=Ext.getCmp("er_enddate").getValue();var e=Ext.getCmp("er_sthr").getValue();var k=Ext.getCmp("er_endhr").getValue();m.setHours(e);a.setHours(k);var c=appConstants.publicJsonData.selectedFields.reportGenerationSelected;if(isSettingsEnabled){c=Ext.getCmp("reportGeneration").getValue();
}if(g!=null&&g!="-1"){var o=isUserTimelineLimitExceeded(g,f,m,a);if(!o){Ext.MessageBox.show({title:"Operation Reports Settings",msg:_invalidUserTime,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}var h="Session Usage";obj=Ext.getCmp("er_compType");if(obj.getValue()=="-1"){this.getMessageBox(h,obj.getStore().getAt(0).get("displayField"));
return false;}obj=Ext.getCmp("er_component");var p=obj.getValue();if(p=="-1"){this.getMessageBox(h,obj.getStore().getAt(0).get("displayField"));return false;}if(p.length==0){this.getMessageBox(h,"Please choose Components");return false;}var j="All Components and Individual selection cannot be selected simultaneously";
if((Ext.Array.contains(p,"All")||Ext.Array.contains(p,"all"))&&p.length>1){Ext.MessageBox.show({title:alert_text,msg:j,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return;}obj=Ext.getCmp("er_application");if(obj.getValue()=="-1"){this.getMessageBox(h,obj.getStore().getAt(0).get("displayField"));
return false;}if(obj.getValue().length==0){this.getMessageBox(h,"Please choose Desktop/Application Pools");return false;}var p=obj.getValue();var j="All Components and Individual selection cannot be selected simultaneously";if((Ext.Array.contains(p,"All")||Ext.Array.contains(p,"all"))&&p.length>1){Ext.MessageBox.show({title:"Alert",msg:j,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(c=="foreground"){if(l){var d=b.limitforbg;if(!Ext.isEmpty(d)){if(!checkTimeLineForBgLimit(d,f,m,a)){Ext.MessageBox.confirm("Confirm",appConstants.forGrdReportConfirmMsg,this.showConfirmResult,this);return false;}}}}else{var n=Ext.getCmp("bgReportName").getValue();if(!validateTextBoxWithSpecialChars(n,"Attachment",true)){return false;
}}return true;},validateMainFormForFavAndSch:function(){var b=appConstants.publicJsonData.hiddenFields;var e=b.getMaxDaysInMonth;var f=b.userTimeline;var g=Ext.getCmp("er_timeline").getValue();var j=Ext.getCmp("er_stdate").getValue();var a=Ext.getCmp("er_enddate").getValue();var d=Ext.getCmp("er_sthr").getValue();
var i=Ext.getCmp("er_endhr").getValue();j.setHours(d);a.setHours(i);var c=appConstants.publicJsonData.selectedFields.reportGenerationSelected;if(isSettingsEnabled){c=Ext.getCmp("reportGeneration").getValue();}if(f!=null&&f!="-1"){var k=isUserTimelineLimitExceeded(f,e,j,a);if(!k){Ext.MessageBox.show({title:"Operation Reports Settings",msg:_invalidUserTime,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}}var h=Ext.getCmp("select_farm");if(h.getValue()=="-1"){this.getMessageBox("Application launch",h.getStore().getAt(0).get("displayField"));return false;}h=Ext.getCmp("er_compType");if(h.getValue()=="-1"){this.getMessageBox("Application launch",h.getStore().getAt(0).get("displayField"));
return false;}h=Ext.getCmp("er_component");if(h.getValue()=="-1"&&!h.isHidden()){this.getMessageBox("Application launch",h.getStore().getAt(0).get("displayField"));return false;}return true;},showConfirmResult:function(c){if(c=="yes"){var b=Ext.getCmp("submit");b.setDisabled(false);if(isSettingsEnabled){Ext.get("configMod").animate({duration:500,to:{y:-500}});
}this.getAjaxDataForSubmit(this.foregroundControllerUrl,this.getQueryString(true,true,true));}else{this.getReporterSettings().down("button").fireHandler();var a=Ext.getCmp("reportGeneration");var d=Ext.getCmp("bgReportName");a.setValue("background");d.setValue("");d.show();d.focus(false,1000);Ext.getCmp("submitViaSetting").show();
Ext.getCmp("moreOptionCloseId").hide();validateTextBoxWithSpecialChars(d.getValue(),"Attachment",true);return false;}},validateSettings:function(){var a=true;var e=Ext.getCmp("reportGeneration").getValue();var c=Ext.getCmp("timefrom").getValue();var d=Ext.getCmp("minfrom").getValue();var b=Ext.getCmp("timeto").getValue();
var f=Ext.getCmp("minto").getValue();if(!checkTimePeriod(c,d,b,f)){a=false;}if(e!=null&&e=="background"){var g=Ext.getCmp("bgReportName").getValue();if(!validateTextBoxWithSpecialChars(g,"Attachment",true)){a=false;}}return a;}});