From c835ee17c6a4f450e47a7b60494d3fde187481c5 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 4 Mar 2019 13:38:30 -0600 Subject: [PATCH] Moving views and using router --- index.php | 126 ++++++++++++++-------------------------- views/common/footer.php | 38 ++++++++++++ views/common/head.php | 54 +++++++++++++++++ 3 files changed, 135 insertions(+), 83 deletions(-) create mode 100644 views/common/footer.php create mode 100644 views/common/head.php diff --git a/index.php b/index.php index d7bc7e3..681444f 100644 --- a/index.php +++ b/index.php @@ -1,94 +1,54 @@ - - - - - - - +Dinner in the Woods 2019 - Tickets on sale March 15th! +use Bramus\Router\Router; - - +require __DIR__ . '/vendor/autoload.php'; +require __DIR__ . '/src/functions.php'; - - - +// Load environment variables +$dotenv = \Dotenv\Dotenv::create(__DIR__ . '/src'); +$dotenv->load(); +$dotenv->required([ + 'EVENT_TICKET_PRICE', + 'ENHANCER_TICKET_PRICE', + 'DB_HOST', + 'DB_USER', + 'DB_PASS', + 'POSTMARK_API_KEY', +]); - - - +$router = new Router(); - +// Custom 404 Handler +$router->set404(function () { + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); + echo '404, route not found!'; +}); -
-
-
-

Nature's Classroom Institute & Montessori School Presents

- Dinner in the Woods Event Logo -

Dinner in the Woods

-
Live Music · Local Food · Live & Silent Auction · Cabanas
-
Saturday June 1st, 2019 5:00pm-11:30pm
+// Static route: / (homepage) +$router->get('/', function () { + include 'views/common/head.php'; + include 'views/step1.php'; + include 'views/common/footer.php'; +}); -
+$router->post('/', function () { + // POST variables + $eventTicketQty = getInteger($_POST['eventTicketQty']); + $ticketEnhancerQty = getInteger($_POST['ticketEnhancerQty']); - + // Calculate totals + $additionalContribution = convertPossibleFloatToCents($_POST['additionalContribution']); + $eventTicketPrice = convertPossibleFloatToCents($eventTicketQty * $_SERVER['EVENT_TICKET_PRICE']); + $ticketEnhancerPrice = convertPossibleFloatToCents($ticketEnhancerQty * $_SERVER['ENHANCER_TICKET_PRICE']); -
-

© Natures Classroom Institute of Wisconsin

-
-
-
+ // Sum the cart totals + $cartTotal = $eventTicketPrice + $ticketEnhancerPrice + $additionalContribution; + include 'views/common/head.php'; + include 'views/step2.php'; + include 'views/common/footer.php'; +}); - - - - - - - +// Run it! +$router->run(); \ No newline at end of file diff --git a/views/common/footer.php b/views/common/footer.php new file mode 100644 index 0000000..615213d --- /dev/null +++ b/views/common/footer.php @@ -0,0 +1,38 @@ + + + + + + + + + + + + diff --git a/views/common/head.php b/views/common/head.php new file mode 100644 index 0000000..489a477 --- /dev/null +++ b/views/common/head.php @@ -0,0 +1,54 @@ + + + + + + + + + Dinner in the Woods 2019 - Tickets on sale March 15th! + + + + + + + + + + + + + + +
+
+
+

Nature's Classroom Institute & Montessori School Presents

+ Dinner in the Woods Event Logo +

Dinner in the Woods

+
Live Music · Local Food · Live & Silent Auction · Cabanas
+
Saturday June 1st, 2019 5:00pm-11:30pm
+ +
\ No newline at end of file