<head>

<?php
include("dbset.php");

$con = mysqli_connect("localhost",$dbu,$dbp);
if (!$con)
  {
  die('Could not connect to database: ' . mysqli_error());
  }
   
mysqli_select_db($con, $dbs);


$s = $_GET['s'];
$access_id = $_GET['cx'];

$table_name = "system_users";
	$access_query = "SELECT username FROM $table_name WHERE access_id = '".$access_id."' ";
	$access_result = $con->query($access_query);
	$row = mysqli_fetch_assoc($access_result);
	$login_name = $row["username"];


$update_query = "UPDATE active_users SET logged_into = 'System Admin' WHERE username = '".$login_name."' ";
$update_result = $con->query($update_query);

if ($s==3) {
	$edit_user_id= $_GET["edit_user_select"];
	$table_name = "system_users";
	$name_query = "SELECT  username, password_text, access_limit, email FROM $table_name WHERE userid='".$edit_user_id."' ";
	$name_result = $con->query($name_query);
	$row = mysqli_fetch_assoc($name_result);
	$edit_user_name = $row["username"];
	$edit_password_text = $row["password_text"];
	$edit_access = $row["access_limit"];
	$edit_email_text = $row["email"];
	
	$table_name = "system_users";
	$access_query = "SELECT username, tlh_gab, tlh_ftw, rad_gab, rad_nam, rad_rmc, vertex, pecus, admin, reporting FROM $table_name WHERE userid='".$edit_user_id."' ";
	$access_result = $con->query($access_query);
	$row = mysqli_fetch_assoc($access_result);
	$user_name = $row["username"];
	$edit_tlh_gab = $row["tlh_gab"];
	$edit_tlh_ftw = $row["tlh_ftw"];
	$edit_rad_gab = $row["rad_gab"];
	$edit_rad_nam = $row["rad_nam"];
	$edit_rad_rmc = $row["rad_rmc"];
	$edit_vertex = $row["vertex"];
	$edit_pecus = $row["pecus"];
	$edit_admin = $row["admin"];
	$edit_reporting = $row["reporting"];
	
}
else {
	$userid="";
}

if ($s==4) {
	$del_userid= $_GET["user_select"];
	$table_name = "system_users";
	$name_query = "SELECT  username FROM $table_name WHERE userid='".$del_userid."' ";
	$name_result = $con->query($name_query);
	$row = mysqli_fetch_assoc($name_result);
	$del_user_name = $row["username"];
}
else {
	$userid="";
}

$address_0 = '';
$address_1 = '';
$address_2 = '';
$address_3 = '';
$address_4 = '';

	
$table_name = "ip_address";
$address_query = "SELECT ip_address FROM $table_name where address_no = '1' ";
$address_result = $con->query($address_query);
$row = mysqli_fetch_assoc($address_result);
$address_1 = $row["ip_address"];


$address_query = "SELECT ip_address FROM $table_name where address_no = '2' ";
$address_result = $con->query($address_query);
$row = mysqli_fetch_assoc($address_result);
$address_2 = $row["ip_address"];


$address_query = "SELECT ip_address FROM $table_name where address_no = '3' ";
$address_result = $con->query($address_query);
$row = mysqli_fetch_assoc($address_result);
$address_3 = $row["ip_address"];


$address_query = "SELECT ip_address FROM $table_name where address_no = '4' ";
$address_result = $con->query($address_query);
$row = mysqli_fetch_assoc($address_result);
$address_4 = $row["ip_address"];


$address_query = "SELECT ip_address FROM $table_name where address_no = '5' ";
$address_result = $con->query($address_query);
$row = mysqli_fetch_assoc($address_result);
$address_5 = $row["ip_address"];
	


$table_name = "system_users";
$user_query = "SELECT * FROM $table_name";
$user_result = $con->query($user_query);
$user_num = mysqli_num_rows($user_result);

