Ext.define("applicationbilling.controller.ApplicationBillingReport",{extend:"Ext.app.Controller",refs:[{selector:"newUtilities",ref:"newUtilities"},{selector:"main",ref:"main"},{selector:"nomeasurepanel",ref:"nomeasurepanel"},{selector:"ReporterSettings",ref:"ReporterSettings"}],foregroundJspUrl:"/final/reporter/ErApplicationBillingReportJson.jsp",foregroundControllerUrl:"../servlet/com.eg.ErApplicationBillingReportC",backgroundControllerUrl:"../servlet/com.eg.ErStartBackGroundReportC",isNewFav:false,isNewSch: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},'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 > #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=="Group"||e=="Segment"||e=="Service"){h+="&er_site="+Ext.getCmp("er_site").getValue();
}}var d=g.getValue();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);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);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.loadDataForReportChange();this.loadApplications();},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:"Application Launch",msg:"Chosen timeline not allowed",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}if(d.getId()!="save"){this.isNewSch=true;
}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/ErApplicationBillingReportPrint.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()=="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 c=Ext.getCmp("resultContainer");var b=appConstants.publicJsonData.selectedFields.reportGenerationSelected;this.hideResults();var e=Ext.getCmp("er_stdate").getValue();e.setHours(Ext.getCmp("er_sthr").getValue());var k=Ext.getCmp("er_enddate").getValue();k.setHours(Ext.getCmp("er_endhr").getValue());
var m=checkDateTime(e,k);if(!m){return;}if(b=="foreground"){c.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 f=appConstants.publicJsonData.GridObj;if(f!=undefined){this.loadGrid(f);}this.enableTools();}}}else{if(b=="background"){var l=Ext.getCmp("backGroundPanel");var g=appConstants.publicJsonData.labelFields.bgStatus;if(g=="success"){var i=appConstants.publicJsonData.labelFields.bgResponseText;var j=appConstants.publicJsonData.labelFields.bgAnchor;
var h=appConstants.publicJsonData.urlFields.bgUrl;var a=j;l.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">'+i+".</br>"+'<a class="backgroundMsgLink" href='+h+">"+a+"</a></div></td></tr></table></td></tr></table>");
}else{if(g=="duplicate"){var i=appConstants.publicJsonData.labelFields.bgResponseText;var j=appConstants.publicJsonData.labelFields.bgAnchor;var h=appConstants.publicJsonData.urlFields.bgUrl;var a=j;l.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">'+i+".</br>"+'<a class="backgroundMsgLink" href='+h+">"+a+"</a></div></td></tr></table></td></tr></table>");
}else{var i=appConstants.publicJsonData.labelFields.bgResponseText;l.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">'+i+"</div></td></tr></table></td></tr></table>");
}}l.show();}else{if(b=="background-csv"){var l=Ext.getCmp("backGroundPanel");var d=Ext.getCmp("bgReportName").getValue();d=checkFileName(d);var g=appConstants.publicJsonData.labelFields.bgStatus;if(g!="undefined"){if(g=="success"){var i=appConstants.publicJsonData.labelFields.bgResponseText;var j=appConstants.publicJsonData.labelFields.bgAnchor;
var h=appConstants.publicJsonData.urlFields.bgUrl;var a=j;l.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">'+i+".</br>"+'<a class="backgroundMsgLink" href='+h+">"+a+"</a></div></td></tr></table></td></tr></table>");
}else{if(g=="duplicate"){var i=appConstants.publicJsonData.labelFields.bgResponseText;var j=appConstants.publicJsonData.labelFields.bgAnchor;var h=appConstants.publicJsonData.urlFields.bgUrl;var a=j;l.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">'+i+".</br>"+'<a class="backgroundMsgLink" href='+h+">"+a+"</a></div></td></tr></table></td></tr></table>");
}else{var i=appConstants.publicJsonData.labelFields.bgResponseText;l.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">'+i+"</div></td></tr></table></td></tr></table>");
}}}else{l.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>');
}l.show();}else{console.log("No data found for report generation in json");}}}},loadGrid:function(p){var q=this;var k=Ext.getCmp("resultContainer");if(!Ext.isEmpty(p)){var a=p.columns;var o=p.dataArray;var g=new Array();var j=new Array();var l="left";var h=0;var b=150;for(var r in a){mainColumn=a[r];
j.push(mainColumn);l="left";if(h==0){b=180;}if(h==1){b=160;}else{if(h==3){b=165;}else{if(h==4){b=165;}else{if(h==5){b=100;}else{if(h==6){b=165;}else{if(h==7){b=165;}else{if(h==11){b=100;}else{if(h==12){b=100;}else{b=150;}}}}}}}}var e=false;if(h==0){e=true;}h++;var c=mainColumn;if(mainColumn!=undefined&&mainColumn.indexOf("Cpu Util")>-1){b=100;
l="center";}else{if(mainColumn!=undefined&&mainColumn.indexOf("Memory Util")>-1){b=100;l="center";}else{if(mainColumn!=undefined&&mainColumn.indexOf("Desktop")>-1){b=165;}else{if(mainColumn!=undefined&&mainColumn.indexOf("Duration <br>&nbsp;&nbsp;(Mins)")>-1){b=100;l="center";}else{if(mainColumn!=undefined&&mainColumn.indexOf("Application Launch Time")>-1){b=165;
}else{if(mainColumn!=undefined&&mainColumn.indexOf("Application End Time")>-1){b=165;}else{if(mainColumn!=undefined&&mainColumn.indexOf("Session Start")>-1){b=165;}else{if(mainColumn!=undefined&&mainColumn.indexOf("Session End")>-1){b=165;}else{if(mainColumn!=undefined&&mainColumn.indexOf("Graph")>-1){b=50;
l="center";c="&nbsp";}}}}}}}}}g.push({header:c,sortable:true,width:b,locked:e,align:l,dataIndex:mainColumn,doSort:function(t){var s=this.up("grid").store;var u=this.getSortParam();s.sort({property:u,direction:t,sorterFn:function(z,y){z=z.get(u);y=y.get(u);if(z=="-"){return -1;}else{if(y=="-"){return 1;
}}if(u!=undefined&&(u=="User"||u=="Published Application"||u=="Component"||u=="Client Address"||u=="Client Name"||u=="Client Version"||u=="Desktop")){z=z.toLowerCase();y=y.toLowerCase();return z>y?1:(z<y?-1:0);}if(u!=undefined&&(u=="Application Launch Time"||u=="Application End Time"||u=="Session Start"||u=="Session End")){if(z.indexOf(".")>-1&&z.indexOf(" ")>-1){var w=z.substring(0,z.lastIndexOf(" "));
var x=new Date(Ext.Date.parse(w,mgrDateFormat));var v=Ext.Date.dateFormat(x,getExtjsDateFormat("MMM-dd-yyyy"));z=v+z.substring(z.lastIndexOf(" "),z.length);}if(y.indexOf(".")>-1&&y.indexOf(" ")>-1){var w=y.substring(0,y.lastIndexOf(" "));var x=new Date(Ext.Date.parse(w,mgrDateFormat));var v=Ext.Date.dateFormat(x,getExtjsDateFormat("MMM-dd-yyyy"));
y=v+y.substring(y.lastIndexOf(" "),y.length);}if(!isNaN(new Date(z))&&!isNaN(new Date(y))){y=new Date(y).getTime();z=new Date(z).getTime();return z>y?1:(z<y?-1:0);}}z=Ext.isNumber(z)?z:parseFloat(String(z),10);z=isNaN(z)?0:z;y=Ext.isNumber(y)?y:parseFloat(String(y),10);y=isNaN(y)?0:y;return z>y?1:(z<y?-1:0);
}});},renderer:function(w,t,s,y,v,u,x){if(w.indexOf("?")>-1){t.tdAttr='data-qclass=yellowTip data-qtip="Graph"';return'<div class="iconLineChart" onclick="javascript:loadUrlInDrillDown(\''+w+'\');" style="width:16px;height:16px;display:block;cursor:pointer">&nbsp;<div>';}else{t.tdAttr='data-qclass=yellowTip data-qtip="'+w+'"';
w=Ext.getCmp("appGrid").getDecimalAlignFormat(w);return w;}}});}var d;var i=15;if(o.length<i){d=true;}else{d=false;}var m=Ext.create("Ext.data.Store",{fields:j,proxy:{type:"pagingmemory",reader:{type:"array",root:"data",totalProperty:"total"}},pageSize:i,data:o,remoteSort:true,autoLoad:true,sorters:{property:j[0],direction:"ASC"}});
var n=1;var f=Ext.widget("customgrid",{store:m,sortableColumns:true,ui:"newGridPanel",id:"appGrid",columns:g,scroll:true,autoScroll:true,margin:"0 10 10 10",border:true,listeners:{sortchange:function(v,w,x,u,s){q.gridColIndexParam=w.getIndex();q.gridColStateParam=w.sortState;this.getStore().loadPage(n);
},},dockedItems:[{xtype:"pagingtoolbar",cls:"newPagination",dock:"bottom",layout:{type:"hbox",align:"stretch",pack:"center"},displayInfo:true,store:m,hidden:d,displayInfo:true,displayMsg:"Displaying {0} - {1} of {2}",emptyMsg:"No topics to display",listeners:{change:function(s,t){if(!Ext.isEmpty(t)){n=t.currentPage;
}else{n=1;}}}}]});k.removeAll();k.add(f);k.setTitle("Application Billing");k.doLayout();k.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));
}}}},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();},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.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=="Group"||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.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(j,h,p){var d;var n,u,e,s,v,c,x,i,r;if(isSettingsEnabled){n=Ext.getCmp("timefrom").getValue();
u=Ext.getCmp("minfrom").getValue();e=Ext.getCmp("timeto").getValue();s=Ext.getCmp("minto").getValue();v=Ext.getCmp("er_excwe").getValue();c=Ext.getCmp("reportGeneration").getValue();x=Ext.getCmp("bgReportName").getValue();r=Ext.getCmp("er_groupBy").getValue();}else{var m=appConstants.publicJsonData.selectedFields;
n=m.selectedTimeFrom;u=m.selectedMinsFrom;e=m.selectedTimeTo;s=m.selectedMinsTo;v=m.excludeWeekendsSelected;c=m.reportGenerationSelected;x=m.reportNameSelected;r=m.groupBySelected;}var t=Ext.getCmp("er_option").getValue();d="er_type=No";if(t=="Zone"){d+="&select_farm="+Ext.getCmp("select_farm").getValue();
}else{if(t=="Group"||t=="Segment"||t=="Service"){d+="&er_site="+Ext.getCmp("er_site").getValue();}}if(j){d+="&er_compType="+Ext.getCmp("er_compType").getValue()+"&er_option="+Ext.getCmp("er_option").getValue();}if(p){var o=Ext.Date.dateFormat(Ext.getCmp("er_stdate").getValue(),mgrDateFormat);var a=Ext.Date.dateFormat(Ext.getCmp("er_enddate").getValue(),mgrDateFormat);
var g=Ext.getCmp("er_sthr").dataArray;d+="&er_timeline="+Ext.getCmp("er_timeline").getValue()+"&startdate="+o+"&enddate="+a+"&starthr="+Ext.getCmp("er_sthr").dataArray+"&endhr="+Ext.getCmp("er_endhr").dataArray+"&startmin="+mgr_stmin+"&endmin="+mgr_enmin;d+="&timefrom="+n+"&minfrom="+u+"&timeto="+e+"&minto="+s;
d+="&er_excwe="+v;if(c=="foreground"){d+="&er_reportgenration="+c+"&isSubmit=true&responseType=json";}else{x=checkFileName(x);d+="&er_reportgenration="+c+"&bg_reportname="+x+"&isSubmit=true";}}if(h){var b=new Array();b=Ext.getCmp("er_application").getValue();for(var w in b){d+="&er_application="+encodeURIComponent(b[w]);
}if(appConstants.publicJsonData.hasOwnProperty("hiddenFields")){var l=appConstants.publicJsonData.hiddenFields;for(var f in l){if(this.isNewFav!=undefined&&this.isNewFav){if(f!=undefined&&f=="ID"){continue;}if(f!=undefined&&f=="FavoriteId"){continue;}}if(this.isNewSch!=undefined&&this.isNewSch){if(f!=undefined&&f=="ID"){continue;
}}d+="&"+f+"="+l[f];}}}d+="&er_RmDispName="+appConstants.er_RmDispName;d+="&chartType="+appConstants.chartType;if(h){var b=new Array();b=Ext.getCmp("er_component").getValue();for(var w in b){d+="&er_component="+b[w];}var q=Ext.getCmp("er_compType").getValue();}var q=Ext.getCmp("er_compType").getValue();
d+="&er_groupBy=User&er_detailsBasedOn=user";var k=appConstants.vmComponentListEntry.indexOf(q);if(k>=0){d+="&isVmComp=true";}return d;},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("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);}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(j){var b=appConstants.publicJsonData.hiddenFields;var f=b.getMaxDaysInMonth;var g=b.userTimeline;var h=Ext.getCmp("er_timeline").getValue();
var k=Ext.getCmp("er_stdate").getValue();var a=Ext.getCmp("er_enddate").getValue();var e=Ext.getCmp("er_sthr").getValue();var i=Ext.getCmp("er_endhr").getValue();k.setHours(e);a.setHours(i);var c=appConstants.publicJsonData.selectedFields.reportGenerationSelected;if(isSettingsEnabled){c=Ext.getCmp("reportGeneration").getValue();
}if(g!=null&&g!="-1"){var m=isUserTimelineLimitExceeded(g,f,k,a);if(!m){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("Application launch",obj.getStore().getAt(0).get("displayField"));
return false;}obj=Ext.getCmp("er_component");if(obj.getValue()=="-1"&&!obj.isHidden()){this.getMessageBox("Application launch",obj.getStore().getAt(0).get("displayField"));return false;}obj=Ext.getCmp("er_application");if(obj.getValue()=="-1"&&!obj.isHidden()){this.getMessageBox("Application launch",obj.getStore().getAt(0).get("displayField"));
return false;}if(c=="foreground"){if(j){var d=b.limitforbg;if(!Ext.isEmpty(d)){if(!checkTimeLineForBgLimit(d,f,k,a)){Ext.MessageBox.confirm("Confirm",appConstants.forGrdReportConfirmMsg,this.showConfirmResult,this);return false;}}}}else{var l=Ext.getCmp("bgReportName").getValue();if(!validateTextBoxWithSpecialChars(l,"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;}});