<?php
	session_start();
	if (!isset($_SESSION['view_id']))
		header("Location: index.php");
		
	include "../connect/db_connection.php";
			
		$query = "SELECT * FROM `users`";
		$result = mysql_query($query, $bwb_link);
		$num_results = mysql_num_rows($result);
		$j = 0;
		for ($i = 0; $i < $num_results; $i++)
		{
			$row = mysql_fetch_array($result);
			$tmp_user_name = $row["UserID"];
			if ($tmp_user_name != "admin")
			{
				$user_name[$j] = $row["UserID"];
				$password[$j] = $row["password"];
//				$AccessLevel[$j] = $row["AccessLevel"];
				$j++;
			}
		}
?>
<html>
<head>
<title>Inventory Management System</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<br>
<div align="center">
<table width="80%" border="1" cellspacing="0" cellpadding="0"><tr><td>
<form name="formAddUser" method="post" action="add_user.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="6"><strong>Add User</strong></td>
  </tr>
  <tr>
    <td align="right">User Name: </td>
    <td><input type="text" name="user_name"></td>
    <td align="right">Password: </td>
    <td> <input type="text" name="password"></td>
    <td align="right">Access Level: </td>
    <td><select name="selectAccessLevel" id="selectAccessLevel">
    <option value="3" selected>Reseller
    <option value="2">Associate
    <option value="1">Manager
    </select></td>
  </tr>
  <tr><td colspan="6">&nbsp;</td></tr>
  <tr>
    <td colspan="6" align="center"><input type="submit" name="Submit" value="Add"></td>
  </tr>
  </table>
  </form>
  </td></tr></table>
  <br>
  <table width="80%" border="1" cellspacing="0" cellpadding="0"><tr><td>
  <form name="formChangePassword" method="post" action="change_password.php">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="6"><strong>Change Password</strong></td>
  </tr>
  <tr>
    <td align="right">User Name: </td>
    <td><select name="selectUserName" id="selectUserName">
<?php
	for ($i = 0; $i < ($num_results - 1); $i++)
		echo "<option value='$user_name[$i]'>$user_name[$i]";
	echo "<option value='admin'>admin";
?>
    </select></td>
	 <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">New Password: </td>
    <td><input type="text" name="password"></td>
  </tr>
  <tr><td colspan="6">&nbsp;</td></tr>
  <tr>
    <td colspan="6" align="center"><input type="submit" name="Submit" value="Change Password"></td>
  </tr>
  </table>
  </form>
  </td></tr></table>
  <br>
  <table width="80%" border="1" cellspacing="0" cellpadding="0"><tr><td>
  <form name="formDeleteUser" method="post" action="delete_user_confirm.php">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="6"><strong>Delete User</strong></td>
  </tr>
  <tr>
  	<td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">User Name: </td>
    <td><select name="selectUserName" id="selectUserName">
<?php
	for ($i = 0; $i < ($num_results - 1); $i++)
		echo "<option value='$user_name[$i]'>$user_name[$i]";
?>
    </select></td>
	<td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr><td colspan="6">&nbsp;</td></tr>
  <tr>
    <td colspan="6" align="center"><input type="submit" name="Submit" value="Delete"></td>
  </tr>
</table>
  </form>
  </td></tr></table>
  <br>
  <table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td align="center"><input name="Inventory" type="button" id="Inventory" value="Go to Inventory Manager" onClick="location='manage_inventory.php'"></td>
	  <td align="center"><input name="Artists" type="button" id="Artist" value="Go to Artist Manager" onClick="location='artist.php'"></td>
	  <td align="center"><input name="Categories" type="button" id="Category" value="Go to Category Manager" onClick="location='category.php'"></td>
  </tr>
</table>
</div>
</body>
</html>
