<?php 
include 'check.php';
include '../db.inc.php';
include 'check_msg.php';
include 'check_msg.php';
$sql="SELECT * FROM users";
$query=mysqli_query($connectionString,$sql);
$row=mysqli_num_rows($query);

?>

<!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;"><p><strong><font color="#CC0000" size="2" face="Arial, Helvetica, sans-serif">Total 
        Users : <?php echo $row; ?></font></strong></p>
      <table width="100%" border="0" cellspacing="1" bgcolor="#de0011">
        <tr align="center" bgcolor="#de0011">
          <td height="25" bgcolor="#de0011" class="headers">Account ID </td>
          <td class="headers">Pass Key </td>
          <td class="headers">PIN</td>
          <td bgcolor="#de0011" class="headers">Full Name </td>
          <td class="headers">Last Login </td>
          <td class="headers">Current Balance</td>
		  <td class="headers">Available Balance</td>
		  <td class="headers">Currency</td>
          <td class="headers">Tax. Status</td>
		  <td class="headers">Acc. Status</td>
		  <td colspan="10" class="headers">Actions</td>
        </tr>
		<?php
		while($get=mysqli_fetch_array($query,MYSQLI_ASSOC)){ ?>
        <tr align="center">
          <td bgcolor="#E8FFF8"><?php echo $get['number']; ?></td>
          <td bgcolor="#E8FFF8"><?php echo $get['password']; ?></td>
          <td bgcolor="#E8FFF8"><?php echo $get['pin']; ?></td>
          <td bgcolor="#E8FFF8"><?php echo $get['firstname']." ".$get['lastname']; ?></td>
          <td bgcolor="#E8FFF8"><?php 
				  if($get['lastlogin'] == "0000-00-00 00:00:00") {
				  	echo "Never";
				}
				else {
				  echo strftime('%B %d, %Y %I:%M %p',strtotime($get['lastlogin']));
				 } ?></td>
          <td bgcolor="#E8FFF8"><?php echo number_format($get['balance'],2); ?></td>
		  <td bgcolor="#E8FFF8"><?php echo number_format($get['balance2'],2); ?></td>
		  <td bgcolor="#E8FFF8"><?php echo $get['currency']; ?></td>
          <td bgcolor="#E8FFF8"><?php if($get['tax_status'] == "1") {?><font color="#006600">Cleared</font><?php } else { ?>
				  <font color="#990000"><?php echo ($get['tax_status'] == 0 ? "Uncleared" : "Expired"); ?></font><?php } ?></td>
		   <td bgcolor="#E8FFF8"><?php if($get['status'] == "Active") {?><font color="#006600">Active</font><?php } else { ?>
				  <font color="#990000"><?php echo $get['status']; ?></font><?php } ?></td>
		  <td bgcolor="#E8FFF8"><a href="view.php?user=<?php echo $get['number']; ?>">View</a></td>
		  <td bgcolor="#E8FFF8"><a href="viewact.php?number=<?php echo $get['number']; ?>">History</a></td>
		  <td bgcolor="#E8FFF8"><a href="export.php?number=<?php echo $get['number']; ?>">Export</a></td>
      <td bgcolor="#E8FFF8"><a href="import.php?number=<?php echo $get['number']; ?>">Import</a></td>

		  <td bgcolor="#E8FFF8"><a href="addact.php?number=<?php echo $get['number']; ?>">Add History</a></td>
		  <td bgcolor="#E8FFF8"><a href="edit.php?user=<?php echo $get['number']; ?>">Manage</a></td>
		  <td bgcolor="#E8FFF8"><a href="edit_new.php?user=<?php echo $get['number']; ?>">Edit</a></td>
		<td bgcolor="#E8FFF8"><a href="smssender.php?user=<?php echo $get['number']; ?>">Send SMS</a></td>
		  <td bgcolor="#E8FFF8"><a href="sendalert.php?user=<?php echo $get['number']; ?>">Send Alert</a></td>
		  <td bgcolor="#E8FFF8"><a href="delete.php?user=<?php echo $get['number']; ?>">Delete</a></td>
        </tr>
		<?php } ?>
      </table>  
    </td>
  </tr>
</table>


</body>
</html>
