<?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 = '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'];
$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'];

$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; */
    }
</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="">
                <div class="skdiv">
                    <img style="height:auto;width:100%;" src="<?php echo $headerimg; ?>">
                </div>
                <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 class="f14"><span style="padding-right:10px"> Quotation No. </span> : <b>
                                    <?php echo $getdata['vouchno']; ?></b></td>
                            <td class="f14"><span style="padding-right:55px"> Date </span> : <b>
                                    <?php echo $getdata['mydt']; ?></b></td>
                        </tr>
                        <tr width="100%">
                            <?php
                            $fullname = $getdata['surname'] . " " . $getdata['name'] . " " . $getdata['midname'];
                            $optdate = date("d-m-Y", strtotime($getdata['optdate']));
                            ?>
                            <td class="f14"><span style="padding-right:63px"> Party </span> : <b>
                                    <?php echo $fullname; ?></b></td>
                            <td class="f14"><span style="padding-right:55px"> 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 class="f14"><span style="padding-right:30px"> Nationality </span> : <b>
                                    <?php echo $getdata["nationality"]; ?></b></td>
                            <td class="f14"><span style="padding-right:10px"> Option Date </span> : <b>
                                    <?php echo $optdate; ?></b></td>
                        </tr>
                    </tbody>

                </table>


                <?php if ($getdata["tiktamt"] > 0) { ?>
                    <br>
                    <div>
                        <div>Ticket & Airline Details</div>
                        <table style="width:100%" class="table table-bordered">
                            <tr class="mySearchTr" style="font-size: 12px; ">
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%">
                                    From</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%;">
                                    To</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 10%;">
                                    Airline</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 8%;">
                                    Ticket No.</th>
                                <th
                                    style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%'>
                                    Flight No.</th>
                                <th
                                    style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 10%'>
                                    PNR</th>
                                <th
                                    style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 10%'>
                                    Date</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 5%'
                                    class="text-right">No.<br> Pax</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 5%'
                                    class="text-right">No.<br>Child</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 5%'
                                    class="text-right">No.<br>Inf.</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%'
                                    class="text-right">Adult</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%'
                                    class="text-right">Child</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%'
                                    class="text-right">Infant</th>
                                <th style='-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width: 7%'
                                    class="text-right">Total</th>
                            </tr>

                            <?php
                            $ctr = 0;
                            $ctab = 0;
                            $totqty = 0;
                            $gettiktdtl = mysqli_query($conn, "Select *,DATE_FORMAT(`travdate`,'%d-%m-%Y')as travdate from `$tiktdb` where vouchno ='$getdata[vouchno]' order by srno") or die(mysqli_error($conn));

                            while ($fettikt = mysqli_fetch_array($gettiktdtl)) {
                                $getho = mysqli_query($conn, "SELECT `code`,`name` FROM `airline` where code='$fettikt[airline]'") or die(mysqli_error($conn));
                                $fetho = mysqli_fetch_array($getho);

                                echo "<tr style='font-size: 11px !important;'>";
                                echo "<td style=''>$fettikt[fromdes]</td>";
                                echo "<td>$fettikt[todes]</td>";
                                echo "<td>$fetho[name]</td>";
                                echo "<td>$fettikt[ticketno]</td>";
                                echo "<td style=''>$fettikt[flightno]</td>";
                                echo "<td style=''>$fettikt[pnrno]</td>";
                                echo "<td style='font-size:11px'>$fettikt[travdate]</td>";
                                echo "<td style='text-align:right'>$fettikt[nopax]</td>";
                                echo "<td style='text-align:right'>$fettikt[nochild]</td>";
                                echo "<td style='text-align:right'>$fettikt[noinf]</td>";
                                echo "<td style='text-align:right'>$fettikt[adult]</td>";
                                echo "<td style='text-align:right'>$fettikt[child]</td>";
                                echo "<td style='text-align:right'>$fettikt[infant]</td>";
                                echo "<td style='text-align:right'>$fettikt[amount]</td>";
                                echo "</tr>";
                            }
                            ?>

                            <tr>
                                <td style="text-align: left;"> <b></b></td>
                                <td style="text-align: right;"></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>
                                <td style="text-align: left;"> <b></b></td>
                                <td style="text-align: left;"> <b></b></td>
                                <td style="text-align: left;"> <b></b></td>
                                <!--<td style="text-align: right;"> <b><?= $getdata['tiktpax'] ?></b></td>-->
                                <td style="text-align: right;"> <b></td>
                                <td style="text-align: right;"> <b></td>
                                <td style="text-align: right;"> <b></td>
                                <td style="text-align: right;"> <b></td>
                                <td style="text-align: right;"> <b>Total</b></td>
                                <td style="text-align: right;"> <b><?= $getdata['tiktsubtot'] ?> </b></td>
                            </tr>


                        </table>
                    </div>
                <?php } ?>


                <?php if ($getdata["hotelamt"] > 0) { ?>
                    <br>

                    <div>
                        <div>Hotel</div>

                        <table style="width:100%" class="table table-bordered">
                            <tr class="mySearchTr" style="font-size: 13px;">
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:8%">
                                    City</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:12%">
                                    Hotel Name</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:7%">
                                    Check In</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:7%">
                                    Check Out</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:3%"
                                    class="text-center">No. Nights</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:8%">
                                    Room Category</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:4%">
                                    Type</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:5%">
                                    CNF</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:5%"
                                    class='text-right'>Qty.</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:5%"
                                    class='text-right'>Rate/Pax</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:5%"
                                    class='text-right'>INR Amt</th>
                            </tr>

                            <?php
                            $ctr = 0;
                            $ctab = 0;
                            $totqty = 0;
                            $gettran = mysqli_query($conn, "SELECT *,DATE_FORMAT(`checkin`,'%d-%m-%Y')as checkin,DATE_FORMAT(`checkout`,'%d-%m-%Y')as checkout FROM `$tranpurchdb` WHERE `vouchno`='$getdata[vouchno]' ORDER BY `srno`") or die(mysqli_error($conn));
                            while ($tran = mysqli_fetch_array($gettran)) {

                                $mhotcatg = mysqli_query($conn, "SELECT code,name FROM roomcatg where code='$tran[roomcatg]'") or die(mysqli_error($conn));
                                $thotcatg = mysqli_fetch_array($mhotcatg);

                                $mrtype = mysqli_query($conn, "SELECT code,name FROM roomtype where code='$tran[roomtype]'") or die(mysqli_error($conn));
                                $trtype = mysqli_fetch_array($mrtype);

                                $mhotcity = mysqli_query($conn, "SELECT code,name FROM city where code='$tran[city]'") or die(mysqli_error($conn));
                                $thotcity = mysqli_fetch_array($mhotcity);

                                $mhotel = mysqli_query($conn, "SELECT code,hotelnm FROM hotels where code ='$tran[hotelnm]'") or die(mysqli_error($conn));
                                $thotel = mysqli_fetch_array($mhotel);
                                $hpaxno = $tran['hotelpax'];
                                $hratepp = $tran['amount'] * $roeamt / $hpaxno;
                                $totalhotinr = $hratepp * $hpaxno;

                                if ($trtype['name'] == "Quad" && $tran['hotelpax'] < 4) {
                                    $roomtype = "Quad Sharing";
                                } else {
                                    $roomtype = $trtype['name'];
                                }

                                echo "<tr style='font-size: 11px;'>";
                                echo "<td style=''>$thotcity[name]</td>";
                                echo "<td>$thotel[hotelnm]</td>";
                                echo "<td style='font-size:11px'>$tran[checkin]</td>";
                                echo "<td style='font-size:11px'>$tran[checkout]</td>";
                                echo "<td style=''>$tran[nonights]</td>";
                                echo "<td style=''>$thotcatg[name]</td>";
                                echo "<td style='font-size:10px'>$roomtype</td>";
                                echo "<td style=''>$tran[cnfno]</td>";
                                echo "<td style='text-align:right'>$tran[qty]</td>";
                                echo "<td style='text-align:right'>$hratepp</td>";
                                echo "<td style='text-align:right'>$totalhotinr</td>";
                                echo "</tr>";
                            }
                            ?>

                        </table>
                    </div>
                <?php } ?>



                <?php if ($getdata["foodamt"] > 0) { ?>
                    <br>

                    <div>
                        <div>Food</div>
                        <table style="width:100%" class="table table-bordered">
                            <tr class="mySearchTr" style="font-size: 13px;">
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:10%">
                                    Check In</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:10%">
                                    Check Out</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:30%">
                                    Hotel</th>
                                <th
                                    style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:15%">
                                    Meal Type</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:10%"
                                    class='text-right'>No. Nights</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:10%"
                                    class='text-right'>No. Pax</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:10%"
                                    class='text-right'>Rate/Pax</th>
                                <th style="-webkit-print-color-adjust: exact;background-color: <?= $vmidcolor; ?> !important;color:white !important;width:10%"
                                    class='text-right'>INR Amount</th>
                            </tr>

                            <?php
                            $ctr = 0;
                            $ctab = 0;
                            $totqty = $ttotalfoodinr = 0;
                            $getfooddtl = mysqli_query($conn, "SELECT *,DATE_FORMAT(`checkin`, '%d-%m-%Y')as checkin,DATE_FORMAT(`checkout`, '%d-%m-%Y')as checkout FROM `$fooddb` WHERE vouchno ='$getdata[vouchno]' order by srno") or die(mysqli_error($conn));
                            while ($fetfood = mysqli_fetch_array($getfooddtl)) {
                                $getho = mysqli_query($conn, "SELECT `code`,`hotelnm` FROM `hotels` where code='$fetfood[hotel]'") or die(mysqli_error($conn));
                                $fetho = mysqli_fetch_array($getho);

                                $getmeal = mysqli_query($conn, "SELECT `code`,`name` FROM $zroot.`mealtype` where code='$fetfood[meal]'") or die(mysqli_error($conn));
                                $fetmeal = mysqli_fetch_array($getmeal);

                                // if ($fpaxno > 0) {
                                $fpaxno = $fetfood['nopax'];
                                $fratepp = $fetfood['amount'] * $roeamt / $fpaxno;
                                $totalfoodinr = $fratepp * $fpaxno;
                                // }
                        
                                echo "<tr style='font-size: 11px;'>";
                                echo "<td style=''>$fetfood[checkin]</td>";
                                echo "<td>$fetfood[checkout]</td>";
                                echo "<td>$fetho[hotelnm]</td>";
                                echo "<td>$fetmeal[name]</td>";
                                echo "<td style='text-align: right;'>$fetfood[nonights]</td>";
                                echo "<td style='text-align: right;'>$fetfood[nopax]</td>";
                                echo "<td style='text-align: right;'>$fratepp</td>";
                                echo "<td style='font-size:10px;text-align:right'>$totalfoodinr</td>";
                                echo "</tr>";
                                $ttotalfoodinr += $totalfoodinr;
                            }
                            ?>

                            <tr>
                                <td style="text-align: left;"><b></b></td>
                                <td style="text-align: left;"></td>
                                <td style="text-align: left;"></td>
                                <td style="text-align: right;"><b>Total</b></td>
                                <td style="text-align: right;"><b><?= $getdata['foodnights'] ?> </b></b></td>
                                <td style="text-align: right;"><b><?= $getdata['foodpax'] ?> </b></b></td>
                                <td style="text-align: left;"><b></b></td>
                                <td style="text-align: right;"><b><?= $ttotalfoodinr ?> </b></td>
                            </tr>
                        </table>
                    </div>
                <?php } ?>



                <?php if ($getdata["laundamt"] > 0) { ?>
                    <br>

                    <div>
                        <div>Laundry</div>
                        <table style="width:100%" class="table table-bordered">
                            <tr class="mySearchTr" style="font-size: 13px;">
                                <th style="width:10%">Check In</th>
                                <th style="width:10%">Check Out</th>
                                <th style="width:30%">Hotel</th>
                                <th style="width:10%" class='text-right'>No. Nights</th>
                                <th style="width:10%" class='text-right'>No. Pax</th>
                                <th style="width:10%" class='text-right'>Rate/Pax</th>
                                <th style="width:10%" class='text-right'>INR Amount</th>
                            </tr>

                            <?php
                            $ctr = 0;
                            $ctab = 0;
                            $totqty = $ttotallaundinr = 0;
                            $getlaunddtl = mysqli_query($conn, "SELECT *,DATE_FORMAT(`checkin`, '%d-%m-%Y')as checkin,DATE_FORMAT(`checkout`, '%d-%m-%Y')as checkout FROM `$launddb` where vouchno ='$getdata[vouchno]' order by srno") or die(mysqli_error($conn));
                            while ($fetlaund = mysqli_fetch_array($getlaunddtl)) {
                                $getho2 = mysqli_query($conn, "SELECT `code`,`hotelnm` FROM `hotels` where code='$fetlaund[hotel]'") or die(mysqli_error($conn));
                                $fetho2 = mysqli_fetch_array($getho2);

                                $lpaxno = $fetlaund['nopax'];
                                $fratepp = $fetlaund['amount'] * $roeamt / $lpaxno;
                                $totallaundinr = $fratepp * $lpaxno;

                                echo "<tr style='font-size: 11px;'>";
                                echo "<td style=''>$fetlaund[checkin]</td>";
                                echo "<td>$fetlaund[checkout]</td>";
                                echo "<td>$fetho2[hotelnm]</td>";
                                echo "<td style='text-align: right;'>$fetlaund[nonights]</td>";
                                echo "<td style='text-align: right;'>$fetlaund[nopax]</td>";
                                echo "<td style='text-align: right;'>$fratepp</td>";
                                echo "<td style='font-size:10px;text-align:right'>$totallaundinr</td>";
                                echo "</tr>";

                                $ttotallaundinr += $totallaundinr;
                            }
                            ?>


                            <tr>
                                <td style="text-align: right;"></td>
                                <td style="text-align: left;"> <b></b></td>
                                <td style="text-align: right;"> <b>Total</b></td>
                                <td style="text-align: right;"> <b><?= $getdata['laundnights'] ?> </b></b></td>
                                <td style="text-align: right;"> <b><?= $getdata['laundpax'] ?> </b></b></td>
                                <td style="text-align: left;"> <b></b></td>
                                <td style="text-align: right;"> <b><?= $ttotallaundinr ?> </b></td>
                            </tr>
                        </table>
                    </div>
                <?php } ?>



                <?php if ($getdata["visaamt"] > 0) { ?>
                    <br>

                    <div>
                        <div>Visa</div>
                        <table style="width:100%" class="table table-bordered">
                            <tr class="mySearchTr" style="font-size: 13px;">
                                <th style="width:10%">Country</th>
                                <th style="width:10%" class='text-right'>No. Pax</th>
                                <th style="width:10%" class='text-right'>Rate</th>
                                <th style="width:10%" class='text-right'>Amount</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 "</tr>";
                            }
                            ?>


                            <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>
                            </tr>
                        </table>
                    </div>
                <?php } ?>


                <?php if ($getdata["transamt"] > 0) { ?>
                    <br>

                    <div>
                        <div>Transportation</div>
                        <table style="width:100%" class="table table-bordered">
                            <tr class="mySearchTr" style="font-size: 13px;">
                                <th style="width:13%">From</th>
                                <th style="width:13%">To</th>
                                <th style="width:15%">Pick Up Time</th>
                                <th style="width:10%">Vehicle</th>
                                <th style="width:5%" class='text-right'>No. Pax</th>
                                <th style="width:7%" class='text-right'>No. Vehicle</th>
                                <th style="width:6%" class='text-right'>Rate</th>
                                <th style="width:8%" class='text-right'>Amount</th>
                                <th style="width:15%">Description</th>
                            </tr>

                            <?php
                            $ctr = 0;
                            $ctab = 0;
                            $totqty = $ttotaltransinr = 0;
                            $gettransdtl = mysqli_query($conn, "SELECT * FROM `$transdb` WHERE vouchno ='$getdata[vouchno]' order by srno") or die(mysqli_error($conn));
                            while ($fettrans = mysqli_fetch_array($gettransdtl)) {

                                $getveh = mysqli_query($conn, "SELECT `code`,`vehtype` FROM `vehicle` where code='$fettrans[vehicle]'") or die(mysqli_error($conn));
                                $fetveh = mysqli_fetch_array($getveh);

                                $tpaxno = $fettrans['nopax'];
                                $tratepp = $fettrans['amount'] * $roeamt / $tpaxno;
                                $totaltransinr = $tratepp * $tpaxno;

                                $new_date = date('d-m-Y  H:i A', strtotime($fettrans['pickuptime']));

                                echo "<tr style='font-size: 11px;'>";
                                echo "<td style=''>$fettrans[fromplace]</td>";
                                echo "<td style='text-align: left;'>$fettrans[toplace]</td>";
                                echo "<td style='text-align: left;'>$new_date</td>";
                                echo "<td style='text-align: right;'>$fetveh[vehtype]</td>";
                                echo "<td style='text-align: right;'>$fettrans[nopax]</td>";
                                echo "<td style='text-align: right;'>$fettrans[noveh]</td>";
                                echo "<td style='text-align: right;'>$fettrans[rate]</td>";
                                echo "<td style='text-align: right;'>$tratepp</td>";
                                echo "<td style='text-align: left;'>$totaltransinr</td>";
                                echo "</tr>";

                                $ttotaltransinr += $totaltransinr;
                            }
                            ?>


                            <tr>
                                <td colspan="4" style="text-align: right;"> <b>Total</b></td>
                                <td style="text-align: right;"> <b><?= $getdata['transpax'] ?> </b></b></td>
                                <td style="text-align: right;"> <b><?= $getdata['transveh'] ?> </b></td>
                                <td style="text-align: right;"> </td>
                                <td style="text-align: right;"> <b><?= $ttotaltransinr ?> </b></td>
                            </tr>
                        </table>
                    </div>
                <?php } ?>
                <table class="table table-bordered">
                    <tr class="">
                        <td style="width:50%">
                            <table style="width:100"></table>
                        </td>
                        <td style="width:50%">
                            <table style="width:100%" class="tecle table-bordered">
                                <?php if ($getdata['tiktamt'] > 0) {
                                    $gst = $_REQUEST['gst'];
                                    $tiktsubtot = $getdata['tiktsubtot'];
                                    $tikthandchg = $getdata['tikthandchg'];
                                    $tiktgstamt = $getdata['tiktgstamt'];

                                    if ($getdata['pstatecode'] == $hostatecode) {
                                        $tiktcgstamt = $tiktgstamt / 2;
                                        $tiktsgstamt = $tiktgstamt / 2;
                                    }

                                    ?>
                                    <tr>
                                        <td style="width:50%" class="text-right" colspan="2">
                                            <b style="font-size:14px">Ticket Subtotal</b>
                                        </td>

                                        <td style="width:50%" class="text-right">
                                            <b style="font-size:18px"><?= number_format($tiktsubtot, 2); ?></b>
                                        </td>
                                    </tr>

                                    <?php if ($tikthandchg > 0) { ?>
                                        <tr>
                                            <td style="width:50%" class="text-right" colspan="2">
                                                <b style="font-size:13px">Handling Charges</b>
                                            </td>
                                            <td style="width:50%" class="text-right">
                                                <b style="font-size:18px"><?= number_format($tikthandchg, 2); ?></b>
                                            </td>
                                        </tr>
                                    <?php } ?>

                                    <?php if ($getdata['pstatecode'] == $hostatecode) { ?>

                                        <tr>
                                            <td style="width:50%" class="text-right" colspan="2">
                                                <b style="font-size:13px">CGST</b>
                                            </td>
                                            <td style="width:50%" class="text-right">
                                                <b style="font-size:18px"><?= number_format($tiktcgstamt, 2); ?></b>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td style="width:50%" class="text-right" colspan="2">
                                                <b style="font-size:13px">SGST</b>
                                            </td>
                                            <td style="width:50%" class="text-right">
                                                <b style="font-size:18px"><?= number_format($tiktsgstamt, 2); ?></b>
                                            </td>
                                        </tr>
                                    <?php } else { ?>

                                        <tr>
                                            <td style="width:50%" class="text-right" colspan="2">
                                                <b style="font-size:13px">IGST</b>
                                            </td>
                                            <td style="width:50%" class="text-right">
                                                <b style="font-size:18px"><?= number_format($tiktgstamt, 2); ?></b>
                                            </td>
                                        </tr>

                                    <?php } ?>
                                    <tr>
                                        <td style="width:50%" class="text-right" colspan="2">
                                            <b style="font-size:16px">Ticket Final</b>
                                        </td>
                                        <td style="width:50%" class="text-right">
                                            <b style="font-size:18px"><?= number_format($getdata['tiktamt'], 2); ?></b>
                                        </td>
                                    </tr>
                                    <?php
                                    $tiktamt = $getdata['tiktamt'];
                                }
                                ?>

                                <?php if ($getdata['hotelamt'] > 0) { ?>
                                    <tr>

                                        <td style="width:30%">
                                            <!-- <b style="font-size:14px">FE - <?= rajnumformat($getdata['hotelamt']) ?></b> -->
                                        </td>
                                        <td style="width:20%">
                                            <b style="font-size:18px">Hotel</b>
                                        </td>
                                        <td style="width:50%" class="text-right">

                                            <b style="font-size:18px"><?= rajnumformat($getdata['hotelinramt']) ?></b>
                                        </td>
                                    </tr>
                                    <?php
                                    $hotelamt = $getdata['hotelinramt'];
                                }
                                ?>
                                <?php if ($getdata['foodamt'] > 0) { ?>
                                    <tr>
                                        <td style="width:30%">
                                            <!-- <b style="font-size:14px">FE - <?= rajnumformat($getdata['foodamt']) ?></b> -->
                                        </td>
                                        <td style="width:20%">
                                            <b style="font-size:18px">Food</b>
                                        </td>
                                        <td style="width:50%" class="text-right">

                                            <b style="font-size:18px"><?= rajnumformat($getdata['foodinramt']) ?></b>
                                        </td>
                                    </tr>
                                    <?php
                                    $foodamt = $getdata['foodinramt'];
                                }
                                ?>
                                <?php if ($getdata['laundamt'] > 0) { ?>
                                    <tr>
                                        <td style="width:30%">
                                            <!-- <b style="font-size:14px">FE - <?= rajnumformat($getdata['laundamt']) ?></b> -->
                                        </td>
                                        <td style="width:20%">
                                            <b style="font-size:18px">Laundry</b>
                                        </td>
                                        <td style="width:50%" class="text-right">

                                            <b style="font-size:18px"><?= rajnumformat($getdata['laundinramt']) ?></b>
                                        </td>
                                    </tr>
                                    <?php
                                    $laundamt = $getdata['laundinramt'];
                                }
                                ?>
                                <?php if ($getdata['visaamt'] > 0) { ?>
                                    <tr>
                                        <td style="width:30%">
                                            <b style="font-size:14px"></b>
                                        </td>
                                        <td style="width:20%">
                                            <b style="font-size:18px">Visa</b>
                                        </td>
                                        <td style="width:50%" class="text-right">

                                            <b style="font-size:18px"><?= rajnumformat($getdata['visaamt']) ?></b>
                                        </td>
                                    </tr>
                                    <?php
                                    $visaamt = $getdata['visaamt'];
                                }
                                ?>
                                <?php if ($getdata['transamt'] > 0) { ?>
                                    <tr>
                                        <td style="width:30%">
                                            <!-- <b style="font-size:14px">FE - <?= rajnumformat($getdata['transamt']) ?></b> -->
                                        </td>
                                        <td style="width:20%">
                                            <b style="font-size:18px">Transportation</b>
                                        </td>
                                        <td style="width:50%" class="text-right">

                                            <b style="font-size:18px"><?= rajnumformat($getdata['transinramt']) ?></b>
                                        </td>
                                    </tr>
                                    <?php
                                    $transamt = $getdata['transinramt'];
                                }

                                $netamt = $foodamt + $hotelamt + $transamt + $visaamt + $laundamt + $tiktamt;
                                $finalinramt = $netamt - $getdata['discountinr'];

                                ?>

                                <tr>
                                    <td style="width:25%" colspan="2" class="text-right">
                                        <b style="font-size:18px;">Total INR</b>
                                    </td>
                                    <td style="width:50%" class="text-right">
                                        <b style="font-size:18px;"><?= rajnumformat($netamt) ?></b>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width:25%" colspan="2" class="text-right">
                                        <b style="font-size:18px;color:red !important">Discount INR</b>
                                    </td>
                                    <td style="width:50%" class="text-right">
                                        <b
                                            style="font-size:18px;color:red !important"><?= rajnumformat($getdata['discountinr']) ?></b>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width:25%" colspan="2" class="text-right">
                                        <b style="font-size:18px;color:green !important">Final INR</b>
                                    </td>
                                    <td style="width:50%" class="text-right">
                                        <b
                                            style="font-size:18px;color:green !important"><?= rajnumformat($finalinramt) ?></b>
                                    </td>
                                </tr>

                            </table>
                        </td>
                    </tr>
                </table>
                <p>Amount in Words : <?php echo rsword($finalinramt) ?></p>
                <p style="font-weight:bold">All Rates are mentioned in SAR. ( ROE : <?= $getdata['roe'] ?> )</p>


            </div>

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

                <table>
                    <tr>
                        <td style="text-align: left;"><b>NOTES</b></td>
                    </tr>
                    <?php
                    echo "<tr><td style='text-align: left;'>$comp2[vchnote1]</td></tr>";
                    echo "<tr><td style='text-align: left;'>$comp2[vchnote2]</td></tr>";
                    echo "<tr><td style='text-align: left;'>$comp2[vchnote3]</td></tr>";
                    echo "<tr><td style='text-align: left;'>$comp2[vchnote4]  $comp2[vchnote5] </td></tr>";
                    // echo "<tr><td style='text-align: left;'>$comp2[vchnote5]</td></tr>";
                    echo "<tr><td style='text-align: left;'>$comp2[vchnote6]</td></tr>";
                    if ($comp2['vchnote7'] != "") {
                        echo "<tr><td style='text-align: left;'>$comp2[vchnote7]</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>
            <br>
            <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>

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

</body>

</html>