schema update, guest list form updates, javascript fix removing required
This commit is contained in:
@@ -22,6 +22,10 @@ h4 {
|
|||||||
padding-top: 25px;
|
padding-top: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pad-15-left {
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
/*form validation*/
|
/*form validation*/
|
||||||
.container {
|
.container {
|
||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ CREATE TABLE `orders` (
|
|||||||
`state` varchar(45) NOT NULL,
|
`state` varchar(45) NOT NULL,
|
||||||
`zip` varchar(45) NOT NULL,
|
`zip` varchar(45) NOT NULL,
|
||||||
`payment_type` int(11) NOT NULL DEFAULT '0',
|
`payment_type` int(11) NOT NULL DEFAULT '0',
|
||||||
`stripe_token` varchar(64) NOT NULL,
|
`stripe_token` varchar(64) NULL,
|
||||||
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`uuid` varchar(64) NOT NULL,
|
`uuid` varchar(64) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
|
|||||||
27
index.php
27
index.php
@@ -130,5 +130,32 @@ $router->get('/manage/{uuid}', function ($uuid) {
|
|||||||
include 'views/common/footer.php';
|
include 'views/common/footer.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$router->post('/manage/{uuid}', function ($uuid) {
|
||||||
|
if ($uuid !== $_POST['uuid']) {
|
||||||
|
throw new Exception('Invalid form submission', 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = R::findOne('orders', ' uuid = ?', [$uuid]);
|
||||||
|
$parametersToSearch = $_POST['guestsArray'];
|
||||||
|
array_push($parametersToSearch, $order->id);
|
||||||
|
$guests = R::findAll('guests', ' id IN(' . R::genSlots($_POST['guestsArray']) . ') AND order_id = ?', $parametersToSearch);
|
||||||
|
|
||||||
|
foreach ($guests as $id => $guest) {
|
||||||
|
if (!empty($_POST['guests'][$id]['name']) &&
|
||||||
|
!empty($_POST['guests'][$id]['email']) &&
|
||||||
|
!empty($_POST['guests'][$id]['phone'])) {
|
||||||
|
$guest->name = $_POST['guests'][$id]['name'];
|
||||||
|
$guest->email = $_POST['guests'][$id]['email'];
|
||||||
|
$guest->phone = $_POST['guests'][$id]['phone'];
|
||||||
|
$guest->childcare = $_POST['guests'][$id]['childcare'];
|
||||||
|
$guest->valet = $_POST['guests'][$id]['valet'];
|
||||||
|
$guest->restrictions = $_POST['guests'][$id]['restrictions'];
|
||||||
|
R::store($guest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Location: /manage/'.$uuid);
|
||||||
|
});
|
||||||
|
|
||||||
// Run it!
|
// Run it!
|
||||||
$router->run();
|
$router->run();
|
||||||
@@ -5,10 +5,18 @@ addEventHandler(document, 'DOMContentLoaded', function () {
|
|||||||
addEventHandler(document.getElementById('credit'), 'click', function() {
|
addEventHandler(document.getElementById('credit'), 'click', function() {
|
||||||
document.getElementById('checkDetails').style.display = 'none';
|
document.getElementById('checkDetails').style.display = 'none';
|
||||||
document.getElementById('creditDetails').style.display = '';
|
document.getElementById('creditDetails').style.display = '';
|
||||||
|
document.getElementById('cc-number').required = true;
|
||||||
|
document.getElementById('cc-name').required = true;
|
||||||
|
document.getElementById('cc-expiration').required = true;
|
||||||
|
document.getElementById('cc-cvv').required = true;
|
||||||
});
|
});
|
||||||
addEventHandler(document.getElementById('check'), 'click', function() {
|
addEventHandler(document.getElementById('check'), 'click', function() {
|
||||||
document.getElementById('checkDetails').style.display = '';
|
document.getElementById('checkDetails').style.display = '';
|
||||||
document.getElementById('creditDetails').style.display = 'none';
|
document.getElementById('creditDetails').style.display = 'none';
|
||||||
|
document.getElementById('cc-number').required = false;
|
||||||
|
document.getElementById('cc-name').required = false;
|
||||||
|
document.getElementById('cc-expiration').required = false;
|
||||||
|
document.getElementById('cc-cvv').required = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,44 +2,46 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 order-md-1">
|
<div class="col-md-12 order-md-1">
|
||||||
<h3 class="mb-3">Your ticket information</h3>
|
<h3 class="mb-3">Your ticket information</h3>
|
||||||
|
<form class="needs-validation" novalidate method="POST">
|
||||||
|
<input type="hidden" name="uuid" value="<?=$order->uuid?>">
|
||||||
<?php
|
<?php
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($guests as $guest) {
|
foreach ($guests as $guest) {
|
||||||
$i++;
|
$i++;
|
||||||
?>
|
?>
|
||||||
|
<input type="hidden" name="guests[<?=$i?>][id]" value="<?=$guest->id;?>" >
|
||||||
|
<input type="hidden" name="guestsArray[]" value="<?=$guest->id;?>" >
|
||||||
<h5 class="mb-3">Guest #<?=$i?> <small><?=(is_null($guest->table)) ? '' : 'Table #' . $guest->table; ?><?=(is_null($guest->paddle)) ? '' : ', Paddle #' . $guest->paddle; ?></small></h5>
|
<h5 class="mb-3">Guest #<?=$i?> <small><?=(is_null($guest->table)) ? '' : 'Table #' . $guest->table; ?><?=(is_null($guest->paddle)) ? '' : ', Paddle #' . $guest->paddle; ?></small></h5>
|
||||||
<form class="needs-validation" novalidate method="POST">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
<label for="firstName">Full name</label>
|
<label for="name">Full name</label>
|
||||||
<input type="text" class="form-control" id="firstName" value="<?=$guest->name?>">
|
<input name="guests[<?=$i?>][name]" type="text" class="form-control" id="name" value="<?=$guest->name?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
<label for="lastName">Email</label>
|
<label for="lastName">Email</label>
|
||||||
<input type="text" class="form-control" id="email" value="<?=$guest->email?>">
|
<input name="guests[<?=$i?>][email]" type="text" class="form-control" id="email" value="<?=$guest->email?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
<label for="lastName">Phone</label>
|
<label for="lastName">Phone</label>
|
||||||
<input type="text" class="form-control" id="phone" value="<?=$guest->phone?>">
|
<input name="guests[<?=$i?>][phone]" type="text" class="form-control" id="phone" value="<?=$guest->phone?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
<label for="lastName">Childcare?</label>
|
<label for="childcare">Childcare?</label>
|
||||||
<select class="form-control" name="childcare">
|
<select class="form-control" name="guests[<?=$i?>][childcare]">
|
||||||
<option value="0" <?php if (false == $guest->childcare) { echo 'selected'; } ?>>No</option>
|
<option value="0" <?php if (false == $guest->childcare) { echo 'selected'; } ?>>No</option>
|
||||||
<option value="1" <?php if (true == $guest->childcare) { echo 'selected'; } ?>>Yes</option>
|
<option value="1" <?php if (true == $guest->childcare) { echo 'selected'; } ?>>Yes</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
<label for="lastName">Valet?</label>
|
<label for="valet">Valet?</label>
|
||||||
<select class="form-control" name="valet">
|
<select class="form-control" name="guests[<?=$i?>][valet]">
|
||||||
<option value="0" <?php if (false == $guest->valet) { echo 'selected'; } ?>>No</option>
|
<option value="0" <?php if (false == $guest->valet) { echo 'selected'; } ?>>No</option>
|
||||||
<option value="1" <?php if (true == $guest->valet) { echo 'selected'; } ?>>Yes</option>
|
<option value="1" <?php if (true == $guest->valet) { echo 'selected'; } ?>>Yes</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
<label for="lastName">Restrictions?</label>
|
<label for="restrictions">Restrictions?</label>
|
||||||
<select class="form-control" name="restrictions">
|
<select class="form-control" name="guests[<?=$i?>][restrictions]">
|
||||||
<option value="0" <?php if (0 == $guest->restrictions) { echo 'selected'; } ?>>None</option>
|
<option value="0" <?php if (0 == $guest->restrictions) { echo 'selected'; } ?>>None</option>
|
||||||
<option value="1" <?php if (1 == $guest->restrictions) { echo 'selected'; } ?>>Vegetarian</option>
|
<option value="1" <?php if (1 == $guest->restrictions) { echo 'selected'; } ?>>Vegetarian</option>
|
||||||
<option value="2" <?php if (2 == $guest->restrictions) { echo 'selected'; } ?>>Vegan</option>
|
<option value="2" <?php if (2 == $guest->restrictions) { echo 'selected'; } ?>>Vegan</option>
|
||||||
|
|||||||
@@ -181,20 +181,20 @@
|
|||||||
Credit card number is required
|
Credit card number is required
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-md-3 mb-3">
|
||||||
<div class="col-md-3 mb-3">
|
<label for="cc-expiration">Expiration</label>
|
||||||
<label for="cc-expiration">Expiration</label>
|
<input type="text" class="form-control" id="cc-expiration" placeholder="" required>
|
||||||
<input type="text" class="form-control" id="cc-expiration" placeholder="" required>
|
<div class="invalid-feedback">
|
||||||
<div class="invalid-feedback">
|
Expiration date required
|
||||||
Expiration date required
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 mb-3">
|
||||||
<div class="col-md-3 mb-3">
|
<label for="cc-expiration">CVV</label>
|
||||||
<label for="cc-expiration">CVV</label>
|
<input type="text" class="form-control" id="cc-cvv" placeholder="" required>
|
||||||
<input type="text" class="form-control" id="cc-cvv" placeholder="" required>
|
<div class="invalid-feedback">
|
||||||
<div class="invalid-feedback">
|
Security code required
|
||||||
Security code required
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user