diff --git a/action.php b/action.php index c647fdd..90a9687 100644 --- a/action.php +++ b/action.php @@ -54,7 +54,11 @@ switch ($VARS['action']) { "shirt" => "", "sex" => "", "parentname" => "", - "rank" => "" + "rank" => "", + "den" => "", + "health" => "", + "notes" => "", + "position" => "" ]; if (!empty($VARS['personid']) && $database->has("people", ['personid' => $VARS['personid']])) { $person = $database->get('people', ['personid (id)', @@ -71,7 +75,8 @@ switch ($VARS['action']) { 'email', 'unit', 'shirt', - 'sex'], ['personid' => $VARS['personid']]); + 'sex', + 'notes'], ['personid' => $VARS['personid']]); $editing = true; } @@ -186,7 +191,9 @@ switch ($VARS['action']) { case "camper": $data = [ "parentname" => $people["parentname"], - "rank" => $people["rank"] + "rank" => $people["rank"], + "den" => (empty($people["den"]) ? "" : $people["den"]), + "health" => (empty($people["health"]) ? "" : $people["health"]) ]; if ($editing) { $database->update("campers", $data, ['camperid' => $person['camperid']]); @@ -239,7 +246,8 @@ switch ($VARS['action']) { "email" => empty($people["email"]) ? "" : $people["email"], "unit" => $people["unit"], "shirt" => $people["shirt"], - "sex" => $people["sex"] + "sex" => $people["sex"], + "notes" => (empty($people["notes"]) ? "" : $people["notes"]) ]; if ($editing) { @@ -253,7 +261,7 @@ switch ($VARS['action']) { } }); - returnToSender("person_saved"); + returnToSender("person_saved", "&id=" . htmlentities($VARS['personid'])); break; case "deleteperson": if (!empty($VARS['id']) && $database->count("people", ['personid' => $VARS['id']]) === 1) { diff --git a/database.mwb b/database.mwb index 416b046..f468e39 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/langs/en/messages.json b/langs/en/messages.json index ed98452..bcc7241 100644 --- a/langs/en/messages.json +++ b/langs/en/messages.json @@ -6,5 +6,7 @@ "Are you sure you want to delete this person?": "Are you sure you want to delete this person?", "This action cannot be undone!": "This action cannot be undone!", "Payment saved.": "Payment saved.", - "Only showing {x}s.": "Only showing {x}s." + "Only showing {x}s.": "Only showing {x}s.", + "Person saved.": "Person saved.", + "Person deleted.": "Person deleted." } diff --git a/pages/editperson.php b/pages/editperson.php index d60a775..e75affc 100644 --- a/pages/editperson.php +++ b/pages/editperson.php @@ -26,7 +26,10 @@ $data = [ "sex" => "", "parentname" => "", "rank" => "", - "days" => "" + "days" => "", + "den" => "", + "health" => "", + "notes" => "" ]; $type = "camper"; if (!empty($VARS['type']) && preg_match("/(camper|adult|youth)/", $VARS['type'])) { @@ -48,10 +51,11 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']]) 'email', 'unit', 'shirt', - 'sex'], ['personid' => $personid]); + 'sex', + 'notes'], ['personid' => $personid]); if (!empty($data["camperid"])) { $type = "camper"; - $data = array_merge($data, $database->get('campers', ['parentname', 'rank'], ['camperid' => $data["camperid"]])); + $data = array_merge($data, $database->get('campers', ['parentname', 'rank', 'den', 'health'], ['camperid' => $data["camperid"]])); } else if (!empty($data["adultid"])) { $type = "adult"; $data = array_merge($data, $database->get('adults', ['days', 'position'], ['adultid' => $data["adultid"]])); @@ -288,6 +292,7 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']]) "type" => "select", "width" => 5, "options" => $positions, + "value" => $data["position"], "error" => "Choose a position." ] ]); @@ -326,6 +331,39 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']]) "error" => "Choose a gender." ], ]); + if ($type == "camper") { + $textboxes = array_merge($textboxes, [ + [ + "label" => "Den", + "name" => "den", + "width" => 5, + "maxlength" => 255, + "value" => $data["den"], + "optional" => true, + "error" => "Enter a den" + ], + [ + "label" => "Health", + "name" => "health", + "type" => "textarea", + "width" => 6, + "value" => $data["health"], + "optional" => true, + "error" => "Error" + ] + ]); + } + $textboxes = array_merge($textboxes, [ + [ + "label" => "Notes", + "name" => "notes", + "type" => "textarea", + "width" => 6, + "value" => $data["notes"], + "optional" => true, + "error" => "Error" + ] + ]); foreach ($textboxes as $item) { ?> @@ -334,81 +372,112 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
- - " - name="" - data-name="" - class="form-control" - placeholder="" - aria-label="" - maxlength="" - - pattern="" - - - value="" - /> - - - -
- $label) { - ?> -
- - > - -
- -
- + switch ($item['type']) { + case "select": + ?> + + +
+ $label) { + ?> +
+ > + +
+ +
+ + + + " + name="" + data-name="" + class="form-control" + placeholder="" + aria-label="" + maxlength="" + + min="" + + + pattern="" + + + value="" + /> +
@@ -432,7 +501,7 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']]) } ?> - +