<?php 
include 'check.php';
include '../db.inc.php';
include 'check_msg.php';
$ac=$_GET['user'];
$sql="SELECT * FROM users WHERE number='$ac'";
$query=mysqli_query($connectionString,$sql);
$get=mysqli_fetch_array($query,MYSQLI_ASSOC);
if(isset($_POST['submit'])) {
	$type=$_POST['type'];
	$balance=$_POST['balance'];
	$balance2=$_POST['balance2'];
	$status=$_POST['status'];
	$tax_status=$_POST['tax_status'];
	$sql="UPDATE users SET type='$type', balance='$balance', balance2='$balance2', status='$status', tax_status='$tax_status' WHERE number='$ac'";
	mysqli_query($connectionString,$sql);
	if(is_uploaded_file($_FILES['picture']['tmp_name'])) {
			$tmpName = addslashes(fread(fopen($_FILES['picture']['tmp_name'],"r"),
			filesize($_FILES['picture']['tmp_name'])));
		mysqli_query($connectionString,"UPDATE users SET picture='$tmpName' WHERE number='$ac' LIMIT 1");
	}
?>
<script>
alert('Details Successfully Updated');
location.replace('./');
</script>
<?php
exit;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Administrator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="96%" height="421" border="0" cellspacing="5">
  <tr>
    <td width="14%" height="274" valign="top" style="border:#003399 1px solid;"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="21" bgcolor="#de0011" class="headers">Navigation</td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="1">
          <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="./">Home</a></strong></font></p></td>
          </tr>
           <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="smssender.php">SMS 
              Sender</a></strong></font></p></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><p><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="add.php">Add 
              User</a></strong></font></p></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="addact.php">Add Activity </a></strong></font></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="viewact.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Activities </strong></font></a></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="messages.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Messages (<?php echo $umsg; ?>)</strong></font></a></td>
          </tr>
          <tr>
            <td bgcolor="#E8FFF8"><a href="alerts.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>View Alerts</strong></font></a></td>
          </tr>
          
          <tr>
            <td bgcolor="#E8FFF8"><a href="sql.php"><font size="2" face="Arial, Helvetica, sans-serif"><strong>SQL</strong></font></a></td>
          </tr>
		  
          <tr>
            <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="logout.php">Log 
              Out</a></strong></font></td>
          </tr>
        </table>
        <p>&nbsp;</p>
          </td>
      </tr>
    </table>      
      <p>&nbsp;</p>
    </td>
    <td width="86%" valign="top" style="border:#003399 1px solid;"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="21" bgcolor="#de0011" class="headers">Manage Account </td>
      </tr>
      <tr>
        <td><form action="" method="post" enctype="multipart/form-data" name="form1">
            <table width="100%" border="0" cellspacing="1">
              <tr>
                <td width="14%" bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">Account Type</font></td>
                <td width="86%" bgcolor="#E8FFF8"><input name="type" type="text" id="type" value="<?php echo $get['type']; ?>"></td>
              </tr>
              <tr>
                <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">Balance</font></td>
                <td bgcolor="#E8FFF8"><input name="balance" type="text" id="balance" value="<?php echo $get['balance']; ?>"></td>
              </tr>
              <tr>
                <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">Available Balance </font></td>
                <td bgcolor="#E8FFF8"><input name="balance2" type="text" id="balance2" value="<?php echo $get['balance2']; ?>"></td>
              </tr>

              <tr>
                <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">Status</font></td>
                <td bgcolor="#E8FFF8"><select name="status" id="status">
                  <option value="Active" <?php if($get['status']=="Active"){ echo "selected"; } ?>>Active</option>
                  <option value="Inactive" <?php if($get['status']=="Inactive"){ echo "selected"; } ?>>Inactive</option>
				  <option value="Restricted" <?php if($get['status']=="Restricted"){ echo "selected"; } ?>>Restricted</option>
				  <option value="Dormant" <?php if($get['status']=="Dormant"){ echo "selected"; } ?>>Dormant</option>
                  </select></td>
              </tr>
			  <tr>
                <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">Tax</font></td>
                <td bgcolor="#E8FFF8"><select name="tax_status" id="status">
                  <option value="1" <?php if($get['tax_status']== 1){ echo "selected"; } ?>>Cleared</option>
                  <option value="0" <?php if($get['tax_status']== 0){ echo "selected"; } ?>>Uncleared</option>
				  <option value="2" <?php if($get['tax_status']== 2){ echo "selected"; } ?>>Expired</option>
                  </select></td>
              </tr>
			  <tr>
                <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">Picture</font></td>
                <td bgcolor="#E8FFF8"><input name="picture" type="file" id="picture"></td>
			  </tr>
              <tr>
                <td bgcolor="#E8FFF8"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
                <td bgcolor="#E8FFF8"><input name="submit" type="submit" id="submit" value="Save"></td>
              </tr>
            </table>
          </form>
          </td>
      </tr>
    </table>      
      <p>&nbsp;</p>
    </td>
  </tr>
</table>


</body>
</html>
