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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];

$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

$vouch = $_GET['vouchno'];
$imglogo = $_GET["image"];

$cond = '';
$lcond = '';
$formname = "Visa Voucher";

$maindb = 'pax';
$accdb = 'actran';
$fooddb = 'foodent';
$launddb = 'laundent';
$visadb = 'visaent';
$tiktdb = 'tiktent';
$transdb = 'transent';
$tranpurchdb = 'tranpurch';

$getqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`date`, '%d-%m-%Y')as mydt   FROM `$maindb` WHERE vouchno='$vouch' ORDER BY `vouchno`") or die(mysqli_error($conn));
$getdata = mysqli_fetch_array($getqry);

$fullname = $getdata['surname'] . " " . $getdata['name'] . " " . $getdata['midname'];


$getcomp2 = mysqli_query($conn, "SELECT * FROM $zroot.`company`") or die(mysqli_error($conn));
$comp2 = mysqli_fetch_array($getcomp2);

$compname = $comp2['compname'];
$headerimg = $comp2['reportheadimg'];
$footerimg = $comp2['footerimg'];

$title = "VISA VOUCHER_PUVS#$vouch FOR $fullname";

include("includes/print_linkshead.php");
?>

<!DOCTYPE HTML>
<html lang="en-US">
<style>
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        /*background-color: #FAFAFA;*/
        font: 12pt "Arial";
    }

    @media print {
        .noprint {
            display: none;
        }
    }

    * {
        box-sizing: border-box;
        -moz-box-sizing: border-box;
    }

    .page {
        width: 210mm;
        min-height: 297mm;
        padding: 4mm;
        margin: 10mm auto;
        border: 1px #D3D3D3 solid;
        border-radius: 5px;
        /*background: white;*/

    }

    .subpage {
        padding: 0cm;
        /*        border: 1px solid;*/
        height: 288mm;
        outline: 2cm #ffffff solid;
    }

    @page {
        size: A4;
        margin: 0;
    }

    @media print {
        .noPrint {
            display: none;
        }

        html,
        body {
            width: 210mm;
            height: 297mm;
        }

        .page {
            margin: 0;
            border: initial;
            border-radius: initial;
            width: initial;
            min-height: initial;
            box-shadow: initial;
            background: initial;
            page-break-after: always;
        }
    }

    .numeric {
        text-align: right;
    }

    .rnone {
        border-right: none;
    }

    .lnone {
        border-left: none;
    }

    .outer {
        width: 100%;
        border-collapse: collapse;
        border: 1px solid black;
    }

    .center {
        text-align: center;
    }

    .B {
        padding-left: 15px;
    }


    .d {
        border-collapse: inherit;
    }


    .w {
        width: 40%;
    }

    hr.sk1 {
        border: 2px solid black;
    }
    .skdiv {
        width: 50%;
        margin: auto;
        margin-top: -20px;
        margin-bottom: -20px;
    }

    .table1>tbody>tr>td {
        padding: 2px;
        line-height: 1.42857143;
        /* vertical-align: top; */
        /* border-top: 1px solid #ddd; */
    }
</style>
</head>

