<?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 SalePur2 where ClientID= ".$clientid;
     $stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
	if($result!=null &&  $result>0){
        $response["SalePur2"] = array();
       
	foreach($result as $row) { 
         
$Item1Type["ID"] = $row["ID"];          
$Item1Type["SalePur1ID"] = $row["SalePur1ID"];  
$Item1Type["ItemSerial"] = $row["ItemSerial"];  
$Item1Type["EntryType"] = $row["EntryType"];                                          
$Item1Type["Item3NameID"] = $row["Item3NameID"]; 
$Item1Type["ItemDescription"] = $row["ItemDescription"];
$Item1Type["QtyAdd"] = $row["QtyAdd"];                                  
$Item1Type["QtyLess"] = $row["QtyLess"];                                 
$Item1Type["Qty"] = $row["Qty"];                                     
$Item1Type["Price"] = $row["Price"];                                   
$Item1Type["Total"] = $row["Total"];                                   
$Item1Type["Location"] = $row["Location"];                                           
$Item1Type["ClientID"] = $row["ClientID"];    
$Item1Type["ClientUserID"] = $row["ClientUserID"];
$Item1Type["NetCode"] = $row["NetCode"];                                            
$Item1Type["SysCode"] = $row["SysCode"];                                            
$Item1Type["UpdatedDate"] = $row["UpdatedDate"];
          // push single product into final response array
          array_push($response["SalePur2"], $Item1Type);
        }
	
        // success
         $response["success"] = 1;
      $response["message"] = "Success ";
        // 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 ClietnID ";
        // echoing JSON response
    		echo json_encode($response);
      }
?>
