<?php
if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) { ?>
    <style type="text/css">
        #modalContainer {
            background-color: rgba(0, 0, 0, 0.3);
            position: absolute;
            top: 0;
            width: 100%;
            height: 100%;
            left: 0px;
            z-index: 10000;
            background-image: url(tp.png);
            /* required by MSIE to prevent actions on lower z-index elements */
        }

        #alertBox {
            position: relative;
            width: 33%;
            min-height: 100px;
            max-height: 400px;
            margin-top: 50px;
            border: 1px solid #fff;
            background-color: #fff;
            background-repeat: no-repeat;
            top: 30%;
        }

        #modalContainer>#alertBox {
            position: fixed;
        }

        #alertBox h1 {
            margin: 0;
            font: bold 1em Raleway, arial;
            background-color: #F44336;
            color: #FFF;
            border-bottom: 1px solid #F44336;
            padding: 10px 0 10px 5px;
        }

        #alertBox p {
            height: 50px;
            padding-left: 5px;
            padding-top: 30px;
            text-align: center;
            vertical-align: middle;
        }

        #alertBox #closeBtn {
            display: block;
            position: relative;
            margin: 10px auto 10px auto;
            padding: 7px;
            border: 0 none;
            width: 70px;
            text-transform: uppercase;
            text-align: center;
            color: #FFF;
            background-color: #F44336;
            border-radius: 0px;
            text-decoration: none;
            outline: 0 !important;
        }

        /* unrelated styles */

        #mContainer {
            position: relative;
            width: 600px;
            margin: auto;
            padding: 5px;
            border-top: 2px solid #fff;
            border-bottom: 2px solid #fff;
        }

        h1,
        h2 {
            margin: 0;
            padding: 4px;
        }

        code {
            font-size: 1.2em;
            color: #069;
        }

        #credits {
            position: relative;
            margin: 25px auto 0px auto;
            width: 350px;
            font: 0.7em verdana;
            border-top: 1px solid #000;
            border-bottom: 1px solid #000;
            height: 90px;
            padding-top: 4px;
        }

        #credits img {
            float: left;
            margin: 5px 10px 5px 0px;
            border: 1px solid #000000;
            width: 80px;
            height: 79px;
        }

        .important {
            background-color: #F5FCC8;
            padding: 2px;

        }

        @media (max-width: 600px) {
            #alertBox {
                position: relative;
                width: 90%;
                top: 30%;
            }
    </style>

    <div id="search" class="container-fluid">
        <div class="block-header">

            <!-- transfer type ehino -->
            <div id="ref-no" class="row clearfix">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="header">
                            <h2>
                                Search Excursion
                            </h2>
                        </div>
                        <div class="body">
                            <div class="row clearfix">
                                <div class="col-sm-4">
                                    <div class="form-group form-float form-group">
                                        <div class="form-line">
                                            <!--<input id="ref_no_se" name="ref_no_se" placeholder="Reference No" value="6108910" type="text" class="form-control"/>-->
                                            <input id="ref_no_se" name="ref_no_se" placeholder="Reference No" type="text" class="form-control" />
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-4">
                                    <div class="form-group form-float form-group">
                                        <div class="form-line">
                                            <input id="ticket_no_se" name="ticket_no_se" type="text" placeholder="Ticket No" class="form-control" />
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-4">
                                    <div class="form-group form-float form-group">
                                        <div class="form-line">
                                            <input id="ehi_no_se" name="ehi_no_se" type="text" placeholder="CMD No" class="form-control" />
                                        </div>
                                    </div>
                                </div>

                            </div>

                            <div class="row clearfix">

                                <div class="col-sm-4">
                                    <div class="form-group form-float form-group">
                                        <div class="form-line">
                                            <select id="excursion_se" name="excursion_se" class="form-control show-tick">
                                                <option value="0">Select Excursion</option>
                                                <?php
                                                $sql_2 = "select *
                                                      FROM
                                                        excursion_list
                                                      WHERE
                                                        val=1";
                                                $result_2 = mysqli_query($db, $sql_2);
                                                while ($row_2 = mysqli_fetch_array($result_2)) {
                                                    echo '<option value="' . $row_2['id'] . ' ">' . $row_2['excursion_name'] . '</option>';
                                                }
                                                ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <?php
                                $user_id = $_SESSION['user_id'];
                                $sql_3 = "select role_id
                                              FROM
                                                users
                                              WHERE
                                                id=$user_id";
                                $result_3 = mysqli_query($db, $sql_3);
                                while ($row_3 = mysqli_fetch_array($result_3)) {
                                    $user_role = $row_3['role_id'];
                                }
                                ?>

                                <input type="hidden" name="user_role" id="user_role" value="<?php echo $user_role ?>">

                                <?php if ($user_role == 1) { ?>
                                    <div class="col-sm-4">
                                        <div class="form-group form-float form-group">
                                            <div class="form-line">
                                                <select id="user_se" name="user_se" class="form-control show-tick">
                                                    <option value="0">Select User</option>
                                                    <?php
                                                    $sql_4 = "select *
                                                        FROM
                                                          users
                                                        WHERE
                                                          val=1
                                                        ORDER BY
                                                        first_name ASC;";
                                                    $result_4 = mysqli_query($db, $sql_4);
                                                    while ($row_4 = mysqli_fetch_array($result_4)) {
                                                        echo '<option value="' . $row_4['id'] . ' ">' . $row_4['first_name'] . '</option>';
                                                    }
                                                    ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                <?php } ?>

                                <div class="col-sm-4">
                                    <div class="form-group form-float form-group">
                                        <div class="form-line">
                                            <input id="excursion_date_se" name="excursion_date_se" type="text" class="datepicker form-control" placeholder="Please choose Excursion Date">
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- button -->
                            <div class="row clearfix">
                                <div class="col-lg-8"></div>
                                <div class="col-lg-4">
                                    <button id="btn-search" type="button" class="col-sm-12 btn bg-red btn-block btn-lg waves-effect" style="padding: 24px 16px; border-radius: 4px; font-size: 16px;">SEARCH
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
<?php } else {
    session_unset();
    header("location: sign-in.php");
} ?>