Add available days and preferred positions to volunteer form
This commit is contained in:
parent
326cb874e7
commit
3e5c79f65d
@ -139,6 +139,8 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4>Total: $<span id="total">0</span></h4>
|
||||
<!-- Hi, don't bother tampering with this, the math is checked on the server before charging the card. -->
|
||||
<input type="hidden" name="totalcharge" value="0" />
|
||||
<noscript>
|
||||
<div class="card-text text-danger mb-1">
|
||||
<i class="fas fa-code"></i> JavaScript is required to complete your payment.
|
||||
|
@ -175,8 +175,46 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
]);
|
||||
}
|
||||
if ($type == "adult" || $type == "youth") {
|
||||
// TODO: camp days selection
|
||||
// TODO: help area selection
|
||||
if ($type == "adult") {
|
||||
$positions = [
|
||||
"None" => "No Preference",
|
||||
"Den Walker" => "Den Walker",
|
||||
"Station Leader" => "Station Leader",
|
||||
"Tot Lot" => "Tot Lot",
|
||||
"First Aid" => "First Aid",
|
||||
"Floater" => "Floater"
|
||||
];
|
||||
} else {
|
||||
$positions = [
|
||||
"None" => "No Preference",
|
||||
"Den Chief" => "Den Chief",
|
||||
"Station" => "Station",
|
||||
"Tot Lot" => "Tot Lot",
|
||||
"Floater" => "Floater"
|
||||
];
|
||||
}
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Available Days",
|
||||
"name" => "days",
|
||||
"type" => "checkboxes",
|
||||
"options" => [
|
||||
"Tu" => "Tuesday",
|
||||
"We" => "Wednesday",
|
||||
"Th" => "Thursday",
|
||||
"Fr" => "Friday",
|
||||
],
|
||||
"error" => "Choose at least one day."
|
||||
],
|
||||
[
|
||||
"label" => "Preferred Position",
|
||||
"name" => "position",
|
||||
"type" => "select",
|
||||
"width" => 5,
|
||||
"options" => $positions,
|
||||
"error" => "Choose a position."
|
||||
]
|
||||
]);
|
||||
}
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
@ -206,7 +244,7 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
<div class="form-group mb-3">
|
||||
<label class="mb-0"><?php echo $item['label']; ?>:</label>
|
||||
<div class="input-group">
|
||||
<?php if (empty($item['type']) || $item['type'] != "select") { ?>
|
||||
<?php if (empty($item['type']) || ($item['type'] != "select" && $item['type'] != "checkboxes")) { ?>
|
||||
<input type="<?php echo (empty($item['type']) ? "text" : $item['type']); ?>"
|
||||
name="<?php echo $item['name']; ?>"
|
||||
class="form-control"
|
||||
@ -250,9 +288,26 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
} else if ($item['type'] == "checkboxes") {
|
||||
?>
|
||||
<div class="d-flex justify-content-left flex-wrap">
|
||||
<?php
|
||||
foreach ($item['options'] as $value => $label) {
|
||||
?>
|
||||
<div class="form-check m-1">
|
||||
<input class="form-check-input" type="checkbox" name="<?php echo $item['name']; ?>" value="<?php echo $value; ?>">
|
||||
<label class="form-check-label">
|
||||
<?php echo $label; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="invalid-tooltip">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="invalid-feedback">
|
||||
<?php echo $item['error']; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -262,6 +317,5 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -58,12 +58,25 @@ $("#camper_list").on("change", "input[name=firstname]", function () {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
$("#adult_list").on("change", "input[name=days]", function () {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
function updateTotal() {
|
||||
totalcharge = $(".person-list-item[data-persontype=camper] input[name=firstname]").filter(function () {
|
||||
return $(this).val() != '';
|
||||
}).length * 50.0;
|
||||
|
||||
totalcharge = totalcharge - $(".person-list-item[data-persontype=adult] input[name=days]:checked").filter(function () {
|
||||
return $(this).val() != '';
|
||||
}).length * 10.0;
|
||||
|
||||
totalcharge = Math.max(totalcharge, 0);
|
||||
|
||||
// The server will refuse to finish the registration if this doesn't match
|
||||
// the backend-calculated amount, don't bother being a haxxor
|
||||
$("#total").text(totalcharge);
|
||||
$("input[name=totalcharge]").val(totalcharge);
|
||||
}
|
||||
|
||||
// Create a Stripe client.
|
||||
|
Loading…
x
Reference in New Issue
Block a user