<body id="main_container">
    <div class="book tablerep">

        <button onclick="window.print();return false;" class="btn btn-primary noPrint" style="width: 150px;height:35px;background-color: #A0B1BA;color:white;">Print</button>
        &nbsp;&nbsp;&nbsp;
        <button class="btn btn-primary goBack noPrint" onclick="window.close()" style="width: 150px;height:35px;background-color: white;color:#A0B1BA;padding-left: 1%">Go Back</button>
        <div class="page">
            <div class="">
                <?php if ($imglogo == "Yes") { ?>
                    <div class="skdiv">
                        <img style="height:auto;width:100%;" src="<?php echo $headerimg; ?>">
                    </div>
                <?php } ?>

                <br>

                <div class="row" style="text-align:center;background-color:<?= $vheadcolor; ?>  !important;-webkit-print-color-adjust: exact;height:35px">
                    <p style="font-size: 20px;color:white !important;margin-top:5px">
                        <?php echo $formname ?></p>
                </div>

              
                <table class=" table1 table-borderless" style="width:100%">

                    <tbody>

                        <tr width="100%">
                            <td><b style="font-size:17px;color:<?= $vheadcolor; ?> ">PUVS#
                                    <?php echo $getdata['vouchno']; ?>
                                </b></td>
                        </tr>
                        <tr width="100%">
                            <td><span style="padding-right:48px"> Date </span> : <b>
                                    <?php echo $getdata['mydt']; ?>
                                </b></td>
                        </tr>
                        <?php if ($agentname != "") { ?>
                            <tr width="100%">

                                <td><span style="padding-right:50px"> To </span> : <b>
                                        <?php echo $paxname; ?>
                                    </b></td>
                                <td style="width: 40%;text-align:right"></td>
                            </tr>
                        <?php } ?>
                        <tr width="100%">
                            <?php $fullname = $getdata['surname'] . " " . $getdata['name'] . " " . $getdata['midname']; ?>
                            <td><span style="padding-right:5px"> Guest Name </span> : <b>
                                    <?php echo $fullname; ?>
                                </b></td>
                            <td style="width: 40%;text-align:left"><span style="padding-right:5px"> Staff</span> : <b>
                                    <?php
                                    if ($getdata["edituser"] != '') {
                                        $user = strtoupper($getdata["edituser"]);
                                    } else {
                                        $user = strtoupper($getdata["adduser"]);
                                    }

                                    echo $user;
                                    ?>
                                </b></td>
                        </tr>
                        <tr width="100%">
                            <td><span style="padding-right:16px"> Nationality </span> : <b>
                                    <?php echo $getdata['nationality']; ?> </b></td>
                        </tr>
                    </tbody>
                </table>

                <br>

                <div>

                    <table style="width:100%" class="table table-bordered">
                        <tr class="mySearchTr" style="font-size: 13px;">
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;">Country</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;" class='text-right'>No. Pax</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;" class='text-right'>Rate</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;" class='text-right'>Amount</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;">Visa Type</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;">Validity</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;">Group Code</th>
                            <th style="width:10%;-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;">Travel Date</th>
                        </tr>

                        <?php
                        $ctr = 0;
                        $ctab = 0;
                        $totqty = 0;
                        $getvisadtl = mysqli_query($conn, "SELECT * FROM `$visadb` where vouchno ='$getdata[vouchno]' order by srno") or die(mysqli_error($conn));
                        while ($fetvisa = mysqli_fetch_array($getvisadtl)) {

                            $getho3 = mysqli_query($conn, "SELECT `code`,`country` FROM `visamain` where code='$fetvisa[country]'") or die(mysqli_error($conn));
                            $fetho3 = mysqli_fetch_array($getho3);

                            echo "<tr style='font-size: 11px;'>";
                            echo "<td style=''>$fetho3[country]</td>";
                            echo "<td style='text-align: right;'>$fetvisa[nopax]</td>";
                            echo "<td style='text-align: right;'>$fetvisa[rate]</td>";
                            echo "<td style='text-align: right;'>$fetvisa[amount]</td>";
                            echo "<td style=''>$fetvisa[type]</td>";
                            echo "<td style=''>$fetvisa[validity]</td>";
                            echo "<td style=''>$fetvisa[groupcode]</td>";
                            echo "<td style=''>" . format_date($fetvisa['vtraveldt']). "</td>";
                            echo "</tr>";

                            $ctab = $ctab + 1;
                        }
                        if ($ctab < 6) {
                            for ($i = $ctab; $i < 7; $i++) {
                        ?>
                                <tr style="height:30px;">
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                        <?php
                            }
                        }
                        ?>
                        <tr>
                            <td style="text-align: right;"> <b>Total</b></td>
                            <td style="text-align: right;"> <b><?= $getdata['visapax'] ?> </b></b></td>
                            <td style="text-align: left;"> <b></b></td>
                            <td style="text-align: right;"> <b><?= $getdata['visaamt'] ?> </b></td>
                            <td style="text-align: left;"> <b></b></td>
                            <td style="text-align: left;"> <b></b></td>
                            <td style="text-align: left;"> <b></b></td>
                        </tr>
                    </table>
                </div>

            </div>

            <div style="border:1px solid black">

                <table>
                    <tr>
                        <td style="text-align: left;"><b>NOTES</b></td>
                    </tr>
                    <tr>
                        <td style="text-align: left;">Emergency Contact details: <?= $comp2['emergencyno']; ?></td>
                    </tr>
                    <tr>
                        <td style="text-align: left;">High penalty consequences for staying beyond the permitted duration</td>
                    </tr>
                    <tr>
                        <td style="text-align: left;">Please check all your personal details and inform us on the same day</td>
                    </tr>

                </table>

            </div>
            <tr>
                <td style="text-align: left;">&nbsp;</td>
            </tr>

            <?php
            require("includes/dbconnect.php");
            ?>

            <div>
                <table style="width:100%">
                    <tr style="width:100%">
                        <td style="width:50%;text-align: left;font-size:14px;">Helpline Makkah : <b><?= "$comp2[helpmak]"; ?></b></td>
                        <td style="width:50%;text-align: right;font-size:14px;">Helpline Medina : <b><?= "$comp2[helpmed]"; ?></b></td>
                    </tr>
                </table>
            </div>
<!--            <div class="row" style="background-color:<?= $vheadcolor; ?>  !important;height:35px">
                <table class="border" style="height:35px;width:100%">
                    <tr>
                        <td width="35%" class="padd">&nbsp;&nbsp;</td>
                        <td width="30%" class="padd" style="text-align: center;"></td>
                        <td width="35%" class="right padd" style="text-align: center;"></td>
                    </tr>
                </table>
            </div>-->
            <br>


            <?php if ($imglogo == "Yes") { ?>
                <div class="row" style="text-align:center;background-color:lightgrey !important;">
                    <?php
                    $ztel = $comp2['htel'];
                    $zadd = $comp2["hoadd1"] . " " . $comp2["hoadd2"] . " " . $comp2["hoadd3"] . " " . $comp2["hocity"] . " " . $comp2["hopin"];
                    ?>
                    <b> Regd. Ofc. </b><span style="font-family: verdana;font-size: 14px"><?= $zadd ?></span> <b>Tel.:<?= $ztel ?></b>
                </div>

                <div class="row" style="background-color:<?= $vheadcolor; ?>  !important;height:35px">
                    <table class="border" style="height:35px;width:100%">
                        <tr>
                            <td width="35%" class="padd">&nbsp;&nbsp;<b style="font-size: 14px;color:white !important"><?php echo $comp2['compname']; ?></b></td>
                            <td width="30%" class="padd" style="text-align: center;"><b style="font-size: 12px;color:white !important">Email : <?php echo $comp2['email']; ?></b></td>
                            <td width="35%" class="right padd" style="text-align: center;"><b style="font-size: 12px;color:white !important">Website :&nbsp;<?php echo $comp2['website']; ?></b></td>
                        </tr>
                    </table>
                </div>
            <?php } ?>

        </div>
    </div>
    <?php
    include("includes/linksfoot.php");
    ?>

</body>

</html>