<?php
session_start();
ob_start();
 include "../config/config.php"; 
 include "../config/function.php"; 
 
// print_r($_REQUEST);
 $private_key=get_privatekey($_SESSION['admin_name']);
 $request_from_server=$_SERVER['HTTP_REFERER'];
$this_server=$_SERVER['HTTP_HOST'];
if($request_from_server!=''){
	check_access_url($request_from_server,$this_server);
}

// echo $_SESSION['login_status'];echo "<br>";
// echo $_SESSION['private_key'];echo "<br>";
// echo $_SESSION['admin_name'];echo "<br>";

if($_SESSION['login_status']!='YES' || $_SESSION['private_key']!=$private_key || $_SESSION['private_key']=='' || $_SESSION['admin_name']=='')
{
    echo "Blank";
	header("Location:../AppLogin");
	exit();
}
else
{
$booking_random_no=RemoveSpecialChar(strtoupper(trim($_POST['booking_random_no'])));
$member_user_id=RemoveSpecialChar(strtoupper(trim($_POST['member_user_id'])));
$member_name=RemoveSpecialChar(strtoupper(trim($_POST['member_name'])));
$businessper=RemoveSpecialChar(trim($_POST['businessper']));
$plot_code=RemoveSpecialChar(trim($_POST['plot_code']));
$plot_size=RemoveSpecialChar(trim($_POST['plot_size']));
$plot_rate=RemoveSpecialChar(trim($_POST['plot_rate']));
$total_amount=RemoveSpecialChar($_POST['total_amount']);
$discount_amt=RemoveSpecialChar($_POST['discount_amt']);
$net_amount=RemoveSpecialChar($_POST['net_amount']);
$paid_amount=RemoveSpecialChar($_POST['paid_amount']);
$balance_amt=RemoveSpecialChar($_POST['balance_amt']);

 if($businessper==80 || $businessper==50 || $businessper==60 || $businessper==70)
 {
    $ssl="Select * from tbl_plot_registry_booking where member_user_id='$member_user_id' and booking_random_no='$booking_random_no'";
    $spres=mysqli_query($connection,$ssl);
    if(mysqli_num_rows($spres)>0)
    {
        $Update="Update tbl_plot_registry_booking set plot_id='$plot_code',plot_code='$plot_code',plot_size='$plot_size',plot_rate='$plot_rate',total_amount=$total_amount,discount_amt=$discount_amt,net_amount=$net_amount,paid_amount=$paid_amount,balance_amt=$balance_amt,businessper=$businessper where member_user_id='$member_user_id' and booking_random_no='$booking_random_no'";
        mysqli_query($connection,$Update);
        $msg="Plot Booking Details Update Successfully";
    }
    else
    {
        $msg="Error In Update Plot Booking Details";
    }

}
 else
 {
     $msg="Invalid Business Percentage";
 }

}
header("location:../EditPlotBooking?booking_random_no=$booking_random_no&msg=$msg");
exit();
?>