<?php

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

  $id=$request->getParsedBody()['id'];
   $set_blocks_block_id=$request->getParsedBody()['set_blocks_block_id'];            			    	
    $floors=$request->getParsedBody()['floors'];
     $set_rooms_room_id=$request->getParsedBody()['set_rooms_room_id'];
      $rows=$request->getParsedBody()['rows'];            			    	
       $columns=$request->getParsedBody()['columns'];
	    $seats=$request->getParsedBody()['seats'];
		 $ABseats=$request->getParsedBody()['ABseats'];            			    	
          $proctors=$request->getParsedBody()['proctors'];
            $seat_rows=$request->getParsedBody()['seat_rows'];
		  $seat_rows_get = json_encode($seat_rows);
		 $response=array();
		 
		 $select_sql = "SELECT * FROM set_seats WHERE set_blocks_block_id = '$set_blocks_block_id' AND floors='$floors' AND set_rooms_room_id='$set_rooms_room_id'";
		 $sql_query=mysqli_query($con,$select_sql);

if(mysqli_num_rows($sql_query)>0)
{
    $response=array('status'=>"true",'Message'=>"Data Already Inserted");
    echo json_encode($response);
}

else{
		 
$sql="INSERT INTO set_seats(set_blocks_block_id,floors,set_rooms_room_id,rows,columns,seats,ABseats,proctors,seat_rows) 
VALUES ('$set_blocks_block_id','$floors','$set_rooms_room_id','$rows','$columns','$seats','$ABseats','$proctors','$seat_rows_get')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"id"=>$id,
	"set_blocks_block_id"=>$set_blocks_block_id,
	"floors"=>$floors,
	"set_rooms_room_id"=>$set_rooms_room_id,
	"rows"=>$rows,
	"columns"=>$columns,
	"seats"=>$seats,
	"ABseats"=>$ABseats,
	"proctors"=>$proctors,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data inserted successfully",'set_seats' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
	
}	


?>