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

$maindb = 'pax';
$trandb = 'tiktnewtran';
$formname = 'Quotation + Invoice Register';
$file = "tiktnewsalereg_fr.php";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

$status  = $_POST["status"];
$statuscond = "";

if(!empty($status)){
    $statuscond =" AND `status` = $status ";
}
$username = $_SESSION["username_" . $dbname];
$usertype = $_SESSION["usertype"];

if ($usertype > 1) {
    $keycond1 = "AND agentuser='$username' ";
} else {
    $keycond1 = "";
}

$mfrmdate  = $_POST["fromdt"];
$mtodate  = $_POST["todt"];
$mfdt = format_date($mfrmdate);
$mtdt = format_date($mfrmdate);

if (empty($_POST["fromdt"])) {
    browse("From Date Cannot Be Empty");
    echo "<script>window.close()</script>";
}
if (empty($_POST["todt"])) {
    browse("To Date Cannot Be Empty");
    echo "<script>window.close()</script>";
}


if (isset($_POST["view"])) {
    include("includes/linkshead.php");
?>
    <style type="text/css">
        #tabital {
            font-style: italic;
        }

        #font1 {
            font-style: italic;
        }

        #boldfont {
            font-weight: bold;
        }

        .sksahil2 {
            border-radius: 10px;
            background-color: #fff;
            /* background-color:  rgb(192,192,192,0.1); */
            margin-top: 5px;
            margin-bottom: 5px;
        }

        .sktb>tbody>tr>td {
            padding: 5px !important;
        }
    </style>

    </head>

    <body>
        <div class="container" style="width: 1500px;">
            <?php include("includes/head_rep.php"); ?>
            <div class="row">
                <div class="col-lg-12 skbackcolor">
                    <div class="with-nav-tabs ">
                        <div class="">
                            <ul class="nav nav-tabs sksahil2">
                                <li class="active"><a href="#tab1default" data-toggle="tab"><b style="font-size:15px;">Summary</b></a></li>
                                <li><a href="#tab2default" data-toggle="tab"><b style="font-size:15px;">Ticket & Airline </b></a></li>
                                <li><a href="#tab3default" data-toggle="tab"><b style="font-size:15px;">Hotel </b></a></li>
                                <li><a href="#tab4default" data-toggle="tab"><b style="font-size:15px;">Food </b></a></li>
                                <li><a href="#tab5default" data-toggle="tab"><b style="font-size:15px;">Laundry </b></a></li>
                                <li><a href="#tab6default" data-toggle="tab"><b style="font-size:15px;">Transportation </b></a></li>
                                <li><a href="#tab7default" data-toggle="tab"><b style="font-size:15px;">Visa </b></a></li>
                            </ul>
                        </div>
                        <div class="tab-content">

                            <div class="tab-pane fade  in active" id="tab1default">
                                <h4><b>Summary Details</b></h4>

                                <table style="background: white;width: 100%" class="table table-bordered sktb">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th style="width: 6%;">Date</th>
                                            <th style="width: 4%;">Voucher</th>
                                            <th style="width: 15%;">Name</th>
                                            <th style='width: 4%;'>Gender</th>
                                            <th style='width: 6%;'>Passport</th>
                                            <th style='width: 6%;'>Aadhaar No.</th>
                                            <th style='width: 6%;'>PAN No.</th>
                                            <th style='width: 6%;'>GST No.</th>
                                            <th style='width: 6%;text-align:right'>Ticket & Airline</th>
                                            <th style='width: 6%;text-align:right'>Hotel</th>
                                            <th style='width: 6%;text-align:right'>Food</th>
                                            <th style='width: 6%;text-align:right'>Laundry</th>
                                            <th style='width: 6%;text-align:right'>Transportation</th>
                                            <th style='width: 6%;text-align:right'>Visa</th>
                                            <th style='width: 6%;text-align:right'>Total Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php

                                        $scope = $_POST["scope"];
                                        if ($scope == "M") {
                                            $scopecond =  "AND para = '$scope'";
                                        } elseif ($scope == "A") {
                                            $scopecond =  "AND para = '$scope'";
                                        } else {
                                            $scopecond =  "";
                                        }

                                        $$totalinramt = 0;
                                        $skstyle      =  "";

                                        $get = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                                WHERE vouchno != '' AND `date` >= '$mfrmdate' AND 
                                                                                `date` <= '$mtodate' $keycond1 $scopecond  $statuscond order by vouchno") or die(mysqli_error($conn));

                                        while ($getdata = mysqli_fetch_array($get)) {

                                            if ($getdata['para'] == "M") {
                                                $skstyle   =  "background-color:#e6f1ff";
                                            }

                                            $vouchno = $getdata['vouchno'];
                                            $totalinramt = $getdata['tiktamt'] + $getdata['hotelinramt'] + $getdata['foodinramt'] + $getdata['laundinramt']
                                                + $getdata['transinramt'] + $getdata['visaamt'];

                                            $fullname = strtoupper($getdata['surname']) . " " . strtoupper($getdata['name']) . " " . strtoupper($getdata['midname']) . " " . strtoupper($getdata['suffix']);

                                            echo "<tr data-href='fit_ent.php?mode=edit&paxid=$getdata[vouchno]' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                            echo "<td>$getdata[mydt]</td>";
                                            echo "<td>$getdata[vouchno]</td>";
                                            echo "<td>$fullname</td>";
                                            echo "<td>$getdata[gender]</td>";
                                            echo "<td>$getdata[paxpassport]</td>";
                                            echo "<td>$getdata[aadhaarno]</td>";
                                            echo "<td>$getdata[panno]</td>";
                                            echo "<td>$getdata[gstno]</td>";
                                            echo "<td class='text-right'>$getdata[tiktamt]</td>";
                                            echo "<td class='text-right'>$getdata[hotelinramt]</td>";
                                            echo "<td class='text-right'>$getdata[foodinramt]</td>";
                                            echo "<td class='text-right'>$getdata[laundinramt]</td>";
                                            echo "<td class='text-right'>$getdata[transinramt]</td>";
                                            echo "<td class='text-right'>$getdata[visaamt]</td>";
                                            echo "<td class='text-right' style='color:blue'>" . number_format($totalinramt, 2) . "</td>";
                                            echo "</tr>";
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>


                            <!-- Tab 2 Start -->
                            <div class="tab-pane fade" id="tab2default">
                                <div class="row hidtabpane">

                                    <h4><b>Ticket & Airline Details</b></h4>

                                    <table style="background: white;width: 100%" class="table table-condensed table-striped table-hover table-bordered">
                                        <thead class="mySearchTr">
                                            <tr>
                                                <th width="7%;">Date</th>
                                                <th width="7%;">Voucher</th>
                                                <th width="10%;">For</th>
                                                <th width="20%;">Pax</th>
                                                <th width="10%;" class="text-right">Subtotal</th>
                                                <th width="10%;" class="text-right">Handling Charges</th>
                                                <th width="10%;" class="text-right">GST% </th>
                                                <th width="10%;" class="text-right">GST Amount </th>
                                                <th width="10%;" class="text-right">Final Amount</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php

                                            $tottiktsub = 0;
                                            $tothandchg = 0;
                                            $totgstamt  = 0;
                                            $tottiktamt = 0;
                                            $skstyle    =  "";

                                            $getptikt  = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                                      WHERE vouchno != '' AND `date` >= '$mfrmdate' AND `date` <= '$mtodate'
                                                                                      AND tiktamt > 0 $keycond1 $scopecond order by vouchno") or die(mysqli_error($conn));

                                            while ($ptikt = mysqli_fetch_array($getptikt)) {

                                                if ($ptikt['para'] == "M") {
                                                    $skstyle   =  "background-color:#e6f1ff";
                                                }


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

                                                echo "<tr data-href='fit_ent.php?mode=edit&paxid=$ptikt[vouchno]' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                                echo "<td>$ptikt[mydt]</td>";
                                                echo "<td>$ptikt[vouchno]</td>";
                                                echo "<td>$ptikt[visitingfor]</td>";
                                                echo "<td>$fullname</td>";
                                                echo "<td class='text-right'>$ptikt[tiktsubtot]</td>";
                                                echo "<td class='text-right'>$ptikt[tikthandchg]</td>";
                                                echo "<td class='text-right'>$ptikt[tiktgstperc]</td>";
                                                echo "<td class='text-right'>$ptikt[tiktgstamt]</td>";
                                                echo "<td class='text-right'>$ptikt[tiktamt]</td>";
                                                echo "</tr>";

                                                $tottiktsub = $tottiktsub + $ptikt['tiktsubtot'];
                                                $tothandchg = $tothandchg + $ptikt['tikthandchg'];
                                                $totgstamt = $totgstamt + $ptikt['tiktgstamt'];
                                                $tottiktamt = $tottiktamt + $ptikt['tiktamt'];

                                                if ($_POST["dtype"] == 2) {

                                                    echo "<tr style='height:10px;'>";
                                                    echo "<td colspan='25'>";
                                                    echo "<table style='width:100%;' id='tabital' class='table table-condensed table-hover table-bordered'>";
                                                    echo "<thead>";
                                                    echo "<tr class='' style='background-color:#BABFC2;font-size:14px;font-weight:bold'>";

                                                    echo "<th style='width:3%;'>Sr</th>";
                                                    echo "<th style='width:5%;'>From</th>";
                                                    echo "<th style='width:5%;'>To</th>";
                                                    echo "<th style='width:16%;'>Airline</th>";
                                                    echo "<th style='width:7%;'>Ticket No.</th>";
                                                    echo "<th style='width:6%;'>Flight No.</th>";
                                                    echo "<th style='width:5%;'>PNR</th>";
                                                    echo "<th style='width:5%;'>Date</th>";
                                                    echo "<th style='width:5%;'>No. Adult</th>";
                                                    echo "<th style='width:5%;'>No. Child</th>";
                                                    echo "<th style='width:5%;'>No. Infant</th>";
                                                    echo "<th style='width:5%;text-align:right'>Adult</th>";
                                                    echo "<th style='width:5%;text-align:right'>Child</th>";
                                                    echo "<th style='width:5%;text-align:right'>Infant</th>";
                                                    echo "<th style='width:7%;text-align:right'>Total</th>";
                                                    echo "</tr>";
                                                    echo "</thead>";

                                                    $ctr2 = 0;
                                                    $totamt = 0;

                                                    $gettrantikt = mysqli_query($conn, "SELECT *, DATE_FORMAT(`travdate`, '%d-%m-%Y')as stravdate FROM `tiktent`
                                                                                            WHERE `vouchno`='$ptikt[vouchno]' ORDER BY srno") or die(mysqli_error($conn));
                                                    while ($trantikt = mysqli_fetch_array($gettrantikt)) {

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

                                                        $ctr2++;
                                                        echo "<tr>";
                                                        echo "<td>$ctr2</td>";
                                                        echo "<td>$trantikt[fromdes]</td>";
                                                        echo "<td>$trantikt[todes]</td>";
                                                        echo "<td>$fetho[name]</td>";
                                                        echo "<td>$trantikt[ticketno]</td>";
                                                        echo "<td>$trantikt[flightno]</td>";
                                                        echo "<td>$trantikt[pnrno]</td>";
                                                        echo "<td>$trantikt[stravdate]</td>";
                                                        echo "<td>$trantikt[nopax]</td>";
                                                        echo "<td>$trantikt[nochild]</td>";
                                                        echo "<td>$trantikt[noinf]</td>";
                                                        echo "<td class='text-right'>$trantikt[adult]</td>";
                                                        echo "<td class='text-right'>$trantikt[child]</td>";
                                                        echo "<td class='text-right'>$trantikt[infant]</td>";
                                                        echo "<td class='text-right'>$trantikt[amount]</td>";
                                                        echo "</tr>";

                                                        $totamt = $totamt + $trantikt['amount'];
                                                    }

                                                    echo "<tr style='background-color:#c7ecee;font-weight:bold;'>";
                                                    echo "<td colspan='14' class='text-right'>Total</td>";
                                                    echo "<td class='text-right ; font-bolder'>$totamt</td>";
                                                    echo "</tr>";
                                                    echo "</table>";
                                                    echo "</td>";
                                                    echo "</tr>";
                                                }
                                            }


                                            echo "<tr style='background-color: #0375bc;color: white;'>";
                                            echo "<td></td>";
                                            echo "<td></td>";
                                            echo "<td></td>";
                                            echo "<td style='font-size:17px' class='text-right'><b>Total</b></td>";
                                            echo "<td style='font-size:17px' class='text-right'>$tottiktsub</td>";
                                            echo "<td style='font-size:17px' class='text-right'>$tothandchg</td>";
                                            echo "<td style='font-size:17px' class='text-right'></td>";
                                            echo "<td style='font-size:17px' class='text-right'>$totgstamt</td>";
                                            echo "<td style='font-size:17px' class='text-right'>$tottiktamt</td>";
                                            echo "</tr>";
                                            ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <!-- Tab 2 End -->


                            <!-- Tab 3 Start -->
                            <div class="tab-pane fade" id="tab3default">

                                <h4><b>Hotel Details</b></h4>

                                <table style="background: white;width: 100%" class="table table-condensed table-striped table-hover table-bordered">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th width="7%;">Date</th>
                                            <th width="7%;">Voucher</th>
                                            <th width="10%;">For</th>
                                            <th width="30%;">Pax </th>
                                            <th width="10%;" class="text-right">FE Amount</th>
                                            <th width="10%;" class="text-right">INR Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $pctr = 0;
                                        $tothotelamt = 0;
                                        $tothotelinramt = 0;
                                        $skstyle   =  "";

                                        $getphotel = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                                WHERE vouchno != '' AND `date` >= '$mfrmdate' AND `date` <= '$mtodate'
                                                                                AND hotelinramt > 0 $keycond1 $scopecond order by vouchno ") or die(mysqli_error($conn));

                                        while ($photel = mysqli_fetch_array($getphotel)) {

                                            if ($photel['para'] == "M") {
                                                $skstyle   =  "background-color:#e6f1ff";
                                            }

                                            $voucher      = $photel['vouchno'];
                                            $visiting     = $photel['visitingfor'];
                                            $vouchdt      = $photel['mydt'];
                                            $hotelamt     = $photel['hotelamt'];
                                            $hotelinramt  = $photel['hotelinramt'];
                                            $fullname     = $photel['surname'] . " " . $photel['name'] . " " . $photel['midname'];

                                            $pctr++;
                                            echo "<tr data-href='fit_ent.php?mode=edit&paxid=$photel[vouchno]' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                            echo "<td>$vouchdt</td>";
                                            echo "<td>$voucher</td>";
                                            echo "<td>$visiting</td>";
                                            echo "<td>$fullname</td>";
                                            echo "<td class='text-right'>$hotelamt</td>";
                                            echo "<td class='text-right'>$hotelinramt</td>";
                                            echo "</tr>";

                                            $tothotelamt = $tothotelamt + $hotelamt;
                                            $tothotelinramt = $tothotelinramt + $hotelinramt;

                                            if ($_POST["dtype"] == 2) {

                                                echo "<tr style='height:10px;'>";
                                                echo "<td colspan='25'>";
                                                echo "<table style='width:100%;' id='tabital' class='table table-condensed table-hover table-bordered'>";
                                                echo "<thead>";
                                                echo "<tr class='' style='background-color:#BABFC2;font-size:14px;font-weight:bold'>";

                                                echo "<th style='width:3%;'>Sr</th>";
                                                echo "<th style='width:5%;'>City</th>";
                                                echo "<th style='width:15%;'>Hotel Name</th>";
                                                echo "<th style='width:5%;'>Check In</th>";
                                                echo "<th style='width:5%;'>Check Out</th>";
                                                echo "<th style='width:5%;'>No. Nights</th>";
                                                echo "<th style='width:9%;'>Room Category</th>";
                                                echo "<th style='width:8%;'>Room View</th>";
                                                echo "<th style='width:5%;'>Type</th>";
                                                echo "<th style='width:3%;text-align:right'>Qty.</th>";
                                                echo "<th style='width:4%;text-align:right'>Rate</th>";
                                                echo "<th style='width:5%;text-align:right'>Amount</th>";
                                                echo "<th style='width:7%;'>Meal Type</th>";
                                                echo "<th style='width:7%;'>CNF No.</th>";
                                                echo "<th style='width:10%;'>Remark</th>";
                                                echo "</tr>";
                                                echo "</thead>";

                                                $ctr2 = 0;
                                                $totamt = 0;

                                                $gettranhotel = mysqli_query($conn, "SELECT *,DATE_FORMAT(`checkin`, '%d-%m-%Y')as checkin,DATE_FORMAT(`checkout`, '%d-%m-%Y')as checkout
                                                                        FROM `tranpurch` WHERE `vouchno`='$photel[vouchno]'  $keycond1
                                                                        $citycond2 $hotelcond2 $checkcond2  ORDER BY `srno`") or die(mysqli_error($conn));
                                                while ($tranhotel = mysqli_fetch_array($gettranhotel)) {

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

                                                    $mroomview = mysqli_query($conn, "SELECT code,name FROM roomview WHERE code='$tranhotel[roomview]'") or die(mysqli_error($conn));
                                                    $troomview = mysqli_fetch_array($mroomview);

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

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

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

                                                    $mmeal = mysqli_query($conn, "SELECT code,name FROM $zroot.mealtype WHERE code ='$tranhotel[mealtype]'") or die(mysqli_error($conn));
                                                    $tmeal = mysqli_fetch_array($mmeal);

                                                    $ctr2++;
                                                    echo "<tr>";
                                                    echo "<td>$ctr2</td>";
                                                    echo "<td>$thotcity[name]</td>";
                                                    echo "<td>$thotel[hotelnm]</td>";
                                                    echo "<td>$tranhotel[checkin]</td>";
                                                    echo "<td>$tranhotel[checkout]</td>";
                                                    echo "<td>$tranhotel[nonights]</td>";
                                                    echo "<td>$thotcatg[name]</td>";
                                                    echo "<td>$troomview[name]</td>";
                                                    echo "<td>$trtype[name]</td>";
                                                    echo "<td class='text-right'>$tranhotel[qty]</td>";
                                                    echo "<td class='text-right'>$tranhotel[rate]</td>";
                                                    echo "<td class='text-right'>$tranhotel[amount]</td>";
                                                    echo "<td>$tmeal[name]</td>";
                                                    echo "<td>$tranhotel[cnfno]</td>";
                                                    echo "<td>$tranhotel[remarks]</td>";
                                                    echo "</tr>";

                                                    $totamt = $totamt + $tranhotel['amount'];
                                                }

                                                echo "<tr style='background-color:#c7ecee;font-weight:bold;'>";
                                                echo "<td colspan='11' class='text-right'>Total</td>";
                                                echo "<td class='text-right ; font-bolder'>$totamt</td>";
                                                echo "<td></td>";
                                                echo "<td></td>";
                                                echo "<td></td>";
                                                echo "</tr>";
                                                echo "</table>";
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                        }

                                        echo "<tr style='background-color: #0375bc;color: white;'>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td style='font-size:17px' class='text-right'><b>Total</b></td>";
                                        echo "<td style='font-size:17px' class='text-right'>$tothotelamt</td>";
                                        echo "<td style='font-size:17px' class='text-right'>$tothotelinramt</td>";
                                        echo "</tr>";
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- Tab 3 End -->

                            <!-- Tab 4 Start -->
                            <div class="tab-pane fade" id="tab4default">

                                <h4><b>Food Details</b></h4>

                                <table style="background: white;width: 100%" class="table table-condensed table-striped table-hover table-bordered">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th width="7%;">Date</th>
                                            <th width="7%;">Voucher</th>
                                            <th width="12%;">For</th>
                                            <th width="30%;">Pax Name</th>
                                            <th style="width:10%;text-align:right">FE</th>
                                            <th width="8%;" class="text-right">Total</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $totfoodamt = 0;
                                        $totfoodinramt = 0;
                                        $skstyle   =  "";

                                        $getpfood = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                                WHERE vouchno != '' AND `date` >= '$mfrmdate' AND `date` <= '$mtodate' 
                                                                                AND foodinramt > 0 $keycond1 $scopecond order by vouchno ") or die(mysqli_error($conn));


                                        while ($pfood = mysqli_fetch_array($getpfood)) {

                                            if ($pfood['para'] == "M") {
                                                $skstyle   =  "background-color:#e6f1ff";
                                            }

                                            $gparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` where `accode` = '$pmain[party]'") or die(mysqli_error($conn));
                                            $sparty = mysqli_fetch_array($gparty);

                                            $voucher  = $pfood['vouchno'];
                                            $visiting = $pfood['visitingfor'];
                                            $foodinramt  = $pfood['foodinramt'];
                                            $foodamt  = $pfood['foodamt'];
                                            $fullname = $pfood['surname'] . " " . $pfood['name'] . " " . $pfood['midname'];

                                            $pctr++;
                                            echo "<tr data-href='fit_ent.php?mode=edit&paxid=$voucher' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                            echo "<td>$pfood[mydt]</td>";
                                            echo "<td>$voucher</td>";
                                            echo "<td>$visiting</td>";
                                            echo "<td>$fullname</td>";
                                            echo "<td class='text-right'>$foodamt</td>";
                                            echo "<td class='text-right'>$foodinramt</td>";
                                            echo "</tr>";

                                            $totfoodamt = $totfoodamt + $foodamt;
                                            $totfoodinramt = $totfoodinramt + $foodinramt;


                                            if ($_POST["dtype"] == 2) {

                                                echo "<tr style='height:10px;'>";
                                                echo "<td colspan='25'>";
                                                echo "<table style='width:100%;' id='tabital' class='table table-condensed table-hover table-bordered'>";
                                                echo "<thead>";
                                                echo "<tr class='' style='background-color:#BABFC2'>";
                                                echo "<th style='width:5%;'>Sr</th>";
                                                echo "<th style='width:10%;'>Check In</th>";
                                                echo "<th style='width:10%;'>Check Out</th>";
                                                echo "<th style='width:30%;'>Hotel</th>";
                                                echo "<th style='width:10%;'>No. Nights</th>";
                                                echo "<th style='width:10%;'>No. Pax</th>";
                                                echo "<th style='width:10%;' class='text-right'>Rate</th>";
                                                echo "<th style='width:10%;' class='text-right'>Amount</th>";
                                                echo "</tr>";
                                                echo "</thead>";

                                                $ctr2 = 0;
                                                $totamt = 0;
                                                $totnight = 0;
                                                $totpax = 0;

                                                $getfooddtl = mysqli_query($conn, "SELECT *,DATE_FORMAT(`checkin`, '%d-%m-%Y') as checkin ,DATE_FORMAT(`checkout`, '%d-%m-%Y') as checkout
                                                                           FROM `foodent` WHERE vouchno ='$pfood[vouchno]' $keycond1
                                                                           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);

                                                    $ctr2++;
                                                    echo "<tr>";
                                                    echo "<td>$ctr2</td>";
                                                    echo "<td>$fetfood[checkin]</td>";
                                                    echo "<td>$fetfood[checkout]</td>";
                                                    echo "<td>$fetho[hotelnm]</td>";
                                                    echo "<td>$fetfood[nonights]</td>";
                                                    echo "<td>$fetfood[nopax]</td>";
                                                    echo "<td class='text-right'>$fetfood[rate]</td>";
                                                    echo "<td class='text-right'>$fetfood[amount]</td>";
                                                    echo "</tr>";

                                                    $totnight = $totnight + $fetfood['nonights'];

                                                    $totpax =  $totpax + $fetfood['nopax'];

                                                    $totamt = $totamt + $fetfood['amount'];
                                                }

                                                echo "<tr style='background-color:#c7ecee;font-weight:bold;'>";
                                                echo "<td colspan='4' class='text-right'>Total</td>";
                                                echo "<td class='font-bolder'>$totnight</td>";
                                                echo "<td class='font-bolder'>$totpax</td>";
                                                echo "<td class='text-right font-bolder'></td>";
                                                echo "<td class='text-right font-bolder'>$totamt</td>";
                                                echo "</tr>";
                                                echo "</table>";
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                        }

                                        echo "<tr style='background-color: #0375bc;color: white;'>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td style='font-size:17px' class='text-right'><b>Total</b></td>";
                                        echo "<td style='font-size:17px' class='text-right'>$totfoodamt</td>";
                                        echo "<td style='font-size:17px' class='text-right'>$totfoodinramt</td>";
                                        echo "</tr>";
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- Tab 4 End -->

                            <!-- Tab 5 Start -->
                            <div class="tab-pane fade" id="tab5default">

                                <h4><b>Laundry Details</b></h4>

                                <table style="background: white;width: 100%" class="table table-condensed table-striped table-hover table-bordered">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th width="7%;">Date</th>
                                            <th width="7%;">Voucher</th>
                                            <th width="12%;">For</th>
                                            <th width="30%;">Pax </th>
                                            <th style="width:10%; text-align:right">FE Amount</th>
                                            <th width="8%;" class="text-right">INR Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php

                                        $skstyle   =  "";
                                        $totlaundamt = 0;
                                        $totlaundinramt = 0;

                                        $getplaund = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                           WHERE vouchno != '' AND `date` >= '$mfrmdate' AND `date` <= '$mtodate' 
                                                                           AND laundinramt > 0 $keycond1 $scopecond order by vouchno ") or die(mysqli_error($conn));



                                        while ($plaund = mysqli_fetch_array($getplaund)) {

                                            if ($plaund['para'] == "M") {
                                                $skstyle   =  "background-color:#e6f1ff";
                                            }

                                            $gparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` where `accode` = '$pmain[party]'") or die(mysqli_error($conn));
                                            $sparty = mysqli_fetch_array($gparty);

                                            $voucher  = $plaund['vouchno'];
                                            $visiting = $plaund['visitingfor'];
                                            $laundinramt = $plaund['laundinramt'];
                                            $laundamt = $plaund['laundamt'];
                                            $fullname = $plaund['surname'] . " " . $plaund['name'] . " " . $plaund['midname'];

                                            $pctr++;
                                            echo "<tr data-href='fit_ent.php?mode=edit&paxid=$voucher' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                            echo "<td>$plaund[date]</td>";
                                            echo "<td>$voucher</td>";
                                            echo "<td>$visiting</td>";
                                            echo "<td>$fullname</td>";
                                            echo "<td class='text-right'>$laundamt</td>";
                                            echo "<td class='text-right'>$laundinramt</td>";
                                            echo "</tr>";

                                            $totlaundamt = $totlaundamt + $laundamt;
                                            $totlaundinramt = $totlaundinramt + $laundinramt;

                                            if ($_POST["dtype"] == 2) {

                                                echo "<tr style='height:10px;'>";
                                                echo "<td colspan='25'>";
                                                echo "<table style='width:100%;' id='tabital' class='table table-condensed table-hover table-bordered'>";
                                                echo "<thead>";
                                                echo "<tr class='' style='background-color:#BABFC2'>";
                                                echo "<th style='width:5%;'>Sr</th>";
                                                echo "<th style='width:10%;'>Check In</th>";
                                                echo "<th style='width:10%;'>Check Out</th>";
                                                echo "<th style='width:30%;'>Hotel</th>";
                                                echo "<th style='width:10%;'>No. Nights</th>";
                                                echo "<th style='width:10%;'>No. Pax</th>";
                                                echo "<th style='width:10%;' class='text-right'>Rate</th>";
                                                echo "<th style='width:10%;' class='text-right'>Amount</th>";
                                                echo "</tr>";
                                                echo "</thead>";

                                                $ctr2 = 0;
                                                $totlaund = 0;
                                                $totnight = 0;
                                                $totpax = 0;

                                                $getlaunddtl = mysqli_query($conn, "SELECT *,DATE_FORMAT(`checkin`, '%d-%m-%Y') as checkin ,DATE_FORMAT(`checkout`, '%d-%m-%Y') as checkout 
                                                                                     FROM `laundent` WHERE vouchno ='$plaund[vouchno]' order by srno") or die(mysqli_error($conn));
                                                while ($fetlaund = mysqli_fetch_array($getlaunddtl)) {

                                                    $getho = mysqli_query($conn, "SELECT `code`,`hotelnm` FROM `hotels` where code='$fetlaund[hotel]'") or die(mysqli_error($conn));
                                                    $fetho = mysqli_fetch_array($getho);

                                                    $ctr2++;
                                                    echo "<tr>";
                                                    echo "<td>$ctr2</td>";
                                                    echo "<td>$fetlaund[checkin]</td>";
                                                    echo "<td>$fetlaund[checkout]</td>";
                                                    echo "<td>$fetho[hotelnm]</td>";
                                                    echo "<td>$fetlaund[nonights]</td>";
                                                    echo "<td>$fetlaund[nopax]</td>";
                                                    echo "<td class='text-right'>$fetlaund[rate]</td>";
                                                    echo "<td class='text-right'>$fetlaund[amount]</td>";
                                                    echo "</tr>";

                                                    $totnight = $totnight + $fetlaund['nonights'];

                                                    $totpax = $totpax + $fetlaund['nopax'];

                                                    $totlaund = $totlaund + $fetlaund['amount'];
                                                }

                                                echo "<tr style='background-color:#c7ecee;font-weight:bold;'>";
                                                echo "<td colspan='4' class='text-right'; 'font-bolder';>Total</td>";
                                                echo "<td class='font-bolder'>$totnight</td>";
                                                echo "<td class='font-bolder'>$totpax</td>";
                                                echo "<td class='text-right ; font-bolder'></td>";
                                                echo "<td class='text-right ; font-bolder'>$totlaund</td>";
                                                echo "</tr>";
                                                echo "</table>";
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                        }

                                        echo "<tr style='background-color: #0375bc;color: white;'>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td style='font-size:17px' class='text-right'><b>Total</b></td>";
                                        echo "<td style='font-size:17px' class='text-right'>$totlaundamt</td>";
                                        echo "<td style='font-size:17px' class='text-right'>$totlaundinramt</td>";
                                        echo "</tr>";
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- Tab 5 End -->

                            <!-- Tab 6 Start -->
                            <div class="tab-pane fade" id="tab6default">

                                <h4><b>Transportation Details</b></h4>
                                <table style="background: white;width: 100%" class="table table-condensed table-striped table-hover table-bordered">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th width="7%;">Date</th>
                                            <th width="7%;">Voucher</th>
                                            <th width="12%;">For</th>
                                            <th width="30%;">Pax Name</th>
                                            <th style="width:10%; text-align:right">FE Amount</th>
                                            <th width="8%;" class="text-right">INR Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $skstyle        = "";
                                        $pctr           = 0;
                                        $ctr2           = 0;
                                        $tottransamt    = 0;
                                        $tottransinramt = 0;

                                        $getptrans = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                            WHERE vouchno != '' AND `date` >= '$mfrmdate' AND `date` <= '$mtodate' 
                                                                            AND transinramt > 0 $keycond1 $scopecond order by vouchno") or die(mysqli_error($conn));


                                        while ($ptrans = mysqli_fetch_array($getptrans)) {

                                            if ($ptrans['para'] == "M") {
                                                $skstyle   =  "background-color:#e6f1ff";
                                            }

                                            $voucher  = $ptrans['vouchno'];
                                            $visiting = $ptrans['visitingfor'];
                                            $transinramt = $ptrans['transinramt'];
                                            $transamt = $ptrans['transamt'];
                                            $fullname = $ptrans['surname'] . " " . $ptrans['name'] . " " . $ptrans['midname'];

                                            $pctr++;
                                            echo "<tr data-href='sale.php?mode=edit&vouchno=$voucher' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                            echo "<td>$ptrans[mydt]</td>";
                                            echo "<td>$voucher</td>";
                                            echo "<td>$visiting</td>";
                                            echo "<td>$fullname</td>";
                                            echo "<td class='text-right'>$transamt</td>";
                                            echo "<td class='text-right'>$transinramt</td>";
                                            echo "</tr>";

                                            $tottransamt = $tottransamt + $transamt;
                                            $tottransinramt = $tottransinramt + $transinramt;

                                            if ($_POST["dtype"] == 2) {

                                                echo "<tr style='height:10px;'>";
                                                echo "<td colspan='25'>";
                                                echo "<table style='width:100%;' id='tabital' class='table table-condensed table-hover table-bordered'>";
                                                echo "<thead>";
                                                echo "<tr class='' style='background-color:#BABFC2'>";
                                                echo "<th style='width:5%;'>Sr</th>";
                                                echo "<th style='width:10%;'>Type</th>";
                                                echo "<th style='width:10%;'>From</th>";
                                                echo "<th style='width:10%;'>To</th>";
                                                echo "<th style='width:10%;'>Pick Up Time</th>";
                                                echo "<th style='width:10%;'>Vehicle</th>";
                                                echo "<th style='width:5%;'>No. Pax</th>";
                                                echo "<th style='width:5%;'>No. Vehicle</th>";
                                                echo "<th style='width:10%;text-align:right'>Rate</th>";
                                                echo "<th style='width:10%;'>Amount</th>";
                                                echo "<th style='width:10%;'>CNF No.</th>";
                                                echo "<th style='width:10%;'>Description</th>";
                                                echo "</tr>";
                                                echo "</thead>";

                                                $totamt = $ctr2 = 0;

                                                $gettransdtl = mysqli_query($conn, "SELECT *,DATE_FORMAT(`pickuptime`, '%d-%m-%Y %r') as pickuptime 
                                                                            FROM `transent` WHERE vouchno ='$ptrans[vouchno]' 
                                                                            ORDER BY srno") or die(mysqli_error($conn));

                                                while ($fettrans = mysqli_fetch_array($gettransdtl)) {

                                                    if ($fettrans['picktype'] == "D") {
                                                        $flttypen = "Departure";
                                                    } elseif ($fettrans['picktype'] == "A") {
                                                        $flttypen = "Arrival";
                                                    } elseif ($fettrans['picktype'] == "I") {
                                                        $flttypen = "Internal";
                                                    } else {
                                                        $flttypen = "";
                                                    }

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


                                                    $ctr2++;
                                                    echo "<tr>";
                                                    echo "<td>$ctr2</td>";
                                                    echo "<td>$flttypen</td>";
                                                    echo "<td>$fettrans[fromplace]</td>";
                                                    echo "<td>$fettrans[toplace]</td>";
                                                    echo "<td>$fettrans[pickuptime]</td>";
                                                    echo "<td>$fetveh[vehtype]</td>";
                                                    echo "<td>$fettrans[nopax]</td>";
                                                    echo "<td>$fettrans[noveh]</td>";
                                                    echo "<td class='text-right'>$fettrans[rate]</td>";
                                                    echo "<td class='text-right'>$fettrans[amount]</td>";
                                                    echo "<td>$fettrans[descrip]</td>";
                                                    echo "<td>$fettrans[cnfno]</td>";
                                                    echo "</tr>";

                                                    $totamt = $totamt + $fettrans['amount'];
                                                }
                                                echo "<tr style='background-color:#c7ecee;font-weight:bold;'>";
                                                echo "<td colspan='9' class='text-right'>Total</td>";
                                                echo "<td class='text-right ; font-bolder'>$totamt</td>";
                                                echo "<td></td>";
                                                echo "<td></td>";
                                                echo "</tr>";
                                                echo "</table>";
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                        }

                                        echo "<tr style='background-color: #0375bc;color: white;'>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td style='font-size:17px' class='text-right'><b>Total</b></td>";
                                        echo "<td style='font-size:17px' class='text-right'>$tottransamt</td>";
                                        echo "<td style='font-size:17px' class='text-right'>$tottransinramt</td>";
                                        echo "</tr>";
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- Tab 6 End -->

                            <!-- Tab 7 Start -->
                            <div class="tab-pane fade" id="tab7default">

                                <h4><b>Visa Details</b></h4>

                                <table style="background: white;width: 100%" class="table table-condensed table-striped table-hover table-bordered">
                                    <thead class="mySearchTr">
                                        <tr>
                                            <th width="7%;">Date</th>
                                            <th width="7%;">Voucher</th>
                                            <th width="12%;">For</th>
                                            <th width="30%;">Pax </th>
                                            <th width="8%;" class="text-right">Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $totvisaamt = 0;
                                        $skstyle    =  "";
                                        
                                        $getpvisa = mysqli_query($conn, "SELECT *,DATE_FORMAT(`date`,'%d-%m-%Y')as mydt  FROM $maindb 
                                                                            WHERE vouchno != '' AND `date` >= '$mfrmdate' AND `date` <= '$mtodate' 
                                                                            AND visaamt > 0 $keycond1 $scopecond order by vouchno") or die(mysqli_error($conn));

                                        while ($pvisa = mysqli_fetch_array($getpvisa)) {

                                            if ($pvisa['para'] == "M") {
                                                $skstyle   =  "background-color:#e6f1ff";
                                            }

                                            $voucher  = $pvisa['vouchno'];
                                            $visiting = $pvisa['visitingfor'];
                                            $visaamt  = $pvisa['visaamt'];
                                            $fullname = $pvisa['surname'] . " " . $pvisa['name'] . " " . $pvisa['midname'];

                                            echo "<tr data-href='fit_ent.php?mode=edit&paxid=$pvisa[vouchno]' class='clickable-row2' style='cursor: pointer;$skstyle' [target]='_blank'>";
                                            echo "<td>$pvisa[mydt]</td>";
                                            echo "<td>$voucher</td>";
                                            echo "<td>$visiting</td>";
                                            echo "<td>$fullname</td>";
                                            echo "<td class='text-right'>$visaamt</td>";
                                            echo "</tr>";

                                            $totvisaamt = $totvisaamt + $visaamt;


                                            if ($_POST["dtype"] == 2) {

                                                echo "<tr style='height:10px;'>";
                                                echo "<td colspan='25'>";
                                                echo "<table style='width:100%;' id='tabital' class='table table-condensed table-hover table-bordered'>";
                                                echo "<thead>";
                                                echo "<tr class='' style='background-color:#BABFC2'>";
                                                echo "<th style='width:5%;'>Sr</th>";
                                                echo "<th style='width:30%;'>Country</th>";
                                                echo "<th style='width:10%;'>No. Pax</th>";
                                                echo "<th style='width:10%;text-align:right'>Rate</th>";
                                                echo "<th style='width:10%;text-align:right'>Amount</th>";
                                                echo "<th style='width:10%;'>Visa Type</th>";
                                                echo "<th style='width:10%;'>Validity</th>";
                                                echo "</tr>";
                                                echo "</thead>";

                                                $ctr2 = 0;
                                                $totvisa = 0;
                                                $totpax = 0;

                                                $getvisadtl = mysqli_query($conn, "SELECT * FROM `visaent` WHERE vouchno ='$pvisa[vouchno]'  ORDER BY srno") or die(mysqli_error($conn));
                                                while ($fetvisa = mysqli_fetch_array($getvisadtl)) {

                                                    $getho = mysqli_query($conn, "SELECT `code`,`country` FROM `visamain` WHERE code='$fetvisa[country]'") or die(mysqli_error($conn));
                                                    $fetho = mysqli_fetch_array($getho);

                                                    $ctr2++;
                                                    echo "<tr>";
                                                    echo "<td>$ctr2</td>";
                                                    echo "<td>$fetho[country]</td>";
                                                    echo "<td>$fetvisa[nopax]</td>";
                                                    echo "<td class='text-right'>$fetvisa[rate]</td>";
                                                    echo "<td class='text-right'>$fetvisa[amount]</td>";
                                                    echo "<td>$fetvisa[type]</td>";
                                                    echo "<td>$fetvisa[validity]</td>";
                                                    echo "</tr>";

                                                    $totvisa = $totvisa + $fetvisa['amount'];
                                                    $totpax = $totpax + $fetvisa['nopax'];
                                                }

                                                echo "<tr style='background-color:#c7ecee;font-weight:bold;'>";
                                                echo "<td colspan='2' class='text-right'>Total</td>";
                                                echo "<td class='font-bolder'>$totpax</td>";
                                                echo "<td></td>";
                                                echo "<td class='text-right ; font-bolder'>$totvisa</td>";
                                                echo "<td></td>";
                                                echo "<td></td>";
                                                echo "</tr>";
                                                echo "</table>";
                                                echo "</td>";
                                                echo "</tr>";
                                            }
                                        }

                                        echo "<tr style='background-color: #0375bc;color: white;'>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td></td>";
                                        echo "<td style='font-size:17px' class='text-right'><b>Total</b></td>";
                                        echo "<td style='font-size:17px' class='text-right'>$totvisaamt</td>";
                                        echo "</tr>";
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- Tab 7 End -->

                        </div>
                    </div>
                </div>
            </div>
        </div>

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

    </html>
<?php
}

?>