Ext.define("favorite.view.Main",{extend:((showModifyLink=="true")?"utilities.NewOuterPanel":"Ext.Panel"),alias:"widget.main",refs:[{selector:"favoriteform",ref:"favoriteform"},{selector:"favoritedetails",ref:"favoritedetails"}],requires:["favorite.view.FavoriteForm","favorite.view.FavoriteDetails","Ext.ux.form.MultiSelect","Ext.ux.form.ItemSelector","utilities.ErUtils","utilities.CommonPanel"],preventHeader:((showModifyLink=="true")?false:true),id:"saveschedule",autoScroll:true,layout:{align:"stretch",type:"vbox",pack:"start"},items:[{xtype:"form",id:"parForm",ui:((showModifyLink=="true")?"newFormPanel":""),margin:((showModifyLink=="true")?"10":"0"),standardSubmit:true,url:"",layout:{type:"vbox",align:"stretch"},items:[{xtype:"favoriteform",id:"sch_formpanel",style:{"background-color":"transparent","-webkit-box-shadow":"0px 0px 0px 0px","-moz-box-shadow":"0px 0px 0px 0px","box-shadow":"0px 0px 0px 0px"}},{xtype:"favoritedetails",id:"savedDetails",style:{"background-color":"transparent","-webkit-box-shadow":"0px 0px 0px 0px","-moz-box-shadow":"0px 0px 0px 0px","box-shadow":"0px 0px 0px 0px"},hidden:true},{xtype:"fieldcontainer",id:"buttonCont",layout:{type:"hbox",pack:"center",align:"middle"},items:[{xtype:"button",ui:"newButtonSmall",name:"update",id:"update",text:"Update",margin:"0 20 0 0 ",hidden:true},{xtype:"button",ui:"newButtonSmall",text:"Modify Selection",id:"clickModify",name:"clickModify",hidden:true,handler:function(){var f=Ext.getCmp("parForm");
var g=f.getForm();if(g.isValid()){var c=g.findField("id").getValue();var b=g.findField("fav_name").getValue();var d=g.findField("sharingCombo").getValue();var e=g.findField("shareUsers").getValue();var a="../servlet/com.eg.ErFavoriteC?cmd=Modify&id="+c+"&enableBack=true&backServletName=/servlet/com.eg.ErFavoriteC?&fromFavoriteModify=yes&er_favorite="+d+"&com.eg.CSRF_NONCE="+csrfToken;
document.location=a;}else{if(validateTextBoxWithSpecialChars(g.findField("fav_name").getValue(),"InLine",true)){return;}}}},{xtype:"button",ui:"newButtonSmall",name:"save",id:"save",text:"Save",hidden:true}]}]}],tools:[{xtype:"button",text:backText,cls:"backbutton",hidden:true,margin:"0 10 0 0",id:"favBackButton",iconCls:"iconBack",listeners:{"click":function(){document.location="../reporter/ErViewFavorite.jsp?com.eg.CSRF_NONCE="+csrfToken;
}}}],loadData:function(o){var f=Ext.getCmp("parForm").getForm();var n=o.screenLabels;var b=o.shareCombojson;var h=o.sharecombo_value;var i=o.favoritename;f.findField("fav_name").setFieldLabel(n["reporter.common.Name"]);f.findField("fav_name").setValue(i);f.findField("sharingCombo").setFieldLabel(n["reporter.common.Sharing"]);
f.findField("sharingCombo").getStore().loadRawData(b);f.findField("sharingCombo").suspendEvents(false);f.findField("sharingCombo").setValue(h);f.findField("sharingCombo").resumeEvents();var a=Ext.getCmp("savedDetails");a.loadDetails(o);var c=o.hiddenfields;var m=Ext.getCmp("parForm");for(var g in c){if(!f.findField("'"+g+"'")){m.add({xtype:"hidden",name:g,id:g,value:c[g]});
}else{f.findField("'"+g+"'").setValue(c[g]);}}var d=f.findField("Rep_name").getValue();var l="";var k="&P0=["+l+"]&P1=[REPORTER-"+o.ReportType+"]";var e="F=getValidUsers&C=fromview1"+k;var j=Ext.getCmp("itemselector-field");Ext.Ajax.request({url:"/final/servlet/com.eg.ErRemoteScriptingServlet",params:e,scope:this,method:"POST",success:function(r){var v=r.responseText;
var t=Ext.decode(v);if(!Ext.isEmpty(t)){j.getStore().removeAll();j.getStore().loadRawData(t.combo);f.findField("publicUsers").setValue(t.values);if(h=="Share"){j.show();f.findField("shareUsers").setValue(t.values);var q=f.findField("fav_name").getValue();var s=f.findField("urs_name").getValue();var p=q+"$"+s;
var u="&P0=["+p+"]&P1=[Share]&P2=[favorite]";var w="F=getFavoriteExistingUsers&C=fromview"+u;Ext.Ajax.request({url:"/final/servlet/com.eg.ErRemoteScriptingServlet",params:w,scope:this,method:"POST",success:function(x){var y=x.responseText;var z=Ext.decode(y);if(!Ext.isEmpty(t)){j.getStore().remove(z.values);
j.setValue(z.values);f.findField("publicUsers").setValue(t.values);f.findField("shareUsers").setValue(t.values);}}});}}}});if(h=="Share"){Ext.getCmp("itemselector-field").show();}},loadPanel:function(d){var e=d.errMsg;if(!Ext.isEmpty(e)){Ext.MessageBox.show({title:"Save as Favourite",msg:e["error"],buttons:Ext.MessageBox.OK,icon:"iconExclamation",fn:function(f){console.log(f);
if(f=="ok"){Ext.getCmp("fav_name").setValue("");Ext.getCmp("fav_name").focus();}}});}else{var a=d.savelink;var c='<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">'+a["reporter.common.Your selection has been saved successfully"]+"<br/> "+a["To view your selections, please go to the"]+' <a class="backgroundMsgLink" id="/final/servlet/com.eg.ErFavoriteC?cmd=View&fromNavLink=true" href="javascript:void(0)">Favorites</a> '+a["reporter.common.link"]+"</div>"+"</td>"+"</tr>"+"</table></td>"+"</tr>"+"</table>";
var b={xtype:"panel",id:"favResPane",flex:1,align:"stretch",html:c,listeners:{"afterRender":function(){Ext.get("favResPane").on("click",function(g,h,f){if(window.parent.loadFavouriteConfigureApp!=undefined){window.parent.loadFavouriteConfigureApp(h.id);}else{parent.document.getElementById("main").src=h.id;
}},this,{delegate:"a"});}}};this.removeAll();this.add(b);}}});