setBlock.php 4.37 KB
<?php
session_start();
require_once 'classes/realops.php';
$get = new Get();
$stats = new Stats();
date_default_timezone_set('Australia/Sydney');
/*
if(!$get->isATC($_SESSION['vatsimID']))
{
    echo "Unauthorised";
    die();
} */
?>
    <!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">Set Block Time</h2>

                <form method="get" action="setBlock.php" class="form-horizontal" >
                    <p class="help-block">If the callsign does not appear here, it has not been booked</p>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Select Flight:</label>
                        <div class="col-sm-6">
                            <select name="flight" class="form-control">
                                <option selected disabled>Select one...</option>
                                <?php foreach($get->bookings() as $row)
                {?>
                    <option <?php if($_GET['flight'] == $row['id']) echo "selected"; ?> value="<?php echo $row['id']; ?>"><?php echo $row['airline'] . $row['flightnum']; ?> (<?php echo $row['pilotName'] ?>)</option>
                    <?php } ?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Request</button>
                    </div>
                </form>
                <?php if(isset($_GET['flight']))
                {
                    $bookings = $get->bookingFromFlightID($_GET['flight']);
                    $flight = $get->flight($_GET['flight']);
                    ?>

            <div class="well">
                <h3><?php echo $flight['airline'] . $flight['flightnum']; ?></h3>
                <h4>Scheduled <?php if($flight['deparr'] == 0) echo "Off"; else echo "On"; ?> Blocks: <?php echo date('Hi', strtotime($flight['time']) - 36000); ?>z</h4>
                <form method="post" action="setBlock.php" class="form-horizontal" >
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Block Out:</label>
                        <div class="col-sm-6">
                            <input type="text" <?php if($flight['deparr'] == 1) echo "readonly"; ?> class="form-control" name="blockOut" value="<?php echo $bookings['blockOut']; ?>" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Block Off:</label>
                        <div class="col-sm-6">
                            <input type="text" <?php if($flight['deparr'] == 1) echo "readonly"; ?> class="form-control" name="blockOff" value="<?php echo $bookings['blockOff']; ?>" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Block On:</label>
                        <div class="col-sm-6">
                            <input type="text" <?php if($flight['deparr'] == 0) echo "readonly"; ?> class="form-control" name="blockOn" value="<?php echo $bookings['blockOn']; ?>" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Block In:</label>
                        <div class="col-sm-6">
                            <input type="text" <?php if($flight['deparr'] == 0) echo "readonly"; ?> class="form-control" name="blockIn" value="<?php echo $bookings['blockIn']; ?>" />
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Update/Save</button>
                    </div>
                </form>
            </div>
                    <?php } ?>
            </article>
        </div><!-- /.row -->
    </div><!-- /.container -->
</div><!-- /.wrapper -->

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