panel.php 8.54 KB
<?php
session_start();
require_once '../classes/realops.php';
$get = new Get();
$admin = new Admin();
date_default_timezone_set('Australia/Sydney');
if(!$admin->checkStatus($_SESSION['vatsimID']))
{
    echo "Not authorised.";
    die();
}

if(isset($_GET['approve']))
{
    $db = db::connect();
    $getRow = $db->getRow("SELECT approved FROM tbl_vas WHERE id = ?", array($_GET['approve']));
    switch ($getRow['approved'])
    {
        case 0:
            $db->updateRow("UPDATE tbl_vas SET approved = 1 WHERE id = ?", array($_GET['approve']));
            break;
        case 1:
            $db->updateRow("UPDATE tbl_vas SET approved = 0 WHERE id = ?", array($_GET['approve']));

    }

}

    if(isset($_GET['makeAdmin']))
    {
    $db = db::connect();
    $getRow = $db->getRow("SELECT admin FROM tbl_pilots WHERE vatsimID = ?", array($_GET['makeAdmin']));
    switch ($getRow['admin'])
    {
    case 0:
    $db->updateRow("UPDATE tbl_pilots SET admin = 1 WHERE vatsimID = ?", array($_GET['makeAdmin']));
    break;
    case 1:
    $db->updateRow("UPDATE tbl_pilots SET admin = 0 WHERE vatsimID = ?", array($_GET['makeAdmin']));

    }

    }
    ?>
    <!DOCTYPE html>
<html lang="en">
    <head>
        <?php include '../sections/header.php'; ?>
    </head>
<body>
<div class="wrapper"><br /><br />

    <div class="container" id="realops-container">
        <div class="row">
            <article class="col-sm-12 panel panel-default" id="realops-body">

                <h2 class="sub-header">VA's Awaiting Approval</h2>


                <div class="table-responsive col-lg-12">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>Name</th>
                            <th>Description</th>
                            <th>URL</th>
                            <th>Logo</th>
                            <th>Approved</th>
                            <th>Registrant Name</th>
                            <th>Registrant Email</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $vas = $admin->vas();
                        if(!empty($vas)) {
                            foreach($vas as $row)
                            {
                                ?>
                                <tr>
                                    <td style=""><?php echo $row['name'] ?></td>
                                    <td><?php echo $row['description'] ?></td>
                                    <td><?php echo $row['url'] ?></td>
                                    <td><img src="/logos/vas/<?php echo $row['logo'] ?>" /></td>
                                    <td><?php echo $row['approved'] ?></td>
                                    <td><?php echo $row['regName'] ?></td>
                                    <td><?php echo $row['regEmail'] ?></td>
                                    <td><a href="?approve=<?php echo $row['id'] ?>" class="btn btn-primary">Approve/Deny</a></td>
                                </tr>
                            <?php } }
                        else {
                            echo "<br /><div class=\"alert alert-danger\" role=\"alert\"><strong>No VA's Found.</strong> Please adjust your search and try again.</div>";
                        }
                        ?>
                        </tbody>
                    </table>
                </div>

            </article>

            <article class="col-sm-12 panel panel-default" id="realops-body">

                <h2 class="sub-header">ATC Applications</h2>


                <div class="table-responsive col-lg-12">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>VATSIM ID:</th>
                            <th>Name:</th>
                            <th>Email:</th>
                            <th>Rating:</th>
                            <th>Preffered Positions:</th>
                            <th>Shifts:</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $atc = $admin->atc();
                        if(!empty($atc)) {
                            foreach($atc as $row)
                            {
                                $shifts = unserialize($row['shifts'])
                                ?>
                                <tr>
                                    <td style=""><?php echo $row['vatsimID'] ?></td>
                                    <td><?php echo $row['firstName'] . " " . $row['lastName']; ?></td>
                                    <td><?php echo $row['email'] ?></td>
                                    <td><?php echo $row['rating'] ?></td>
                                    <td><strong>1: </strong><?php echo $row['position1'] ?>, <strong>2: </strong><?php echo $row['position2'] ?>, <strong>3: </strong><?php echo $row['position3'] ?></td>
                                    <td><?php
                                        foreach($shifts as $x)
                                        {
                                            switch($x)
                                            {
                                                case "04":
                                                    echo "0400z-0600z <br />";
                                                    break;
                                                case "06":
                                                    echo "0600z-0800z <br />";
                                                    break;
                                                case "08":
                                                    echo "0800z-1000z <br />";
                                                    break;
                                                case "10":
                                                    echo "1000z-1200z";
                                                    break;
                                            }
                                        }?></td>
                                </tr>
                            <?php } }
                        else {
                            echo "<br /><div class=\"alert alert-danger\" role=\"alert\"><strong>No VA's Found.</strong> Please adjust your search and try again.</div>";
                        }
                        ?>
                        </tbody>
                    </table>
                </div>

            </article>
            <article class="col-sm-12 panel panel-default" id="realops-body">

                <h2 class="sub-header">Registered Pilots</h2>


                <div class="table-responsive col-lg-12">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>VATSIM ID:</th>
                            <th>First Name:</th>
                            <th>Last Name:</th>
                            <th>Email:</th>
                            <th>Admin:</th>
                            <th>Make Admin:</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $pilots = $admin->pilots();
                        if(!empty($pilots)) {
                            foreach($pilots as $row)
                            {
                                ?>
                                <tr>
                                    <td style=""><?php echo $row['vatsimID'] ?></td>
                                    <td><?php echo $row['firstName']; ?></td>
                                    <td><?php echo $row['lastName']; ?></td>
                                    <td><?php echo $row['email'] ?></td>
                                    <td><?php echo $row['admin'] ?></td>
                                    <td><a href="?makeAdmin=<?php echo $row['vatsimID'] ?>" class="btn btn-info">Make/Revoke Admin</a></td>
                                </tr>
                            <?php } }
                        else {
                            echo "<br /><div class=\"alert alert-danger\" role=\"alert\"><strong>No VA's Found.</strong> Please adjust your search and try again.</div>";
                        }
                        ?>
                        </tbody>
                    </table>
                </div>

            </article>
        </div><!-- /.row -->
    </div><!-- /.container -->
</div><!-- /.wrapper -->

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