<?php
    include'connection.php';
    include'time.php';
 if(isset($_POST['submit']))
 {
     $fdate=$_POST['fdate'];
     $ldate=$_POST['ldate'];
     $usr=$_POST['usr'];
    $TotalTopUpAmount=0;
    echo "<table border='1' cellpadding='10' align='center'>";
        
        echo "<tr>";
            echo "<th>Total Payment</th>";
        echo "</tr>";
    
    $qu="select * from paymentreq where Userid='$usr' and Status='APPROVED' and Paymentdate>='$fdate' and Paymentdate<='$ldate'";
    $re=mysqli_query($con,$qu);
    while($data=mysqli_fetch_array($re))
    {
        $TopUpAmount=$data['Amount'];
        
        $TotalTopUpAmount=$TotalTopUpAmount+$TopUpAmount;
    }
        echo "<tr>";
            echo "<td>".$TotalTopUpAmount."</td>";
        echo "</tr>";
    echo "</table><br><br>";
    
    
    $TotalRechAmount=0;
    $TotalDebitAmount=0;
    echo "<table border='1' cellpadding='10' align='center'>";
        
        echo "<tr>";
            echo "<th>Total Rech Amount</th>";
            echo "<th>Total Debit Amount</th>";
        echo "</tr>";
    
    $qu2="select * from recharge where Userid='$usr' and Status='SUCCESS' and Rechargedate>='$fdate' and Rechargedate<='$ldate'";
    $re2=mysqli_query($con,$qu2);
    while($data2=mysqli_fetch_array($re2))
    {
        $RechAmount=$data2['Amount'];
        $DebitAmount=$data2['Debitamount'];
        
        $TotalRechAmount=$TotalRechAmount+$RechAmount;
        $TotalDebitAmount=$TotalDebitAmount+$DebitAmount;
    }
        echo "<tr>";
            echo "<td>".$TotalRechAmount."</td>";
            echo "<td>".$TotalDebitAmount."</td>";
        echo "</tr>";
    echo "</table>";
}
?>
<html>
    <head>
        <style>
        </style>
    </head>
    <body>
        <form method="post">
        <input type="date" name="fdate" id="inp">
        <input type="date" name="ldate" id="inp">
        <input type="text" name="usr" id="inp">
        <input type="submit" name="submit" id="inp">
        </from>
    </body>
</html>