slots.php 8.07 KB
<?php 
session_start();
require_once 'classes/realops.php';
$get = new Get();
date_default_timezone_set('Australia/Sydney');
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php include 'sections/header.php'; ?>
</head>
<body>
<div class="wrapper">
    <?php include 'sections/navbar.php' ?>
    <div class="container" id="realops-container">
        <div class="row">
            <article class="col-sm-12 panel panel-default" id="realops-body">

            <h2 class="sub-header">Available Flights</h2>
            <nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li<?php if(($_GET['deparr'] == "0" && $_GET['domint'] == "0") || (empty($_GET['deparr']) && empty($_GET['domint']))) echo " class=\"active\""; ?>><a href="slots.php?deparr=0&domint=0">Domestic Departures <span class="sr-only">(current)</span></a></li>
        <li<?php if($_GET['deparr'] == "1" && $_GET['domint'] == "0") echo " class=\"active\""; ?>><a href="slots.php?deparr=1&domint=0">Domestic Arrivals</a></li>
        <li<?php if($_GET['deparr'] == "0" && $_GET['domint'] == "1") echo " class=\"active\""; ?>><a href="slots.php?deparr=0&domint=1">International Departures</a></li>
        <li<?php if($_GET['deparr'] == "1" && $_GET['domint'] == "1") echo " class=\"active\""; ?>><a href="slots.php?deparr=1&domint=1">International Arrivals</a></li>
      </ul>
        
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
            <form method="get" action="">
                <input type="hidden" name="deparr" value="<?php echo $_GET['deparr'] ?>">
                <input type="hidden" name="domint" value="<?php echo $_GET['domint'] ?>">
                <div class="col-lg-3">
                    <select style="width:100%;" name="airport">
                        <option disabled selected><?php if($_GET['deparr'] == 1) echo "Departure"; else echo "Arrival"; ?> Airport</option>
                        <?php 
                        foreach($get->scheduleAirports() as $row){ 
                            $row = explode(".", $row)
                            ?>
                            <option value="<?php echo $row[0] ?>" <?php if($_GET['airport'] == $row[0]) echo "selected"; ?>><?php echo $row[1]; ?></option>
                       <?php } ?>
                    </select>
                </div>
                <div class="col-lg-3">
                    <select style="width:100%;" name="timeFrame">
                        <option disabled selected>Time Frame</option>
                        <option value="14" <?php if($_GET['timeFrame'] == 14) echo "selected"?>>14:00-15:00</option>
                        <option value="15" <?php if($_GET['timeFrame'] == 15) echo "selected"?>>15:00-16:00</option>
                        <option value="16" <?php if($_GET['timeFrame'] == 16) echo "selected"?>>16:00-17:00</option>
                        <option value="17" <?php if($_GET['timeFrame'] == 17) echo "selected"?>>17:00-18:00</option>
                        <option value="18" <?php if($_GET['timeFrame'] == 18) echo "selected"?>>18:00-19:00</option>
                        <option value="19" <?php if($_GET['timeFrame'] == 19) echo "selected"?>>19:00-20:00</option>
                        <option value="20" <?php if($_GET['timeFrame'] == 20) echo "selected"?>>20:00-21:00</option>
                        <option value="21" <?php if($_GET['timeFrame'] == 21) echo "selected"?>>21:00-CURFEW</option>
                    </select>
                </div>
                <div class="col-lg-3">
                    <select style="width:100%;" name="airline">
                        <option selected disabled>Airline</option>
                        <?php foreach($get->scheduleAirline() as $row)
                        { ?>
                            <option value="<?php echo $row ?>" <?php if($_GET['airline'] == $row) echo "selected"; ?>><?php echo $row ?></option>
                        <?php } ?>
                    </select>
                </div>
                <div class="col-lg-3">
                    <select style="width:100%;" name="aircraft">
                        <option disabled selected>Aircraft</option>
                        <?php foreach($get->scheduleAircraft() as $row)
                        {
                            $row = explode(".", $row); ?>
                            <option value="<?php echo $row[0] ?>" <?php if($_GET['aircraft'] == $row[0]) echo "selected"; ?>><?php echo $row[1] ?></option>
                        <?php } ?>
                    </select><br />
                </div>
                <div class="col-lg-9">
                    <button type="submit" class="btn btn-primary" style="width:100%; margin-top:10px;">Sort</button>

                </div>
                <div class="col-lg-3">
                    <a href="slots.php?deparr=<?php echo $_GET['deparr'] ?>&domint=<?php echo $_GET['domint'] ?>" class="btn btn-default" style="width:100%; margin-top:10px;">Clear Filter</a>
                </div>
            
            </form>

            <div class="table-responsive col-lg-12">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>Flight Number</th>
                        <th>Departure</th>
                        <th>Arrival</th>
                        <th>Aircraft</th>
                        <th>Slot Time</th>
                        <th>Actions</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php  
                        $schedules = $get->schedules($_GET);
                        if(!empty($schedules)) {
                        foreach($schedules as $row) 
                        { 
                            ?>
                    <tr>
                        <td style=""><img src="logos/<?php echo $row['airline']; ?>.png" /><br /><strong><?php echo $row['airline'] . $row['flightnum']; ?></strong>/<?php echo $row['fbnum'] ?></td>
                        <td><?php if($row['deparr'] == "0") echo "Sydney (YSSY)"; else echo $get->airport($row['icao'])['name'] . " (" . $row['icao'] . ")"; ?></td>
                        <td><?php if($row['deparr'] == "1") echo "Sydney (YSSY)"; else echo $get->airport($row['icao'])['name'] . " (" . $row['icao'] . ")"; ?></td>
                        <td><?php echo $get->aircraft($row['aircraft'])['name'] ?></td>
                        <td><?php echo date('H:i', strtotime($row['time'])); ?> LOC<br /><?php echo date('H:i', strtotime($row['time'])- 60 * 60 * Z); ?> UTC</td>
                        <td>
<?php if(empty($_SESSION['firstName']))
{ ?>
<a href="sso/index.php?redirect=<?php echo $_SERVER['PHP_SELF'] ;?>" class="btn btn-info loginButton" id="<?php echo $row['id']; ?>" data-toggle="modal" data-target="#realops-login-info">Login to Book</a>
 <?php } 
else
{ 
 ?>
                <button class="btn btn-success bookButton" id="flight<?php echo $row['id']; ?>">Book Flight</button> </td>
 <?php } ?>
                    </tr>
                    <?php } }
                    else {
                        echo "<br /><div class=\"alert alert-danger\" role=\"alert\"><strong>No Flights Found.</strong> Please adjust your search and try again.</div>";
                    }
                    ?>
                    </tbody>
                </table>
            </article>
        </div>
    </div>
</div>

<?php include 'sections/footer.php'; ?>