<?php
	session_start();
	if($_SESSION['adm'])
	{
		$userid= $_SESSION['adm'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<html>
<head>
<style>
#red a{color:red; text-decoration:none;}
#green a{color:green; text-decoration:none;}
</style>
</head>
<body>
    <form method="post">
    From :  <input type="date" name="fdate">
    To :  <input type="date" name="ldate">
        <input type="submit" name="submit">
        </form>
<table border="1" cellpadding="10">
    
<?php
    include'connection.php';
    date_default_timezone_set("asia/kolkata");
    $date = Date("Y-m-d");
    $sl=0;
    
    if(isset($_POST['submit']))
    {
        $fdate = $_POST['fdate'];
        $ldate = $_POST['ldate'];
        $quGetSucRech="select * from recharge where Status='SUCCESS' and Rechargedate>='$fdate' and Rechargedate<='$ldate'";
        $reGetSucRech=mysqli_query($con,$quGetSucRech);
         while($dataGetSucRech=mysqli_fetch_array($reGetSucRech))
        {
            $successRechId=$dataGetSucRech['Id'];
        
            $quGetSucRechRef="select * from wallet where Paynrechid='$successRechId' and Transactiontype='Recharge_Refund' and ActiveRefund='0'";
            $reGetSucRechRef=mysqli_query($con,$quGetSucRechRef);
             $countSucRechRef=mysqli_num_rows($reGetSucRechRef);
        
               while($dataGetSucRechRef=mysqli_fetch_array($reGetSucRechRef))
              {
                  $sl=$sl+1;
                  echo "<tr>";
                     echo "<td>".$sl."</td>";
                      echo "<td>".$dataGetSucRechRef['Paynrechid']."</td>";
                     echo "<td id='red'><a href='ReverseWrongRefund.php?id=".$dataGetSucRechRef['Paynrechid']."'>Reverse Wrong Refund</a></td>";
                     echo "<td id='green'><a href='InactiveWrongRefund.php?id=".$dataGetSucRechRef['Paynrechid']."'>Inactive Wrong Refund</a></td>";
                 echo "</tr>";
              }
         }
    }
    else
    {
         $quGetSucRech="select * from recharge where Status='SUCCESS' and Rechargedate='$date'";
         $reGetSucRech=mysqli_query($con,$quGetSucRech);
            while($dataGetSucRech=mysqli_fetch_array($reGetSucRech))
            {
                $successRechId=$dataGetSucRech['Id'];
        
               $quGetSucRechRef="select * from wallet where Paynrechid='$successRechId' and Transactiontype='Recharge_Refund' and ActiveRefund='0'";
               $reGetSucRechRef=mysqli_query($con,$quGetSucRechRef);
                $countSucRechRef=mysqli_num_rows($reGetSucRechRef);
        
               while($dataGetSucRechRef=mysqli_fetch_array($reGetSucRechRef))
               {
                  $sl=$sl+1;
                  echo "<tr>";
                      echo "<td>".$sl."</td>";
                     echo "<td>".$dataGetSucRechRef['Paynrechid']."</td>";
                     echo "<td id='red'><a href='ReverseWrongRefund.php?id=".$dataGetSucRechRef['Paynrechid']."'>Reverse Wrong Refund</a></td>";
                     echo "<td id='green'><a href='InactiveWrongRefund.php?id=".$dataGetSucRechRef['Paynrechid']."'>Inactive Wrong Refund</a></td>";
                 echo "</tr>";
                }
             }
    }

    echo $sl;

?>
</table>
</body>
</html>