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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$user = $_SESSION["usertype"];

$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');
$tourcode = $_SESSION['tourcode'];
$tourname = $_SESSION['tourname'];
//browse($tourcode);
//browse($tourname);
$para = $_GET['para'];

if ($para == "CS") {
    $formname = "Class Report";
    $action = "classrep_fr.php";
} elseif ($para == "MC") {
    $formname = "Monthly Class Report";
    $action = "monclass_fr.php";
} elseif ($para == "AW") {
    $formname = "Agentwise Class Report";
    $action = "agenclass_fr.php";
} elseif ($para == "MS") {
    $formname = "Main Summary";
    $action = "mainsumm_fr.php";
} elseif ($para == "MD") {
    $formname = "Main Detail";
    $action = "maindtl_fr.php";
} elseif ($para == "NR") {
    $formname = "Namelist Report";
    $action = "namelist_fr.php";
} elseif ($para == "AR") {
    $formname = "Airline Report";
    $action = "airline_fr.php";
} elseif ($para == "VR") {
    $formname = "Visa Report";
    $action = "visalist_fr.php";
} elseif ($para == "PER") {
    $formname = "Passport Expiry Report";
    $action = "ppexpiry_fr.php";
} elseif ($para == "QR") {
    $formname = "Qurbani Report";
    $action = "qurbani_fr.php";
} elseif ($para == "DR") {
    $formname = "Data Report";
    $action = "dataxl_fr.php";
}

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

include("includes/linkshead.php");
?>
</head>

