<?php
// array for JSON response
  $response= array();

    // include db connect class
 require_once __DIR__ . '/../DBConnect.php';
 if(isset($_POST['ClientID'])){
	$clientid=$_POST['ClientID'];
      $sql = "SELECT * FROM Item3Name where ClientID= ".$clientid;
      $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["SalePrice"] = $row["SalePrice"];                               
$Item3Name["ItemCode"] = $row["ItemCode"];
		 $Item3Name["Stock"] = $row["Stock"];

          // 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"] = "ClientID Not Exist";
        // echoing JSON response
        echo json_encode($response);
	 }
}else {
        // success
        $response["success"] = 0;
        $response["message"] = "Set Client ID";
        // echoing JSON response
    		echo json_encode($response);
      }
?>
