<?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 Item3Name WHERE ClientID = $ClientID AND UpdatedDate > '$MaxDate'");
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
		
		
	   if($result!=null &&  $result>0){
			 $response["Item3Name"] = array();
      foreach($result as $row) { 
		  //12 Column Total
		  
        $Item3Name["Item3NameID"] = $row["Item3NameID"];
        $Item3Name["Item2GroupID"] = $row["Item2GroupID"];
        $Item3Name["ItemName"] = $row["ItemName"];
        $Item3Name["ClientID"] = $row["ClientID"];
        $Item3Name["ClientUserID"] = $row["ClientUserID"];
        $Item3Name["NetCode"] = $row["NetCode"];
        $Item3Name["SysCode"] = $row["SysCode"];
        $Item3Name["UpdatedDate"] = $row["UpdatedDate"];
      //  $Item3Name["SerialNo"] = $row["SerialNo"];
        $Item3Name["SalePrice"] = $row["SalePrice"];
        $Item3Name["ItemCode"] = $row["ItemCode"];
         $Item3Name["ItemStatus"] = $row["ItemStatus"];

        // push single product into final response array
        array_push($response["Item3Name"], $Item3Name);
      }
      // success
      $response["success"] = 1;
      // echoing JSON response
      echo json_encode($response);
		}
		else{
				
		 // success
			$response["success"] = 0;
			$response["message"] = "No Data Availaible in Item3Name";
		   // 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 Item3Name";
       // echoing JSON response
       echo json_encode($response);
}
  $conn = null;
?>























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

  $sql = "SELECT * FROM Item3Name WHERE ClientID = $ClientID AND Item3NameID <= $MaxID AND UpdatedDate > '$SessionDate'";

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

   if($result!=null &&  $result>0){
      $response["Item3Name"] = array();
      foreach($result as $row) { 
		  //12 Column Total
		  
		   $Item3Name["ID"] = $row["ID"];
        $Item3Name["Item3NameID"] = $row["Item3NameID"];
        $Item3Name["Item2GroupID"] = $row["Item2GroupID"];
        $Item3Name["ItemName"] = $row["ItemName"];
        $Item3Name["ClientID"] = $row["ClientID"];
        $Item3Name["ClientUserID"] = $row["ClientUserID"];
        $Item3Name["NetCode"] = $row["NetCode"];
        $Item3Name["SysCode"] = $row["SysCode"];
        $Item3Name["UpdatedDate"] = $row["UpdatedDate"];
      //  $Item3Name["SerialNo"] = $row["SerialNo"];
        $Item3Name["SalePrice"] = $row["SalePrice"];
        $Item3Name["ItemCode"] = $row["ItemCode"];
 $Item3Name["ItemStatus"] = $row["ItemStatus"];
        $current_date = date("Y-m-d H:i:s");
        $Item3Name["SessionDate"] = $current_date;

        // push single product into final response array
        array_push($response["Item3Name"], $Item3Name);
      }
      // 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 Item3Name WHERE ClientID = $ClientID AND Item3NameID > $MaxID";

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

   if($result!=null &&  $result>0){
        $response["Item3Name"] = array();
      foreach($result as $row) { 

		 
			 $Item3Name["ID"] = $row["ID"];
          $Item3Name["Item3NameID"] = $row["Item3NameID"];
          $Item3Name["Item2GroupID"] = $row["Item2GroupID"];
          $Item3Name["ItemName"] = $row["ItemName"];
          $Item3Name["ClientID"] = $row["ClientID"];
          $Item3Name["ClientUserID"] = $row["ClientUserID"];
          $Item3Name["NetCode"] = $row["NetCode"];
          $Item3Name["SysCode"] = $row["SysCode"];
          $Item3Name["UpdatedDate"] = $row["UpdatedDate"];
      //    $Item3Name["SerialNo"] = $row["SerialNo"];
          $Item3Name["SalePrice"] = $row["SalePrice"];
          $Item3Name["ItemCode"] = $row["ItemCode"];

          $current_date = date("Y-m-d H:i:s");
          $Item3Name["SessionDate"] = $current_date;

          // push single product into final response array
          array_push($response["Item3Name"], $Item3Name);
        }
        // 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);
  }

?>
