<?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
{
    $plot_random_number=str_shuffle("0123654789");
    $project_name=text_input($_REQUEST['project_name']);
    echo $sector_code=strtoupper(text_input($_REQUEST['sector_code']));
    echo $plot_code=strtoupper(text_input($_REQUEST['plot_code']));
    $starting_no=text_input($_REQUEST['starting_no']);
    $total_plots=text_input($_REQUEST['total_plots']);
    $plot_width=text_input($_REQUEST['plot_width']);
    $plot_Length=text_input($_REQUEST['plot_Length']);
    $plot_area=text_input($_REQUEST['plot_area']);
    $plot_rate=text_input($_REQUEST['plot_rate']);
    $plotAmt=text_input($_REQUEST['plotAmt']);
    
    for ($i=$starting_no; $i<$starting_no+$total_plots; $i++)
 {
	 if(strlen($plot_code)>0)
	 {
		$plot_code_reg=$plot_code.'-'.$i;
	 }
	 else
	 {
		 $plot_code_reg=$i;
	 }
		echo $qry="Insert Into tbl_plot_master(plot_random_number,sector_code,plot_code,plot_width,plot_length,plot_area,plot_rate,booking_status,project_id,plotAmt)values('$plot_random_number','$sector_code','$plot_code_reg','$plot_width','$plot_Length','$plot_area','$plot_rate',0,$project_name,$plotAmt)";
		$result3=mysqli_query($connection,$qry) or die(mysqli_error($connection));
		$msg=" New Plot Add Successfully....";
		
}

}
header("Location:../AddNewPlot?msg=$msg");
exit();
?>