Pricing updates

This commit is contained in:
Chris Smith
2019-03-31 18:58:50 -05:00
parent 6f045b5180
commit 22605b96cc
5 changed files with 86 additions and 12 deletions

View File

@@ -13,7 +13,9 @@ require __DIR__ . '/src/functions.php';
$dotenv = \Dotenv\Dotenv::create(__DIR__ . '/src');
$dotenv->load();
$dotenv->required([
'EVENT_TICKET_PRICE',
'EVENT_TICKET_PRICE_1',
'EVENT_TICKET_PRICE_2',
'EVENT_TICKET_PRICE_3',
'ENHANCER_TICKET_PRICE',
'CHILDCARE_PRICE',
'CABANA_PRICE',
@@ -39,6 +41,9 @@ $router->set404(function () {
echo '404, route not found!';
});
// Get event pricing based on dates
list($_SERVER['EVENT_TICKET_PRICE'], $_SERVER['TABLE_TICKET_PRICE']) = getEventPricing(new DateTime('now', new DateTimeZone('America/Chicago')));
$router->before('GET|POST', '/admin/.*', function() {
session_start();

View File

@@ -1,5 +1,9 @@
EVENT_TICKET_PRICE="55"
TABLE_TICKET_PRICE="350"
EVENT_TICKET_PRICE_1="55"
TABLE_TICKET_PRICE_1="350"
EVENT_TICKET_PRICE_2="65"
TABLE_TICKET_PRICE_2="450"
EVENT_TICKET_PRICE_3="75"
TABLE_TICKET_PRICE_3="500"
ENHANCER_TICKET_PRICE="20"
CHILDCARE_PRICE="25"
CABANA_PRICE="250"

View File

@@ -21,6 +21,47 @@ function getInteger($variable, $postiveOnly = true)
return $variable;
}
/**
* Calculate Event Pricing based on date
*
* @param DateTime $date
* @return array
* @throws Exception
*/
function getEventPricing($date = null)
{
$priceIncrease1 = new DateTime('4/1/2019', new DateTimeZone('America/Chicago'));
$priceIncrease2 = new DateTime('5/1/2019', new DateTimeZone('America/Chicago'));
if (empty($date)) {
return [
$_SERVER['EVENT_TICKET_PRICE_1'],
$_SERVER['TABLE_TICKET_PRICE_1'],
];
}
$interval = $date->diff($priceIncrease1);
if ($interval->invert !== 0) {
return [
$_SERVER['EVENT_TICKET_PRICE_2'],
$_SERVER['TABLE_TICKET_PRICE_2'],
];
}
$interval = $date->diff($priceIncrease2);
if ($interval->invert !== 0) {
return [
$_SERVER['EVENT_TICKET_PRICE_3'],
$_SERVER['TABLE_TICKET_PRICE_3'],
];
}else {
return [
$_SERVER['EVENT_TICKET_PRICE_1'],
$_SERVER['TABLE_TICKET_PRICE_1'],
];
}
}
/**
* Converts possible float or string to cents
*
@@ -86,7 +127,8 @@ function shoppingCartTotal($price)
</li>';
}
function checkIfTicketsAreOnSale() {
function checkIfTicketsAreOnSale()
{
$todaysDate = new DateTime('now', new DateTimeZone('America/Chicago'));
$dateOnSale = new DateTime('3/15/2019 8:00am', new DateTimeZone('America/Chicago'));
$interval = $todaysDate->diff($dateOnSale);

View File

@@ -1,15 +1,31 @@
<div class="text-center">
<h4>Nature's Classroom Institute & Montessori School Presents</h4>
<iframe width="560" height="315" src="https://www.youtube.com/embed/lODWa6DkDaU?rel=0&amp;showinfo=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <h5>Saturday June 1st, 2019 5:00pm-11:30pm</h5>
<iframe width="560" height="315" src="https://www.youtube.com/embed/lODWa6DkDaU?rel=0&amp;showinfo=0"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
<h5>Saturday June 1st, 2019 5:00pm-11:30pm</h5>
<h5>W336 S8455 Hwy E, Mukwonago, WI 53149</h5>
</div>
<div class="row" style="margin-top: 50px">
<div class="col-md-12 mb-12">
<div class="mb-12 text-center">
<?php
$aprilIncrease = new DateTime('4/1/2019', new DateTimeZone('America/Chicago'));
$now = new DateTime('now', new DateTimeZone('America/Chicago'));
$interval = $now->diff($aprilIncrease);
if ($interval->invert == 0) { ?>
<h3>Are you a current NCI family or alum?</h3>
<a href="/step-1" class="btn btn-success">Yes</a>&nbsp;
<a href="/notify">No</a>
<?php
}else {?>
<a href="/step-1" class="btn-lg btn-success">Purchase Tickets</a>&nbsp;
<?php
}
?>
</div>
<br/><br/>
</div>

View File

@@ -1,7 +1,14 @@
<?php
$aprilIncrease = new DateTime('4/1/2019', new DateTimeZone('America/Chicago'));
$now = new DateTime('now', new DateTimeZone('America/Chicago'));
$interval = $now->diff($aprilIncrease);
if ($interval->invert == 0) { ?>
<div class="alert alert-warning" role="alert">
Pricing increases on April 1st! Buy tickets now!
</div>
<?php
}
$settings = \RedBeanPHP\R::load('settings', 1);
$tickets = $settings->value;
if ($tickets <= 25) { ?>