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

$zdb = $_SESSION["zdbyear_$dbname"];
$ztit = $_SESSION["tit"];
$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];
$keyfld = "vouchno";

mysqli_select_db($conn,$zdb);

if (isset($_REQUEST["status"])) {
    $stats = $_REQUEST["status"];

    if ($stats == "0") {
        $getrec = mysqli_query($conn,"SELECT a.destination,a.mobile, b.* FROM `visamain` a, `visatran` b WHERE  a.vouchno = b.vouchno and `pastatus`='0'")or die(mysqli_error($conn));
    } else {
        $getrec = mysqli_query($conn,"SELECT a.destination,a.mobile, b.* FROM `visamain` a, `visatran` b WHERE  a.vouchno = b.vouchno and `pastatus`='1'")or die(mysqli_error($conn));
    }

    $get1 = mysqli_num_rows($getrec);
    ?>
    <table style="background-color: #64CCFC" class="table table-bordered">
        <?php 
        if($stats == "1"){
        ?>
        <thead><b><i>In Hand</i></b></thead>
        <?php } else{
            ?>
        <thead><b><i>Sent to Supplier</i></b></thead>
        <?php } ?>
        <th>Sr.</th>
        <th>Given Name</th>
        <th>Last Name</th>
        <th>Mobile</th>
        <th>Passport No.</th>
        <th>Destination</th>
        <?php
        $ctr = 1;
        while ($rec = mysqli_fetch_array($getrec)) {
            Echo "<tr>";
            Echo "<td class='text-right'>$ctr</td>";
            Echo "<td class=''>$rec[givename]</td>";
            Echo "<td class=''>$rec[lastname]</td>";
            Echo "<td class=''>$rec[mobile]</td>";
            Echo "<td class=''>$rec[passport]</td>";
            Echo "<td class=''>$rec[destination]</td>";
            Echo "</tr>";
            $ctr++;
        }
        ?>
    </table>
    <?php
}
?>