diff --git a/action.php b/action.php index 82b702d..c647fdd 100644 --- a/action.php +++ b/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(); } - $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(); } - $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(); } - $youthid = $database->id(); break; } @@ -244,7 +247,7 @@ switch ($VARS['action']) { } else { $database->insert("people", $data); } - + } catch (Exception $ex) { errorBack($ex->getMessage()); } diff --git a/pages/404.php b/pages/404.php index 7a2be4e..99d36d6 100644 --- a/pages/404.php +++ b/pages/404.php @@ -5,6 +5,6 @@ ?>
-
get("404 error");?>
get("page not found"); ?>
+
get("404 error"); ?>
get("page not found"); ?>
\ No newline at end of file diff --git a/pages/editperson.php b/pages/editperson.php index eb73f6e..d60a775 100644 --- a/pages/editperson.php +++ b/pages/editperson.php @@ -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", diff --git a/pages/home.php b/pages/home.php index d15e4d1..aa8d477 100644 --- a/pages/home.php +++ b/pages/home.php @@ -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; } diff --git a/public/actions/submit.php b/public/actions/submit.php index 8b4b04a..60e5626 100644 --- a/public/actions/submit.php +++ b/public/actions/submit.php @@ -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 diff --git a/public/parts/signup.php b/public/parts/signup.php index 98122d8..331ff03 100644 --- a/public/parts/signup.php +++ b/public/parts/signup.php @@ -94,10 +94,14 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_ ?> -
-
+
+
Add Adult
+
+ A $10 discount is applied for every day an adult volunteers.
+ Shirts are $10, or free for adults who volunteer all four days. +
@@ -118,10 +122,13 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_ ?>
-
-
+
+
Add Youth
+
+ Shirts are $10, or free for youth who volunteer at least two days. +
diff --git a/public/parts/template_person.php b/public/parts/template_person.php index 97e1296..a5ff20e 100644 --- a/public/parts/template_person.php +++ b/public/parts/template_person.php @@ -214,28 +214,50 @@ 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", + "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, [ - [ - "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", "name" => "sex", diff --git a/public/static/bigcheck.svg b/public/static/bigcheck.svg index 5b6c4ba..7568d07 100644 --- a/public/static/bigcheck.svg +++ b/public/static/bigcheck.svg @@ -1,14 +1,14 @@ - - - - - - - + + + + + + + + + + - - - diff --git a/public/static/signup.js b/public/static/signup.js index be755f2..1555cbb 100644 --- a/public/static/signup.js +++ b/public/static/signup.js @@ -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