ladder.php 3.54 KB
<?php
session_start();
require_once 'classes/realops.php';
$get = new Get();
$stats = new Stats();
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">Virtual Airline Ladder<a href="vaRegister.php" class="btn btn-info pull-right">+ Add Virtual Airline</a></h2>
<div class="well">
    <div class="row">
        <?php $leadingVA = $get->leadingVA(); ?>
        <div class="col-md-4 pull-right"><img src="logos/vas/<?php echo $leadingVA['logo']; ?>" style="max-width: 200px;" /><br /><br /><?php echo $leadingVA['description'] ?></div>
        <div class="col-md-8">

        <div style="font-size:48px;"><strong>#1 - <?php echo $leadingVA['name'] ?><br /></strong> </div>
        <div style="font-size:24px;"><?php echo $leadingVA['value_occurrence'] ?> flights // <a href="<?php echo $leadingVA['url']; ?>"><?php echo $leadingVA['url']; ?></a></div>
        </div>
        
    </div>
</div>
        <div class="panel panel-default">
      <!-- Default panel contents -->
      <div class="panel-heading"><strong>Leading Virtual Airline:</strong><br />
</div>

      <!-- Table -->
      <table class="table">
        <thead>
          <tr>
            <th>#</th>
            <th>Logo</th>
            <th>Name</th>
            <th>Number of Flights</th>
          </tr>
        </thead>
        <tbody>
            <?php $vas = $get->vas(); 
            $position = 0;
            $airlinesArray = array();
foreach($vas as $row)
{ 
    $row['flights'] = $get->totalFlightsForVA($row['id']);
    $airlinesArray[$row['id']]['id'] = $row['id'];
    $airlinesArray[$row['id']]['flights'] = $row['flights']; 
    $airlinesArray[$row['id']]['name'] = $row['name']; 
    $airlinesArray[$row['id']]['logo'] = $row['logo']; 
    $airlinesArray[$row['id']]['url'] = $row['url']; 
    $airlinesArray[$row['id']]['description'] = $row['description']; 
}
    function cmp($a, $b) {
        return $b["flights"] - $a["flights"];
}
    usort($airlinesArray, "cmp");
    foreach($airlinesArray as $row)
    {
    if($previousFlight != $row['flights'])
    {
        $position++;
    }
$previousFlight = $row['flights'];
    ?>
          <tr>
            <th scope="row"><?php echo $position ?></th>
            <td><img src="logos/vas/<?php echo $row['logo'] ?>" style="max-height:20px;" /></td>
            <td><?php if($position == 1) echo "<strong>" . $row['name'] . "</strong>"; else echo $row['name']; ?></td>
            <td><?php echo $row['flights']; ?></td>
          </tr>
         <?php }
?>
        </tbody>
      </table>
    </div>
    <?php $x = 1;

    foreach($airlinesArray as $row)
    {
        if($x == 1)
        {
            $x++;
            continue;
        }
        else
        { 
             ?>
    <div class="col-md-6">
<div class="well">
    
<div style="font-size:24px;"><strong>#<?php echo $x; ?></strong> - <?php echo $row['name']; ?> <img style="max-height:50px; float:right;" src="logos/vas/<?php echo $row['logo'] ?>" /></div>
<?php echo $row['description']; ?><br />
<a class="btn btn-default" target="_blank" href="<?php echo $row['url'] ?>"><?php echo $row['url']; ?></a>
</div>
</div>
<?php $x++; } } ?>
            </article>
        </div><!-- /.row -->
    </div><!-- /.container -->
</div><!-- /.wrapper -->

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