<?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"];
$zcomp = $_SESSION["comp_" . $dbname];

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

$vouch = $_GET['vouchno'];

$cond = '';
$lcond = '';
$formname = "Quotation Print";

$maindb = 'quotmain';
$trandb = 'quottran';

$getqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') AS mydt, DATE_FORMAT(`depdt`, '%d-%m-%Y') AS depdt FROM `$maindb` WHERE vouchno='$vouch' ORDER BY `vouchno`") or die(mysqli_error($conn));
$getdata = mysqli_fetch_array($getqry);
$fullname = $getdata['name'] . " " . $getdata['surname'];
$roeamt = $getdata['roe'];

$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'];
$hostatecode = $comp2['hostatecode'];
$address = $comp2['hoadd1'] . $comp2['hoadd2'] . $comp2['hoadd3'];

$title = "QUOTATION PRINT#$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;
    }

    .f13 {
        font-size: 13px;
    }

    .f14 {
        font-size: 14px;
    }

    .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; */
    }

    /* body {
        font-family: Arial, sans-serif;
    } */
    .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        border-bottom: 2px solid #ccc;
    }

    /* .header h1 {
        color: #003366;
        margin: 0;
        font-size: 24px;
    } */

    .address {
        font-size: 12px;
        color: #004e82 !important;
        text-decoration: underline;
        font-weight: bold;
        font-size: 13px;
        text-align: center;
        /* margin-left: 17%; */
    }

    .logo {
        max-height: 100%;
        margin-left: 35%;
    }

    .title {
        text-align: center;
        font-size: 23px;
        font-weight: bold;
        color: #a33;
        text-decoration: underline;
        margin: 10px 0;
    }

    .skdiv {
        width: 50%;
        margin: auto;
    }
