<?php
 

  
 
// array for JSON response
$response = array();
 
 require_once __DIR__ . '/catchexception.php';
// include db connect class
require_once __DIR__ . '/db_config.php';
  
$parabranchcode = urldecode($_POST['parabranchcode']);
$paraimeino = urldecode($_POST['paraimeino']);
 // $paraimeino ='398bcd7a638d12b2'; 
 // $parabranchcode ='73'; 
try{
if ($paraimeino !="" ) { 
    $paravanquery="SELECT *,'Insert' as  process from tblbranchcreditcustomermapping as a where  statuscode='1' and branchcode=$1 ";
      $resultmax=  pg_prepare($con,"paravanquery",$paravanquery);
      $data = [$parabranchcode];
      $result = pg_execute($con,"paravanquery",$data);
    if (!empty($result)) {
        // check for empty result
        if (pg_num_rows($result) > 0) {
      // user node
            $response["Value"] = array();
 
            while ($row = pg_fetch_assoc($result)) {        
              $report = array();
               
                $report["autonum"] = $row["autonum"];
                $report["customercode"] = $row["customercode"];
                $report["customername"] = $row["customername"];
                $report["branchcode"] = $row["branchcode"];
                $report["statuscode"] = $row["statuscode"];
                $report["createddate"] = $row["createddate"];
                $report["updateddate"] = $row["updateddate"];
                $report["makerid"] = $row["makerid"]; 
                $report["clientcode"] = $row["clientcode"];
                $report["address"] = $row["address"];
                $report["mobilenum"] = $row["mobilenum"];
                $report["process"] = $row["process"];  
              // push single product into final response array
              array_push($response["Value"], $report);
            }
            // success
            $response["success"] = 1;
 
            // echoing JSON response
            echo  json_encode($response,JSON_UNESCAPED_UNICODE);


        } else {
            // no user found
            $response["success"] = 0;
            $response["message"] = "No Report found";
 
            // echo no users JSON
            echo json_encode($response);
        }
    } else {
        // no user found
        $response["success"] = 0;
        $response["message"] = "No found";
 
        // echo no users JSON
        echo json_encode($response);
    }
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
     echo  json_encode($response,JSON_UNESCAPED_UNICODE);
  }
  mch_db_release($con);
}
//catch exception
catch(Exception $e) {
mch_db_release($con);
echo 'Message: ' .$e->getMessage();
}
?>
