Add calculation for shirt pricing, fix issue with saving people
This commit is contained in:
parent
361ed358f1
commit
4b2b9bc0f1
13
action.php
13
action.php
@ -101,7 +101,7 @@ switch ($VARS['action']) {
|
|||||||
"zip" => "[0-9]{5}(-?[0-9]{4})?",
|
"zip" => "[0-9]{5}(-?[0-9]{4})?",
|
||||||
"phone1" => "[0-9]{10}",
|
"phone1" => "[0-9]{10}",
|
||||||
"email" => "_EMAIL_",
|
"email" => "_EMAIL_",
|
||||||
"shirt" => ["YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
"shirt" => ["NO", "YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
||||||
"sex" => ["M", "F"]
|
"sex" => ["M", "F"]
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -190,10 +190,11 @@ switch ($VARS['action']) {
|
|||||||
];
|
];
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$database->update("campers", $data, ['camperid' => $person['camperid']]);
|
$database->update("campers", $data, ['camperid' => $person['camperid']]);
|
||||||
|
$camperid = $person['camperid'];
|
||||||
} else {
|
} else {
|
||||||
$database->insert("campers", $data);
|
$database->insert("campers", $data);
|
||||||
|
$camperid = $database->id();
|
||||||
}
|
}
|
||||||
$camperid = $database->id();
|
|
||||||
break;
|
break;
|
||||||
case "adult":
|
case "adult":
|
||||||
$data = [
|
$data = [
|
||||||
@ -202,10 +203,11 @@ switch ($VARS['action']) {
|
|||||||
];
|
];
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$database->update("adults", $data, ['adultid' => $person['adultid']]);
|
$database->update("adults", $data, ['adultid' => $person['adultid']]);
|
||||||
|
$adultid = $person['adultid'];
|
||||||
} else {
|
} else {
|
||||||
$database->insert("adults", $data);
|
$database->insert("adults", $data);
|
||||||
|
$adultid = $database->id();
|
||||||
}
|
}
|
||||||
$adultid = $database->id();
|
|
||||||
break;
|
break;
|
||||||
case "youth":
|
case "youth":
|
||||||
$data = [
|
$data = [
|
||||||
@ -215,10 +217,11 @@ switch ($VARS['action']) {
|
|||||||
];
|
];
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$database->update("youth", $data, ['youthid' => $person['youthid']]);
|
$database->update("youth", $data, ['youthid' => $person['youthid']]);
|
||||||
|
$youthid = $person['youthid'];
|
||||||
} else {
|
} else {
|
||||||
$database->insert("youth", $data);
|
$database->insert("youth", $data);
|
||||||
|
$youthid = $database->id();
|
||||||
}
|
}
|
||||||
$youthid = $database->id();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +247,7 @@ switch ($VARS['action']) {
|
|||||||
} else {
|
} else {
|
||||||
$database->insert("people", $data);
|
$database->insert("people", $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
errorBack($ex->getMessage());
|
errorBack($ex->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
?>
|
?>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-12 col-sm-10 col-md-8 col-lg-6">
|
<div class="col-12 col-sm-10 col-md-8 col-lg-6">
|
||||||
<div class="alert alert-warning"><b><?php $Strings->get("404 error");?></b><br /> <?php $Strings->get("page not found"); ?></div>
|
<div class="alert alert-warning"><b><?php $Strings->get("404 error"); ?></b><br /> <?php $Strings->get("page not found"); ?></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -300,6 +300,7 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
|
|||||||
"value" => $data["shirt"],
|
"value" => $data["shirt"],
|
||||||
"options" => [
|
"options" => [
|
||||||
"" => "Choose...",
|
"" => "Choose...",
|
||||||
|
"NO" => "No Shirt",
|
||||||
"YS" => "Youth Small",
|
"YS" => "Youth Small",
|
||||||
"YM" => "Youth Medium",
|
"YM" => "Youth Medium",
|
||||||
"YL" => "Youth Large",
|
"YL" => "Youth Large",
|
||||||
|
@ -93,6 +93,9 @@
|
|||||||
$shirtcount = $database->select("people", "shirt");
|
$shirtcount = $database->select("people", "shirt");
|
||||||
$shirts = ["YS" => 0, "YM" => 0, "YL" => 0, "AS" => 0, "AM" => 0, "AL" => 0, "AX" => 0, "A2" => 0];
|
$shirts = ["YS" => 0, "YM" => 0, "YL" => 0, "AS" => 0, "AM" => 0, "AL" => 0, "AX" => 0, "A2" => 0];
|
||||||
foreach ($shirtcount as $str) {
|
foreach ($shirtcount as $str) {
|
||||||
|
if ($str == "NO") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$shirts[$str] += 1;
|
$shirts[$str] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ $database->action(function($database) {
|
|||||||
"zip" => "[0-9]{5}(-?[0-9]{4})?",
|
"zip" => "[0-9]{5}(-?[0-9]{4})?",
|
||||||
"phone1" => "[0-9]{10}",
|
"phone1" => "[0-9]{10}",
|
||||||
"email" => "_EMAIL_",
|
"email" => "_EMAIL_",
|
||||||
"shirt" => ["YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
"shirt" => ["NO", "YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
|
||||||
"sex" => ["M", "F"]
|
"sex" => ["M", "F"]
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -131,7 +131,12 @@ $database->action(function($database) {
|
|||||||
case "adult":
|
case "adult":
|
||||||
$discount = 10.0 * (strlen($days) / 2);
|
$discount = 10.0 * (strlen($days) / 2);
|
||||||
$dueusd -= $discount;
|
$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", [
|
$database->insert("adults", [
|
||||||
"position" => $people["position"][$pid],
|
"position" => $people["position"][$pid],
|
||||||
"days" => $days
|
"days" => $days
|
||||||
@ -139,6 +144,10 @@ $database->action(function($database) {
|
|||||||
$adultid = $database->id();
|
$adultid = $database->id();
|
||||||
break;
|
break;
|
||||||
case "youth":
|
case "youth":
|
||||||
|
if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < 2) {
|
||||||
|
echo "Adding $10 for a tshirt.\n";
|
||||||
|
$dueusd += 10.0;
|
||||||
|
}
|
||||||
$database->insert("youth", [
|
$database->insert("youth", [
|
||||||
"position" => $people["position"][$pid],
|
"position" => $people["position"][$pid],
|
||||||
"days" => $days
|
"days" => $days
|
||||||
|
@ -94,10 +94,14 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
|
|||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body d-flex flex-wrap align-items-center">
|
||||||
<div class="btn btn-sm btn-teal mt-1" id="add_adult">
|
<div class="btn btn-sm btn-teal mt-1 mr-4" id="add_adult">
|
||||||
<i class="fas fa-plus"></i> Add Adult
|
<i class="fas fa-plus"></i> Add Adult
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -118,10 +122,13 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
|
|||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body d-flex flex-wrap align-items-center">
|
||||||
<div class="btn btn-sm btn-teal mt-1" id="add_youth">
|
<div class="btn btn-sm btn-teal mt-1 mr-4" id="add_youth">
|
||||||
<i class="fas fa-plus"></i> Add Youth
|
<i class="fas fa-plus"></i> Add Youth
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -214,28 +214,50 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
|||||||
"width" => 5,
|
"width" => 5,
|
||||||
"options" => $positions,
|
"options" => $positions,
|
||||||
"error" => "Choose a position."
|
"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",
|
||||||
|
"name" => "shirt",
|
||||||
|
"type" => "select",
|
||||||
|
"value" => $personinfo["shirt"],
|
||||||
|
"options" => [
|
||||||
|
"" => "Choose...",
|
||||||
|
"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."
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$textboxes = array_merge($textboxes, [
|
$textboxes = array_merge($textboxes, [
|
||||||
[
|
|
||||||
"label" => "Shirt Size",
|
|
||||||
"name" => "shirt",
|
|
||||||
"type" => "select",
|
|
||||||
"value" => $personinfo["shirt"],
|
|
||||||
"options" => [
|
|
||||||
"" => "Choose...",
|
|
||||||
"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."
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"label" => "Gender",
|
"label" => "Gender",
|
||||||
"name" => "sex",
|
"name" => "sex",
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<svg width="256" height="256" version="1.1" viewBox="0 0 67.733 67.733" xmlns="http://www.w3.org/2000/svg">
|
<svg width="256" height="256" version="1.1" viewBox="0 0 67.733 67.733" xmlns="http://www.w3.org/2000/svg">
|
||||||
<g transform="translate(0 -229.27)">
|
<g transform="translate(0 -229.27)">
|
||||||
<g transform="translate(-2.1594 -2.3301)">
|
<g transform="translate(-2.1594 -2.3301)">
|
||||||
<circle cx="36.026" cy="265.46" r="25.346" fill="none" stroke="#fff" stroke-width="2.1167"/>
|
<circle cx="36.026" cy="265.46" r="25.346" fill="none" stroke="#fff" stroke-width="2.1167"/>
|
||||||
<g transform="matrix(.92594 0 0 .92594 15.724 23.148)" fill="#fff">
|
<g transform="matrix(.92594 0 0 .92594 15.724 23.148)" fill="#fff">
|
||||||
<g transform="translate(0 -10.583)" fill="#fff">
|
<g transform="translate(0 -10.583)" fill="#fff">
|
||||||
<rect transform="rotate(-45)" x="-186.61" y="215.33" width="50.291" height="2.286"/>
|
<rect transform="rotate(-45)" x="-186.61" y="215.33" width="50.291" height="2.286"/>
|
||||||
<rect transform="matrix(-.70711 -.70711 -.70711 .70711 0 0)" x="-217.62" y="184.32" width="18.288" height="2.286"/>
|
<rect transform="matrix(-.70711 -.70711 -.70711 .70711 0 0)" x="-217.62" y="184.32" width="18.288" height="2.286"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 698 B After Width: | Height: | Size: 797 B |
@ -61,6 +61,18 @@ $("#adult_list").on("change", "input[data-name=days]", function () {
|
|||||||
updateTotal();
|
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 () {
|
$(".list-group").on("click", ".rmpersonbtn", function () {
|
||||||
$(this).parent().remove();
|
$(this).parent().remove();
|
||||||
updateTotal();
|
updateTotal();
|
||||||
@ -75,6 +87,24 @@ function updateTotal() {
|
|||||||
return $(this).val() != '';
|
return $(this).val() != '';
|
||||||
}).length * 10.0;
|
}).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);
|
totalcharge = Math.max(totalcharge, 0);
|
||||||
|
|
||||||
// The server will refuse to finish the registration if this doesn't match
|
// The server will refuse to finish the registration if this doesn't match
|
||||||
|
Loading…
x
Reference in New Issue
Block a user