<?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 CashBook where ClientID = $ClientID";
	
  		$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
	if($result!=null &&  $result>0){
        $response["CashBook"] = array();
       foreach($result as $row) { 
          $CashBook["ID"] = $row["ID"];          
      $CashBook["CashBookID"] = $row["CashBookID"];  
     $CashBook["ClientID"] = $row["ClientID"];    
     $CashBook["ClientUserID"] = $row["ClientUserID"]; 
      $CashBook["CBDate"] = $row["CBDate"];     
     $CashBook["DebitAccount"] = $row["DebitAccount"]; 
      $CashBook["CreditAccount"] = $row["CreditAccount"]; 
     $CashBook["CBRemarks"] = $row["CBRemarks"];                 
     $CashBook["Amount"] = $row["Amount"];      
      $CashBook["NetCode"] = $row["NetCode"];                                            
      $CashBook["SysCode"] = $row["SysCode"];
       $CashBook["UpdatedDate"] = $row["UpdatedDate"];             
       $CashBook["SerialNo"] = $row["SerialNo"];    
     $CashBook["TableName"] = $row["TableName"];                                          
     $CashBook["TableID"] = $row["TableID"];

          // push single product into final response array
    			array_push($response["CashBook"], $CashBook);
        }
        // success
    		$response["success"] = 1;
        // echoing JSON response
    		echo json_encode($response);
      }else {
		  $response["success"] = 0;
		  $response["message"] = "No Cash Book";
        // echoing JSON response
    	  echo json_encode($response);
	  }
    }else {
		  $response["success"] = 0;
		  $response["message"] = "Set ClientID First ";
        // echoing JSON response
    	  echo json_encode($response);
	  }
?>
