diff --git a/index.php b/index.php index 4cfbedc..667f657 100644 --- a/index.php +++ b/index.php @@ -47,6 +47,7 @@ $router->get('/', function () { header('Location: /sold-out'); } + checkIfTicketsAreOnSale(); include 'views/common/head.php'; include 'views/family.php'; include 'views/common/footer.php'; @@ -59,6 +60,7 @@ $router->get('/notify', function () { }); $router->get('/step-1', function () { + checkIfTicketsAreOnSale(); include 'views/common/head.php'; include 'views/step1.php'; include 'views/common/footer.php'; diff --git a/src/functions.php b/src/functions.php index 226486f..9b3b763 100644 --- a/src/functions.php +++ b/src/functions.php @@ -84,4 +84,15 @@ function shoppingCartTotal($price) Total ' . '$' . number_format(($price / 100), 2) . ' '; +} + +function checkIfTicketsAreOnSale() { + $todaysDate = new DateTime('now', new DateTimeZone('America/Chicago')); + $dateOnSale = new DateTime('3/15/2019 9:00am', new DateTimeZone('America/Chicago')); + $interval = $todaysDate->diff($dateOnSale); + + if($interval->days >= 0 && $interval->invert === 0) { + header('Location: /notify?d='.$dateOnSale->format('c')); + } + } \ No newline at end of file diff --git a/views/notify.php b/views/notify.php index 6dabfd9..0e92f34 100644 --- a/views/notify.php +++ b/views/notify.php @@ -3,6 +3,12 @@


Sorry - tickets are not on sale to the public yet.

+ Tickets go on sale ' . $date->format('F jS, Y \a\t h:ia') . ''; + } + ?>