?>
<br>
Barcode column: <?php 
echo TICKET_COL;
?>
<br>
Scanned boolean column: <?php 
echo SCAN_COL;
?>
<br>
Strict barcode checking is: <?php 
echo !STRICT_CHECKING ? 'Disabled' : 'Enabled';
?>
<br>
<?php 
$ticket = new ticket();
$barcode = 'ZZZ111111111';
echo testCheck("Successful import", $ticket->importTickets("Testing,{$barcode}"), 3);
echo testCheck('Valid scan', $ticket->scanTicket($barcode, 'nick'), 3);
echo testCheck('Duplicate scan', $ticket->scanTicket($barcode, 'nick'), 1);
echo testCheck('Empty barcode', $ticket->scanTicket('', 'nick'), 0);
echo testCheck('Invalid barcode', $ticket->scanTicket('asdfghjkl', 'nick'), 0);
echo testCheck('Empty user', $ticket->scanTicket($barcode, ''), 2);
echo testCheck('Empty user, empty barcode', $ticket->scanTicket('', ''), 2);
$db = new database();
$db->query("DELETE FROM tbl_ticket WHERE tbl_ticket.barcode = '{$barcode}'");
$db->execute();
?>

</pre>
<?php

require_once 'inc/bootstrap.php';
$scanner = new scanner();
$ticket = new ticket();
$returnCodes = array(0 => 'Invalid Ticket ID', 1 => 'Duplicate Scan', 2 => 'Missing username', 3 => 'Success (cleared to enter)');
$col = TICKET_COL;
$user = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_SPECIAL_CHARS);
$barcode = $ticket->sanitizeBarcode(filter_input(INPUT_POST, 'ticket', FILTER_SANITIZE_SPECIAL_CHARS));
if (!$user) {
    $return = json_encode(array('message' => "No username specified", 'code' => 2));
    $scanner->logEvent("NU", "Tried to scan without a username");
    return;
}
if ($barcode) {
    $return = $ticket->scanTicket($barcode, $user);
} else {
    $return = json_encode(array('message' => "Barcode cannot be empty", 'code' => 2));
}
if (isset($_GET['barcode']) && is_admin()) {
    $return = $ticket->scanTicket($_GET['barcode'], $_GET['user']);
}
if (isset($_GET['format'])) {
    require_once 'header.php';
    ?>
    <div class="jumbotron">
      <h1>Ready to scan</h1>
      <input id="username" name="username" placeholder="Who are you" />
      <input id="ticket" name="ticket" placeholder="Barcode" />
    </div>
    <div class="panel panel-default hide" id="ticketInfo">