Ext.define("DeleteUsers.controller.Main",{extend:"Ext.app.Controller",views:["FormItems"],refs:[{selector:"FormItems",ref:"FormItems"},],init:function(){appCnt=this;this.control({"formitems":{"afterrender":this.afterMainRender},'formitems button[id="deleteusers"]':{"click":this.deleteUsers},'formitems combo[id="usertypes"]':{"select":this.changeUserCategory},'formitems button[id="selectAll"]':{"click":this.selectAllNodes}});
},getSelectedNodeDetails:function(){selectedUsersCount=0;var c=new Array();var a=Ext.getCmp("userTreePanel");if(a.getRootNode()!=null&&a.getRootNode()!="undefined"){for(var b=0;b<a.getRootNode().childNodes.length;b++){var d=a.getRootNode().childNodes[b];if(d.data.checked){selectedUsersCount++;c.push(d.data.id);
selectedUsersCount+=d.childNodes.length;}else{var e=d.childNodes;if(e.length>0){if(d.data.checked){c.push(d.data.id);}appCnt.getChildrenDetails(e,c);}else{if(d.data.checked){c.push(d.data.id);}}}}}return c;},getChildrenDetails:function(d,c){var f="";for(var a=0;a<d.length;a++){var b=d[a];if(b.data.checked){selectedUsersCount++;
c.push(b.data.id);selectedUsersCount+=b.childNodes.length;}else{var e=b.childNodes;if(e.length==0){if(f.indexOf(",")==-1){f+=","+b.data.id;if(b.data.checked){c.push(b.data.id);}}else{f+=","+b.data.id;if(b.data.checked){c.push(b.data.id);}}}else{if(f.indexOf(",")==-1){f=","+b.data.id;if(b.data.checked){c.push(b.data.id);
}}else{f+=","+b.data.id;if(b.data.checked){c.push(b.data.id);}}f+=appCnt.getChildrenDetails(e,c);}}}return c;},selectAllNodes:function(d){var a=Ext.ComponentQuery.query("treepanel[id=userTreePanel]")[0];var b=Ext.getCmp("selectAll");var c=b.getText();if(c!=null&&c!="undefined"&&c==selectTxt){a.getRootNode().cascadeBy(function(){var e=this.data.id;
var f=Ext.getCmp("searchbox").getValue();if(e!="egenterprise"&&(Ext.isEmpty(f)||(!Ext.isEmpty(f)&&(this.data.text.toLowerCase()).indexOf(f.toLowerCase())>-1))){if(publicJSON["editableNodes"].indexOf(e)>-1){this.set("checked",true);b.setText(deSelectTxt);if(this.hasChildNodes()&&(!Ext.isEmpty(f)&&(this.data.text.toLowerCase()).indexOf(f.toLowerCase())>-1)){Ext.getCmp("userTreePanel").fireEvent("checkchange",this,true,"");
b.setText(deSelectTxt);}}}});}else{a.getRootNode().cascadeBy(function(){var e=this.data.id;if(e!="egenterprise"){if(publicJSON["editableNodes"].indexOf(e)>-1){this.set("checked",false);b.setText(selectTxt);}}});}},afterMainRender:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();
Ext.Ajax.request({url:"/final/admin/DeleteUsers/data/EgDeleteUserElementsJson.jsp?operation=renderer&categoryType=all",method:"POST",timeout:120000,success:function(b){a.hide();if(b.status==200){if(!Ext.isEmpty(b.responseText.trim())){Ext.getCmp("delete_button_container").show();var d=b.responseText;
publicJSON=Ext.decode(d);if(publicJSON.noUsersConfigured){usersNotYetConfigured();}else{Ext.getCmp("single_listbox_container").show();var c={text:"Enterprise Organizations",expanded:true,children:publicJSON["exportDataArr"]};Ext.getCmp("userTreePanel").setRootNode(c);Ext.getCmp("selectAll").setText(selectTxt);
}}else{usersNotYetConfigured();}}}});},deleteUsers:function(){var b=this.getSelectedNodeDetails();if(b.length==0){Ext.MessageBox.show({title:pageTitle,msg:select_users+".",width:select_users.length*7,icon:"iconInformation",buttons:Ext.Msg.OK});}else{var a=null;if(manager_model=="msp"){if(alert_type=="1"){a=confirmation_common1;
if(selectedUsersCount>1){a=confirmation_common2;}}else{a=confirmation_common3;if(selectedUsersCount>1){a=confirmation_common4;}}}else{if(alert_type=="1"){a=confirmation_common1;if(selectedUsersCount>1){a=confirmation_common2;}}else{a=confirmation_common3;if(selectedUsersCount>1){a=confirmation_common4;
}}}var c=Ext.getCmp("usertypes").getValue();Ext.Msg.show({title:pageTitle,msg:a,width:a.length*7,icon:"iconConfirmation",buttons:Ext.Msg.YESNO,fn:function(d){if(d=="yes"){callDeleteUserCode(b,c);}}});}},changeUserCategory:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();var b=Ext.getCmp("usertypes").getValue();
if(b!=currentSelection){Ext.getCmp("imagemsg").hide();currentSelection=b;Ext.Ajax.request({url:"/final/admin/DeleteUsers/data/EgDeleteUserElementsJson.jsp?operation=renderer&categoryType="+currentSelection,method:"POST",timeout:120000,success:function(d){a.hide();if(d.status==200){if(!Ext.isEmpty(d.responseText.trim())){publicJSON=Ext.decode(d.responseText);
if(publicJSON.orgUsersNotFound){Ext.getCmp("delete_button_container").hide();Ext.getCmp("searchbox").setDisabled(true);Ext.getCmp("selectAll").setDisabled(true);Ext.getCmp("nodeExpand").setDisabled(true);Ext.getCmp("nodeCollapse").setDisabled(true);var e={text:"Organizations",expanded:true,children:publicJSON["exportDataArr"]};
Ext.getCmp("userTreePanel").setRootNode(e);var c=Ext.getElementById("noDataFound");if(c==null||c===undefined){Ext.DomHelper.append(Ext.get(Ext.getCmp("userTreePanel").getView().id),{tag:"div",style:{"height":"95%","width":"100%","textAlign":"center","display":"table"},cls:"new-div-cls",id:"noDataFound",html:LoadAlert});
}else{c.style.display="table";}}else{Ext.getCmp("deleteusers").show();Ext.getCmp("searchbox").setDisabled(false);Ext.getCmp("selectAll").setDisabled(false);Ext.getCmp("nodeExpand").setDisabled(false);Ext.getCmp("nodeCollapse").setDisabled(false);Ext.getCmp("delete_button_container").show();Ext.getCmp("single_listbox_container").show();
var e={text:"Organizations",expanded:true,children:publicJSON["exportDataArr"]};Ext.getCmp("userTreePanel").setRootNode(e);Ext.getCmp("selectAll").setText(selectTxt);var c=Ext.getElementById("noDataFound");if(c!=null&&c!=undefined){c.style.display="none";}}}else{Ext.getCmp("deleteusers").hide();Ext.getCmp("searchbox").setDisabled(true);
Ext.getCmp("selectAll").setDisabled(true);Ext.getCmp("nodeExpand").setDisabled(true);Ext.getCmp("nodeCollapse").setDisabled(true);Ext.getCmp("delete_button_container").hide();var e={text:"Organizations",expanded:true,children:publicJSON["exportDataArr"]};Ext.getCmp("userTreePanel").setRootNode(e);var c=Ext.getElementById("noDataFound");
if(c==null||c===undefined){Ext.DomHelper.append(Ext.get(Ext.getCmp("userTreePanel").getView().id),{tag:"div",style:{"height":"95%","width":"100%","textAlign":"center","display":"table"},cls:"new-div-cls",id:"noDataFound",html:LoadAlert});}else{c.style.display="table";}}}}});}}});function callDeleteUserCode(d,h){var f="/final/admin/DeleteUsers/data/Egdeleteuserp.jsp";
var c=new Ext.LoadMask(Ext.getBody(),{msg:processingLabel});c.show();try{for(var b in d){d[b]=d[b];}}catch(g){d=d;}Ext.Ajax.request({url:f,method:"POST",params:{"uname":d},standardSubmit:false,timeout:300000,success:function(a){c.hide();if(a.status==200){c.show();Ext.Ajax.request({url:"/final/admin/DeleteUsers/data/EgDeleteUserElementsJson.jsp?operation=afterDelete&categoryType="+h,method:"POST",timeout:300000,success:function(e){c.hide();
if(e.status==200){Ext.MessageBox.show({title:pageTitle,msg:deletedMessage+".",width:deletedMessage.length*7,icon:"iconInformation",buttons:Ext.Msg.OK});if(!Ext.isEmpty(e.responseText.trim())){var k=e.responseText;publicJSON=Ext.decode(k);if(publicJSON.noUsersConfigured){usersNotYetConfigured();}else{if(publicJSON.orgUsersNotFound){Ext.getCmp("single_listbox_container").hide();
Ext.getCmp("imagemsg").show();Ext.getCmp("delete_button_container").hide();}else{Ext.getCmp("single_listbox_container").show();var j={text:"Organizations",expanded:true,children:publicJSON["exportDataArr"]};Ext.getCmp("userTreePanel").setRootNode(j);Ext.getCmp("searchbox").setValue("");Ext.getCmp("selectAll").setText(selectTxt);
}}}else{usersNotYetConfigured();}}}});}},failure:function(a){c.hide();}});}function usersNotYetConfigured(){Ext.getCmp("no_user_container").show();Ext.getCmp("single_listbox_container").hide();Ext.getCmp("delete_button_container").hide();}function egTitleSearch(){var h=Ext.getCmp("userTreePanel");var c=Ext.getCmp("searchbox").getValue();
var f="MyTrigger_searchbox_0";var e="MyTrigger_searchbox_1";if(c==""||c.length==0){Ext.get(f).setStyle("display","none");Ext.get(e).setStyle("display","block");}else{Ext.get(e).setStyle("display","none");Ext.get(f).setStyle("display","block");}if(c==null||c==""){Ext.getCmp("userTreePanel").filterBy(c,"text");
var b=Ext.getElementById("noDataFound");if(b){Ext.getCmp("delete_button_container").show();b.style.display="none";}}else{Ext.getCmp("userTreePanel").filterBy(c,"text");}var a=publicJSON["editableNodes"];var d=new Array();var g=new Array();for(i=0;i<a.length;i++){if(!Ext.Array.contains(d,a[i])){d.push(a[i]);
if(Ext.getCmp("userTreePanel").getStore().getNodeById(a[i]).data.checked){g.push(a[i]);}}}if(g.length==d.length){Ext.getCmp("selectAll").setText(deSelectTxt);}else{Ext.getCmp("selectAll").setText(selectTxt);}}