<?php
// array for JSON response
$response = array();
//check for required fields
if (isset($_POST['Lat']) && isset($_POST['Lng']) && isset($_POST['ProjectID'])){

      $Lat = $_POST['Lat'];
	  $Lng = $_POST['Lng'];
	  $ProjectID = $_POST['ProjectID'];

		$float_Lat = floatval($Lat); 
		$float_Lng = floatval($Lng); 
      // include db connect class
  require_once __DIR__ . '/DBConnect.php';
      $UpdatedDate = date("Y-m-d H:i:s");

      $sql = "SELECT        ClientID, Lat, Lng, 6371 * ACOS(COS(RADIANS($float_Lat)) * COS(RADIANS(Lat)) * COS(RADIANS(Lng) - RADIANS($float_Lng)) + SIN(RADIANS($float_Lat)) 
                         * SIN(RADIANS(Lat))) AS ABC, CompanyName, CompanyAddress, CompanyNumber, WebSite, Country, City, SubCity, ProjectID, Email, CapacityOfPersons
 FROM            Client
 WHERE        (ProjectID = $ProjectID)
 ORDER BY ABC";

	//	$sqli="SELECT * FROM Client;";
	
    $stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
	if($result!=null &&  $result>0){
        $response["ShadiHall"] = array();
       
	foreach($result as $row) { 
          $ShadiHall["ClientID"] = $row["ClientID"];
          $ShadiHall["Lat"] = $row["Lat"];
          $ShadiHall["Lng"] = $row["Lng"];
         // $ShadiHall["[Distance Km]"] = $row["[Distance Km]"];
          $ShadiHall["CompanyName"] = $row["CompanyName"];
          $ShadiHall["CompanyAddress"] = $row["CompanyAddress"];
          $ShadiHall["CompanyNumber"] = $row["CompanyNumber"];
          $ShadiHall["WebSite"] = $row["WebSite"];
		  $ShadiHall["Country"] = $row["Country"];
          $ShadiHall["City"] = $row["City"];
          $ShadiHall["SubCity"] = $row["SubCity"];
          $ShadiHall["ProjectID"] = $row["ProjectID"];
		  $ShadiHall["Email"] = $row["Email"];
		  $ShadiHall["CapacityOfPersons"] = $row["CapacityOfPersons"];

          // push single product into final response array
    			array_push($response["ShadiHall"], $ShadiHall);
        }
        // success
    		$response["success"] = 1;
		  $response["message"] = "Success";
        // echoing JSON response
    		echo json_encode($response);
      }else{
		  $response["success"] = 0;
      $response["message"] = $LoginMobileNo." Not Register";
	// echoing JSON response
    		echo json_encode($response);
	  }
    }else {
      $response["success"] = 0;
      $response["message"] = "Please Send AcMobileNo";
	// echoing JSON response
    		echo json_encode($response);
    }
?>
