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

$maindb = "hotels";
$formname = "Hotels Print";
$file = "hotels_print_fr.php";

// $fseries = $_SESSION["series_" . $dbname];
// $keycond = " and `series`='$fseries'";
$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
$zroot = $_SESSION["zdir"];
$zcomp = $_SESSION["comp_" . $dbname];
$fsocity = $_SESSION["society_" . $dbname];
$getcomp = mysqli_query($conn, "SELECT * FROM $zroot.`company` where `code` = '$fseries'")or die(mysqli_error($conn));
$comp = mysqli_fetch_array($getcomp);

mysqli_select_db($conn, $zdb);

$city = $_POST['city'];
$hotelnm = $_POST['hotelnm'];
$category = $_POST['category'];

$categorycond = "";
$hotelnmcond = "";
$citycond = "";

if (!empty($category)) {
    $categorycond = " AND m.`category`='$category' ";
}
if (!empty($hotelnm)) {
    $hotelnmcond = " AND m.`hotelnm`='$hotelnm' ";
}
if (!empty($city)) {
    $citycond = " AND m.`city`='$city' ";
}


$getpmain = mysqli_query($conn, "SELECT *,c.name as city,h.name AS category FROM `$maindb` m LEFT JOIN city c ON m.city = c.code
                                 LEFT JOIN hotelcatg h ON m.category = h.code   
                                 WHERE m.code != ''  $categorycond $hotelnmcond $citycond ")or die(mysqli_error($conn));

if (isset($_POST["view"])) {
    include("includes/linkshead.php");
    ?>
    <script src="MyScript/item.js" type="text/javascript"></script>
    </head>
    <body>
        <div class="container">
            <?php include("includes/head_rep.php"); ?>
            <div class="row">
                <div class="col-lg-12">
                    <table class="table table-condensed table-bordered">
                        <tr class="mySearchTr">
                            <th width="5%">Sr.</th>
                            <th width="15%">City</th>
                            <th width="15%">Hotel Name</th>
                            <th width="15%">Category</th>
                        </tr>
                        <?php
                        $ctr = 1;
                        while ($pmain = mysqli_fetch_array($getpmain)) {

                            $category  = $pmain['category'];
                            $city  = $pmain['city'];
                            $hotelnm  = $pmain['hotelnm'];

                            Echo "<tr>";
                            Echo "<td>$ctr</td>";
                            Echo "<td>$city</td>";
                            Echo "<td>$hotelnm</td>";
                            Echo "<td>$category</td>";
                           
                            Echo "</tr>";
                            $ctr++;
                        }
                        ?>
                    </table>
                </div>
            </div>
        </div>

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

?>