$table_name = "system_users";
$select_query = "SELECT userid, username FROM $table_name ORDER BY username";
	$arrId = array ();
	$arrName = array ();
	$select_result = $con->query($select_query);
	$a = 0;
	while($row = $select_result->fetch_assoc()) {
	$arrId[$a] = $row["userid"];
	$arrName[$a] = $row["username"];
	$a++;
	}
	
$table_name2 = "system_admin_tracking";
$tracking_query = "SELECT * FROM $table_name2  ORDER BY action_id DESC ";
$tracking_result = $con->query($tracking_query);
$tracking_num = mysqli_num_rows($tracking_result);

$table_name = "active_users";
$active_query = "SELECT * FROM $table_name";
$active_result = $con->query($active_query);
$active_num = mysqli_num_rows($active_result);

	
?>

<title>Tocotex CMS</title>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">


<!--style sheets-->
<link rel="stylesheet" type="text/css" href="css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="css/tooltip.css" />
<link rel="stylesheet" type="text/css" href="css/tabs.css" />
<link rel="stylesheet" type="text/css" href="css/system_admin.css" />

<script type="text/javascript" language="javascript" src="jscript/jquery.1.4.2.js"></script>
<script language="JavaScript" src="jscript/gen_validatorv4_2.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="jscript/alert_message.js"  type="text/javascript"></script>
<script language="JavaScript" src="jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="JavaScript" src="jscript/no_spaces.js"  type="text/javascript"></script> 
</head>

<body bgcolor="#CED3E8" onLoad="<?php if ($s==2) { ?> alert('User name already exits') <?php } ?>">
<div class="main_div" style="height:650px;"><br>
<img src="images/tocotex_logo_black.png" width="150" height="35"><label class="label_std" style="font-size:18px;">&nbsp;&nbsp; Company Management System Administration.</label><br>
<label class="label_std" >You are logged is as: <?php echo $login_name ?>.</label>

<div style="float:inherit;">
  <ul class="tabs">
      <li>
          <input type="radio" <?php if ($s==1) { ?> checked <?php } ?>  name="tabs" id="tab1">
          <label class="tab" for="tab1">User list</label>
          <div id="tab-content1" class="tab-content animated fadeIn">


<script type="text/javascript" language="javascript" src="jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "375px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "asc" ]],
					"aoColumns": [
								{"bSortable": true},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true}
								 ]
				} );
			} );
		</script>
        
<table id="scroll_table" class="data_display" >
  <thead>
  <tr>
    <th>User name</th>
    <th>Password</th>
    <th>Email address</th>
    <th>Tlh<br>Gab</th>
	<th>Tlh<br>Ftw</th>
    <th>Rad<br>Gab</th>
    <th>Rad<br>Nam</th>
    <th>Rad<br>Rmc</th>
    <th>Vert</th>
    <th>Pecus</th>
    <th>Admin</th>
    <th>Report</th>
  </tr>
  </thead>
