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

    // include db connect class
    require_once __DIR__ . '/../DBConnect.php';
if(isset($_POST['ClientID']) && isset($_POST['EntryType'])){
	$clientid=$_POST['ClientID'];
       $entrytype=$_POST['EntryType'];
      $sql = "SELECT * FROM QRSalePur1 where ClientID= ".$clientid." AND EntryType= '".$entrytype."'";
    
      
	$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
	if($result!=null &&  $result>0){
        $response["QRSalePur1"] = array();
       
	 					foreach($result as $row) { 
         $QRSalePur1["ID"] = $row["ID"];          
$QRSalePur1["SalePur1ID"] = $row["SalePur1ID"];  
$QRSalePur1["EntryType"] = $row["EntryType"];  
$QRSalePur1["SPDate"] = $row["SPDate"];     
$QRSalePur1["AcNameID"] = $row["AcNameID"];    
$QRSalePur1["Remarks"]=$row["Remarks"];                                                                                              
$QRSalePur1["ClientID"] = $row["ClientID"];    
$QRSalePur1["ClientUserID"] = $row["ClientUserID"]; 
$QRSalePur1["NetCode"] = $row["NetCode"];                                            
$QRSalePur1["SysCode"] = $row["SysCode"];                                            
$QRSalePur1["UpdatedDate"] = $row["UpdatedDate"];             
$QRSalePur1["NameOfPerson"]=$row["NameOfPerson"];          
$QRSalePur1["PayAfterDay"] = $row["PayAfterDay"];
$QRSalePur1["BillAmount"] = $row["BillAmount"];
$QRSalePur1["BillStatus"] = $row["BillStatus"];
$QRSalePur1["ContactNo"] = $row["ContactNo"];


          // push single product into final response array
          array_push($response["QRSalePur1"], $QRSalePur1);
        }
	
        // 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 if(isset($_POST['ClientID'])){
	$clientid=$_POST['ClientID'];
      // $entrytype=$_POST['EntryType'];
      $sql = "SELECT * FROM QRSalePur1 where ClientID= ".$clientid;
     $stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
	
if($result!=null &&  $result>0){
        $response["QRSalePur1"] = array();
       
	 					foreach($result as $row) { 
         $QRSalePur1["ID"] = $row["ID"];          
$QRSalePur1["SalePur1ID"] = $row["SalePur1ID"];  
$QRSalePur1["EntryType"] = $row["EntryType"];  
$QRSalePur1["SPDate"] = $row["SPDate"];     
$QRSalePur1["AcNameID"] = $row["AcNameID"];    
$QRSalePur1["Remarks"]=$row["Remarks"];                                                                                              
$QRSalePur1["ClientID"] = $row["ClientID"];    
$QRSalePur1["ClientUserID"] = $row["ClientUserID"]; 
$QRSalePur1["NetCode"] = $row["NetCode"];                                            
$QRSalePur1["SysCode"] = $row["SysCode"];                                            
$QRSalePur1["UpdatedDate"] = $row["UpdatedDate"];             
$QRSalePur1["NameOfPerson"]=$row["NameOfPerson"];          
$QRSalePur1["PayAfterDay"] = $row["PayAfterDay"];
$QRSalePur1["BillAmount"] = $row["BillAmount"];
$QRSalePur1["BillStatus"] = $row["BillStatus"];
$QRSalePur1["ContactNo"] = $row["ContactNo"];
          // push single product into final response array
          array_push($response["QRSalePur1"], $QRSalePur1);
        }
	
        // 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 ClientID and EntryType Both ";
        // echoing JSON response
    		echo json_encode($response);
      }
?>
