<?php
// include db connect class
	require_once __DIR__ . '/../DBConnect.php';
	if (isset($_POST['ClientID']) && isset($_POST['SessionDate'])) {
    $ClientID = $_POST['ClientID'];
  
    $SessionDate = $_POST['SessionDate'];

  $sql = "SELECT * FROM Account5customGroup1 WHERE ClientID = $ClientID AND  UpdatedDate > '$SessionDate'";

			$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
			   

		   if($result!=null &&  $result>0){
      $response["Account5customGroup1"] = array();
      foreach($result as $row) { 
		    
		$Account5customGroup1["ID"] = $row["ID"];          
		$Account5customGroup1["CustomGroup1ID"] = $row["CustomGroup1ID"];
  		$Account5customGroup1["CustomGroupName"] = $row["CustomGroupName"];
  		$Account5customGroup1["UpdatedDate"] = $row["UpdatedDate"];
  		$Account5customGroup1["ClientID"] = $row["ClientID"];
  		$Account5customGroup1["ClientUserID"] = $row["ClientUserID"];
  		$Account5customGroup1["NetCode"] = $row["NetCode"];
  		$Account5customGroup1["SysCode"] = $row["SysCode"];
		

          // push single product into final response array
          array_push($response["Account5customGroup1"], $Account5customGroup1);
      }
      // success
      $response["success"] = 1;
      // echoing JSON response
      echo json_encode($response);
    }else {
      // success
      $response["success"] = 0;
      $response["message"] = "No Data Availaible";
      // echoing JSON response
      echo json_encode($response);
    }
  }
  else if (isset($_POST['ClientID']) && isset($_POST['MaxID'])) {
      $ClientID = $_POST['ClientID'];
      $MaxID = $_POST['MaxID'];
      
		$sql = "SELECT * FROM Account5customGroup1 WHERE ClientID = $ClientID  AND CustomGroup1ID > $MaxID";

	$params = array();
		$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
			   

		if($result!=null &&  $result>0){
         $response["Account5customGroup1"] = array();
       
	foreach($result as $row) { 
		 
		$Account5customGroup1["ID"] = $row["ID"];          
		$Account5customGroup1["CustomGroup1ID"] = $row["CustomGroup1ID"];
  		$Account5customGroup1["CustomGroupName"] = $row["CustomGroupName"];
  		$Account5customGroup1["UpdatedDate"] = $row["UpdatedDate"];
  		$Account5customGroup1["ClientID"] = $row["ClientID"];
  		$Account5customGroup1["ClientUserID"] = $row["ClientUserID"];
  		$Account5customGroup1["NetCode"] = $row["NetCode"];
  		$Account5customGroup1["SysCode"] = $row["SysCode"];
		
          // push single product into final response array
          array_push($response["Account5customGroup1"], $Account5customGroup1);
        }
	
        // success
         $response["success"] = 1;
      
        // echoing JSON response
        echo json_encode($response);
      }else {
        // success
        $response["success"] = 0;
        $response["message"] = "No Data Availaible";
        // echoing JSON response
    		echo json_encode($response);
      }
	}else {
        // success
        $response["success"] = 0;
        $response["message"] = "No Data Availaible";
        // echoing JSON response
    		echo json_encode($response);
  }

?>
