<? include "header.php";
$insid=$_REQUEST['id'];
$action=$_REQUEST['action'];
if($action=='approve'){
    

$slisql="UPDATE `payment_details` SET 
`active`=1 WHERE `id`='$insid'";





    $res=mysql_query($slisql);
    if(!$res){
        echo mysql_error();
        
    }
}
     elseif($action=='disapprove'){
   $slisql="UPDATE `payment_details` SET 
`active`=0 WHERE `id`='$insid'";
    $res=mysql_query($slisql);
    if(!$res){
        echo mysql_error();
        
    } 
     }
     
    
    elseif($action=='delete'){
    $insid=$_REQUEST['id'];
    $del=mysql_query("DELETE FROM `payment_details` WHERE `id`='$insid'");
        
        echo "<script>alert('Data deleted')</script>";
    }
    
?>

<section class="content">
            <div class="row clearfix">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="header">
                            <h2>
                                Payment Details
                            </h2>
                        </div>
                        <div class="body table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Mode of Payment</th>
                                        <th>Image</th>
                                        <th>Transaction</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                               <tbody>
                    
                                <?      $k=0;
                                        $cq=mysql_query("SELECT * FROM payment_details");
                                        while($arrc=mysql_fetch_array($cq)){
                                            $phpsessid=generateRandomString(120);
                                            $k=$k+1;
                                ?>
                            <tr>
                                <td><?=$k?></td>
								<td><?=$arrc['mode_of_payment']?></td>
								<td style="width: 30%;"><img src="../send_details/<?=$arrc['image']?>" width="50%"></td>
								<td><?=$arrc['transaction']?></td>
                           
								<td><?php if ($arrc['active']==0){?><a href="payment_details.php?action=approve&id=<?=$arrc['id']?>">Approve</a><br><?php } else { ?> 
								<a href="payment_details.php?action=disapprove&id=<?=$arrc['id']?>">Disapprove</a><br> <?php } ?>
								<a onclick="return confirm('Are you sure you want Delete?')" href="payment_details.php?action=delete&id=<?=$arrc['id']?>">DELETE</a>
								</td>                               
                            </tr>

                            
                            
                       <? } ?>
                            </tbody>  
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

<? include "footer.php"; ?>