Add calculation for shirt pricing, fix issue with saving people
This commit is contained in:
parent
361ed358f1
commit
4b2b9bc0f1
11
action.php
11
action.php
@ -101,7 +101,7 @@ switch ($VARS['action']) {
|
||||
"zip" => "[0-9]{5}(-?[0-9]{4})?",
|
||||
"phone1" => "[0-9]{10}",
|
||||
"email" => "_EMAIL_",
|
||||
"shirt" => ["YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
||||
"shirt" => ["NO", "YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
||||
"sex" => ["M", "F"]
|
||||
];
|
||||
|
||||
@ -190,10 +190,11 @@ switch ($VARS['action']) {
|
||||
];
|
||||
if ($editing) {
|
||||
$database->update("campers", $data, ['camperid' => $person['camperid']]);
|
||||
$camperid = $person['camperid'];
|
||||
} else {
|
||||
$database->insert("campers", $data);
|
||||
}
|
||||
$camperid = $database->id();
|
||||
}
|
||||
break;
|
||||
case "adult":
|
||||
$data = [
|
||||
@ -202,10 +203,11 @@ switch ($VARS['action']) {
|
||||
];
|
||||
if ($editing) {
|
||||
$database->update("adults", $data, ['adultid' => $person['adultid']]);
|
||||
$adultid = $person['adultid'];
|
||||
} else {
|
||||
$database->insert("adults", $data);
|
||||
}
|
||||
$adultid = $database->id();
|
||||
}
|
||||
break;
|
||||
case "youth":
|
||||
$data = [
|
||||
@ -215,10 +217,11 @@ switch ($VARS['action']) {
|
||||
];
|
||||
if ($editing) {
|
||||
$database->update("youth", $data, ['youthid' => $person['youthid']]);
|
||||
$youthid = $person['youthid'];
|
||||
} else {
|
||||
$database->insert("youth", $data);
|
||||
}
|
||||
$youthid = $database->id();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -300,6 +300,7 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
|
||||
"value" => $data["shirt"],
|
||||
"options" => [
|
||||
"" => "Choose...",
|
||||
"NO" => "No Shirt",
|
||||
"YS" => "Youth Small",
|
||||
"YM" => "Youth Medium",
|
||||
"YL" => "Youth Large",
|
||||
|
@ -93,6 +93,9 @@
|
||||
$shirtcount = $database->select("people", "shirt");
|
||||
$shirts = ["YS" => 0, "YM" => 0, "YL" => 0, "AS" => 0, "AM" => 0, "AL" => 0, "AX" => 0, "A2" => 0];
|
||||
foreach ($shirtcount as $str) {
|
||||
if ($str == "NO") {
|
||||
continue;
|
||||
}
|
||||
$shirts[$str] += 1;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ $database->action(function($database) {
|
||||
"zip" => "[0-9]{5}(-?[0-9]{4})?",
|
||||
"phone1" => "[0-9]{10}",
|
||||
"email" => "_EMAIL_",
|
||||
"shirt" => ["YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
||||
"shirt" => ["NO", "YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
||||
"sex" => ["M", "F"]
|
||||
];
|
||||
|
||||
@ -131,7 +131,12 @@ $database->action(function($database) {
|
||||
case "adult":
|
||||
$discount = 10.0 * (strlen($days) / 2);
|
||||
$dueusd -= $discount;
|
||||
echo "\Subtracting $$discount from the total for an adult volunteer, dueusd is $dueusd\n";
|
||||
echo "Subtracting $$discount from the total for an adult volunteer, dueusd is $dueusd\n";
|
||||
// Add shirt cost
|
||||
if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < 4) {
|
||||
echo "Adding $10 for a tshirt.\n";
|
||||
$dueusd += 10.0;
|
||||
}
|
||||
$database->insert("adults", [
|
||||
"position" => $people["position"][$pid],
|
||||
"days" => $days
|
||||
@ -139,6 +144,10 @@ $database->action(function($database) {
|
||||
$adultid = $database->id();
|
||||
break;
|
||||
case "youth":
|
||||
if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < 2) {
|
||||
echo "Adding $10 for a tshirt.\n";
|
||||
$dueusd += 10.0;
|
||||
}
|
||||
$database->insert("youth", [
|
||||
"position" => $people["position"][$pid],
|
||||
"days" => $days
|
||||
|
@ -94,10 +94,14 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="btn btn-sm btn-teal mt-1" id="add_adult">
|
||||
<div class="card-body d-flex flex-wrap align-items-center">
|
||||
<div class="btn btn-sm btn-teal mt-1 mr-4" id="add_adult">
|
||||
<i class="fas fa-plus"></i> Add Adult
|
||||
</div>
|
||||
<div>
|
||||
<i class="fas fa-calendar-alt fa-fw"></i> A $10 discount is applied for every day an adult volunteers.<br />
|
||||
<i class="fas fa-tshirt fa-fw"></i> Shirts are $10, or free for adults who volunteer all four days.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -118,10 +122,13 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="btn btn-sm btn-teal mt-1" id="add_youth">
|
||||
<div class="card-body d-flex flex-wrap align-items-center">
|
||||
<div class="btn btn-sm btn-teal mt-1 mr-4" id="add_youth">
|
||||
<i class="fas fa-plus"></i> Add Youth
|
||||
</div>
|
||||
<div>
|
||||
<i class="fas fa-tshirt fa-fw"></i> Shirts are $10, or free for youth who volunteer at least two days.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -214,9 +214,28 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
"width" => 5,
|
||||
"options" => $positions,
|
||||
"error" => "Choose a position."
|
||||
],
|
||||
[
|
||||
"label" => "Shirt Size",
|
||||
"name" => "shirt",
|
||||
"type" => "select",
|
||||
"value" => $personinfo["shirt"],
|
||||
"options" => [
|
||||
"" => "Choose...",
|
||||
"NO" => "No Shirt",
|
||||
"YS" => "Youth Small",
|
||||
"YM" => "Youth Medium",
|
||||
"YL" => "Youth Large",
|
||||
"AS" => "Adult Small",
|
||||
"AM" => "Adult Medium",
|
||||
"AL" => "Adult Large",
|
||||
"AX" => "Adult Extra Large",
|
||||
"A2" => "Adult 2X Large"
|
||||
],
|
||||
"error" => "Choose a shirt size."
|
||||
]
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Shirt Size",
|
||||
@ -235,7 +254,10 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
"A2" => "Adult 2X Large"
|
||||
],
|
||||
"error" => "Choose a shirt size."
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Gender",
|
||||
"name" => "sex",
|
||||
|
@ -61,6 +61,18 @@ $("#adult_list").on("change", "input[data-name=days]", function () {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
$("#youth_list").on("change", "input[data-name=days]", function () {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
$("#adult_list").on("change", "select[data-name=shirt]", function () {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
$("#youth_list").on("change", "select[data-name=shirt]", function () {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
$(".list-group").on("click", ".rmpersonbtn", function () {
|
||||
$(this).parent().remove();
|
||||
updateTotal();
|
||||
@ -75,6 +87,24 @@ function updateTotal() {
|
||||
return $(this).val() != '';
|
||||
}).length * 10.0;
|
||||
|
||||
// Add $10 for adult shirts if they aren't working four days
|
||||
totalcharge = totalcharge + $(".person-list-item[data-persontype=adult]").filter(function () {
|
||||
var days = $("input[data-name=days]:checked", $(this)).length;
|
||||
if (days < 4 && $("select[data-name=shirt]", $(this)).val() != "NO" && $("select[data-name=shirt]", $(this)).val() != "") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}).length * 10.0;
|
||||
|
||||
// Add $10 for youth shirts if they aren't working two days
|
||||
totalcharge += $(".person-list-item[data-persontype=youth]").filter(function () {
|
||||
var days = $("input[data-name=days]:checked", $(this)).length;
|
||||
if (days < 2 && $("select[data-name=shirt]", $(this)).val() != "NO" && $("select[data-name=shirt]", $(this)).val() != "") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}).length * 10.0;
|
||||
|
||||
totalcharge = Math.max(totalcharge, 0);
|
||||
|
||||
// The server will refuse to finish the registration if this doesn't match
|
||||
|
Loading…
x
Reference in New Issue
Block a user