Ext.define("cpSystemApp.controller.Main",{extend:"Ext.app.Controller",views:["Main"],refs:[{selector:"main",ref:"main"},{selector:"newUtilities",ref:"newUtilities"},{selector:"capacityplanningsystemmainform",ref:"capacityplanningsystemmainform"},{selector:"capacityplanningsystemsettings",ref:"capacityplanningsystemsettings"},{selector:"mainform",ref:"Mainform"},{selector:"ReporterSettings",ref:"ReporterSettings"},{selector:"nomeasurepanel",ref:"nomeasurepanel"},{selector:"backGroundPanel",ref:"backGroundPanel"}],init:function(){this.control({"newUtilities":{"afterrender":this.hideTools},"main":{"afterrender":this.defaultLoad},"capacityplanningsystemsettings":{"afterrender":this.loadSettings},'reportgeneration combo[name="reportGeneration"]':{"select":this.showBackgroundReport},'reportgeneration button[id="moreOptionCloseId"]':{"click":this.validateAndCloseSettings},'reportgeneration button[id="submitViaSetting"]':{"click":this.closeSettingAndSubmit},'main button[name="mainformsubmit"]':{"click":this.beforeReportSubmit},'main button[name="mainformsave"]':{"click":this.addTo},'capacityplanningsystemmainform button[name="submit"]':{"click":this.beforeReportSubmit},'capacityplanningsystemmainform button[name="save"]':{"click":this.addTo},'capacityplanningsystemmainform combo[name="er_site"]':{"select":this.changeCompType},'capacityplanningsystemmainform combo[name="er_type"]':{"select":this.changeReportType},"newUtilities > #saveTool > button":{"click":this.savePdf},"newUtilities > #mailTool > button":{"click":this.sendMail},"newUtilities > #printTool > button":{"click":this.print},"newUtilities > #favoriteTool > button":{"click":this.addTo},"newUtilities > #scheduleTool > button":{"click":this.addTo},'egcomponent button[id="expandSelectorComp"]':{"click":this.expandMe},"newUtilities > #csvTool > button":{"click":this.saveAsCSV},"grid":{},'egcomponent trigger[id="compSearch"]':{"change":this.filterMultiselect},'mainform button[id="panelinsidetoggle"]':{"click":this.toggleForm}});
},showConfigDropdown:function(){isSettingsEnabled=true;var b=this;var a=new Ext.XTemplate('<div style="float:left;margin: 0px 0px 0px 0px;">More Options</div><div style="text-align:right;float:right;"><div class="iconCloseNew" id="closeSettings"></div></div>');Ext.create("Ext.container.Container",{width:565,id:"configMod",ui:"settingsWindowContainer",items:[{xtype:"container",cls:"configMode_popupArrow",style:{"top":"-14px","left":"355px"}},{xtype:"container",html:a.apply(),cls:"containerHeader",style:{"top":"0px","margin":"0px"}},{xtype:"capacityplanningsystemsettings",parent:this}],renderTo:"cpsystem-body",listeners:{render:function(){Ext.get("closeSettings").on("click",function(){b.validateAndCloseSettings();
});}}});},resizePanel:function(){var a=this;Ext.EventManager.onWindowResize(function(){if(!Ext.isEmpty(appConstants.publicJsonData)){a.loadCapacityGridandTable(appConstants.publicJsonData);}});},filterMultiselect:function(a){if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");
}a.toggleTriggger();appConstants.erUtils.filterComboStore(a,Ext.getCmp("components"),appConstants.rawDataForComponents);},saveAsCSV:function(){var a="../servlet/egurkha.reporter.SaveInCSVFormat?reporttype=null";if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");}appConstants.erUtils.savePDF(a);
},sendMail:function(){Ext.widget("sendmail").show();},savePdf:function(){var a=this.getCapacityplanningsystemmainform().getForm();var m=Ext.getCmp("mainform").getForm();var d=appConstants.publicJsonData["hiddenParams"]["select_group"];var g=appConstants.publicJsonData["hiddenParams"]["pageWidthProces"];
var s="";if(d!=null&&(d=="Service"||d=="Segment"||d=="Zone")){s="&select_group="+d+"&er_site="+a.findField("er_site").getValue();}else{var r=a.findField("er_site").getValue();var x=new Array();x=m.findField("components").getValue();var f="";s="&select_group="+d+"&er_comptype="+r+f;}var n=a.findField("er_timeline").getValue();
if(Ext.isEmpty(n)){n="1 day";}var u="";var b="";var j="";var i="";var t="";var p="";if(isSettingsEnabled){var o=this.getCapacityplanningsystemsettings().getForm();u=o.findField("timefrom").getValue();b=o.findField("minfrom").getValue();j=o.findField("timeto").getValue();i=o.findField("minto").getValue();
t=o.findField("reportGeneration").getValue();p=o.findField("er_excwe").getValue();}else{var q=appConstants.publicJsonData.pageParams;u=q.timefrom;b=q.minfrom;j=q.timeto;i=q.minto;t=q.er_reportgenration;p=q.excludeWeekEnd;}var e=Ext.Date.dateFormat(a.findField("er_stdate").getValue(),mgrDateFormat);var v=Ext.Date.dateFormat(a.findField("er_enddate").getValue(),mgrDateFormat);
var w=a.findField("er_stdate").dataArray;var l=a.findField("er_enddate").dataArray;var k=a.findField("er_sthr").dataArray;var c=a.findField("er_endhr").dataArray;s=s+"&startdate="+w+"&enddate="+l+"&starthr="+k+"&endhr="+c+"&timeto="+j+"&minto="+i+"&er_excwe="+p+"&timefrom="+u+"&minfrom="+b+"&er_reportgenration="+t+"&startmin="+mgr_stmin+"&endmin="+mgr_enmin;
var h="../reporter/ErHtmlToSavePdf.jsp?&inidate="+appConstants.publicJsonData["hiddenParams"]["inidate"]+"&pageWidthProces="+g+s;if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");}appConstants.erUtils.savePDF(h);},bookletQuery:function(k){var a=this.getCapacityplanningsystemmainform().getForm();
var n=Ext.getCmp("mainform").getForm();var d=appConstants.publicJsonData["hiddenParams"]["select_group"];var g=appConstants.publicJsonData["hiddenParams"]["pageWidthProces"];var t="";if(d!=null&&(d=="Service"||d=="Segment"||d=="Zone")){t="&select_group="+d+"&er_site="+a.findField("er_site").getValue();
}else{var s=a.findField("er_site").getValue();var y=new Array();y=n.findField("components").getValue();var f="";t="&select_group="+d+"&er_comptype="+s+f;}var o=a.findField("er_timeline").getValue();if(Ext.isEmpty(o)){o="1 day";}var v="";var b="";var j="";var i="";var u="";var q="";if(isSettingsEnabled){var p=this.getCapacityplanningsystemsettings().getForm();
v=p.findField("timefrom").getValue();b=p.findField("minfrom").getValue();j=p.findField("timeto").getValue();i=p.findField("minto").getValue();u=p.findField("reportGeneration").getValue();q=p.findField("er_excwe").getValue();}else{var r=appConstants.publicJsonData.pageParams;v=r.timefrom;b=r.minfrom;j=r.timeto;
i=r.minto;u=r.er_reportgenration;q=r.excludeWeekEnd;}var e=Ext.Date.dateFormat(a.findField("er_stdate").getValue(),mgrDateFormat);var w=Ext.Date.dateFormat(a.findField("er_enddate").getValue(),mgrDateFormat);var x=a.findField("er_stdate").dataArray;var m=a.findField("er_enddate").dataArray;var l=a.findField("er_sthr").dataArray;
var c=a.findField("er_endhr").dataArray;t=t+"&startdate="+x+"&enddate="+m+"&starthr="+l+"&endhr="+c+"&timeto="+j+"&minto="+i+"&er_excwe="+q+"&timefrom="+v+"&minfrom="+b+"&er_reportgenration="+u+"&startmin="+mgr_stmin+"&endmin="+mgr_enmin;var h="&inidate="+appConstants.publicJsonData["hiddenParams"]["inidate"]+"&pageWidthProces="+g+t;
return h;},bookletScheduleQuery:function(b){var a=appConstants.queryString+"&isSchedule=true";return a;},bookletPreview:function(){this.print();},print:function(){var a=this.getCapacityplanningsystemmainform().getForm();var k=Ext.getCmp("mainform").getForm();var d=appConstants.publicJsonData["hiddenParams"]["select_group"];
var q="";if(d!=null&&(d=="Service"||d=="Segment"||d=="Zone")){q="&select_group="+d+"&er_site="+a.findField("er_site").getValue();}else{var p=a.findField("er_site").getValue();var u=new Array();u=k.findField("components").getValue();var e="";q="&select_group="+d+"&er_comptype="+p+e;}var l=a.findField("er_timeline").getValue();
if(Ext.isEmpty(l)){l="1 day";}var s="";var b="";var h="";var g="";var r="";var n="";if(isSettingsEnabled){var m=this.getCapacityplanningsystemsettings().getForm();s=m.findField("timefrom").getValue();b=m.findField("minfrom").getValue();h=m.findField("timeto").getValue();g=m.findField("minto").getValue();
r=m.findField("reportGeneration").getValue();n=m.findField("er_excwe").getValue();}else{var o=appConstants.publicJsonData.pageParams;s=o.timefrom;b=o.minfrom;h=o.timeto;g=o.minto;r=o.er_reportgenration;n=o.excludeWeekEnd;}var t=a.findField("er_stdate").dataArray;var j=a.findField("er_enddate").dataArray;
var i=a.findField("er_sthr").dataArray;var c=a.findField("er_endhr").dataArray;q=q+"&startdate="+t+"&enddate="+j+"&starthr="+i+"&endhr="+c+"&timeto="+h+"&minto="+g+"&er_excwe="+n+"&timefrom="+s+"&minfrom="+b+"&er_reportgenration="+r+"&startmin="+mgr_stmin+"&endmin="+mgr_enmin;var f="/final/reporter/ErSystemCapacityReportPrint.jsp?inidate="+appConstants.publicJsonData["hiddenParams"]["inidate"]+"&pdfPrint=yes&isChartRequest=true&er_width=450&er_height=250"+q;
parent.printWindowFn(f);},addTo:function(c){var j=this.validateForm();if(j){this.updateQueryString();var g="";var i=c.getId();var f=i;var b=appConstants.publicJsonData["hiddenParams"]["fromScheduleModify"];if(b=="Yes"){i="scheduleImg";}if(i=="scheduleImg"){g="/final/reporter/ErSaveSchedule.jsp?isSchedule=true&"+appConstants.queryString+"&com.eg.CSRF_NONCE="+csrfToken;
if(f=="save"||f=="mainformsave"){g+="&showSchWindow=no";var d=g.substr(0,g.indexOf("?"));var a=g.substr(g.indexOf("?")+1,g.length-1);var e=Ext.create("Ext.form.Panel");e.submit({url:d,params:a,standardSubmit:true,method:"POST"});}else{parent.scheduleWindowFn(g);}}else{var h=appConstants.favorite_id;if(h==undefined){h=appConstants.publicJsonData.hiddenParams["favorite_id"];
}g="../servlet/com.eg.ErFavoriteC?er_view=GRAPH&cmd=client&"+appConstants.queryString+"&er_RmDispName="+appConstants.er_RmDispName+"&com.eg.CSRF_NONCE="+csrfToken;if(f=="save"||f=="mainformsave"){g+="&showSchWindow=no"+"&FavoriteId="+h;var d=g.substr(0,g.indexOf("?"));var a=g.substr(g.indexOf("?")+1,g.length-1);
var e=Ext.create("Ext.form.Panel");e.submit({url:d,params:a,standardSubmit:true,method:"POST"});}else{parent.favouriteWindowFn(g);}}}},changeCompType:function(e){var c=appConstants.publicJsonData["pageParams"]["selectedGroup"];var d=e.up("form").getForm();var b=Ext.getCmp("mainform").getForm();var a=appConstants.publicJsonData.hiddenParams.er_type;
if(c!=null&&c=="Component"){Ext.Ajax.request({url:"/final/reporter/ErSystemCapacityReportJson.jsp",params:"&select_group=Component&action=changeComponent&er_comptype="+e.getValue()+"&er_type="+a,scope:this,success:function(f){var i=f.responseText;var h=Ext.decode(i);var g=b.findField("components");appConstants.rawDataForComponents=h["componentList"];
g.getStore().loadRawData(h["componentList"]);g.setValue(h["pageParams"]["selectedComps"]);appConstants.publicJsonData["pageParams"]["startmin"]=h["pageParams"]["startmin"];appConstants.publicJsonData["pageParams"]["endmin"]=h["pageParams"]["endmin"];}});}},closeSettingAndSubmit:function(){if(this.validateAndCloseSettings()){this.beforeReportSubmit();
}},changeReportType:function(b){var c=Ext.getCmp("gridPanel");var e=Ext.getCmp("tablePanel");c.removeAll();e.removeAll();c.hide();var a=b.getValue();Ext.getCmp("saveTool").setDisabled(true);Ext.getCmp("printTool").setDisabled(true);Ext.getCmp("mailTool").setDisabled(true);Ext.getCmp("csvTool").setDisabled(true);
Ext.getCmp("upbutton").setDisabled(true);var h=appConstants.publicJsonData.hiddenParams["favorite_id"];if(h!=undefined){appConstants.favorite_id=h;}appConstants.publicJsonData.hiddenParams.er_type=a;var d=appConstants.publicJsonData.hiddenParams;var f=appConstants.publicJsonData["pageParams"]["selectedGroup"];
var g=Ext.getCmp("mainform").getForm();var i="&select_group="+f+"&action=defaultLoad&er_trenddata=Yes&isLegendEnabled=true&er_type="+a+"&er_RmDispName=System Capacity Analysis  By Component";Ext.Ajax.request({url:"/final/reporter/ErSystemCapacityReportJson.jsp",params:i,scope:this,success:function(j){var m=j.responseText;
var l=Ext.decode(m);appConstants.publicJsonData=l;appConstants.publicJsonData.hiddenParams=d;this.getCapacityplanningsystemmainform().loadFields();var k=g.findField("components");appConstants.rawDataForComponents=l["componentList"];k.getStore().loadRawData(l["componentList"]);k.setValue(l["pageParams"]["selectedComps"]);
appConstants.publicJsonData["pageParams"]["startmin"]=l["pageParams"]["startmin"];appConstants.publicJsonData["pageParams"]["endmin"]=l["pageParams"]["endmin"];}});},validateAndCloseSettings:function(){var d=this.getCapacityplanningsystemsettings().getForm();var a=d.findField("timefrom").getValue();var c=d.findField("minfrom").getValue();
var b=d.findField("timeto").getValue();var e=d.findField("minto").getValue();if(!checkTimePeriod(a,c,b,e)){return;}if(Ext.getCmp("reportGeneration").getValue()=="background"&&!validateTextBoxWithSpecialChars(Ext.getCmp("bgReportName").getValue(),"Attachment",true)){return false;}else{if(Ext.getCmp("reportGeneration").getValue()=="background-csv"&&!validateTextBoxWithSpecialChars(Ext.getCmp("bgReportName").getValue(),"Attachment",true)){return false;
}}Ext.getCmp("submit").setDisabled(false);Ext.getCmp("mainformsubmit").setDisabled(false);Ext.get("configMod").animate({duration:500,to:{y:-500}});return true;},validateSettings:function(){var m=this.getCapacityplanningsystemmainform().getForm();var d,o;if(isSettingsEnabled){var b=this.getCapacityplanningsystemsettings().getForm();
d=b.findField("reportGeneration").getValue();o=b.findField("bgReportName").getValue();}else{var l=appConstants.publicJsonData.pageParams;d=l.er_reportgenration;o=l.bgReportName;}var n=m.findField("er_stdate").getValue();var a=m.findField("er_enddate").getValue();n.setHours(m.findField("er_sthr").getValue());
a.setHours(m.findField("er_endhr").getValue());var h=m.findField("er_timeline").getValue();if(Ext.isEmpty(h)){h="1 day";}if(h!=null&&h=="Any"){if(!checkDateTime(n,a)){return;}}var q=appConstants.publicJsonData["hiddenParams"]["getMaxDaysInMonth"];var c="";if(!Ext.isEmpty(q)){c=q;}var f="";var i=appConstants.publicJsonData["hiddenParams"]["er_usertimeline"];
if(!Ext.isEmpty(i)){f=i;}if(f!=null&&f!="-1"){if(!isUserTimelineLimitExceeded(f,c,n,a)){return false;}}var j=true;if(d=="foreground"){var e=appConstants.publicJsonData["hiddenParams"]["limitforbg"];if(!Ext.isEmpty(e)){if(!checkTimeLineForBgLimit(e,c,n,a)){Ext.MessageBox.confirm("Confirm",appConstants.forGrdReportConfirmMsg,this.showResult,this);
j=false;}}}else{var g=b.findField("bgReportName");if(!validateTextBoxWithSpecialChars(o,"Attachment",true)){g.focus(false,1000);return false;}}if(j&&isSettingsEnabled){var k=Ext.getCmp("submit");k.setDisabled(false);var p=Ext.getCmp("mainformsubmit");p.setDisabled(false);Ext.get("configMod").animate({duration:500,to:{y:-500}});
}return j;},showResult:function(c){if(c=="yes"){if(isSettingsEnabled){var a=Ext.getCmp("submit");a.setDisabled(false);var e=Ext.getCmp("mainformsubmit");e.setDisabled(false);Ext.get("configMod").animate({duration:500,to:{y:-500}});}this.submitReport();}else{this.getReporterSettings().down("button").fireHandler();
var d=this.getCapacityplanningsystemsettings().getForm();d.findField("reportGeneration").setValue("background");var b=d.findField("bgReportName");b.show();Ext.getCmp("submitViaSetting").show();Ext.getCmp("moreOptionCloseId").hide();this.beforeReportSubmit();}},validateForm:function(){var a=this.getCapacityplanningsystemmainform().getForm();
var j=Ext.getCmp("mainform").getForm();var b=appConstants.publicJsonData["hiddenParams"]["select_group"];if(b!=null&&(b=="Service"||b=="Segment"||b=="Zone")){var o=a.findField("er_site").getValue();if(o!=null&&o=="-1"){alert("Please choose a "+b);return false;}}else{var m=a.findField("er_site").getValue();
var o=a.findField("er_site").getValue();if(m!=null&&m=="-1"){alert("Please choose a component type");return false;}var s=new Array();s=j.findField("components").getValue();var d="";if(s!=null&&s[0]=="-1"){Ext.Msg.show({title:"Alert",msg:"Component is not applicable",buttons:Ext.Msg.OK,icon:Ext.Msg.WARNING});
return;}if(s!=null&&(s!=""&&s!="null")){for(var n=0;n<s.length;n++){d+="&er_component="+encodeURIComponent(s[n]);}}if(d!=null&&d==""){alert("Please choose a component");return false;}}var f=a.findField("er_stdate").getValue();var k=a.findField("er_enddate").getValue();var p=a.findField("er_sthr").getValue();
var t=a.findField("er_endhr").getValue();var q=a.findField("er_stdate").parseDate(f);var g=a.findField("er_enddate").parseDate(k);var c=Ext.Date.dateFormat(q,mgrDateFormat);var l=Ext.Date.dateFormat(g,mgrDateFormat);var e=formatDate(new Date(getDateFromFormat(c,appConstants.iniDateFormat)),"MM/dd/yyyy");
var r=formatDate(new Date(getDateFromFormat(l,appConstants.iniDateFormat)),"MM/dd/yyyy");var h=checktime(e,r,p,t);if(!h){Ext.Msg.show({title:"Alert",msg:appConstants.datealert,buttons:Ext.Msg.OK,icon:Ext.Msg.WARNING});return;}return true;},beforeReportSubmit:function(){var a=this.validateForm();if(a&&this.validateSettings()){this.submitReport();
}},updateQueryString:function(){var A,e,n,l,z,t,x;if(isSettingsEnabled){var s=this.getCapacityplanningsystemsettings().getForm();A=s.findField("timefrom").getValue();e=s.findField("minfrom").getValue();n=s.findField("timeto").getValue();l=s.findField("minto").getValue();z=s.findField("reportGeneration").getValue();
t=s.findField("er_excwe").getValue();x=s.findField("bgReportName").getValue();}else{var u=appConstants.publicJsonData.pageParams;A=u.timefrom;e=u.minfrom;n=u.timeto;l=u.minto;z=u.er_reportgenration;t="Yes";x=u.bgReportName;}var b=this.getCapacityplanningsystemmainform().getForm();var q=Ext.getCmp("mainform").getForm();
var h=appConstants.publicJsonData["hiddenParams"]["select_group"];var y="";if(h!=null&&(h=="Service"||h=="Segment"||h=="Zone")){y="&er_site="+b.findField("er_site").getValue();}else{var v=b.findField("er_site").getValue();var C=new Array();C=q.findField("components").getValue();var k="";if(C!=null&&(C!=""&&C!="null")){for(var w=0;
w<C.length;w++){k+="&er_component="+encodeURIComponent(C[w]);}}y="&er_comptype="+v+k;}var r=b.findField("er_timeline").getValue();if(Ext.isEmpty(r)){r="1 day";}var B=b.findField("er_stdate").dataArray;var p=b.findField("er_enddate").dataArray;var o=b.findField("er_sthr").dataArray;var g=b.findField("er_endhr").dataArray;
var j=b.findField("er_timeline").getValue();y=y+"&er_timeline="+j+"&startdate="+B+"&enddate="+p+"&starthr="+o+"&endhr="+g+"&timeto="+n+"&minto="+l+"&er_excwe="+t+"&timefrom="+A+"&minfrom="+e+"&er_reportgenration="+z+"&startmin="+mgr_stmin+"&endmin="+mgr_enmin;var a="";var m=appConstants.publicJsonData["hiddenParams"];
var d=m["er_type"];var c="chart";if(d=="No"){c="data";}y+="&opt="+c;for(var f in m){a+="&"+f+"="+m[f];}if(a!=null&&(a!="null"&&a!="undefined")){y=a+y;}if(z!=null&&z=="background"){x=checkFileName(x);y=y+"&forwardto=ErSystemCapacityReportJson&bg_reportname="+x;appConstants.urlForSubmit="../servlet/com.eg.ErStartBackGroundReportC";
}else{if(z!=null&&z=="background-csv"){x=checkFileName(x);y=y+"&forwardto=ErSystemCapacityReportJson&bg_reportname="+x;appConstants.urlForSubmit="../servlet/com.eg.ErStartBackGroundReportC?isSubmit=true&SaveFormat=CSV";}else{y=y+"&forwardto=ErSystemCapacityReport";appConstants.urlForSubmit="../servlet/com.eg.ErSystemCapacityReportC";
}}appConstants.queryString=y+"&isSubmit=true";},loadCapacityGridandTable:function(S){var x=Ext.getCmp("gridPanel");var l=S.hasAdminTab;var E=S.isCompletedUserRole;var c=S.isCapacityTrendEnabled.toLowerCase();var H=Ext.getCmp("tablePanel");x.removeAll();H.removeAll();x.show();this.getNomeasurepanel().hide();
this.getBackGroundPanel().hide();if(!Ext.isEmpty(S)){var M=Ext.getCmp("noTrendPanel");M.hide();appConstants.publicJsonData=S;var w;if(isSettingsEnabled){w=Ext.getCmp("reportGeneration").getValue();}else{w=S.pageParams.er_reportgenration;}Ext.getCmp("selectionDetails").setSelectionDetailsData(S.selDetailsJson);
if(w!=null&&w=="foreground"){var T=S.hiddenParams["er_type"];if(T=="No"){var h=S["dataAvailable"];if(h!=null&&h=="true"){Ext.getCmp("bookletTool").setDisabled(false);Ext.getCmp("saveTool").setDisabled(false);Ext.getCmp("printTool").setDisabled(false);Ext.getCmp("mailTool").setDisabled(false);Ext.getCmp("csvTool").setDisabled(false);
Ext.getCmp("upbutton").setDisabled(false);var q=S["gridObj"];var L=q["GRID_TITLE"];var r=q["COLUMNS"];var o=new Array();var e=q["gridData"];var B=x.getWidth();var f=q["gridColumnCnt"];var aa=(B/f);aa=Math.round(aa);var C=e;var ab=new Array();var N=1;for(var Z=0;Z<r.length;Z++){var U=r[Z];var k=U["colName"];
var af=U["Measurement"];var ac=U["SUB_COLUMNS"];var J=U["subHeadingsForMeasure"];if(af=="NONE"){af="&nbsp;";}var b=new Array();for(var Y=0;Y<ac;Y++){var O=J[Y];if(Y==0&&ac==4){ab.push({name:"COLUMN_"+N,type:"string"});}else{ab.push({name:"COLUMN_"+N,type:"float"});}ab.push({name:"COLUMN_Color"+N,type:"string"});
if(O=="NONE"){O="&nbsp;";}var D=0;if(ac==1){if(r.length<6){D=90;}else{D=90;}}else{if(r.length<6){D=110;}else{D=55;}}b.push({header:O,sortable:true,align:"center",dataIndex:"COLUMN_"+(N),renderer:function(aj,j,i,al,ah,ag,ak){if(typeof aj=="number"){if(isNaN(aj)){aj="-";}var ai=i.get("COLUMN_Color"+ah);
if(aj!=""&&(ai!=null&&ai!="undefined"&&ai!=undefined)&&(ai!="-"&&ai!="")){aj='<div style="background-color:'+ai+';height:14px;line-height:16px;margin-top:-2px">'+aj+"</div>";}}return aj;}});N++;}var P=new Array();P.push({header:af,sortable:true,align:"center",columns:b});if(Z==0){ab.push({name:"COLUMN_0",type:"string"});
o.push({header:k,sortable:true,align:"center",dataIndex:"COLUMN_0",renderer:function(ai,j,i,ak,ah,ag,aj){return ai;}});}else{var t=k;o.push({header:t,sortable:true,align:"center",columns:P});}}var A=true;var G=15;if(e.length>G){A=false;}appConstants.initLdgMask.hide();var I=Ext.create("Ext.data.Store",{fields:ab,data:e,pageSize:G,proxy:{type:"pagingmemory",reader:{type:"json",root:"data",totalProperty:"total"}},groupField:"COLUMN_0"});
x.add({xtype:"panel",ui:"newGraphPanel",title:L,columnWidth:1,items:[{xtype:"customgrid",store:I,border:true,ui:"newGridPanel",scroll:true,frame:false,margin:"0 10 10 10",autoScroll:true,popUpData:"grid",needtoFixColumn:true,columns:o,features:[{id:"group",ftype:"grouping",groupHeaderTpl:"{name}",hideGroupedHeader:true,enableGroupingMenu:false}],dockedItems:[{xtype:"pagingtoolbar",cls:"newPagination",dock:"bottom",id:"pageingTool",store:I,hidden:A,displayInfo:true,displayMsg:"Displaying {0} - {1} of {2}",emptyMsg:"No topics to display",listeners:{change:function(i,j){activePage=j.currentPage;
}}}]}]});x.doLayout();var u=S["measThreshDataArr"];H.add({xtype:"dataview",id:"measureStateView",margin:"10 10 10 10",store:new Ext.data.Store({fields:["measure","major","critical"],data:u}),tpl:new Ext.XTemplate('<div class="newTable" >','<table cellspacing="0" cellpadding="0" align="center" border="0" width="100%">',"<thead>","<tr>",'<th style="text-align:left">',"<div>"+S["screenLabels"]["reporter.common.Measurements"]+"</div>","</th>",'<th style="text-align:center">','<div><div style="float:left;margin-right:4px;margin-left:25%" class="state_footer_INTERMEDIATE"></div><div style="float:left">'+S["screenLabels"]["reporter.capacity.Major"]+"</div>","</th>",'<th style="text-align:center">','<div><div style="float:left;margin-right:4px;margin-left:25%" class="state_footer_HIGH"></div><div style="float:left">'+S["screenLabels"]["reporter.capacity.Critical"]+"</div>","</th>","</tr>","</thead>","<tbody>",'<tpl for=".">',"<tr>",'<td style="text-align:left">',"<div>{measure}</div>","</td>",'<td style="text-align:center">',"<div>{major}</div>","</td>",'<td style="text-align:center">',"<div>{critical}</div>","</td>","</tr>","</tpl>","</tbody>","</table>","</div>"),itemSelector:"div.newTable"});
H.doLayout();x.show();H.show();}else{if(c!=null&&c=="false"){M.show();if(l||E){M.update('<div class="egFlexCenterByColumnWise" style="height:100%"><div class="iconInformation"></div><div class="commonErrorMsgText">No Measures Available</div><div class="commonErrorMsgText"> Capacity trend computation is currently not enabled.<a href="javascript:void(0)" onclick="callAdminToEnableCP()"> Please <span style="text-decoration:underline">click here</span> to enable the flag</a></div></div>');
M.doLayout();appConstants.initLdgMask.hide();}else{M.update('<div class="egFlexCenterByColumnWise" style="height:100%"><div class="iconInformation"></div><div class="commonErrorMsgText">No Measures Available</div></div>');M.doLayout();appConstants.initLdgMask.hide();}}else{x.hide();this.getNomeasurepanel().doLayout();
this.getNomeasurepanel().show();appConstants.initLdgMask.hide();}}}else{if(T=="Yes"){var n=S.chartDataArr;var m=S.DATA_URL;var X=S.CSV_URL;if(n!=null&&n!="undefined"){appConstants.opt="chart";Ext.getCmp("saveTool").setDisabled(false);Ext.getCmp("printTool").setDisabled(false);Ext.getCmp("mailTool").setDisabled(false);
Ext.getCmp("csvTool").setDisabled(false);Ext.getCmp("upbutton").setDisabled(false);for(var a in n){var d=n[a];var p=d["title"];d["title"]="";var F="chartPannel"+a;marginVal="0 10 10 0";if(a%2!=0){marginVal="0 0 10 0";}var g=1;if(n.length>1){g=0.5;}var R="<div id="+F+' style="height:100%;width:100% !important;overflowY:hidden;padding-top:10px"></div>';
x.add({xtype:"panel",ui:"newGraphPanel",title:p,columnWidth:g,margin:marginVal,autoScroll:false,items:[{xtype:"container",height:335,id:"chartPannel"+a+"_GraphPanel",html:R,},{xtype:"container",height:55,id:"chartPannel"+a+"_legendPanel",}],header:{style:(strSkin=="Light")?"border-bottom: 1px solid #EBEBEB !important;padding: 2px 0 2px 0;margin:0px 10px 10px 10px":"margin:0px 10px 10px 10px; padding:  2px 0 2px 0;border-bottom: 1px solid #5e5e5e !important;"},tools:[this.addToolBarItems([{xtype:"button",cls:"iconData",style:{"border":"0px"},width:16,height:16,margin:"0 3 0 3",id:p+"_data",handler:function(){loadDataWindow(m+"&graphParam="+this.id);
}},{xtype:"button",width:16,height:16,margin:"0 3 0 3",style:{"border":"0px"},cls:"iconCsv",id:p+"_csv",handler:function(){window.location=X+"&isDrillDown=true&graphParam="+this.id;}}])]});var z={};z=jQuery.extend(true,{},getHighChartsBarInstance(F,270,490),z);z.setData(d,"<%=currentDateFormat%>","");
z.drawChart();}}else{x.hide();this.getNomeasurepanel().doLayout();this.getNomeasurepanel().show();appConstants.initLdgMask.hide();}appConstants.initLdgMask.hide();}}}else{if(w!=null&&(w=="background"||w=="background-csv")){x.hide();var ae=this.getBackGroundPanel();ae.removeAll();Ext.getCmp("bookletTool").setDisabled(false);
Ext.getCmp("saveTool").setDisabled(false);Ext.getCmp("printTool").setDisabled(false);Ext.getCmp("mailTool").setDisabled(false);Ext.getCmp("csvTool").setDisabled(false);Ext.getCmp("upbutton").setDisabled(false);var y=S.pageParams["bggroundStr"];var K=S.pageParams["status"];var v=S.pageParams["bgRrtMsg"];
var V=S.pageParams["bgRrtUrl"];var Q=S.pageParams["bgRptLinkMsg"];var W="";var ad="";var s="iconSuccess";if(K!=null&&(K=="duplicate"||K=="exceedLimit")){s="iconExclamation";}ad='<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="'+s+'"></div></td><td><div style="line-height:1.5em" class="font_bold11">'+v+".</br>"+'<a class="backgroundMsgLink" href='+V+">"+Q+"</a></div></td></tr></table></td></tr></table>";
ae.add({xtype:"panel",margin:0,bodyPadding:0,html:ad});ae.doLayout();ae.show();appConstants.initLdgMask.hide();}}}else{x.update('<div style="text-align:center""><div class="iconExclamation" style="margin:15% auto 0 auto;"></div><div>No Measures Available</div></div>');x.doLayout();appConstants.initLdgMask.hide();
}},submitReport:function(b){var a;if(isSettingsEnabled){Ext.get("configMod").animate({duration:500,to:{y:-500}});a=Ext.getCmp("reportGeneration").getValue();}else{a=appConstants.publicJsonData.pageParams.er_reportgenration;}this.updateQueryString();if(a=="foreground"){appConstants.queryString=appConstants.queryString+"&responseType=json";
}appConstants.queryString+="&er_RmDispName="+appConstants.er_RmDispName;appConstants.initLdgMask.show();Ext.Ajax.request({url:appConstants.urlForSubmit,params:appConstants.queryString,scope:this,success:function(c){var e=c.responseText;var d=Ext.decode(e);this.loadCapacityGridandTable(d);}});},showBackgroundReport:function(c){var b=this.getCapacityplanningsystemsettings().getForm();
var d=c.getValue();var a=b.findField("bgReportName");if(d=="background"){a.show();Ext.getCmp("submitViaSetting").show();Ext.getCmp("moreOptionCloseId").hide();}else{if(d=="background-csv"){a.show();Ext.getCmp("submitViaSetting").show();Ext.getCmp("moreOptionCloseId").hide();}else{a.hide();Ext.getCmp("submitViaSetting").hide();
Ext.getCmp("moreOptionCloseId").show();}}},defaultLoad:function(){if(appConstants.er_RmDispName!=null&&appConstants.er_RmDispName!="null"){this.getMain().setTitle(appConstants.er_RmDispName);}var f=appConstants.publicJsonData["hiddenParams"]["fromScheduleModify"];var c=appConstants.publicJsonData["hiddenParams"]["fromFavoriteModify"];
if(!Ext.isEmpty(appConstants.publicJsonData["gTypeArr"])){var e=appConstants.publicJsonData["gTypeArr"];var b=Ext.getCmp("er_type");b.suspendEvents(true);b.getStore().loadRawData(e);if(!Ext.isEmpty(appConstants.publicJsonData.hiddenParams)){b.setValue(appConstants.publicJsonData.hiddenParams["er_type"]);
}else{b.setValue(e[0].valueField);}b.resumeEvents();}this.getCapacityplanningsystemmainform().loadFields();if(!appConstants.hideBackButton){Ext.getCmp("capacityplanningsystem").add({xtype:"hidden",id:"ID",name:"ID",value:appConstants.publicJsonData["ID"]});}isTrend=true;var d=appConstants.publicJsonData["pageParams"]["selectedGroup"];
if(d!=null&&!(d=="Service"||d=="Segment"||d=="Zone")){var a=this.getCapacityplanningsystemmainform().getForm();}if(appConstants.isSubmit=="true"&&c==null&&f==null){this.beforeReportSubmit();}else{if(appConstants.isForceSubmit=="true"){appConstants.isForceSubmit="false";this.beforeReportSubmit();}}},loadSettings:function(){Ext.getCmp("moreOptionCloseId").show();
var b=appConstants.publicJsonData.hiddenParams;var a=b["favorite_id"];if(!Ext.isEmpty(a)){Ext.getCmp("reportGeneration").setDisabled(true);}if(isSettingsEnabled){this.getCapacityplanningsystemsettings().loadSettingsData();}},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();}},hideMode:function(){Ext.get("er_mode").hide();},hideTools: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);},expandMe:function(a){if(Ext.isEmpty(appConstants.erUtils)){appConstants.erUtils=Ext.widget("erutils");}appConstants.erUtils.expandMultiComboButton(Ext.getCmp("components"),"Components",a);},addToolBarItems:function(a){if(Ext.isArray(a)){var b={xtype:"toolbar",padding:"4 5 4 0",bodypadding:0,margin:"0 0 0 0",border:false,items:a};
return b;}else{alert("error in  @param, use as array [{..},{..}]");}}});