<?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 * FROM `visatran` WHERE passport ='$passport'";
    $result2 = mysqli_query($conn, $query2) or die(mysqli_error($conn));

    $r2 = mysqli_fetch_assoc($result2);
    $getfile = mysqli_query($conn, "SELECT `manualno`,`broker` FROM visamain WHERE vouchno='$r2[vouchno]' ") or die (mysqli_error($conn));
    $fetfile = mysqli_fetch_array($getfile);
    $fileno = $fetfile['manualno'];
    // $getref = mysqli_query($conn, "SELECT ref, paxname FROM courintran WHERE passport='$passport' ") or die (mysqli_error($conn));
    // $fetref = mysqli_fetch_array($getref);
    $ref = $fetfile['broker'];
    $paxname = $r2['paxname'];

    $rows = array();
    $ctr = 0;
    $rows = array('success' => true,
        'passport'=> "$passport",
        'paxname' => "$paxname",
        'agent' => "$ref",
        'fileno'   => "$fileno");

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

