Ext.define("netscaleruserreport.controller.NetScalerUserReport",{extend:"Ext.app.Controller",refs:[{selector:"newUtilities",ref:"newUtilities"},{selector:"main",ref:"main"},{selector:"nomeasurepanel",ref:"nomeasurepanel"},{selector:"ReporterSettings",ref:"ReporterSettings"}],foregroundJspUrl:"/final/reporter/ErNetScalerUserReportJson.jsp",foregroundControllerUrl:"../servlet/com.eg.ErNetScalerUserReportC",backgroundControllerUrl:"../servlet/com.eg.ErStartBackGroundReportC",isNewFav:false,init:function(){this.control({"main":{"afterrender":this.boxready},"mainform":{"afterrender":this.loadForm},"newUtilities":{"render":this.loadTools},"applicationbillingsettings":{"afterrender":this.loadSettings},'applicationbillingform combo[name="er_type"]':{"select":this.onReportChange},'applicationbillingform combo[name="select_farm"]':{"select":this.onZoneChange},'applicationbillingsettings combo[name="reportGeneration"]':{"select":this.onChangeReportGeneration},'applicationbillingsettings button[id="moreOptionCloseId"]':{"click":this.validateAndCloseSettings},'applicationbillingsettings button[id="submitViaSetting"]':{"click":this.closeSettingAndSubmit},'applicationbillingform combo[name="er_compType"]':{"select":this.onComponentTypeChange},'applicationbillingform 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},'userinfo trigger[id="userSearch"]':{"change":this.filterMultiselect},"newUtilities > #printTool > button":{"click":this.printFile},"newUtilities > #saveTool > button":{"click":this.saveReportAsPDF},"newUtilities > #mailTool > button":{"click":this.sendMail},"newUtilities > #csvTool > button":{"click":this.saveCsv},"newUtilities > #favoriteTool > button":{"click":this.saveFavorite},"newUtilities > #scheduleTool > button":{"click":this.saveSchedule},'applicationbillingform 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();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();
}}if(g.id=="er_component"){h+="&er_info="+Ext.getCmp("er_info").getValue();if(Ext.getCmp("er_user").isVisible()){h+="&er_user="+Ext.getCmp("er_user").getValue();}else{h+="&er_user="+Ext.getCmp("er_user_txt").getValue();}}var d=g.getValue();if(d==undefined||d.length==0){return;}for(var b in d){h+="&er_component="+d[b];
}var c=this;Ext.Ajax.request({url:this.foregroundJspUrl,params:h,scope:this,success:function(i){appConstants.publicJsonData=Ext.decode(i.responseText);this.loadUsersAndInfo();}});},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);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.loadDataForReportChange();
this.loadUsersAndInfo();},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.loadDataForReportChange();this.loadUsersAndInfo();},goTo:function(a){if(appConstants.frmSchModify=="Yes"){this.saveSchedule(a);}else{this.saveFavorite(a);}},saveSchedule:function(d){if(this.validateMainForm(false)&&Ext.getCmp("er_timeline").getValue()=="Any"){Ext.MessageBox.show({title:"User Application",msg:"Chosen timeline not allowed",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}var c="/final/reporter/ErSaveSchedule.jsp?"+this.getQueryString(true,true,true)+"&option=data&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(e){var d=this.validateMainForm(false);var c="";if(e.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 f=c.substr(c.indexOf("?")+1,c.length-1);var a=Ext.create("Ext.form.Panel");a.submit({url:b,params:f,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)+"&option=data";
return a;},bookletPreview:function(){this.printFile();},printFile:function(){var a="/final/reporter/ErNetScalerUserReportPrint.jsp?"+appConstants.publicJsonData.urlFields.saveQueryString+"&er_view=PRINT&pdfPrint=yes";parent.printWindowFn(a);},sendMail:function(){Ext.widget("sendmail").show();},saveCsv:function(){window.location="../servlet/egurkha.reporter.SaveInCSVFormat";
},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()=="userSearch"){appConstants.erUtils.filterComboStore(a,Ext.getCmp("er_user"),appConstants.publicJsonData.combo.userCombo);
}}},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);}},toggleChildTables:function(d){var c=$("#"+d).hasClass("iconTreeExpand");var b=d.split("_");
if(c){$("#"+d).removeClass("iconTreeExpand");$("#"+d).addClass("iconTreeCollapse");}else{$("#"+d).removeClass("iconTreeCollapse");$("#"+d).addClass("iconTreeExpand");}if(b[0]=="exp1"){var a="child_tr1"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";
}});}else{if(b[0]=="exp2"){var a="child_tr2"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";}});}else{if(b[0]=="exp3"){var a="child_tr3"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";
}});}else{if(b[0]=="exp4"){var a="child_tr4"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";}});}else{if(b[0]=="exp5"){var a="child_tr5"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";
}});}else{if(b[0]=="add1"){var a="add1_tr1"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";}});}else{if(b[0]=="add2"){var a="add2_tr2"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";
}});}else{if(b[0]=="add3"){var a="add3_tr3"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";}});}else{if(b[0]=="add4"){var a="add4_tr4"+b[1];$("#vengat tr[id^="+a+"]").each(function(e,f){if(c){f.style.display="table-row";}else{f.style.display="none";
}});}else{conosle.log("issue in toggling");}}}}}}}}}Ext.getCmp("resultContainer").doLayout();},loadReportData:function(){var b=Ext.getCmp("resultContainer");var a=appConstants.publicJsonData.selectedFields.reportGenerationSelected;this.hideResults();var d=Ext.getCmp("er_stdate").getValue();d.setHours(Ext.getCmp("er_sthr").getValue());
var j=Ext.getCmp("er_enddate").getValue();j.setHours(Ext.getCmp("er_endhr").getValue());var l=checkDateTime(d,j);if(!l){return;}if(a=="foreground"){b.removeAll();if(appConstants.publicJsonData.hasOwnProperty("data")){if(appConstants.publicJsonData.data.hasOwnProperty("noMeasures")){this.disableTools();
this.getNomeasurepanel().show();}else{Ext.getCmp("selectionDetails").setSelectionDetailsData(appConstants.publicJsonData.selectionDetails);var e=appConstants.publicJsonData.GridObj;if(e!=undefined){this.loadGrid(e);}this.enableTools();}}}else{if(a=="background"){var k=Ext.getCmp("backGroundPanel");var f=appConstants.publicJsonData.labelFields.bgStatus;
if(f=="success"){var h=appConstants.publicJsonData.labelFields.bgResponseText;var i=appConstants.publicJsonData.labelFields.bgAnchor;var g=appConstants.publicJsonData.urlFields.bgUrl;k.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">'+h+".</br>"+'<a class="backgroundMsgLink" href='+g+">"+i+"</a></div></td></tr></table></td></tr></table>");
}else{if(f=="duplicate"){var h=appConstants.publicJsonData.labelFields.bgResponseText;var i=appConstants.publicJsonData.labelFields.bgAnchor;var g=appConstants.publicJsonData.urlFields.bgUrl;k.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">'+h+".</br>"+'<a class="backgroundMsgLink" href='+g+">"+i+"</a></div></td></tr></table></td></tr></table>");
}else{var h=appConstants.publicJsonData.labelFields.bgResponseText;k.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">'+h+"</a></div></td></tr></table></td></tr></table>");
}}k.show();}else{if(a=="background-csv"){var k=Ext.getCmp("backGroundPanel");var c=Ext.getCmp("bgReportName").getValue();c=checkFileName(c);var f=appConstants.publicJsonData.labelFields.bgStatus;if(f!="undefined"){if(f=="success"){var h=appConstants.publicJsonData.labelFields.bgResponseText;var i=appConstants.publicJsonData.labelFields.bgAnchor;
var g=appConstants.publicJsonData.urlFields.bgUrl;k.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">'+h+".</br>"+'<a class="backgroundMsgLink" href='+g+">"+i+"</a></div></td></tr></table></td></tr></table>");
}else{if(f=="duplicate"){var h=appConstants.publicJsonData.labelFields.bgResponseText;var i=appConstants.publicJsonData.labelFields.bgAnchor;var g=appConstants.publicJsonData.urlFields.bgUrl;k.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">'+h+".</br>"+'<a class="backgroundMsgLink" href='+g+">"+i+"</a></div></td></tr></table></td></tr></table>");
}else{var h=appConstants.publicJsonData.labelFields.bgResponseText;k.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">'+h+"</div></td></tr></table></td></tr></table>");
}}}else{k.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">Error In BackGround Generation</a></div></td></tr></table></td></tr></table>');
}k.show();}else{console.log("No data found for report generation in json");}}}},loadGrid:function(y){var x=this;var n=Ext.getCmp("resultContainer");if(!Ext.isEmpty(y)){var i=new Array();var m=new Array();var c=y.gridColumn;var s=y.gridColumnUI;var j=y.gridData;var q=y.summaryInfo;var g=y.additionaInfoCol;
var w=y.barChartObj;for(var B in c){var r="left";var b=c[B];if(B==c.length-1||b.indexOf("Port")>-1){r="center";}m.push(b);i.push({header:s[B],sortable:true,resizable:true,flex:1,align:r,dataIndex:b,renderer:function(F,C,k,H,E,D,G){C.tdAttr='data-qtip="'+F+'"';return F;},doSort:function(C){var k=this.up("grid").store;
var D=this.getSortParam();k.sort({property:D,direction:C,sorterFn:function(I,H){I=I.get(D);H=H.get(D);if(I.indexOf(".")>-1&&I.indexOf(" ")>-1){var F=I.substring(0,I.lastIndexOf(" "));var G=new Date(Ext.Date.parse(F,mgrDateFormat));var E=Ext.Date.dateFormat(G,getExtjsDateFormat("MMM-dd-yyyy"));I=E+I.substring(I.lastIndexOf(" "),I.length);
}if(H.indexOf(".")>-1&&H.indexOf(" ")>-1){var F=H.substring(0,H.lastIndexOf(" "));var G=new Date(Ext.Date.parse(F,mgrDateFormat));var E=Ext.Date.dateFormat(G,getExtjsDateFormat("MMM-dd-yyyy"));H=E+H.substring(H.lastIndexOf(" "),H.length);}if(!isNaN(I)&&!isNaN(H)){I=Ext.isNumber(I)?I:parseFloat(String(I),10);
H=Ext.isNumber(H)?H:parseFloat(String(H),10);if(C=="ASC"){I=isNaN(I)?999999:I;H=isNaN(H)?999999:H;}else{I=isNaN(I)?0:I;H=isNaN(H)?0:H;}}else{if(!isNaN(new Date(I))&&!isNaN(new Date(H))){H=new Date(H).getTime();I=new Date(I).getTime();}}return I>H?1:(I<H?-1:0);}});},});var a=Ext.getCmp("er_info").getValue();
if(a!=undefined&&a!="VPN"){if(b.indexOf("Time")>-1){i[i.length-1].minWidth=145;}else{if(b.indexOf("Port")>-1){i[i.length-1].maxWidth=90;}else{if(b.indexOf(" IP")>-1){i[i.length-1].minWidth=110;}else{if(b.indexOf("Durations")>-1){i[i.length-1].width=80;}else{if(b.indexOf("Connection Type")>-1){i[i.length-1].minWidth=120;
}else{i[i.length-1].minWidth=100;}}}}}}}var e=false;var l=10;if(j!=undefined&&j.length<l){e=true;}else{e=false;}var t=Ext.create("Ext.data.Store",{fields:m,proxy:{type:"pagingmemory",reader:{type:"array",root:"data",totalProperty:"total"},data:j,},pageSize:l,remoteSort:true,autoLoad:true,sorters:{property:m[0],direction:"ASC"},});
var v=1;var A=new Array();var f=true;if(c.length>6){f=false;}var h=Ext.widget("customgrid",{store:t,title:y.title,forceFit:f,columnWidth:1,sortableColumns:true,ui:"newGridPanel withHeader",border:true,id:"vengat",margin:"10 10 10 10",columns:i,style:{"box-shadow":"none !important",},header:{style:"padding:3px 5px 5px 5px"},scroll:true,autoScroll:true,dockedItems:[{xtype:"pagingtoolbar",cls:"newPagination",dock:"bottom",displayInfo:true,store:t,hidden:e,displayInfo:true,displayMsg:"Displaying {0} - {1} of {2}",emptyMsg:"No topics to display",listeners:{change:function(k,C){if(!Ext.isEmpty(C)){v=C.currentPage;
}else{v=1;}}}}]});var o='<div width="100%" align="center" class="newTable"><table align="center" valign="middle" width="500px">';o+="<thead>";o+='<tr><th colspan=3 class="font_bold12" style="text-align:center;font-weight:bold">'+summaryTxt+"</th></tr>";o+="<tr>";o+="<th>"+connectionTypeTxt+"</th>";o+='<th style="text-align:center">'+completedSessionTxt+"</th>";
o+='<th style="text-align:center">'+uniqueUserTxt+"</th>";o+="</tr></thead><tbody>";for(var p in q){var d=q[p];o+="<tr>";for(var z in d){var u='"text-align:center';if(z==0){u='"text-align:left';}if(q.length>1&&p==0){o+="<td style="+u+';font-weight:bold;font-size:12px;">'+d[z]+"</td>";}else{o+="<td style="+u+'">'+d[z]+"</td>";
}}o+="</tr>";}o+="</tbody></table>";o+="</div>";A.push({xtype:"container",columnWidth:1,margin:"10 0 0 0",html:o});A.push({xtype:"panel",ui:"newGraphPanel",height:340,columnWidth:1,margin:"10 0 0 0",title:w.chartTitle,items:[{xtype:"container",flex:1,html:'<div id="graphPanelId" style="width:100%"></div>',listeners:{"boxready":function(){var k={};
k=jQuery.extend(true,{},getHighChartsBarInstance("graphPanelId",w.chartHeight,this.getWidth()),k);k.setData(w,"<%=currentDateFormat%>","");k.drawChart();}}},]});A.push(h);n.add({xtype:"panel",margin:"10 10 10 10",padding:"0 0 0 0",ui:"newGraphPanel",layout:{type:"column",align:"stretch",},items:A});n.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&isBackgroundCSV=Yes",this.getQueryString(true,true,true));}else{if(b=="background"&&this.validateMainForm(true)){this.getAjaxDataForSubmit(this.backgroundControllerUrl,this.getQueryString(true,true,true));
}}}},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("submitViaSetting").hide();Ext.getCmp("moreOptionCloseId").show();Ext.getCmp("bgReportName").hide();}}},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.loadUsersAndInfo();},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);var a=Ext.getCmp("er_compType").getValue();this.loadComboField("er_component","componentCombo","componentLabel","componentSelected",appConstants.publicJsonData,true,"componentpane",true);
Ext.getCmp("componentpane").show();this.loadUsersAndInfo();},loadDataForReportChange:function(){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.loadDataForReportChange();this.loadUsersAndInfo();},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,h,q){var e;var o,u,f,s,v,d,x;if(isSettingsEnabled){o=Ext.getCmp("timefrom").getValue();
u=Ext.getCmp("minfrom").getValue();f=Ext.getCmp("timeto").getValue();s=Ext.getCmp("minto").getValue();v=Ext.getCmp("er_excwe").getValue();d=Ext.getCmp("reportGeneration").getValue();x=Ext.getCmp("bgReportName").getValue();}else{var n=appConstants.publicJsonData.selectedFields;o=n.selectedTimeFrom;u=n.selectedMinsFrom;
f=n.selectedTimeTo;s=n.selectedMinsTo;v=n.excludeWeekendsSelected;d=n.reportGenerationSelected;x=n.reportNameSelected;}var t=Ext.getCmp("er_option").getValue();e="er_type=No";if(t=="Zone"){e+="&select_farm="+Ext.getCmp("select_farm").getValue();}else{if(t=="Segment"||t=="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();}if(q){var p=Ext.getCmp("er_stdate").dataArray;var a=Ext.getCmp("er_enddate").dataArray;var i=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="+u+"&timeto="+f+"&minto="+s;e+="&er_excwe="+v;var c=new Array();if(d=="foreground"){e+="&er_reportgenration="+d+"&isSubmit=true&responseType=json";}else{x=checkFileName(x);e+="&er_reportgenration="+d+"&bg_reportname="+x+"&isSubmit=true";}}if(h){if(Ext.getCmp("er_user").isVisible()){var j=Ext.getCmp("er_user").getValue();
e+="&er_user="+encodeURIComponent(j);}else{var j=Ext.getCmp("er_user_txt").getValue();e+="&er_user="+encodeURIComponent(j);}var b=Ext.getCmp("er_info").getValue();e+="&er_info="+encodeURIComponent(b);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(h){var c=new Array();c=Ext.getCmp("er_component").getValue();
for(var w in c){e+="&er_component="+c[w];}var r=Ext.getCmp("er_compType").getValue();}var r=Ext.getCmp("er_compType").getValue();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","analysisByComboLabel","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("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);
this.loadUsersAndInfo();Ext.getCmp("componentpane").show();},loadUsersAndInfo:function(){listOfUser=appConstants.publicJsonData.combo.userCombo;var a=appConstants.publicJsonData.needUserAsCombo;if(a!=undefined&&a=="yes"){Ext.getCmp("er_user").show();Ext.getCmp("er_user_txt").hide();this.loadComboField("er_user","userCombo","userComboLabel","userSelected",appConstants.publicJsonData,false,null,true);
Ext.getCmp("er_user").setValue(appConstants.publicJsonData.selectedFields.userSelected);}else{Ext.getCmp("er_user").hide();Ext.getCmp("er_user_txt").show();Ext.getCmp("er_user_txt").setValue(appConstants.publicJsonData.selectedFields.userSelected);}this.loadComboField("er_info","infoCombo","infoComboLabel","infoSelected",appConstants.publicJsonData,false,null,true);
},loadSettings:function(){var c=appConstants.publicJsonData.hiddenFields;var b=c["FavoriteId"];if(!Ext.isEmpty(b)){Ext.getCmp("reportGeneration").setDisabled(true);}Ext.getCmp("moreOptionCloseId").show();this.loadComboField("er_excwe","excludeWeekendsCombo","excludeWeekendsLabel","excludeWeekendsSelected",appConstants.publicJsonData,false,null,true);
this.loadComboField("reportGeneration","reportGenerationCombo","reportGenerationLabel","reportGenerationSelected",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();Ext.getCmp("panelinsidetoggle").setDisabled(false);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(m){var c=appConstants.publicJsonData.hiddenFields;var g=c.getMaxDaysInMonth;var i=c.userTimeline;var j=Ext.getCmp("er_timeline").getValue();
var n=Ext.getCmp("er_stdate").getValue();var a=Ext.getCmp("er_enddate").getValue();var f=Ext.getCmp("er_sthr").getValue();var l=Ext.getCmp("er_endhr").getValue();n.setHours(f);a.setHours(l);var d=appConstants.publicJsonData.selectedFields.reportGenerationSelected;if(isSettingsEnabled){d=Ext.getCmp("reportGeneration").getValue();
}if(i!=null&&i!="-1"){var q=isUserTimelineLimitExceeded(i,g,n,a);if(!q){Ext.MessageBox.show({title:"Operation Reports Settings",msg:_invalidUserTime,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}obj=Ext.getCmp("er_compType");if(obj.getValue()=="-1"){this.getMessageBox("User Application","Please choose Component Type");
return false;}obj=Ext.getCmp("er_component");if(obj.getValue()==""||(obj.getValue()=="-1"&&!obj.isHidden())){this.getMessageBox("User Application","Please choose Components");return false;}obj=Ext.getCmp("er_user");var k=obj.getValue();var h=false;if(obj.isVisible()){for(var p in listOfUser){if(listOfUser[p].valueField==k){h=true;
break;}}}else{var b=Ext.getCmp("er_user_txt").getValue();if(b.trim().length>0){h=true;}}if(!h){this.getMessageBox("User Application","Invalid user");return false;}if(k=="Not Applicable"){this.getMessageBox("User Application","Invalid user");return false;}if(d=="foreground"){if(m){var e=c.limitforbg;if(!Ext.isEmpty(e)){if(!checkTimeLineForBgLimit(e,g,n,a)){Ext.MessageBox.confirm("Confirm",appConstants.forGrdReportConfirmMsg,this.showConfirmResult,this);
return false;}}}}else{var o=Ext.getCmp("bgReportName").getValue();if(!validateTextBoxWithSpecialChars(o,"Attachment",true)){return false;}}return true;},validateMainFormForFavAndSch:function(){var c=appConstants.publicJsonData.hiddenFields;var f=c.getMaxDaysInMonth;var h=c.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 l=Ext.getCmp("er_endhr").getValue();m.setHours(e);a.setHours(l);var d=appConstants.publicJsonData.selectedFields.reportGenerationSelected;if(isSettingsEnabled){d=Ext.getCmp("reportGeneration").getValue();
}if(h!=null&&h!="-1"){var o=isUserTimelineLimitExceeded(h,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 j=Ext.getCmp("select_farm");if(j.getValue()=="-1"){this.getMessageBox("User Application",j.getStore().getAt(0).get("displayField"));
return false;}j=Ext.getCmp("er_compType");if(j.getValue()=="-1"){this.getMessageBox("User Application","Please choose Component Type");return false;}j=Ext.getCmp("er_component");if(j.getValue()==""||(j.getValue()=="-1"&&!j.isHidden())){this.getMessageBox("User Application","Please choose Components");
return false;}j=Ext.getCmp("er_user");var k=j.getValue();var g=false;if(j.isVisible()){for(var n in listOfUser){if(listOfUser[n].valueField==k){g=true;break;}}}else{var b=Ext.getCmp("er_user_txt").getValue();if(b.trim().length>0){g=true;}}if(!g){this.getMessageBox("User Application","Invalid user");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"||e=="background-csv")){var g=Ext.getCmp("bgReportName").getValue();
if(!validateTextBoxWithSpecialChars(g,"Attachment",true)){a=false;}}return a;},getNumberFormat:function(a){if(!isNaN(a)&&!isNaN(parseFloat(a))||a=="-"){if(a!=null&&a.indexOf(".")>-1){strDecimal=a.substring(a.indexOf("."));str=a.substring(0,a.indexOf("."));a='<span class="decimal-align">'+str+'</span><span class="decimal-align2">'+strDecimal+"</span>";
}else{a='<span class="decimal-align">'+a+"</span>";}}return a;}});