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

    
	if(isset($_POST['edit'])){
		$id = $_POST['name']; 
		$wallet=$_POST['amount'];
		$currentDate = date('Y-m-d');
		$sql = "UPDATE users SET booking_wallet = booking_wallet+ '$wallet' WHERE name = '$id'";
		$sqltransaction = "INSERT INTO transaction_history(name,amount, dates, receiver_id,type) VALUES ('admin','$wallet','$currentDate','$id','booking')"; 

		if($conn->query($sql) && $conn->query($sqltransaction)){
			$_SESSION['success'] = 'Booking Wallet updated successfully';

			
		}
		else{
			$_SESSION['error'] = $conn->error;
		}
	}
	else{
		$_SESSION['error'] = 'Fill up edit form first';
	}
 echo '<script type="text/javascript">
            alert("Booking Wallet Added!!!");
            window.location.href = "add_tobookingwallet.php";
        </script>';


?>