</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>

                <div class="skdiv">
                    <img style="height:100%;width:100%;" src="<?php echo $headerimg; ?>">
                </div>

                <br>

                <div class="address">
                    <?php echo $address; ?>
                </div>
                <hr>
            </div>

            <div class="title">UMRAH QUOTATION</div>

            <!-- <div class="hoteldet" style="text-decoration: underline;">HOTEL DETAILS :</div> -->

            <table class="table table-hover table-bordered" style="width:100%;">
                <thead>

                </thead>
                <tbody>
                    <tr class="mySearchTr">
                        <th style="width:45%">Pax Name</th>
                        <th style="width:13%">Class No</th>
                        <th style="width:13%">Airline</th>
                        <th style="width:13%">Dep Date</th>
                    </tr>

                    <tr>
                        <td class="f14"><span style=""> <?= $fullname; ?> </span> </td>
                        <td class="f14"><span style=""> <?= $getdata['classno']; ?> </span> </td>
                        <td class="f14"><span style=""> <?= $getdata['airline']; ?> </span> </td>
                        <td class="f14"><span style=""> <?= $getdata['depdt']; ?> </span> </td>
                    </tr>

                </tbody>
            </table>
            <br>
            <table class="table table-hover table-bordered" style="width:100%;">
                <thead>
                    <tr class="mySearchTr">
                        <th></th>
                        <th colspan="6">Hotel Details</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="mySearchTr">
                        <th>City</th>
                        <th>Hotel</th>
                        <th>Date</th>
                        <th class="text-center">Room Type</th>
                        <th class="text-center">No. Of Room</th>
                        <th class="text-center">Nights</th>
                        <th>Meal Plan</th>
                    </tr>
                    <?php
                    $gettran = mysqli_query($conn, "SELECT *, DATE_FORMAT(`checkin`, '%d-%m-%Y') as indt, DATE_FORMAT(`checkout`, '%d-%m-%Y') as outdt FROM `$trandb` WHERE `vouchno`='$getdata[vouchno]' ORDER BY `srno`") or die(mysqli_error($conn));
                    while ($tran = mysqli_fetch_array($gettran)) {

                        $mhotel = mysqli_query($conn, "SELECT code,hotelnm FROM hotels where code='$tran[hotelnm]'") or die(mysqli_error($conn));
                        $thotel = mysqli_fetch_array($mhotel);

                        $mctr++;
                        if ($tran['city'] == 99) {
                            $cityname = "OTHER";
                        } else {
                            $mhotcity = mysqli_query($conn, "SELECT code,name FROM city where code='$tran[city]'") or die(mysqli_error($conn));
                            $thotcity = mysqli_fetch_array($mhotcity);
                            $cityname = $thotcity['name'];
                        }
                        ?>
                        <tr>
                            <td class="f14"><span style=""> <?= $cityname; ?> </span> </td>
                            <td class="f14"><span style=""> <?= $thotel['hotelnm']; ?> </span> </td>
                            <td class="f14"><span style=""> <b><?php echo $tran['indt']; ?> to
                                        <?php echo $tran['outdt']; ?></b></td>
                            <td class="f14"><span style=""> <?= $tran['roomtype']; ?> </span> </td>
                            <td class="f14 text-right"><span style=""> <?= $tran['roomsno']; ?> </span> </td>
                            <td class="f14 text-right"><span style="font-weight:bold"> <?= $tran['nonights']; ?> </span>
                            </td>
                            <td class="f14"><span style=""> <?= $tran['mealplan']; ?> </span> </td>
                        </tr>
                    <?php } ?>

                </tbody>
            </table>
            <br>
            <table class="table table-hover table-bordered" style="width:100%;">
                <thead>

                </thead>
                <tbody class="container">
                    <tr class="mySearchTr">
                        <th style="width:5%">Pax Type</th>
                        <th class="text-right" style="width:5%">Charges Per Pax</th>
                        <th class="text-right" style="width:5%">Pax No.</th>
                        <th class="text-right" style="width:5%">Total</th>
                    </tr>
                    <tr>
                        <td class="f14"><span>ADULT </span> </td>
                        <td class="f14 text-right"><span><b><?= $getdata['adultchg']; ?></b></span></td>
                        <td class="f14 text-right"><span><b><?= $getdata['adultpax']; ?></b></span></td>
                        <td class="f14 text-right"><span><?= $getdata['totadult']; ?></span></td>
                    </tr>
                    <tr>
                        <td class="f14">CHILD &nbsp;&nbsp; <span style="color:#ff0000">(With Bed)</span></td>
                        <td class="f14 text-right"><span> <b><?= $getdata['childchg']; ?></b> </span> </td>
                        <td class="f14 text-right"><span><b><?= $getdata['childpax']; ?></b></span></td>
                        <td class="f14 text-right"><span> <?= $getdata['totchildbed']; ?> </span> </td>
                    </tr>
                    <tr>
                        <td class="f14">CHILD &nbsp;&nbsp; <span style="color:#0000ff">(Without Bed)</span></td>
                        <td class="f14 text-right"><span> <b><?= $getdata['chwobed']; ?></b></span> </td>
                        <td class="f14 text-right"><span><b><?= $getdata['chwobedpax']; ?></b></span></td>
                        <td class="f14 text-right"><span><?= $getdata['totchildwobed']; ?></span> </td>
                    </tr>
                    <tr>
                        <td class="f14"><span>INFANT </span> </td>
                        <td class="f14 text-right"><span> <b><?= $getdata['infantchg']; ?></b> </span> </td>
                        <td class="f14 text-right"><span><b><?= $getdata['infantpax']; ?></b></span></td>
                        <td class="f14 text-right"><span><?= $getdata['totinfant']; ?></span></td>
                    </tr>
                    <tr style='background:#CFE4FA'>
                        <td class="f14 text-right" colspan="3">Final Total</td>
                        <td class="f14 text-right"><span><b><?= $getdata['netamt']; ?></b></span></td>
                    </tr>
                </tbody>
            </table>
            <br>
            <table class="table table-hover table-bordered" style="width:100%;">
                <thead>

                </thead>
                <tbody>
                    <tr class="mySearchTr">
                        <th style="width:45%">Inclusion</th>
                    </tr>
                    <tr>
                        <td class="f14"><span style=""> <?= $getdata['inc1']; ?> </span> </td>
                    </tr>
                    <tr>
                        <td class="f14"><span style=""> <?= $getdata['inc2']; ?> </span> </td>
                    </tr>
                    <tr>
                        <td class="f14"><span style=""> <?= $getdata['inc3']; ?> </span> </td>
                    </tr>
                    <tr>
                        <td class="f14"><span style=""> <?= $getdata['inc4']; ?> </span> </td>
                    </tr>
                    <tr>
                        <td class="f14"><span style=""> <?= $getdata['inc5']; ?> </span> </td>
                    </tr>
                </tbody>
            </table>
            <br>
            <!-- <br>
            <br>
            <br>
            <br>
            <br>
            <br>
            <br> -->
            <tr style="width: 100%;">
                <td class="f14"></td>
                <td class="f14">
                    <div style="margin-right:20px; text-align:right; font-size: 14px; ">For
                        &nbsp;<b><? echo "$compname"; ?></b></div>
                </td>
            </tr>
        </div>
        <tr>
            <td style="text-align: left;">&nbsp;</td>
        </tr>

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

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

</body>

</html>