<?php
	include 'includes/session.php';
	include 'includes/sessions.php';

	if(isset($_POST['edit'])){
		$id = $_POST['id']; 
		$wallet=$_POST['amount'];
		$trx_id=$_POST['trx_id'];
		$status=$_POST['status'];
		$username=$_POST['username'];
		if ($status=='Completed') {
			# code...
			$sql = "UPDATE deposit  SET  status='Completed' WHERE trx_id='$trx_id' ";
		if($conn->query($sql)){

			$booking_fund_update="UPDATE users SET  booking_wallet=booking_wallet+'$wallet' WHERE name='$username' ";
			if($conn->query($booking_fund_update)){

				$_SESSION['success'] = 'Fund updated successfully';

			}


			

			
		}


		else{
			$_SESSION['error'] = $conn->error;
		}


		}
		else{

			$sql = "UPDATE deposit  SET  status='Rejected' WHERE trx_id='$trx_id' ";
		if($conn->query($sql)){
			$_SESSION['success'] = 'Fund updated successfully';


		}



		}

		
	}
	else{
		$_SESSION['error'] = 'Fill up edit form first';
	}

	header('location:add_fund_report.php');

?>