select("youth", "days");
- $days = ["Tu" => 0, "We" => 0, "Th" => 0, "Fr" => 0];
+ $days = $SETTINGS["camp_days"];
+ foreach ($days as $short => $long) {
+ $days[$short] = 0;
+ }
foreach ($daystrs as $str) {
if ($str == "") {
continue;
}
$arr = str_split($str, 2);
foreach ($arr as $day) {
- $days[$day] += 1;
+ if (array_key_exists($day, $days)) {
+ $days[$day] += 1;
+ }
}
}
diff --git a/public/actions/submit.php b/public/actions/submit.php
index 15aa4be..0fb7515 100644
--- a/public/actions/submit.php
+++ b/public/actions/submit.php
@@ -12,7 +12,7 @@ require_once __DIR__ . "/../../lib/Email.lib.php";
function errorBack(string $errormsg) {
global $familyid;
- header("Location: ../?page=signup&error=" . htmlentities($errormsg));
+ //header("Location: ../?page=signup&error=" . htmlentities($errormsg));
$database->delete("families", ["familyid" => $familyid]);
die($errormsg);
}
@@ -50,6 +50,13 @@ $database->action(function($database) {
errorBack("You need to register at least one person.");
}
+ $campercount = 0;
+ foreach ($people['ids'] as $pid) {
+ if ($people["type"][$pidd] == "camper") {
+ $campercount++;
+ }
+ }
+
foreach ($people['ids'] as $pid) {
// Clear these out
$camperid = null;
@@ -119,7 +126,9 @@ $database->action(function($database) {
$days = "";
if (is_array($people["days"][$pid])) {
- $validdays = ["Tu", "We", "Th", "Fr"];
+ foreach ($SETTINGS["camp_days"] as $short => $long) {
+ $validdays[] = $short;
+ }
$days = "";
foreach ($people["days"][$pid] as $day) {
if (in_array($day, $validdays)) {
@@ -142,21 +151,28 @@ $database->action(function($database) {
$discount = 10.0 * (strlen($days) / 2);
$dueusd -= $discount;
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;
+ // Add shirt charge if not working all days
+ if ($SETTINGS["prices"]["alone_adult_free_tshirt"] === true && $campercount == 0) {
+ // No shirt cost
+ } else if ($SETTINGS["prices"]["adult_tshirt"] !== false) {
+ if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < $SETTINGS["prices"]["adult_tshirt"]) {
+ echo "Adding $10 for a tshirt.\n";
+ $dueusd += 10.0;
+ }
}
$database->insert("adults", [
"position" => $people["position"][$pid],
- "days" => $days
+ "days" => $days,
+ "child_care" => (empty($people["child_care"][$pid]) ? null : $people["child_care"][$pid])
]);
$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;
+ if ($SETTINGS["prices"]["youth_tshirt"] !== false) {
+ if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < $SETTINGS["prices"]["youth_tshirt"]) {
+ echo "Adding $10 for a tshirt.\n";
+ $dueusd += 10.0;
+ }
}
$database->insert("youth", [
"position" => $people["position"][$pid],
diff --git a/public/parts/signup.php b/public/parts/signup.php
index d8c60dc..322e286 100644
--- a/public/parts/signup.php
+++ b/public/parts/signup.php
@@ -118,7 +118,22 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
A $10 discount is applied for every day an adult volunteers.
- Shirts are $10, or free for adults who volunteer all four days.
+
+ Shirts and patches are free for adult volunteers.
+
+ Shirts are $, or free for adults who volunteer at least days.
+
+ Shirts are also free for volunteers who are not attending with Cub Scouts.
+
@@ -145,7 +160,17 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
Add Youth
- Shirts are $10, or free for youth who volunteer at least two days.
+
+ Shirts and patches are free for youth volunteers.
+
+ Shirts are $, or free for youth who volunteer at least days.
+
@@ -216,5 +241,8 @@ if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_
\ No newline at end of file
diff --git a/public/parts/template_person.php b/public/parts/template_person.php
index 9dea637..d83fa51 100644
--- a/public/parts/template_person.php
+++ b/public/parts/template_person.php
@@ -226,12 +226,7 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
"label" => "Available Days",
"name" => "days",
"type" => "checkboxes",
- "options" => [
- "Tu" => "Tuesday",
- "We" => "Wednesday",
- "Th" => "Thursday",
- "Fr" => "Friday",
- ],
+ "options" => $SETTINGS["camp_days"],
"error" => "Choose at least one day."
],
[
@@ -301,6 +296,17 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
"error" => "Choose a gender."
],
]);
+ if ($type == "adult") {
+ $textboxes = array_merge($textboxes, [
+ [
+ "label" => "If you need child care for younger children, type their ages here",
+ "name" => "child_care",
+ "optional" => true,
+ "width" => 12,
+ "value" => $personinfo["child_care"]
+ ],
+ ]);
+ }
foreach ($textboxes as $item) {
?>
@@ -386,8 +392,8 @@ if (isset($personid) && $database->has('people', ['personid' => $personid])) {
?>
-
- Tigers (boys entering the first grade in the Fall) must be accompanied by a parent or guardian.
-
+
+ Tigers (boys entering the first grade in the Fall) must be accompanied by a parent or guardian.
+
\ No newline at end of file
diff --git a/public/static/signup.js b/public/static/signup.js
index 896fd1f..dec8e00 100644
--- a/public/static/signup.js
+++ b/public/static/signup.js
@@ -87,23 +87,32 @@ function updateTotal() {
return $(this).val() != '';
}).length * 10.0;
- // Add $10 for adult shirts if they aren't working four days
+ // Add charge for adult shirts
totalcharge = totalcharge + $(".person-list-item[data-persontype=adult]").filter(function () {
+ if (prices.adult_tshirt == false) {
+ return false;
+ }
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() != "") {
+ if (prices.alone_adult_free_tshirt == true && $(".person-list-item[data-persontype=camper]").length == 0) {
+ return false;
+ }
+ if (days < prices.adult_tshirt && $("select[data-name=shirt]", $(this)).val() != "NO" && $("select[data-name=shirt]", $(this)).val() != "") {
return true;
}
return false;
- }).length * 10.0;
+ }).length * prices.tshirt;
- // Add $10 for youth shirts if they aren't working two days
+ // Add charge for youth shirts
totalcharge += $(".person-list-item[data-persontype=youth]").filter(function () {
+ if (prices.youth_tshirt == false) {
+ return false;
+ }
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() != "") {
+ if (days < prices.youth_tshirt && $("select[data-name=shirt]", $(this)).val() != "NO" && $("select[data-name=shirt]", $(this)).val() != "") {
return true;
}
return false;
- }).length * 10.0;
+ }).length * prices.tshirt;
totalcharge = Math.max(totalcharge, 0);
diff --git a/settings.template.php b/settings.template.php
index 641a106..63342d5 100644
--- a/settings.template.php
+++ b/settings.template.php
@@ -29,6 +29,22 @@ $SETTINGS = [
"site_title" => "Camp Portal",
// Set to true to disable registration.
"disable_registration" => false,
+ "camp_days" => [
+ "Mo" => "Monday",
+ "Tu" => "Tuesday",
+ "We" => "Wednesday"
+ ],
+ "prices" => [
+ "camp" => 50.0,
+ "tshirt" => 10.0,
+ // Set to false to make shirts always free, set to a number to make them
+ // free for people who work at least that many days
+ "youth_tshirt" => false,
+ "adult_tshirt" => 3,
+ // Set whether adults get free shirts when they're not bringing Cub Scouts,
+ // regardless of how many days they volunteer
+ "alone_adult_free_tshirt" => true
+ ],
// Stripe keys for payment processing
"stripe" => [
"pubkey" => "",