<?php 
include 'check.php';
include '../db.inc.php';
include 'check_msg.php';
if(isset($_GET['number'])) {
   $number=$_GET['number'];

   $userss  =mysqli_fetch_array(mysqli_query($connectionString,"SELECT * FROM users WHERE number=$number LIMIT 1"),MYSQLI_ASSOC);

   $sql="SELECT * FROM history WHERE number='$number' or `user_id`= ".$userss['id']." ORDER BY date DESC";
}
else {
   $sql="SELECT * FROM history ORDER BY date DESC";
}
$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="#FF0000" class="headers"><p>Navigation</p></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="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 
        Activities : <?php echo $row; ?></font></strong></p>
      <table width="100%" border="0" cellspacing="1" bgcolor="#FF0000">
        <tr align="center" bgcolor="#FF0000">
          <td height="25" bgcolor="#FF0000" class="headers">Account ID </td>
          <td class="headers">Tran. ID  </td>
          <td class="headers">Date</td>
          <td class="headers">Tran. Type</td>
          <td class="headers">Amount </td>
          <td class="headers">Description</td>
		  <td class="headers">Status</td>
		  <td class="headers">Action</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['tid']; ?></td>
          <td bgcolor="#E8FFF8"><?php echo strftime('%d-%m-%Y %I:%M %p',strtotime($get['date'])); ?></td>
          <td bgcolor="#E8FFF8"><?php echo $get['type']; ?></td>
          <td bgcolor="#E8FFF8"><?php echo number_format($get['amount'],2); ?></td>
          <td bgcolor="#E8FFF8"><?php echo stripslashes($get['details']); ?></td>
		  <td bgcolor="#E8FFF8"><?php echo $get['status']; ?></td>
          <td bgcolor="#E8FFF8"><a href="deleteact.php?tid=<?php echo $get['tid']; ?>">Delete</a></td>
        </tr>
		<?php } ?>
      </table>  
    </td>
  </tr>
</table>


</body>
</html>
