remaining ticket check

This commit is contained in:
Chris Smith
2019-04-01 09:18:43 -05:00
parent 9ed7e21b0b
commit 2152ea5f1f
2 changed files with 15 additions and 1 deletions

View File

@@ -150,6 +150,12 @@ $router->post('/', function () {
$eventTicketQty = getInteger($_POST['eventTicketQty']);
$ticketEnhancerQty = getInteger($_POST['ticketEnhancerQty']);
$settings = \RedBeanPHP\R::load('settings', 1);
$tickets = $settings->value;
if (($eventTicketQty - $tickets) < 0) {
header('Location: /step-1?error=tickets');
}
// Calculate totals
$additionalContribution = convertPossibleFloatToCents($_POST['additionalContribution']);
$cabanaReservation = convertPossibleFloatToCents($_POST['cabanaReservation']);

View File

@@ -15,7 +15,15 @@ if ($tickets <= 50) { ?>
<div class="alert alert-danger" role="alert">
<strong>Hurry!</strong> Only <?=$tickets?> tickets remaining!
</div>
<?php } ?>
<?php }
if (isset($_GET['error']) && $_GET['error'] == 'tickets') { ?>
<div class="alert alert-warning" role="alert">
Sorry. There are only <?=$tickets?> remaining. Please select an amount less than or equal to the tickets remaining.
</div>
<?php
}
?>
<div class="row">
<div class="col-md-4 order-md-1 mb-4">
<h4 class="d-flex justify-content-between align-items-center mb-3">