<?php
include_once('../connect.php');
$user ="";
if(isset($_GET['user'])){
$user =$_GET['user'];

}
if(isset($_POST['user'])){
$user= $_POST['user'];
$c = $_POST['credit'];
$d = $_POST['debit'];
$des = $_POST['desc'];
$sta =$_POST['status'];
$type = $_POST['type'];
$cur= $_POST['currency'];
$date = $_POST['date'];
if ($type =='credit'){
$amt = $c;
}
if($type =='debit'){
$amt = $d;
}
$t = $c-$d;

$sql = mysqli_query($con, "INSERT INTO transactions (username,credit,debit,currency,description,date) VALUES
					('$user','$c','$d','$cur','$des','$date')");
$sql = mysqli_query($con, "INSERT INTO history (username,type,amount,description,status,date) VALUES
('$user','$type','$amt','$des','$sta','$date')");
if($sql){
echo "transaction added successful";
}else{
echo "transaction added successful";
}
}
$user ="";
?>

<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Page-Enter" content="revealTrans(Duration=7.0,Transition=14)">
<title>Customer Statement of Account</title>
</head>
<body bgcolor="#000099" link="#336666">
<p align="center"><font color="#FFFFFF">ADMIN PAGE </font></p>
<p align="center"><a href="./adminview.php"><font color="#FF0000"><strong>
CLICK HERE TO GO BACK</strong></font></a></p>
<p align="center"><strong><font color="#FFFFFF"><?php if(isset($_GET['user'])){$user=$_GET['user'];} echo $user; ?></font></strong></p>
<form action="addtransaction.php" method="post" enctype="multipart/form-data" name="form1" target="_self">
  <div align="center">
    <table border="0">
      <tbody>
        <tr>
          <td colspan="5"><div align="right"><font color="#336666"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="/admin_logout.php">
			Logout</a></font></strong></font></div></td>
        </tr>
        <tr>
          <td colspan="5"><div align="center">
            <p><b><font color="#FFFFFF" size="2" face="Verdana">ADD TRANSACTION</font></b></p>
            <p><b><font color="#FFFFFF" size="2" face="Verdana">USER: 
<input name="user" type="hidden" id="user" value="<?php echo $_GET['user']; ?>">
</font></b></p>
          </div></td>
        </tr>
        <tr>
          <td bgcolor="#336666"><div align="right"><font size="2" face="Verdana" color="#FFFFFF"><strong>
			Credit</strong></font></div></td>
          <td><input name="credit" type="text" id="credit"></td>
          <td colspan="2" bgcolor="#336666"><div align="right"><font size="2" face="Verdana" color="#FFFFFF"><strong>
			Debit</strong></font></div></td><td><input name="debit" type="text" id="debit"></td>
        </tr>
        <tr>
          <td width="128" bgcolor="#336666"><div align="right"><font size="2" face="Verdana" color="#FFFFFF"><strong>
			Description</strong></font></div></td>
          <td width="295"><textarea name="desc" id="desc"></textarea></td>
          <td colspan="2" bgcolor="#336666"><div align="right"><font size="2" face="Verdana" color="#FFFFFF"><strong>
			Status</strong></font></div></td>
          <td width="287"><input name="status" type="text" id="debit"></td>
        </tr>
        <tr>
          <td bgcolor="#336666"><div align="right"><strong><font color="#FFFFFF">
			Date</font></strong></div></td>
          <td><input name="date" type="text" id="date">
            <font color="#FFFFFF">[e.g 2017-10-01 04:23]</font></td>
          <td colspan="2" bgcolor="#336666">&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#336666"><div align="right"><font size="2" face="Verdana" color="#FFFFFF"><strong>
			Transaction Type </strong></font></div></td>
          <td><p>
            <strong>
            <label>
            <font color="#FFFFFF">
  <input type="radio" name="type" value="credit">
  			credit</font></label>
            <font color="#FFFFFF"><br>
            <label>
            <input type="radio" name="type" value="debit">
  			debit</label>
            </font></strong><br>
          </p>            </td>
          <td colspan="2" bgcolor="#336666"><font size="2" face="Verdana" color="#FFFFFF"><strong>
			Currency Symbol Only. </strong></font></td>
          <td>          <p>
            <label>
            <input type="radio" name="currency" value="$">
			Dollars</label>
            <br>
            <label>
            <input type="radio" name="currency" value="£">
			Pounds</label>
            <br>
            <label>
            <input type="radio" name="currency" value="&#8364;">
			Euros</label>
            <br>
          </p>          </td>
        </tr>
      </tbody>
    </table>
    <p>
      <input type="submit" name="Submit" value="Submit">
    </p>
  </div>
</form>
<p align="center">&nbsp; </p>
</body>
</html>