<body>
    <form method='POST' action="<?= $action; ?>">
        <div class="col-lg-8 col-md-12 col-sm-12 col-xs-12  pad">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><?php echo $formname; ?></h3>
                </div>
                <div class="panel-body">

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Tour</label>
                        </div>
                        <div class="col-lg-3 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class="form-control form select2 tour" name="tour" required>
                                <option value="<?= $tourcode ?>"><?= $tourname ?></option>
                            </select>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Name</label>
                        </div>
                        <div class="col-lg-6 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="text" name="name" class="form-control name" autofocus="autofocus">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg" style="color: #2FBFFD;">Regn. No.</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">

                            <?php if ($para == "CS" || $para == "NR") { ?>
                                 <select name="regnno[]" class="form-control regnno select2" style="width:100%" multiple>
                                    <option value=""></option>
                                    <?php
                                        $mgrp = mysqli_query($conn, "SELECT distinct(`regnno`) FROM bookform where regnno != '' AND tourno = '$tourcode'") or die(mysqli_error($conn));
                                        while ($tgrp = mysqli_fetch_array($mgrp)) {
                                            echo "<option value='$tgrp[regnno]'>$tgrp[regnno]</option>";
                                        }
                                    ?>
                                </select> 
                            <?php } else { ?>
                                <input type="text" name="regnno" class="form-control regnno">
                            <?php } ?>
                        </div>
                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg" style="color: #2FBFFD;">Pax. No.</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="text" name="paxno" class="form-control paxno">
                        </div>
                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg" style="color: blue;">Only Infant</label>
                        </div>
                        <div class="col-lg-1 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="checkbox" name="inf" value="1" class="form-control inf" style="width: 30px">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Group</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <select name="group" class="form-control group select2" style="width:100%">
                                <option value=""></option>
                                <?php
                                $mgrp = mysqli_query($conn, "SELECT distinct(`groupno`) FROM bookform where groupno != '' AND tourno = '$tourcode'") or die(mysqli_error($conn));
                                while ($tgrp = mysqli_fetch_array($mgrp)) {
                                    echo "<option value='$tgrp[groupno]'>$tgrp[groupno]</option>";
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Class</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <select name="class[]" class="form-control class select2" style="width:100%" multiple>
                                <option value=""></option>
                                <?php
                                $mgrp = mysqli_query($conn, "SELECT distinct(`batchno`) FROM bookform where batchno != '' AND tourno = '$tourcode' ") or die(mysqli_error($conn));
                                while ($tgrp = mysqli_fetch_array($mgrp)) {
                                    echo "<option value='$tgrp[batchno]'>$tgrp[batchno]</option>";
                                }
                                ?>
                            </select>
                        </div>

                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg" style="color: red;">Only Cancelled</label>
                        </div>
                        <div class="col-lg-1 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="checkbox" name="canc" value="1" class="form-control canc" style="width: 30px">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg"></label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                        </div>
                    </div>
                    
                    <?php if ($para == "AR") { ?>
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Sector</label>
                        </div>
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 pad">
                            <select name="sector" class="form-control sector select2" style="width:100%">
                                <option value=""></option>
                                <?php
                                $mgrp = mysqli_query($conn, "SELECT distinct(`sector`) FROM bookform where sector != '' AND tourno = '$tourcode'") or die(mysqli_error($conn));
                                while ($tgrp = mysqli_fetch_array($mgrp)) {
                                    echo "<option value='$tgrp[sector]'>$tgrp[sector]</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <?php } ?>
                    

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">City</label>
                        </div>
                        <div class="col-lg-3 col-md-5 col-sm-8 col-xs-8 pad">
                            <select name="city" class="form-control city select2" style="width:100%">
                                <option value=""></option>
                                <?php
                                $mcity = mysqli_query($conn, "SELECT distinct(`city`) FROM bookform where haji != '' AND tourno = '$tourcode' ") or die(mysqli_error($conn));
                                while ($tcity = mysqli_fetch_array($mcity)) {
                                    echo "<option value='$tcity[city]'>$tcity[city]</option>";
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Sex</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class='form-control select2 sex' name='sex'>
                                <option value=""></option>
                                <option value='M'>Male</option>
                                <option value='F'>Female</option>
                            </select>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">State</label>
                        </div>
                        <div class="col-lg-3 col-md-5 col-sm-8 col-xs-8 pad">
                            <select name="state" class="form-control state select2" style="width:100%">
                                <option value=""></option>
                                <?php
                                $mown4 = mysqli_query($conn, "SELECT `code`, `name` FROM `state` ORDER BY name") or die(mysqli_error($conn));
                                while ($trow4 = mysqli_fetch_array($mown4)) {
                                    echo "<option value='$trow4[name]'>$trow4[name]</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>

                    <?php if ($para == "CS" || $para == "AR") { ?>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Ticket</label>
                            </div>
                            <div class="col-lg-1 col-md-5 col-sm-8 col-xs-8 pad">
                                <select class='form-control select2 ticketchk' name='ticketchk'>
                                    <option value=""></option>
                                    <option value='1'>Yes</option>
                                    <option value='2'>No</option>
                                </select>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Visa</label>
                            </div>
                            <div class="col-lg-1 col-md-5 col-sm-8 col-xs-8 pad">
                                <select class='form-control select2 visachk' name='visachk'>
                                    <option value=""></option>
                                    <option value='1'>Yes</option>
                                    <option value='2'>No</option>
                                </select>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Land Package</label>
                            </div>
                            <div class="col-lg-1 col-md-5 col-sm-8 col-xs-8 pad">
                                <select class='form-control select2 landchk' name='landchk'>
                                    <option value=""></option>
                                    <option value='1'>Yes</option>
                                    <option value='2'>No</option>
                                </select>
                            </div>
                        </div>
                        <?php
                    }
                    ?>

                    <br>

                    <?php if ($para == "CS" || $para == "AR" || $para == "MS" || $para == "MD") { ?>
                    
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Local Flight Sector</label>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                            <select class='form-control select2 locflsec' name='locflsec'>
                                <option value="">All</option>
                                <option value="1">Same</option>
                                <option value="2">Different</option>
                            </select>
                        </div>
                    </div>

                    <?php } ?>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Passport Expiry In</label>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                            <select class='form-control select2 ppexpiry' name='ppexpiry'>
                                <option value="99">All</option>
                                <option value="1">1 Month</option>
                                <option value="2">2 Month</option>
                                <option value="3">3 Month</option>
                                <option value="4">4 Month</option>
                                <option value="5">5 Month</option>
                                <option value="6">6 Month</option>
                            </select>
                        </div>
                        <!--                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Passport In Hand</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class='form-control select2 ppinhand' name='ppinhand'>
                                <option value="0">Both</option>
                                <option value="1">Yes</option>
                                <option value="2">No</option>
                            </select>
                        </div>-->
                    </div>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg" style="color:#91003D;font-weight:bold">Departure
                                Date</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="date" id="depdate" name="depdate" class="form-control depdate"
                                style="color:#91003D">
                        </div>
                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Dep. PNR</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class='form-control select2 deppnr' name='deppnr'>
                                <option value="A">All</option>
                                <option value="P">Pending</option>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Airlines/Carrier</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="text" name="airlines" class="form-control airlines">
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Agent Name</label>
                        </div>
                        <div class="col-lg-6 col-md-5 col-sm-8 col-xs-8 pad">
                            <!-- <input type="text" name="agent" class="form-control agent"> -->
                            <select name="agent" class="form-control agent select2" style="width:100%">
                                <option value=""></option>
                                <?php
                                $mgrp = mysqli_query($conn, "SELECT distinct(`agent`) FROM bookform where agent != '' AND tourno = '$tourcode'") or die(mysqli_error($conn));
                                while ($tgrp = mysqli_fetch_array($mgrp)) {
                                    echo "<option value='$tgrp[agent]'>$tgrp[agent]</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control ">Arrival Date</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <input type="date" id="arrvdate" name="arrvdate" class="form-control arrvdate" />
                        </div>
                        <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control marg">Arrival PNR</label>
                        </div>
                        <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class='form-control select2 arrvpnr' name='arrvpnr'>
                                <option value="A">All</option>
                                <option value="P">Pending</option>
                            </select>
                        </div>
                    </div>
                    <?php if ($para == "AR") { ?>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control ">With Image</label>
                            </div>
                            <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                                <select class='form-control select2 withimg' name='withimg'>
                                    <option value="N">No</option>
                                    <option value="Y">Yes</option>
                                </select>
                            </div>
                        </div>
                    <?php } ?>


                </div>

                <div class="panel-footer">
                    <div class="col-lg-12 col-md-3 col-sm-3 col-xs-3 text-right pad">

                        <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">

                            <?php if ($para == "CS" && $user == 1) { ?>
                                <td class=" buttonform tooltip-bottom" style="display: <? echo $savedisabled ?>"
                                    data-toggle="tooltip" data-placement="bottom" title="" data-original-title="View">
                                    <button type='submit' name="genview" formtarget="_blank" class="btn btn-pad btn-square"
                                        style="background-image: linear-gradient(135deg, #0acffe 10%, #495aff 100%) !important;border-radius:10px"
                                        onClick="">
                                        <b style="color:white">GENERATE</b>
                                    </button>
                                </td>
                            <?php } ?>
                        </div>


                        <div class="col-lg-11 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <?php include("includes/but_rep.php"); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>

</html>