<?php
    require_once __DIR__ . '/../DBConnect.php';
if (isset($_POST['ClientID']) && isset($_POST['MaxDate'])) {
	try 
	{
	    $ClientID = $_POST['ClientID'];
     $MaxDate = $_POST['MaxDate'];
			$stmt = $conn->prepare("SELECT * FROM SalePurLocation WHERE ClientID = $ClientID AND UpdatedDate > '$MaxDate'");
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
		
		
	   if($result!=null &&  $result>0){
			 $response["SalePurLocation"] = array();
      foreach($result as $row) {
        $SalePurLocation["LocationID"] = $row["LocationID"];
        $SalePurLocation["LocationName"] = $row["LocationName"];
        $SalePurLocation["ClientID"] = $row["ClientID"];
        $SalePurLocation["ClientUserID"] = $row["ClientUserID"];
        $SalePurLocation["NetCode"] = $row["NetCode"];
        $SalePurLocation["SysCode"] = $row["SysCode"];
        $SalePurLocation["UpdatedDate"] = $row["UpdatedDate"];

        // push single product into final response array
        array_push($response["SalePurLocation"], $SalePurLocation);
      }
			 // success
			$response["success"] = 1;
			// echoing JSON response
			echo json_encode($response);
		}
		else{
				
		 // success
			$response["success"] = 0;
			$response["message"] = "No Data Availaible in SalePurLocation";
		   // echoing JSON response
			echo json_encode($response);
		}
	}
	catch(PDOException $e){
		
		echo "Error: " . $e->getMessage();
		
	}
}else{
    $response["success"] = 0;
       $response["message"] = "Parameters are not set of SalePurLocation";
       // echoing JSON response
       echo json_encode($response);
}
  $conn = null;
?>

