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


mysqli_query($conn, "SET NAMES 'utf8'");
mysqli_query($conn, 'SET CHARACTER SET utf8');

header('Content-Type: text/html;charset=UTF-8');
ini_set('default_charset', 'utf-8');

$maindb = 'visamain';
$trandb = 'visatran';

$file = 'visa_pdf.php';
$formname = "Visaform";
$keyfld = "vouchno";

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

$admin = $_SESSION["admin_" . $dbname];
$myvouch = $_REQUEST["myvouch"];
$ppno = $_REQUEST["passport"];
$passport = trim($ppno);

// browse($passport);
$pname = $getacc['name'];
$add1 = $getacc['add1'];
$add2 = $getacc['add2'];
$mainqry = mysqli_query($conn, "SELECT a. *, b. * FROM `$maindb` a LEFT JOIN `$trandb` b ON a.myvouch = b.myvouch WHERE a.myvouch = '$myvouch' ") or die(mysqli_error($conn));
// print table($mainqry);
//die();
$fetdata = mysqli_fetch_array($mainqry);
$sponsor = $fetdata['sponsor'];
$mofano = $fetdata['mofano'];
$mofano2 = $fetdata['mofano2'];
$imagepath = $fetdata['imagepath'];
$visapdf = $fetdata['visapdf'];
?>
<!DOCTYPE html>

<head>
    <title>VISA PDF</title>
        <style>
        body {
            margin: 0;
            padding: 0;
        }
        iframe {
            width: 100%;
            height: 100vh; /* Full screen height */
            border: none;
        }
    </style>
</head>

<body>
    <?php
// Example: $visapdf = "uploads/visa123.pdf";
if (!empty($visapdf) && file_exists($visapdf)) {
?>
    <!-- Show PDF -->
    <iframe src="<?= $visapdf ?>"></iframe>

<?php
} else {
    browse("No PDF File Uploaded");
    echo "<script>window.close()</script>";
}
?>
    <?php //browse ($visapdf); ?>
</body>

</html>