<?php 
$i=0;
while($row = $user_result->fetch_assoc()) {
	$user_name = $row["username"];
	$password_text = $row["password_text"];
	$access = $row["access_limit"]; 
	$email = $row["email"];
	$tlh_gab = $row["tlh_gab"];
	$tlh_ftw = $row["tlh_ftw"];
	$rad_gab = $row["rad_gab"];
	$rad_nam = $row["rad_nam"]; 
	$rad_rmc = $row["rad_rmc"]; 
	$vertex = $row["vertex"];
	$pecus = $row["pecus"];
	$admin = $row["admin"];
	$reporting = $row["reporting"];
?>

  <tr>
    <td align="left"><?php echo $user_name ?></td>
    <td align="left"><?php echo $password_text ?></td>
    <td align="left"><?php echo $email ?></td>
    <td align="center"><?php if ($tlh_gab==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($tlh_ftw==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($rad_gab==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($rad_nam==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($rad_rmc==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($vertex==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($pecus==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($admin==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    <td align="center"><?php if ($reporting==1) { ?> <img src="images/check_mark_purple.png" width="16" height="16"> <?php } ?></td>
    </tr>
  <?php
  $i++;
}
?>

</table>


</div>
</li>
       <li>
          <input type="radio" <?php if ($s==2) { ?> checked <?php } ?>   name="tabs" id="tab2">
          <label class="tab" for="tab2">New user</label>
          <div id="tab-content2" class="tab-content animated fadeIn">

<form id="form1" name="form1" method="get" action="save_user.php">
          <br />
          <table width="650" border="0" cellspacing="0" cellpadding="0">
            <tr >
              <td height="40" colspan="2" align="left"><label class="label_std">Enter a user name and password for the new user.</label></td>
              </tr>
            <tr>
              <td width="125" height="40" align="left" ><label class="label_std">User name:</label>&nbsp;&nbsp;&nbsp;<label class="star">*</label></td>
              <td width="250" ><input name="user_name_text" type="text" class="text200" id="user_name_text" onKeyUp="nospaces(this)"  autocomplete="off" maxlength="25"/></td>
              <td><label class="label_std">(Min length 6 characters/numbers, no spaces, <br>&nbsp;&nbsp;&nbsp;case sensitive)</label></td>
              </tr>
            <tr>
              <td height="40" align="left" ><label class="label_std">Password:</label>&nbsp;&nbsp;&nbsp;<label class="star">*</label></td>
              <td ><input name="user_password_text" type="text" class="text200" id="user_password_text" onKeyUp="nospaces(this)" autocomplete="off"/></td>
              <td><label class="label_std">(Min length 6 characters/numbers, no spaces, <br>&nbsp;&nbsp;&nbsp;case sensitive)</label></td>
            </tr>
            <tr>
              <td height="40" align="left" ><label class="label_std">Limited access</label>&nbsp;&nbsp;&nbsp;</td>
              <td>
              <input name="access_checkbox" id="access_checkbox" type="checkbox" value="yes"><label class="label_std">Only to log in from saved ip address</label>
              </td>
              <td><label class="label_std">Un-check for user to log-in from anywhere</label></td>
            </tr>
            <tr>
              <td height="40" align="left" ><label class="label_std">email address: &nbsp;</label></td>
              <td colspan="2" ><input name="email_text" type="text" class="text300" id="email_text" autocomplete="off"/></td>
              </tr>
            <tr>
            <td align="center" valign="top">
            <label class="label_std">Companies to access: </label>
            </td>
            <td valign="top"> <label class="label_std">Tlhomeso Gab <input name="tlh_gab_checkbox" type="checkbox">&nbsp;&nbsp;&nbsp; Tlhomeso FTW <input name="tlh_ftw_checkbox" type="checkbox"><br><br>&nbsp;&nbsp;Radstone Gab <input name="rad_gab_checkbox" type="checkbox">&nbsp;&nbsp;&nbsp;Radstone Nam <input name="rad_nam_checkbox" type="checkbox"><br><br>&nbsp;&nbsp;Radstone RMC <input name="rad_rmc_checkbox" type="checkbox">&nbsp;&nbsp;Vertex <input name="vertex_checkbox" type="checkbox">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pecus <input name="pecus_checkbox" type="checkbox"><br><br>Admin <input name="admin_checkbox" type="checkbox">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reporting <input name="reporting_checkbox" type="checkbox"></label>
            </td>
            
            </tr>
            <tr>
              <td colspan="2" align="center"><br />
                <br />
                <input name="cx" type="hidden" value="<?php echo $access_id ?>">
                <input name="button" type="submit" class="imagebutton" id="button" value="Add new user" onClick="needToConfirm = false; "/>
                </td>
              </tr>
            </table>
        </form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("user_name_text","req","Please enter a user name.");
  frmvalidator.addValidation("user_name_text","minlen=6","Mininum length for a user name is 6 characters.");
  frmvalidator.addValidation("user_password_text","req","Please enter a password.");
  frmvalidator.addValidation("user_password_text","minlen=6","Mininum length for a password is 6 characters.");
  frmvalidator.addValidation("user_password_text","neelmnt=user_name_text","The password should not be same as user name");
  </script>      

</div>
</li>
       <li>
          <input type="radio" <?php if ($s==3) { ?> checked <?php } ?>  name="tabs" id="tab3">
          <label class="tab" for="tab3">Edit&nbsp;user</label>
          <div id="tab-content3" class="tab-content animated fadeIn">
<table width="650" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="62" height="52"></td>
      <td width="645" height="52"><div class="page_inside_frame">
        <form name="form3" id="form3" action="admin_settings.php" method="get">
          <label class="std">Select a user to edit:&nbsp;&nbsp;&nbsp;&nbsp;</label>
          <select name="edit_user_select" class="select160" onChange="window.location.href= this.form.edit_user_select.options[this.form.edit_user_select.selectedIndex].value" >
            <option value=""></option>
            <?php
        	for ($i = 0; $i < count($arrId); $i++) {
    		  echo "<option value=admin_settings.php?edit_user_select=".$arrId[$i]."&s=3&cx=".$access_id.">".$arrName[$i]."</option>";
	}
?>
          </select>
        </form>
</div>
    
<?php if ($s==3) { ?>
        <form id="form3a" name="form3a" method="get" action="save_edit_user.php">
          <br />
          <table width="600" border="0" cellspacing="0" cellpadding="0">
            <tr >
              <td height="40" colspan="2" align="left"><label class="label_std">Edit password and email address for this user.</label></td>
              </tr>
            <tr>
              <td width="125" height="40" align="left" ><label class="label_std">User name:</label>&nbsp;&nbsp;&nbsp;</td>
              <td width="250" ><?php echo $edit_user_name ?><input name="edit_user_name_text" type="hidden" value="<?php echo $edit_user_name ?>">
                <br /></td>
                <td>&nbsp;&nbsp;</td>
              </tr>
            <tr>
              <td height="40" align="left" ><label class="label_std">Password:</label>&nbsp;&nbsp;&nbsp;<label class="star">*</label></td>
              <td ><input name="edit_user_password_text" type="text" class="text150" id="edit_user_password_text" value="<?php echo $edit_password_text ?>" onKeyUp="nospaces(this)" autocomplete="off" onfocus = "this.select();"/></td>
              <td><label class="label_std">(Min length 6 characters/numbers, no spaces, case sensitive)</label></td>
              </tr>
           <tr>
              <td height="40" align="left" ><label class="label_std">Limited access</label>&nbsp;&nbsp;&nbsp;</td>
              <td>
              <input name="access_checkbox" id="access_checkbox" type="checkbox" <?php if ($edit_access=='yes') {?> checked <?php } ?>><label class="label_std">Only to log in from saved ip address</label>
              </td>
              <td><label class="label_std">Un-check for user to log-in from anywhere</label></td>
            </tr>   
            <tr>
              <td height="40" align="left" ><label class="label_std">email address: &nbsp;</label></td>
              <td colspan="2" ><input name="edit_email_text" type="text" class="text300" id="email_text" value="<?php echo $edit_email_text?>" autocomplete="off" onKeyUp="nospaces(this)" onfocus = "this.select();" /></td>
              </tr>
            <tr>
              <td colspan="2" align="center"><br />
                <input name="cx" type="hidden" value="<?php echo $access_id ?>">
                <input name="button" type="submit" class="imagebutton" id="button" value="Save changes" onClick="needToConfirm = false; "/>
                </td>
              </tr>
              </table>
              </form>
              <script language="JavaScript" type="text/javascript" xml:space="preserve">
  				var frmvalidator  = new Validator("form3a");
  				frmvalidator.EnableMsgsTogether();
  			    frmvalidator.addValidation("edit_user_password_text","req","Please enter a password.");
                frmvalidator.addValidation("edit_user_password_text","minlen=6","Mininum length for a password is 6 characters.");
 			 </script> 
             <hr> 
             <label class="label_std">Click + or - to add or remove access rights.</label><br><br>


            <table width="650" border="0" cellspacing="0" cellpadding="0">    
            <tr>
            <td align="left" height="40">
            <?php if ($edit_tlh_gab==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=tlh_gab1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Tlhomeso Gab.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=tlh_gab0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Tlhomeso Gab.<?php } ?>
            </td>
            <td align="left" height="40">
            <?php if ($edit_rad_gab==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=rad_gab1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Radstone Gab.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=rad_gab0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Radstone Gab.<?php } ?>
            </td>
            
            <td align="left" height="40">
            <?php if ($edit_rad_rmc==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=rad_rmc1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Radstone RMC.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=rad_rmc0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Radstone RMC.<?php } ?>
            </td>
            
            <td align="left" height="40">
            <?php if ($edit_vertex==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=vertex1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Vertex.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=vertex0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Vertex.<?php } ?>
            </td>
            
            <td align="left" height="40">
            <?php if ($edit_pecus==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=pecus1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Pecus.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=pecus0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Pecus.<?php } ?>
            </td>
            </tr>
            <tr>
            <td><?php if ($edit_tlh_ftw==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=tlh_ftw1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Tlhomeso Ftw.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=tlh_ftw0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Tlhomeso Ftw.<?php } ?>
            </td>
            <td><?php if ($edit_rad_nam==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=rad_nam1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Radstone Namibia.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=rad_nam0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Radstone Namibia.<?php } ?>
            </td>
            <td><?php if ($edit_admin==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=admin1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Admin.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=admin0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Admin.<?php } ?>
            </td>
            <td><?php if ($edit_reporting==0) { ?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=reporting1"><img src="images/plus.png" width="16" height="16"></a>&nbsp;<font color="#999999">Reporting.</font><?php } else {?><a href="save_access_user.php?edit_user_id=<?php echo $edit_user_id?>&cx=<?php echo $access_id ?>&access=reporting0"><img src="images/minus.png" width="16" height="16"></a>&nbsp;Reporting.<?php } ?>
            </td>
            </tr>
            <tr>
            
            
            </tr>
           </table>
        
        <?php } ?></td>
      <td width="43" height="52"></td>
    </tr>
  </table>
</div>
</li>
<li>
          <input type="radio" <?php if ($s==4) { ?> checked <?php } ?>  name="tabs" id="tab4">
          <label class="tab" for="tab4">Remove user</label>
          <div id="tab-content4" class="tab-content animated fadeIn">
<table width="650" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="62" height="52"></td>
      <td width="645" height="52"><div class="page_inside_frame">
        <form name="form2" id="form2" action="admin_settings.php" method="get">
          <label class="std">Select a user to remove:&nbsp;&nbsp;&nbsp;&nbsp;</label>
          <select name="user_select" class="selectbox120" onChange="window.location.href= this.form.user_select.options[this.form.user_select.selectedIndex].value" >
            <option value=""></option>
            <?php
        	for ($i = 0; $i < count($arrId); $i++) {
    		  echo "<option value=admin_settings.php?user_select=".$arrId[$i]."&s=4&cx=".$access_id.">".$arrName[$i]."</option>";
	}
?>
          </select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         
        </form>
      
      </div>
        <br />
        <br />
        <br /><br />
<br />
<?php if ($s==4) { ?>
        <div class="page_inside_frame">
            <img src="images/exclamation-mark_small.png" width="24" height="24">
            <label class="label_std">If you remove the user, the user will be permantly be removed from the system. All settings for all programs (including permissions) will be deleted. This action cannot be undone.<br />
            </label>
            <br /><br />


            <label class="label_std">To remove user:&nbsp;<font size="3"><b>"<?php echo $del_user_name ?>"</b></font> &nbsp;&nbsp;&nbsp;&nbsp;click </label>&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="remove_button" type="button" class="imagebutton" id="remove_button" value="Remove" onClick="MM_goToURL('parent','save_remove_user.php?del_userid=<?php echo $del_userid ?>&cx=<?php echo $access_id ?>');return document.MM_returnValue"/>
                      
        </div>
        <?php } ?></td>
      <td width="43" height="52"></td>
    </tr>
  </table>
</div>
</li>
<li>
          <input type="radio"  name="tabs" id="tab5">
          <label class="tab" for="tab5">History</label>
          <div id="tab-content5" class="tab-content animated fadeIn">
          
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script>
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table2').dataTable( {
					"sScrollY": "350px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 5, "desc" ]],
					"aoColumns": [
								{"iDataSort": 5},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
        
<table width="500" id="scroll_table2" class="data_display">
  <thead>
  <tr>
    <th width="30">date</th>
    <th width="10">time</th>
    <th width="30">user</th>
    <th width="80">action</th>
    <th width="350">details</th>
    <th>&nbsp;</th>
    </tr>
   </thead>
<?php 

$i=0;

while($row = $tracking_result->fetch_assoc()) {
    $b0  =  $row["action_id"];
	$b1 =  $row["entry_date"];
	$b2 =  $row["user_name"];
	$b3 =  $row["action"];
	$d1 = $row["details_1"];
	$d2 = $row["details_2"];
	$d3 = $row["details_3"];
	$d4 = $row["details_4"];
	
	
	$action='';
	$details='';
	switch ($b3) {
   	case 10:
        $action = 'New user';
		$details = '<b>'.$d1.'</b> was added as new user';
        break;
	case 11:
        $action = 'Set access';
		$details = '<b>'.$d1.'</b> was given access to <b>'.$d2.'<b>.';
        break;	
	case 12:
        $action = 'Set access';
		$details = '<b>'.$d1.'</b> was given access to <b>'.$d2.'<b>.';
        break;
	case 13:
        $action = 'Withdraw access';
		$details = '<b>'.$d1.'</b> was withdrawn access to <b>'.$d2.'<b>.';
        break;	
	case 14:
        $action = 'Edit user details';
		$details = $d4.' for <b>'.$d1.'</b> was changed from <b>'.$d2.'</b> to <b>'.$d3.'</b>.';
        break;				
	case 15:
        $action = 'Remove user';
		$details = '<b>'.$d1.'</b> was removed as user';
        break;
}
	
	?>
  
  
  <tr>
    <td  align="left"><?php echo date("d-m-Y", strtotime($b1 )) ?></td>
    <td  align="left"><?php echo date("H:i", strtotime($b1 ))  ?></td>
    <td  align="left"><?php echo $b2 ?></td>
    <td  align="left"><?php echo $action ?></td>
    <td  align="left"><?php echo $details ?></td>
    <td  align="left"><?php echo $b1?></td>
  </tr>
  <?php
  $i++;
}
?>
</table>                  
          
</div>
</li>


<li>
          <input type="radio"  name="tabs" id="tab7">
          <label class="tab" for="tab7">IP-address</label>
          <div id="tab-content7" class="tab-content animated fadeIn">

<form action="save_address.php" method="get" name="ip_form">  
Authorised  IP addresses:<br><br>

1.&nbsp;<input name="ip_text1" class="text150" type="text" autocomplete="off" value="<?php echo $address_1 ?>"><br><br> 
2.&nbsp;<input name="ip_text2" class="text150" type="text" autocomplete="off" value="<?php echo $address_2 ?>"><br><br>  
3.&nbsp;<input name="ip_text3" class="text150" type="text" autocomplete="off" value="<?php echo $address_3 ?>"><br><br>  
4.&nbsp;<input name="ip_text4" class="text150" type="text" autocomplete="off" value="<?php echo $address_4 ?>"><br><br>  
5.&nbsp;<input name="ip_text5" class="text150" type="text" autocomplete="off" value="<?php echo $address_5 ?>"><br><br> 
<br><br>

<input name="cx" type="hidden" value="<?php echo $access_id ?>">
<input name="save_address_button" type="submit" class="imagebutton"  value="Save addresses" > 
</form>                    


</div>
</li> 
         
</ul>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>



<div style="float:left;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="../main.php?e="><input name="return_button" type="button" value="Return to log in page." class="imagebutton"></a>

<a href="../mainmenu.php?log=2&e=0&cx=<?php echo $access_id ?>">
<input name="return_button2" type="button" value="Return to main menu." class="imagebutton">
</a></div>
</div>

</div>
</body>