 <?php include("header.php");
 include("side.php");
 include("../db.php");
 if(isset($_GET['userid'])){
	$userid = mysqli_real_escape_string($conn,$_GET['userid']);
	$amount = mysqli_real_escape_string($conn,$_GET['amount']);
	
	$date = date("Y-m-d");
	
	$query = mysqli_query($conn,"insert into income_received(`userid`, `amount`, `date`) value('$userid', '$amount', '$date')");
	
	$query = mysqli_query($conn,"update income set current_bal=0 where userid='$userid'");
	
	// echo '<script>alert("Payment has paid");window.location.assign("PV_transfer_list.php");</script>';
}
?>
            <div id="layoutSidenav_content">
                <main>
                    <div class="container-fluid">
                        <h2 class="mt-30 page-title">Income</h2>
                        <ol class="breadcrumb ">
                            <li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
                            <li class="breadcrumb-item active">Income</li>
                        </ol>
                        <div class="row justify-content-between">
							<!-- <div class="col-lg-12">
								<a href="add_page.html" class="add-btn hover-btn">Add New Page</a>
							</div>
							 -->
							
							<div class="col-lg-12 col-md-12">
								<div class="card card-static-2 mb-30">
									<div class="card-title-2">
										<h4>Income Recive</h4>
									</div>
									<div class="card-body-table">
										<div class="table-responsive">
											<table class="table ucp-table table-hover" id="table_id">
											<thead>
                            			<tr>
                                    	<th>S.N.</th>
                                        <th>Userid</th>
                                        <th>Amount</th>
                                        <th>Account</th>
                                        <th>Send</th>
                                    </tr>
                                </thead>
                                <tbody>
								<?php
                                	$query = mysqli_query($conn,"select * from income where current_bal>=100");
									if(mysqli_num_rows($query)>0){
										$i=1;
										while($row=mysqli_fetch_array($query)){
											$userid = $row['userid'];
											$amount = $row['current_bal'];
											
											$query_user = mysqli_query($conn,"select * from user where email='$userid'");
											$result = mysqli_fetch_array($query_user);
											$account = $result['account'];
										?>
                                        	<tr>
                                            	<td><?php echo $i; ?></td>
                                                <td><?php echo $userid; ?></td>
                                                <td><?php echo $amount; ?></td>
                                                <td><?php echo $account; ?></td>
                                                <td><a href="PV_transfer_list.php?<?php echo 'userid='.$userid.'&amount='.$amount ?>" class="btn btn-primary">Send</a></td>
                                            </tr>
                                        <?php
											$i++;
										}
									}
									else{
									?>
                                    	<tr>
                                        	<td colspan="5">No user exist</td>
                                        </tr>
                                    <?php
									}
                                ?>
                                </tbody>
                            </table>
										</div>
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </main>
               <?php include("footer.php"); ?>