<%@ page language="VB" autoeventwireup="false" inherits="Manage_EditUserPermissions, App_Web_xr0wyyam" enableEventValidation="false" %>
<%@ Register TagPrefix="obout" Namespace="Obout.Grid" Assembly="obout_Grid_NET" %>
<%@ Register TagPrefix="obout" Namespace="OboutInc.Flyout2" Assembly="obout_Flyout2_NET" %>
<%@ Register Assembly="obout_Window_NET" Namespace="OboutInc.Window" TagPrefix="owd" %>
<%@ Register TagPrefix="oem" Namespace="OboutInc.EasyMenu_Pro" Assembly="obout_EasyMenu_Pro" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Edit User Details</title>
        <link href="../StyleSheet.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../md5-min.js"></script>

        <script type="text/javascript">

		      
		       function SelectAllPermissions()
		        {
		            var DivObjevt=document.getElementById("<%=div_Edittree.ClientID %>");
		            var arrCheckboxes = DivObjevt.getElementsByTagName("INPUT");    
                    for(var i=0; i<arrCheckboxes.length; i++)
                     {      
                        if(arrCheckboxes[i].type == "checkbox")
                         {
                            arrCheckboxes[i].checked=true;
                        }
                    }
		        }
		        
		       
		      
		       function DeSelectAllPermissions()
		        {
		            var DivObjevt=document.getElementById("<%=div_Edittree.ClientID %>");
		            var arrCheckboxes = DivObjevt.getElementsByTagName("INPUT");    
                    for(var i=0; i<arrCheckboxes.length; i++)
                     {      
                        if(arrCheckboxes[i].type == "checkbox")
                         {
                            arrCheckboxes[i].checked=false;
                        }
                    }
		        }
		        
		        function SelectPermissions()
		        {
		            var listString = document.getElementById('Hdn_EditPermissionsId').value;
                    var PermissionArray=new Array();
                    PermissionArray = listString.split(',');
                    var DivObjevt=document.getElementById("<%=div_Edittree.ClientID %>");
		            var arrCheckboxes = DivObjevt.getElementsByTagName("INPUT");   
		                for(var i=0;i<PermissionArray.length;i++)
		                {
		                    for(var j=0;j<arrCheckboxes.length;j++)
		                    {
		                        if (PermissionArray[i]==arrCheckboxes[j].name)
		                        {
		                            arrCheckboxes[j].checked=true;
		                        }
		                    }
		                }
		        }
		        
		        
		        function btn_Save_onclick()
		        {
		            document.getElementById("<%=Hdn_EditPermissionsId.ClientID %>").value='';
		            document.getElementById("<%=Hdn_EditCompaniesId.ClientID %>").value='';
		            var oRecord = new Object();
		            
		            var DivObjevt=document.getElementById("<%=div_Edittree.ClientID %>");
		            var arrCheckboxes = DivObjevt.getElementsByTagName("INPUT");    
                    for(var i=0; i<arrCheckboxes.length; i++)
                    {      
                        if(arrCheckboxes[i].type == "checkbox" && arrCheckboxes[i].checked==true)
                         {
	                        document.getElementById("<%=Hdn_EditPermissionsId.ClientID %>").value=document.getElementById("<%=Hdn_EditPermissionsId.ClientID %>").value+arrCheckboxes[i].name+','
                            
                        }
                    }
                    
                    var str = '<%= Session("rnumb") %>';
                    if(document.getElementById('<%= txt_EditPassword.ClientID %>').value != "")
                    {
                     var passstr=document.getElementById('<%= txt_EditPassword.ClientID %>').value;
                     document.getElementById('<%= txt_EditPassword.ClientID %>').value= str+ hex_md5(passstr);
                    }
                    
	               
		        }
		        
		        function Close() {  
                   opener.ReloadGrid();  
                   self.close();  
                } 
		      
        
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="rowEditTable">
            <tr>
                <td>
                    <fieldset>
                        <legend>System User Information</legend>
                        <table>
                            <tr>
                                <td style="font-weight: bold;">
                                    Login&nbsp;Name</td>
                                <td>
                                    <asp:TextBox ID="txt_EditLogin" AutoComplete="off"  runat="server" Width="130px"></asp:TextBox>
                                </td>
                                <td style="font-weight: bold;">
                                    Password
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_EditPassword" runat="server" CssClass="WebControls" TextMode="Password"
                                        Width="130px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Role Name
                                </td>
                                <td colspan="3">
                                    <asp:TextBox ID="txt_EditRoleName" CssClass="WebControls" runat="server" Width="333px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    Permissions Allowed
                                </td>
                                <td colspan="2">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                       <div id="div_Edittree" runat="server" style="border-right: black 1px solid; border-top: black 1px solid;
                                        border-left: black 1px solid; border-bottom: black 1px solid;">
                                        <asp:Literal ID="EditTreeview" EnableViewState="true" runat="server" />
                                    </div>
                                    <select visible="false" id="lst_EditPermissions" class="WebControls" runat="server"
                                        multiple="true" style="width: 202px; height: 200px">
                                    </select></td>
                                <td colspan="2">
                                 
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: left">
                                    <asp:HyperLink ID="lnk_EditPermissionsSelectAll" Style="cursor: hand;" CssClass="WebControls"
                                        onclick="SelectAllPermissions()" runat="server">Select All</asp:HyperLink><asp:HyperLink ID="lnk_EditPermissionsDeSelectAll" Style="cursor: hand;" CssClass="WebControls"
                                        onclick="DeSelectAllPermissions()" runat="server">Deselect All</asp:HyperLink></td>
                                <td colspan="2">
                                    &nbsp; &nbsp;&nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:CheckBox ID="chkEditIsAdmin" runat="server" CssClass="WebControls" Text="Is Admin" /></td>
                                <td colspan="2">
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
            <tr>
                <td align="right" colspan="2">
                    <asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="btn_Save_onclick()"  />
                    <input
                        id="btn_EditCancel" type="button" value="Close" onclick="Close();" />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp; &nbsp; &nbsp;
                    <asp:Label runat="server" ForeColor="red" EnableViewState="false" ID="Label1"></asp:Label>
                    <asp:HiddenField ID="Hdn_EditUserId" runat="server" />
                    <asp:HiddenField ID="Hdn_EditLoginUserId" runat="server" />
                    <asp:HiddenField ID="Hdn_EditPermissionsId" runat="server" />
                    <asp:HiddenField ID="Hdn_EditCompaniesId" runat="server" />
                    <asp:HiddenField ID="Hdn_EditLoginPassword" runat="server" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
