<?php 
session_start();
if(isset($_SESSION['SESS_ADMINLOGGEDIN']) == FALSE) {
    header("Location: " . $config_basedir."adminlogin.php");
}
require("config.php");
require("db.php");
require("functions.php");
require("aheader.php");
?>
<?php
$reports = array();
function report($reports){
    foreach($reports as $report)
        echo $report;
}


if(isset($_POST['log_id']) && isset($_POST['date']) && isset($_POST['description']) && isset($_POST['amount'])){
    $log_id = mysql_real_escape_string($_POST['log_id']);
    $date = mysql_real_escape_string($_POST['date']);
    $description = mysql_real_escape_string($_POST['description']);
    $amount = mysql_real_escape_string($_POST['amount']);
    
    if(!empty($log_id) && !empty($date) && !empty($description) && !empty($amount)){
        $query = "INSERT INTO `withdrawal`(`log_id`,`date`,`description`,`amount`) VALUES('$log_id', '$date', '$description', '$amount')";
        
        if(mysql_query($query)===true){
            $reports[]="Withdrawal history created successfully";
        }else{
            $reports[]="There was an error creating history, please try again";
        }
            
    }else{
        $reports[]="All fields are required";
    }
}

?>
<form action="" enctype="multipart/form-data" name="myForm" id="myform" method="post" >
    <div class="container" align="center">
        <div class="col-md-5" align="right"></div><div class="col-md-7" align="left">
        <p><?php report($reports); ?><br></p>
        </div>
    </div>
    <div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Log Id :</label></div><div class="col-md-7" align="left">
    <input type="number" name="log_id" id="details" min="1"/>
    </div>
    </div>
    <div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Date :</label></div><div class="col-md-7" align="left">
    <input type="text" name="date" id="details" min="1"/>
    </div></div>
    <div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Description :</label></div><div class="col-md-7" align="left">
    <input type="text" name="description" id="details" min="1"/>
    </div></div>
    <div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" style="margin-top:12px;">Amount :</label></div><div class="col-md-7" align="left">
    <input type="number" name="amount" id="details" min="1"/>
    </div>
    </div>
    <div clas="container" align="center"><div class="col span-3-of-3"><label>
    <input type="submit" name="button" id="btn-mlogin" value="Set" />
    </label>
        </div>
    </div>
</form>
<br><br><br><br>
<?php
require ("footer.php");
?>