<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];
$zroot = $_SESSION["zdbroot"];

$fseries = $_SESSION["series_" . $dbname];
$keycond = "and `series`='$fseries'";

$success = false;


if (isset($_REQUEST["passport"])) {
    
    $passport = $_REQUEST['passport'];
    
    $query2 = "SELECT a.*, b.broker FROM `visatran` a LEFT JOIN visamain b ON a.vouchno=b.vouchno WHERE a.passport ='$passport'";
    $result2 = mysqli_query($conn, $query2) or die(mysqli_error($conn));
    $r2 = mysqli_fetch_assoc($result2);

    // $getag = mysqli_query($conn, "SELECT `name` FROM accmast WHERE accode=$r2[broker]")or die(mysqli_error($conn));
    // $fetag = mysqli_fetch_assoc($getag);
    $agent = $r2['broker'];

    if ($r2["delvstatus"] =='E'){
        $delvstatus = "ECR";
    } elseif($r2["delvstatus"] =='N'){
        $delvstatus = "ECNR";
    }else{
        $delvstatus = "";
    }

    $rows = array();
    $ctr = 0;
    $rows = array('success' => true,
        'paxname'          => "$r2[paxname]",
        'agent'          => "$agent",
        // 'memcash'          => "$r2[memcash]",
        'memcash'           => "$r2[memcash]");

    header("Content-type: application\json");
    echo json_encode($rows);
}

