Add person management

master
Skylar Ittner 5 years ago
parent 5e37ad192b
commit 99d749e644

@ -34,216 +34,237 @@ switch ($VARS['action']) {
session_destroy();
header('Location: index.php?logout=1');
die("Logged out.");
case "editfamily":
if (!(new User($_SESSION['uid']))->hasPermission("HACHEPORTAL_EDIT")) {
returnToSender("no_permission");
}
case "editperson":
$family = new Family();
$editing = false;
if (!empty($VARS['familyid']) && $database->has("families", ['familyid' => $VARS['familyid']])) {
$family = (new Family())->load($VARS['familyid']);
$person = [
"id" => null,
"familyid" => null,
"camperid" => null,
"adultid" => null,
"youthid" => null,
"firstname" => "",
"lastname" => "",
"address" => "",
"zip" => "",
"phone1" => "",
"phone2" => "",
"email" => "",
"unit" => "",
"shirt" => "",
"sex" => "",
"parentname" => "",
"rank" => ""
];
if (!empty($VARS['personid']) && $database->has("people", ['personid' => $VARS['personid']])) {
$person = $database->get('people', ['personid (id)',
'familyid',
'camperid',
'adultid',
'youthid',
'firstname',
'lastname',
'address',
'zip',
'phone1',
'phone2',
'email',
'unit',
'shirt',
'sex'], ['personid' => $VARS['personid']]);
$editing = true;
}
function errorBack(string $errormsg) {
global $family, $editing;
if ($editing) {
returnToSender($errormsg, "&id=" . $family->getID());
}
returnToSender($errormsg);
}
$database->action(function($database) {
global $family, $VARS, $editing;
global $person, $VARS, $editing;
try {
$lastname = $VARS['familyname'];
$father = $VARS['fathername'];
$mother = $VARS['mothername'];
if (empty($lastname)) {
errorBack("Enter a last name.");
}
if (empty($father)) {
errorBack("Enter a father name.");
}
if (empty($mother)) {
errorBack("Enter a mother name.");
}
$family->setName($lastname);
$family->setFather($father);
$family->setMother($mother);
$family->setPhone($VARS['phone']);
$family->setEmail($VARS['email']);
if ($editing) {
if ($database->has("families", ["AND" => ["email" => $family->getEmail(), "familyid[!]" => $family->getID()]])) {
errorBack("That email address is already in use with another family.");
}
$familyid = $person['familyid'];
} else {
if ($database->has("families", ["email" => $family->getEmail()])) {
errorBack("That email address is already in use with another family.");
}
}
$address = $VARS['streetaddress'];
$city = $VARS['city'];
$state = strtoupper($VARS['state']);
$zip = $VARS['zip'];
if (empty($address)) {
errorBack("Enter a street address.");
}
if (empty($city)) {
errorBack("Enter a city.");
}
$family->setAddress($address);
$family->setCity($city);
$family->setState($state);
$family->setZip($zip);
if (empty($VARS['date']) || strtotime($VARS['date']) === false) {
returnToSender("invalid_parameters");
$database->insert("families", []);
$familyid = $database->id();
}
$family->setExpires(null, $VARS['date']);
$newsletter = $VARS['newsletter_method'];
$membership_cost = 2500;
if (empty($newsletter)) {
errorBack("Select a newsletter preference.");
}
$family->setNewsletter($newsletter);
switch ($newsletter) {
case 1: // Email only
$membership_cost = 2500;
$people = array_merge($person, $VARS);
$requiredfields = [
"firstname" => ".+",
"lastname" => ".+",
"address" => ".+",
"zip" => "[0-9]{5}(-?[0-9]{4})?",
"phone1" => "[0-9]{10}",
"email" => "_EMAIL_",
"shirt" => ["YS", "YM", "YL", "AS", "AM", "AL", "AX", "A2"],
"sex" => ["M", "F"]
];
switch ($people["type"]) {
case "camper":
$checkfields = array_merge($requiredfields, [
"parentname" => ".+",
"unit" => "[0-9]{3,4}",
"rank" => ["Tiger", "Wolf", "Bear", "Webelos", "Arrow of Light"]
]);
break;
case 2: // Print only
$membership_cost = 3500;
case "adult":
$checkfields = array_merge($requiredfields, [
"position" => [
"None",
"Den Walker",
"Station Leader",
"Tot Lot",
"First Aid",
"Floater"
]
]);
break;
case 3: // Email and print
$membership_cost = 3500;
case "youth":
$checkfields = array_merge($requiredfields, [
"position" => [
"None",
"Den Chief",
"Station",
"Tot Lot",
"Floater"
]
]);
break;
default:
errorBack("Select a valid newsletter preference.");
}
$photopermission = $VARS['photo_permission'];
if (!empty($photopermission) && $photopermission == "1") {
$photopermission = true;
} else {
$photopermission = false;
errorBack("Invalid person type.");
}
$family->setPhotoPermission($photopermission);
$private = $VARS['private'];
if (!empty($private) && $private == "1") {
$private = true;
} else {
$private = false;
}
$family->setPrivate($private);
$family->save();
//
// Children
//
$children = $VARS['child'];
$childObjects = $family->getChildren();
$childrenToDelete = [];
foreach ($children['ids'] as $cid) {
if (empty($children['name'][$cid])) {
$childrenToDelete[] = $cid;
continue;
foreach ($checkfields as $name => $regex) {
$validatefunction = function ($str) use ($regex) {
return preg_match("/$regex/", $str);
};
if (is_array($regex)) {
// Array of options
$validatefunction = function ($str) use ($regex) {
return in_array($str, $regex);
};
} else if (strpos($regex, "_") === 0) {
// Special cases
switch ($regex) {
case "_EMAIL_":
$validatefunction = function ($str) {
return filter_var($str, FILTER_VALIDATE_EMAIL);
};
break;
}
}
if (!preg_match("/^([1-9]|1[012])$/", $children['month'][$cid])) {
errorBack("Invalid birth month chosen for " . htmlentities($children['name'][$cid]) . ".");
// Validate
if (!$validatefunction($people[$name])) {
errorBack("Please check your input and try again ($name).");
}
}
if (!is_numeric($children['year'][$cid])) {
errorBack("Invalid birth year chosen for " . htmlentities($children['name'][$cid]) . ".");
}
$children['year'][$cid] = $children['year'][$cid] * 1;
if ($children['year'][$cid] < 1980 || $children['year'][$cid] > date("Y")) {
errorBack("Invalid birth year chosen for " . htmlentities($children['name'][$cid]) . ".");
}
if (Child::exists($cid, $family->getID())) {
// iterate over existing children to find the correct one
for ($i = 0; $i < count($childObjects); $i++) {
if ($childObjects[$i]->getID() == $cid) {
$childObjects[$i]->setName($children['name'][$cid]);
$childObjects[$i]->setBirthday(null, $children['year'][$cid] . "-" . $children['month'][$cid] . "-00");
$childObjects[$i]->setGraduated(empty($children['graduate'][$cid]) ? false : true);
}
$days = "";
if (is_string($people["days"])) {
$people["days"] = str_split($people["days"], 2);
}
if (is_array($people["days"])) {
$validdays = ["Tu", "We", "Th", "Fr"];
$days = "";
foreach ($people["days"] as $day) {
if (in_array($day, $validdays)) {
$days .= $day;
}
} else {
$child = new Child();
$child->setName($children['name'][$cid]);
$child->setBirthday(null, $children['year'][$cid] . "-" . $children['month'][$cid] . "-00");
$child->setGraduated(empty($children['graduate'][$cid]) ? false : true);
$child->setFamilyID($family->getID());
$childObjects[] = $child;
}
}
foreach ($childObjects as $child) {
$child->save();
switch ($people["type"]) {
case "camper":
$data = [
"parentname" => $people["parentname"],
"rank" => $people["rank"]
];
if ($editing) {
$database->update("campers", $data, ['camperid' => $person['camperid']]);
} else {
$database->insert("campers", $data);
}
$camperid = $database->id();
break;
case "adult":
$data = [
"position" => $people["position"],
"days" => $days
];
if ($editing) {
$database->update("adults", $data, ['adultid' => $person['adultid']]);
} else {
$database->insert("adults", $data);
}
$adultid = $database->id();
break;
case "youth":
$data = [
"position" => $people["position"],
"days" => $days
];
if ($editing) {
$database->update("youth", $data, ['youthid' => $person['youthid']]);
} else {
$database->insert("youth", $data);
}
$youthid = $database->id();
break;
}
foreach ($childrenToDelete as $rip) {
$database->delete("people", ['personid' => $rip]);
$data = [
"familyid" => $familyid,
"camperid" => $camperid,
"adultid" => $adultid,
"youthid" => $youthid,
"firstname" => $people["firstname"],
"lastname" => $people["lastname"],
"address" => $people["address"],
"zip" => $people["zip"],
"phone1" => empty($people["phone1"]) ? "" : $people["phone1"],
"phone2" => empty($people["phone2"]) ? "" : $people["phone2"],
"email" => empty($people["email"]) ? "" : $people["email"],
"unit" => $people["unit"],
"shirt" => $people["shirt"],
"sex" => $people["sex"]
];
if ($editing) {
$database->update("people", $data, ['personid' => $VARS['personid']]);
} else {
$database->insert("people", $data);
}
} catch (Exception $ex) {
errorBack($ex->getMessage());
}
});
returnToSender("family_saved", "&id=" . $family->getID());
returnToSender("person_saved");
break;
case "deletefamily":
if (!(new User($_SESSION['uid']))->hasPermission("HACHEPORTAL_EDIT")) {
returnToSender("no_permission");
}
if (!empty($VARS['familyid']) && $database->count("families", ['familyid' => $VARS['familyid']]) === 1) {
$database->delete("people", ["familyid" => $VARS['familyid']]);
$database->delete("interests", ["familyid" => $VARS['familyid']]);
$database->delete("payments", ["familyid" => $VARS['familyid']]);
$database->delete("families", ["familyid" => $VARS['familyid']]);
returnToSender("family_deleted");
case "deleteperson":
if (!empty($VARS['id']) && $database->count("people", ['personid' => $VARS['id']]) === 1) {
$ids = $database->get("people", ['camperid', 'adultid', 'youthid'], ['personid' => $VARS['id']]);
if (!is_null($ids['camperid'])) {
$database->delete("campers", ['camperid' => $ids['camperid']]);
} else if (!is_null($ids['adultid'])) {
$database->delete("adults", ['adultid' => $ids['adultid']]);
} else if (!is_null($ids['youthid'])) {
$database->delete("youth", ['youthid' => $ids['youthid']]);
}
$database->delete("people", ["personid" => $VARS['id']]);
returnToSender("person_deleted");
} else {
returnToSender("family_doesnt_exist");
returnToSender("person_doesnt_exist");
}
break;
case "editevents":
if (!(new User($_SESSION['uid']))->hasPermission("HACHEPORTAL_EDIT")) {
returnToSender("no_permission");
}
foreach ($_POST['events'] as $k => $v) {
if ($database->has("events", ["eventid" => $k])) {
if (empty($v)) {
$database->delete("interests", ["eventid" => $k]);
$database->delete("events", ["eventid" => $k]);
continue;
}
$database->update("events", ["event" => $v], ["eventid" => $k]);
} else {
if (empty($v)) {
continue;
}
$database->insert("events", ["event" => $v]);
}
}
returnToSender("events_updated");
case "editpayment":
if (!(new User($_SESSION['uid']))->hasPermission("HACHEPORTAL_EDIT")) {
returnToSender("no_permission");

@ -120,7 +120,7 @@ END;
// For mobile app
echo "<script nonce=\"$SECURE_NONCE\">var navbar_breakpoint = \"$navbar_breakpoint\";</script>"
?>
<nav class="navbar navbar-expand-<?php echo $navbar_breakpoint; ?> navbar-dark bg-blue fixed-top">
<nav class="navbar navbar-expand-<?php echo $navbar_breakpoint; ?> navbar-dark bg-teal fixed-top">
<button class="navbar-toggler my-0 py-0" type="button" data-toggle="collapse" data-target="#navbar-collapse" aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle navigation">
<!--<i class="fas fa-bars"></i>-->
<span class="navbar-toggler-icon"></span>

@ -1,5 +1,7 @@
{
"Add Camper": "Add Camper",
"Add Adult": "Add Adult",
"Add Youth": "Add Youth",
"Edit": "Edit",
"View": "View",
"Save": "Save",
@ -8,6 +10,8 @@
"Edit Family": "Edit Family",
"View Campers": "View Campers",
"View Volunteers": "View Volunteers",
"View Adults": "View Adults",
"View Youth": "View Youth",
"View Payments": "View Payments",
"Manual Entry": "Manual Entry",
"View Expiring": "View Expiring",

@ -3,9 +3,15 @@
"Actions": "Actions",
"Campers": "Campers",
"Volunteers": "Volunteers",
"Camper": "Camper",
"Adult": "Adult",
"Adults": "Adults",
"Youth": "Youth",
"Total Income": "Total Income",
"Card Payments": "Card Payments",
"First": "First",
"Last": "Last",
"Last Name": "Last Name",
"Parent": "Parent",
"Unit": "Unit",
"Rank": "Rank",
@ -17,6 +23,8 @@
"State": "State",
"ZIP Code": "ZIP Code",
"ZIP": "ZIP",
"Shirt": "Shirt",
"Total": "Total",
"Yes": "Yes",
"No": "No",
"Newsletter": "Newsletter",
@ -27,8 +35,15 @@
"Born": "Born",
"Graduated": "Graduated",
"Okay to use photos?": "Okay to use photos?",
"Adding Family": "Adding Family",
"Editing Family": "Editing {family} Family",
"Adding Person": "Adding Person",
"Editing Person": "Editing {person}",
"Adding camper": "Adding Camper",
"Editing camper": "Editing Camper {person}",
"Adding adult": "Adding Adult",
"Editing adult": "Editing Adult {person}",
"Adding youth": "Adding Youth",
"Editing youth": "Editing Youth {person}",
"Delete Person": "Delete Person",
"Recent Payments": "Recent Payments",
"Interests": "Interests",
"Event List": "Event List",

@ -3,14 +3,14 @@
"That family ID does not exist.": "That family ID does not exist.",
"Family saved.": "Family saved.",
"Family deleted.": "Family deleted.",
"Are you sure you want to delete this family?": "Are you sure you want to delete this family?",
"This action cannot be undone! All information about this family, including payment history, will be purged forever.": "This action cannot be undone! All information about this family, including payment history, will be purged forever.",
"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!",
"To remove a child, delete the contents of the Name box.": "To remove a child, delete the contents of the Name box.",
"No interests selected.": "No interests selected.",
"Events updated.": "Events updated.",
"You agree to use the information in this directory for homeschool use ONLY. All other purposes, such as soliciting, is strictly prohibited.": "You agree to use the information in this directory for homeschool use ONLY. All other purposes, such as soliciting, is strictly prohibited.",
"Payment saved.": "Payment saved.",
"Only showing expired or expiring memberships.": "Only showing expired or expiring memberships.",
"Only showing {x}s.": "Only showing {x}s.",
"This family wishes to remain private. Do not share this information, even with other HACHE members.": "This family wishes to remain private. Do not share this information, even with other HACHE members.",
"That email address is already in use with another family.": "That email address is already in use with another family."
}

@ -1,5 +1,6 @@
{
"Home": "Home",
"People": "People",
"Families": "Families",
"Members": "Members",
"View Family": "View Family",

@ -11,26 +11,23 @@ define("PAGES", [
"navbar" => true,
"icon" => "fas fa-home"
],
"campers" => [
"title" => "Campers",
"people" => [
"title" => "People",
"navbar" => true,
"icon" => "fas fa-campground",
"icon" => "fas fa-user",
"styles" => [
"static/css/datatables.min.css",
"static/css/tables.css"
],
"scripts" => [
"static/js/datatables.min.js",
"static/js/campers.js"
"static/js/people.js"
],
],
"viewfamily" => [
"title" => "View Family"
],
"editfamily" => [
"title" => "Edit Family",
"editperson" => [
"title" => "Edit Person",
"scripts" => [
"static/js/editfamily.js"
"static/js/editperson.js"
],
],
"confirmdelete" => [
@ -55,14 +52,6 @@ define("PAGES", [
"static/js/editpayment.js"
]
],
"events" => [
"title" => "Events",
"navbar" => true,
"icon" => "fas fa-volleyball-ball",
"scripts" => [
"static/js/events.js"
],
],
"reports" => [
"title" => "Reports",
"navbar" => true,

@ -8,14 +8,14 @@ require_once __DIR__ . "/../required.php";
redirectifnotloggedin();
if (!empty($VARS['id'])) {
if ($database->has('families', ['familyid' => $VARS['id']])) {
$family = (new Family())->load($VARS['id']);
if ($database->has('people', ['personid' => $VARS['id']])) {
$person = $database->get("people", ["firstname", "lastname", "address", "phone1", "email"], ['personid' => $VARS['id']]);
} else {
header('Location: app.php?page=families&msg=family_doesnt_exists');
header('Location: app.php?page=people&msg=person_doesnt_exist');
die();
}
} else {
header('Location: app.php?page=families&msg=family_doesnt_exists');
header('Location: app.php?page=people&msg=person_doesnt_exist');
die();
}
?>
@ -23,36 +23,27 @@ if (!empty($VARS['id'])) {
<div class="col-12 col-sm-6 col-sm-offset-3">
<div class="card border-red text-center">
<h3 class="card-header text-red">
<?php $Strings->get("Delete Family"); ?>
<?php $Strings->get("Delete Person"); ?>
</h3>
<div class="card-body">
<p><i class="fas fa-exclamation-triangle fa-10x"></i></p>
<h4><?php $Strings->get("Are you sure you want to delete this family?") ?></h4>
<h5><?php $Strings->get("This action cannot be undone! All information about this family, including payment history, will be purged forever."); ?></h5>
<h4><?php $Strings->get("Are you sure you want to delete this person?") ?></h4>
<h5><?php $Strings->get("This action cannot be undone!"); ?></h5>
<div class="list-group">
<div class="list-group-item">
<i class="fas fa-fw fa-users"></i> <?php echo $family->getName(); ?>
<i class="fas fa-fw fa-user"></i> <?php echo $person["firstname"] . " " . $person["lastname"]; ?>
</div>
<div class="list-group-item">
<i class="fas fa-fw fa-male"></i> <?php echo $family->getFather(); ?>
<i class="fas fa-fw fa-at"></i> <?php echo $person["email"]; ?>
</div>
<div class="list-group-item">
<i class="fas fa-fw fa-female"></i> <?php echo $family->getMother(); ?>
<i class="fas fa-fw fa-phone"></i> <?php echo $person["phone1"]; ?>
</div>
<?php
foreach ($family->getChildren() as $child) {
?>
<div class="list-group-item">
<i class="fas fa-fw fa-user-graduate"></i> <?php echo $child->getName(); ?>
</div>
<?php
}
?>
</div>
</div>
<div class="card-footer d-flex">
<a href="app.php?page=families" class="btn btn-primary mr-auto"><i class="fas fa-arrow-left"></i> <?php $Strings->get('Cancel'); ?></a>
<a href="action.php?action=deletefamily&source=families&familyid=<?php echo htmlspecialchars($VARS['id']); ?>" class="btn btn-danger"><i class="fas fa-times"></i> <?php $Strings->get('Delete'); ?></a>
<a href="app.php?page=people" class="btn btn-primary mr-auto"><i class="fas fa-arrow-left"></i> <?php $Strings->get('Cancel'); ?></a>
<a href="action.php?action=deleteperson&source=people&id=<?php echo htmlspecialchars($VARS['id']); ?>" class="btn btn-danger"><i class="fas fa-times"></i> <?php $Strings->get('Delete'); ?></a>
</div>
</div>
</div>

@ -1,368 +0,0 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
redirectIfNotLoggedIn();
$user = new User($_SESSION['uid']);
if (!$user->hasPermission("HACHEPORTAL_EDIT")) {
header("Location: ./app.php?msg=no_permission");
die();
}
$editing = false;
if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id']])) {
$family = new Family();
$family->setExpires(strtotime("+1 year"));
} else {
$famid = $VARS['id'];
$family = (new Family())->load($famid);
$editing = true;
}
?>
<form action="action.php" method="post" id="editform">
<div class="card">
<h3 class="card-header d-flex">
<div>
<?php
if ($editing) {
?>
<i class="fas fa-edit"></i> <?php $Strings->build("Editing Family", ['family' => "<span id=\"name_title\">" . htmlentities($family->getName()) . "</span>"]); ?>
<?php
} else {
?>
<i class="fas fa-edit"></i> <?php $Strings->get("Adding Family"); ?>
<?php
}
?>
</div>
<a href="./app.php?page=families" class="ml-auto btn btn-outline-info btn-sm">
<i class="fas fa-times"></i> <?php $Strings->get("Cancel"); ?>
</a>
</h3>
<div class="card-body">
<h4><i class="fas fa-info fa-fw"></i> Basic Information</h4>
<div class="row">
<?php
$textboxes = [
[
"label" => "Family Name (Last Name)",
"icon" => "fas fa-users",
"name" => "familyname",
"maxlength" => 100,
"value" => $family->getName(),
"error" => "Enter a last name."
],
[
"label" => "Father's Name",
"icon" => "fas fa-male",
"name" => "fathername",
"maxlength" => 255,
"value" => $family->getFather(),
"error" => "Enter the father's name."
],
[
"label" => "Mother's Name",
"icon" => "fas fa-female",
"name" => "mothername",
"maxlength" => 255,
"value" => $family->getMother(),
"error" => "Enter the mother's name."
],
[
"label" => "Street Address",
"icon" => "fas fa-home",
"name" => "streetaddress",
"maxlength" => 500,
"value" => $family->getAddress(),
"error" => "Enter an address."
],
[
"label" => "City",
"icon" => "fas fa-city",
"name" => "city",
"maxlength" => 255,
"width" => 3,
"value" => $family->getCity(),
"error" => "Enter a city."
],
[
"label" => "State",
"icon" => "fas fa-flag",
"name" => "state",
"type" => "select",
"value" => $family->getState(),
"error" => "Select a state.",
"options" => [
'MT' => 'Montana',
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'DC' => 'District of Columbia',
'FL' => 'Florida',
'GA' => 'Georgia',
'HI' => 'Hawaii',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'IA' => 'Iowa',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine',
'MD' => 'Maryland',
'MA' => 'Massachusetts',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MS' => 'Mississippi',
'MO' => 'Missouri',
'MT' => 'Montana',
'NE' => 'Nebraska',
'NV' => 'Nevada',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NY' => 'New York',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VT' => 'Vermont',
'VA' => 'Virginia',
'WA' => 'Washington',
'WV' => 'West Virginia',
'WI' => 'Wisconsin',
'WY' => 'Wyoming'
],
"width" => 2
],
[
"label" => "ZIP/Postal Code",
"icon" => "fas fa-mail-bulk",
"name" => "zip",
"maxlength" => 10,
"width" => 3,
"value" => $family->getZip(),
"error" => "Enter a valid 5 or 9 digit ZIP code.",
"pattern" => "[0-9]{5}(-?[0-9]{4})?"
],
[
"label" => "Phone Number",
"icon" => "fas fa-phone",
"name" => "phone",
"width" => 3,
"maxlength" => 10,
"type" => "tel",
"pattern" => "[0-9]{10}",
"value" => $family->getPhone(),
"error" => "Enter a valid ten-digit phone number."
],
[
"label" => "Email",
"icon" => "fas fa-at",
"name" => "email",
"maxlength" => 255,
"type" => "email",
"value" => $family->getEmail(),
"error" => "Enter an email address."
],
[
"label" => "Newsletter Preference",
"icon" => "fas fa-newspaper",
"name" => "newsletter_method",
"type" => "select",
"value" => $family->getNewsletter(),
"error" => "Choose an option.",
"options" => [
"1" => "Email ($25)",
"2" => "Paper ($35)",
"3" => "Email and Paper ($35)"
]
],
[
"label" => "Membership Expiration",
"icon" => "fas fa-calendar",
"name" => "date",
"type" => "date",
"width" => 3,
"value" => date("Y-m-d", $family->getExpires()),
"error" => "Choose a valid date."
]
];
foreach ($textboxes as $item) {
?>
<div class="col-12 col-md-<?php echo (empty($item['width']) ? "4" : $item['width']); ?>">
<div class="form-group mb-3">
<label class="mb-0"><?php echo $item['label']; ?>:</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="<?php echo $item['icon']; ?>"></i></span>
</div>
<?php if (empty($item['type']) || $item['type'] != "select") { ?>
<input type="<?php echo (empty($item['type']) ? "text" : $item['type']); ?>"
name="<?php echo $item['name']; ?>"
class="form-control"
placeholder=""
aria-label="<?php echo $item['label']; ?>"
maxlength="<?php echo $item['maxlength']; ?>"
<?php
if (!empty($item['pattern'])) {
?>
pattern="<?php echo $item['pattern']; ?>"
<?php
}
?>
<?php
if (!empty($item['value'])) {
?>
value="<?php echo htmlspecialchars($item['value']); ?>"
<?php
}
?>required />
<?php } else if ($item['type'] == "select") { ?>
<select class="form-control"
name="<?php echo $item['name']; ?>"
aria-label="<?php echo $item['label']; ?>"
required>
<?php
foreach ($item['options'] as $value => $label) {
$selected = "";
if (!empty($item['value']) && $value == $item['value']) {
$selected = " selected";
}
echo "<option value=\"$value\"$selected>$label</option>\n";
}
?>
</select>
<?php
}
?>
<div class="invalid-feedback">
<?php echo $item['error']; ?>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
<hr />
<h4><i class="fas fa-user-graduate fa-fw"></i> Children</h4>
<p class="card-text ml-2 mb-1">
<i class="fas fa-info-circle"></i> <?php $Strings->get("To remove a child, delete the contents of the Name box."); ?>
<div class="list-group" id="child_list">
<?php
if (count($family->getChildren()) > 0) {
foreach ($family->getChildren() as $child) {
$childid = $child->getID();
include __DIR__ . "/../lib/template_child_entry.php";
}
} else {
include __DIR__ . "/../lib/template_child_entry.php";
}
?>
</div>
<div class="btn btn-sm btn-primary mt-1" id="add_child_row">
<i class="fas fa-plus"></i> Add another
</div>
<hr />
<h4><i class="fas fa-check-circle fa-fw"></i> Consent</h4>
<div>
<div>
<?php $Strings->get("Okay to use photos?"); ?>
<br />
<span class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="photo_permission" id="photo_permission" value="1" <?php
if ($family->getPhotoPermission()) {
echo "checked";
}
?> required>
<label class="form-check-label" for="photo_permission">Yes</label>
</span>
<span class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="photo_permission" id="photo_permission" value="0" <?php
if (!$family->getPhotoPermission()) {
echo "checked";
}
?> required>
<label class="form-check-label" for="photo_permission">No</label>
</span>
</div>
<div class="mt-2">
<span class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="private" id="private" value="1" <?php
if ($family->getPrivate()) {
echo "checked";
}
?>>
<label class="form-check-label" for="private"><?php $Strings->get("Member wishes to be remain private (excluded from member directory)"); ?></label>
</span>
</div>
</div>
</div>
<?php
if ($editing) {
?>
<input type="hidden" name="familyid" value="<?php echo $family->getID(); ?>" />
<?php
}
?>
<input type="hidden" name="source" value="editfamily" />
<input type="hidden" name="action" value="editfamily" />
<div class="card-footer d-flex">
<button type="submit" class="btn btn-success mr-1" id="savebutton">
<i class="fas fa-save"></i> <?php $Strings->get("Save"); ?>
</button>
<?php if ($editing) { ?>
<a href="./app.php?page=confirmdelete&id=<?php echo $family->getID(); ?>" class="btn btn-danger ml-auto">
<i class="fas fa-times"></i> <?php $Strings->get("Delete"); ?>
</a>
<?php } ?>
</div>
</div>
</form>

@ -24,9 +24,8 @@ $data = [
if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id']])) {
$editing = true;
$payment = $database->get("payments", ['paymentid (id)', "familyid (family)", "amount", "date", "type", "paid"], ["paymentid" => $_GET['id']]);
$payment = $database->get("payments", ['paymentid (id)', "familyid (family)", "amount", "amountpaid", "date", "type"], ["paymentid" => $_GET['id']]);
$payment["date"] = date("Y-m-d", strtotime($payment["date"]));
$payment["paid"] = ($payment["paid"] == 1 ? true : false);
$data = $payment;
}
?>
@ -54,25 +53,9 @@ if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id'
<div class="row">
<?php
$families = $database->select("families", ["familyid (id)", "familyname (name)", "mother_name", "father_name"]);
$familylist = [
"" => $Strings->get("Choose...", false)
];
foreach ($families as $f) {
$familylist[$f['id']] = "$f[name], $f[father_name] and $f[mother_name]";
}
$textboxes = [
[
"label" => "Family",
"icon" => "fas fa-users",
"name" => "familyid",
"type" => "select",
"value" => $data["family"],
"options" => $familylist,
"error" => "Choose a family."
],
[
"label" => "Amount",
"label" => "Total Amount",
"icon" => "fas fa-dollar-sign",
"name" => "amount",
"type" => "number",
@ -81,6 +64,16 @@ if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id'
"width" => 2,
"error" => "Enter a dollar amount."
],
[
"label" => "Amount Paid",
"icon" => "fas fa-dollar-sign",
"name" => "amountpaid",
"type" => "number",
"maxlength" => 5,
"value" => $data["amountpaid"],
"width" => 2,
"error" => "Enter a dollar amount."
],
[
"label" => "Date",
"icon" => "fas fa-calendar",
@ -169,30 +162,6 @@ if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id'
}
?>
<div class="col-12 col-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" name="paid" id="paid" <?php
if ($data["paid"]) {
echo "checked";
}
?>>
<label class="form-check-label" for="paid">
<?php $Strings->get("Mark as paid"); ?>
</label>
</div>
</div>
<?php if (!$editing) { ?>
<div class="col-12 col-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="1" name="extendmembership" id="extendmembership" checked>
<label class="form-check-label" for="extendmembership">
<?php $Strings->get("This payment is a membership renewal (automatically add one year to the family's membership)"); ?>
</label>
</div>
</div>
<?php } ?>
</div>
</div>

@ -0,0 +1,396 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
redirectIfNotLoggedIn();
$editing = false;
$data = [
"id" => null,
"camperid" => null,
"adultid" => null,
"youthid" => null,
"firstname" => "",
"lastname" => "",
"address" => "",
"zip" => "",
"phone1" => "",
"phone2" => "",
"email" => "",
"unit" => "",
"shirt" => "",
"sex" => "",
"parentname" => "",
"rank" => ""
];
$type = "camper";
if (!empty($VARS['type']) && preg_match("/(camper|adult|youth)/", $VARS['type'])) {
$type = $VARS['type'];
}
if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])) {
$personid = $VARS['id'];
$data = $database->get('people', ['personid (id)',
'camperid',
'adultid',
'youthid',
'firstname',
'lastname',
'address',
'zip',
'phone1',
'phone2',
'email',
'unit',
'shirt',
'sex'], ['personid' => $personid]);
if (!empty($data["camperid"])) {
$type = "camper";
$data = array_merge($data, $database->get('campers', ['parentname', 'rank'], ['camperid' => $data["camperid"]]));
} else if (!empty($data["adultid"])) {
$type = "adult";
$data = array_merge($data, $database->get('adults', ['days', 'position'], ['adultid' => $data["adultid"]]));
} else if (!empty($data["youthid"])) {
$type = "youth";
$data = array_merge($data, $database->get('youth', ['days', 'position'], ['youthid' => $data["youthid"]]));
}
$editing = true;
}
?>
<form action="action.php" method="post" id="editform">
<div class="card">
<h3 class="card-header d-flex">
<div>
<?php
if ($editing) {
?>
<i class="fas fa-edit"></i> <?php $Strings->build("Editing $type", ['person' => "<span id=\"name_title\">" . htmlentities($data["firstname"] . " " . $data["lastname"]) . "</span>"]); ?>
<?php
} else {
?>
<i class="fas fa-edit"></i> <?php $Strings->get("Adding $type"); ?>
<?php
}
?>
</div>
<a href="./app.php?page=people" class="ml-auto btn btn-outline-info btn-sm">
<i class="fas fa-times"></i> <?php $Strings->get("Cancel"); ?>
</a>
</h3>
<div class="card-body">
<div class="row">
<?php
$textboxes = [
[
"label" => "First Name",
"name" => "firstname",
"maxlength" => 255,
"width" => 6,
"value" => $data["firstname"],
"error" => "Enter the person's first name."
],
[
"label" => "Last Name",
"name" => "lastname",
"width" => 6,
"maxlength" => 255,
"value" => $data["lastname"],
"error" => "Enter the person's last name."
]
];
if ($type == "camper") {
$textboxes = array_merge($textboxes, [
[
"label" => "Parent/Guardian Name",
"name" => "parentname",
"width" => 12,
"maxlength" => 255,
"value" => $data["parentname"],
"error" => "Enter the parent or guardian's full name."
]
]);
}
$textboxes = array_merge($textboxes, [
[
"label" => "Address",
"name" => "address",
"maxlength" => 500,
"width" => 8,
"value" => $data["address"],
"error" => "Enter the person's home address."
],
[
"label" => "ZIP Code",
"name" => "zip",
"maxlength" => 10,
"width" => 4,
"value" => $data["zip"],
"pattern" => "[0-9]{5}(-?[0-9]{4})?",
"error" => "Enter a valid 5 or 9 digit ZIP code."
],
[
"label" => "Phone Number",
"name" => "phone1",
"type" => "tel",
"maxlength" => 20,
"width" => 3,
"value" => $data["phone1"],
"pattern" => "[0-9]{10}",
"error" => "Enter a 10-digit phone number (numbers only)."
],
[
"label" => "Email",
"name" => "email",
"maxlength" => 255,
"width" => 5,
"type" => "email",
"value" => $data["email"],
"error" => "Enter your email address."
]
]);
if ($type == "camper") {
$textboxes = array_merge($textboxes, [
[
"label" => "Pack #",
"name" => "unit",
"width" => 2,
"maxlength" => 4,
"pattern" => "[0-9]{3,4}",
"value" => $data["unit"],
"error" => "Enter the pack number."
],
[
"label" => "Rank",
"name" => "rank",
"type" => "select",
"width" => 2,
"value" => $data["rank"],
"options" => [
"" => "Choose...",
"Tiger" => "Tiger",
"Wolf" => "Wolf",
"Bear" => "Bear",
"Webelos" => "Webelos",
"Arrow of Light" => "Arrow of Light",
],
"error" => "Choose a rank."
]
]);
}
if ($type == "youth") {
$textboxes = array_merge($textboxes, [
[
"label" => "Parent Name",
"name" => "parentname",
"width" => 4,
"maxlength" => 255,
"value" => $data["parentname"],
"error" => "Enter the parent or guardian's full name."
],
[
"label" => "Parent Phone",
"name" => "phone2",
"type" => "tel",
"maxlength" => 20,
"width" => 3,
"value" => $data["phone2"],
"pattern" => "[0-9]{10}",
"error" => "Enter a 10-digit phone number (numbers only)."
]
]);
}
if ($type == "adult" || $type == "youth") {
if ($type == "adult") {
$positions = [
"None" => "No Preference",
"Den Walker" => "Den Walker",
"Station Leader" => "Station Leader",
"Tot Lot" => "Tot Lot",
"First Aid" => "First Aid",
"Floater" => "Floater"
];
} else {
$positions = [
"None" => "No Preference",
"Den Chief" => "Den Chief",
"Station" => "Station",
"Tot Lot" => "Tot Lot",
"Floater" => "Floater"
];
}
$textboxes = array_merge($textboxes, [
[
"label" => "Available Days",
"name" => "days",
"type" => "checkboxes",
"options" => [
"Tu" => "Tuesday",
"We" => "Wednesday",
"Th" => "Thursday",
"Fr" => "Friday",
],
"error" => "Choose at least one day."
],
[
"label" => "Preferred Position",
"name" => "position",
"type" => "select",
"width" => 5,
"options" => $positions,
"error" => "Choose a position."
]
]);
}
$textboxes = array_merge($textboxes, [
[
"label" => "Shirt Size",
"name" => "shirt",
"type" => "select",
"value" => $data["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",
"type" => "select",
"width" => 3,
"value" => $data["sex"],
"options" => [
"" => "Choose...",
"M" => "Male",
"F" => "Female"
],
"error" => "Choose a gender."
],
]);
foreach ($textboxes as $item) {
?>
<div class="col-12 col-md-<?php echo (empty($item['width']) ? "4" : $item['width']); ?>">
<div class="form-group mb-3">
<label class="mb-0"><?php echo $item['label']; ?>:</label>
<div class="input-group">
<?php if (empty($item['type']) || ($item['type'] != "select" && $item['type'] != "checkboxes")) { ?>
<input type="<?php echo (empty($item['type']) ? "text" : $item['type']); ?>"
name="<?php echo $item['name']; ?>"
data-name="<?php echo $item['name']; ?>"
class="form-control"
placeholder=""
aria-label="<?php echo $item['label']; ?>"
maxlength="<?php echo $item['maxlength']; ?>"
<?php
if (!empty($item['pattern'])) {
?>
pattern="<?php echo $item['pattern']; ?>"
<?php
}
?>
<?php
if (!empty($item['value'])) {
?>
value="<?php echo htmlspecialchars($item['value']); ?>"
<?php
}
if (empty($item['optional'])) {
echo "required";
}
?> />
<?php } else if ($item['type'] == "select") { ?>
<select class="form-control"
name="<?php echo $item['name']; ?>"
data-name="<?php echo $item['name']; ?>"
aria-label="<?php echo $item['label']; ?>"
<?php
if (empty($item['optional'])) {
echo "required";
}
?>>
<?php
foreach ($item['options'] as $value => $label) {
$selected = "";
if (!empty($item['value']) && $value == $item['value']) {
$selected = " selected";
}
echo "<option value=\"$value\"$selected>$label</option>\n";
}
?>
</select>
<?php
} else if ($item['type'] == "checkboxes") {
?>
<div class="d-flex justify-content-left flex-wrap">
<?php
foreach ($item['options'] as $value => $label) {
?>
<div class="form-check m-1">
<input class="form-check-input" type="checkbox" data-name="<?php echo $item['name']; ?>" name="<?php echo $item['name']; ?>[]" value="<?php echo $value; ?>">
<label class="form-check-label">
<?php echo $label; ?>
</label>
</div>
<?php
}
?>
</div>
<?php
}
?>
<div class="invalid-feedback">
<?php echo $item['error']; ?>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
if ($editing) {
?>
<input type="hidden" name="personid" value="<?php echo $data['id']; ?>" />
<?php
}
?>
<input type="hidden" name="type" value="<?php echo $type; ?>" />
<input type="hidden" name="source" value="editperson" />
<input type="hidden" name="action" value="editperson" />
<div class="card-footer d-flex">
<button type="submit" class="btn btn-success mr-1" id="savebutton">
<i class="fas fa-save"></i> <?php $Strings->get("Save"); ?>
</button>
<?php if ($editing) { ?>
<a href="./app.php?page=confirmdelete&id=<?php echo $data['id']; ?>" class="btn btn-danger ml-auto">
<i class="fas fa-times"></i> <?php $Strings->get("Delete"); ?>
</a>
<?php } ?>
</div>
</div>
</form>

@ -1,128 +0,0 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
redirectIfNotLoggedIn();
$user = new User($_SESSION['uid']);
if (!$user->hasPermission("HACHEPORTAL_VIEW")) {
header("Location: ./app.php?msg=no_permission");
die();
}
$editpermission = $user->hasPermission("HACHEPORTAL_EDIT");
$editable = ($editpermission && !empty($_GET['edit']));
$events = $database->select('events', ['eventid (id)', 'event (name)']);
?>
<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<h4>
<i class="fas fa-sort-amount-up"></i>
<?php $Strings->get("Popularity"); ?>
</h4>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item d-flex justify-content-between">
<b><?php $Strings->get("Event"); ?></b>
<b><?php $Strings->get("Families"); ?></b>
</li>
<?php
$interests = $database->select("interests", ["[>]events" => ['eventid' => 'eventid']], ['interests.eventid (id)', 'events.event (name)']);
$ranking = [];
$rankingtitles = [];
foreach ($interests as $ev) {
if (empty($ranking[$ev['id']])) {
$ranking[$ev['id']] = 1;
$rankingtitles[$ev['id']] = $ev['name'];
} else {
$ranking[$ev['id']] ++;
}
}
arsort($ranking);
foreach ($ranking as $k => $v) {
?>
<li class="list-group-item d-flex justify-content-between">
<span><?php echo $rankingtitles[$k]; ?></span>
<span><?php echo $v; ?></span>
</li>
<?php
}
?>
</ul>
</div>
</div>
<div class="col-sm-6">
<?php if ($editable) { ?>
<form action="action.php" method="POST">
<input type="hidden" name="action" value="editevents" />
<input type="hidden" name="source" value="events" />
<?php } ?>
<div class="card">
<div class="card-header">
<h4 class="d-flex justify-content-between">
<span>
<i class="fas fa-list-ul"></i>
<?php $Strings->get("Event List"); ?>
</span>
<?php if ($editpermission && !$editable) { ?>
<span>
<a class="btn btn-primary btn-sm" href="./app.php?page=events&edit=1">
<i class="fas fa-edit"></i>
<?php $Strings->get("Edit"); ?>
</a>
</span>
<?php } ?>
</h4>
</div>
<ul class="list-group list-group-flush">
<?php
foreach ($events as $ev) {
?>
<li class="list-group-item py-0 px-1">
<?php
if ($editable) {
?>
<input type="text" class="form-control form-control-sm" name="events[<?php echo $ev['id']; ?>]" value="<?php echo htmlspecialchars($ev['name']); ?>" />
<?php
} else {
echo $ev['name'];
}
?>
</li>
<?php
}
?>
<?php
if ($editable) {
for ($i = 0; $i < 5; $i++) {
?>
<li class="list-group-item py-0 px-1">
<input type="text" class="form-control form-control-sm" name="events[]" value="" />
</li>
<?php
}
}
?>
</ul>
<?php if ($editable) { ?>
<div class="card-footer">
<button type="submit" class="btn btn-success"><i class="fas fa-save"></i> <?php $Strings->get("Save"); ?></button>
</div>
<?php } ?>
</div>
<?php if ($editable) { ?>
</form>
<?php } ?>
</div>
</div>

@ -10,17 +10,46 @@
<h1><i class="fas fa-fw fa-users"></i> <?php echo $database->count('campers'); ?></h1>
</div>
<div class="card-footer">
<a href="app.php?page=campers" class="text-light"><i class="fas fa-arrow-right"></i> <?php $Strings->get("View Campers"); ?></a>
<a href="app.php?page=people&filter=camper" class="text-light"><i class="fas fa-arrow-right"></i> <?php $Strings->get("View Campers"); ?></a>
</div>
</div>
<div class="card bg-indigo text-light">
<div class="card-body">
<h4 class="card-title"><?php $Strings->get("Volunteers") ?></h4>
<h4 class="card-title"><?php $Strings->get("Adults") ?></h4>
<h1><i class="fas fa-fw fa-users"></i> <?php echo $database->count('adults'); ?></h1>
</div>
<div class="card-footer">
<a href="app.php?page=volunteers" class="text-light"><i class="fas fa-arrow-right"></i> <?php $Strings->get("View Volunteers"); ?></a>
<a href="app.php?page=people&filter=adult" class="text-light"><i class="fas fa-arrow-right"></i> <?php $Strings->get("View Adults"); ?></a>
</div>
</div>
<div class="card bg-indigo text-light">
<div class="card-body">
<h4 class="card-title"><?php $Strings->get("Youth") ?></h4>
<h1><i class="fas fa-fw fa-users"></i> <?php echo $database->count('youth'); ?></h1>
</div>
<div class="card-footer">
<a href="app.php?page=people&filter=youth" class="text-light"><i class="fas fa-arrow-right"></i> <?php $Strings->get("View Youth"); ?></a>
</div>
</div>
</div>
<div class="card-deck mt-sm-4">
<div class="card bg-green text-light">
<div class="card-body">
<h4 class="card-title"><?php $Strings->get("Total Income") ?></h4>
<h1><i class="fas fa-fw fa-money-bill-alt"></i> $<?php
$amounts = $database->select("payments", "amount");
$total = 0.0;
foreach ($amounts as $amt) {
$total += $amt;
}
echo number_format($total, 2);
?></h1>
</div>
<div class="card-footer">
<a href="app.php?page=payments" class="text-light"><i class="fas fa-arrow-right"></i> <?php $Strings->get("View Payments"); ?></a>
</div>
</div>

@ -12,25 +12,22 @@ if (!$user->hasPermission("HACHEPORTAL_VIEW")) {
die();
}
$writeaccess = $user->hasPermission("HACHEPORTAL_EDIT");
$payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount', 'paid', 'date', 'type']);
$payments = $database->select("payments", ['familyid', 'paymentid (id)', 'amount', 'amountpaid', 'date', 'type']);
?>
<div class="btn-group">
<?php if ($writeaccess) { ?>
<a href="app.php?page=editpayment" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Manual Entry"); ?></a>
<?php } ?>
<a href="app.php?page=editpayment" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Manual Entry"); ?></a>
</div>
<table id="paytable" class="table table-bordered table-hover table-sm">
<thead>
<tr>
<th data-priority="0"></th>
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
<th data-priority="1"><i class="fas fa-users hidden-sm"></i> <?php $Strings->get('Family'); ?></th>
<th data-priority="1"><i class="fas fa-dollar-sign hidden-sm"></i> <?php $Strings->get('Amount'); ?></th>
<th data-priority="1"><i class="fas fa-users hidden-sm"></i> <?php $Strings->get('Last Name'); ?></th>
<th data-priority="1"><i class="fas fa-dollar-sign hidden-sm"></i> <?php $Strings->get('Total'); ?></th>
<th data-priority="1"><i class="fas fa-dollar-sign hidden-sm"></i> <?php $Strings->get('Paid'); ?></th>
<th data-priority="2"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Date'); ?></th>
<th data-priority="2"><i class="far fa-check-square hidden-sm"></i> <?php $Strings->get('Status'); ?></th>
<th data-priority="3"><i class="fas fa-bars hidden-sm"></i> <?php $Strings->get('Type'); ?></th>
</tr>
</thead>
@ -40,19 +37,18 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount
?>
<tr>
<td></td>
<td>
<a class="btn btn-primary btn-sm" href="app.php?page=editpayment&id=<?php echo $p['id']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
</td>
<td>
<?php
if ($writeaccess) {
?>
<a class="btn btn-primary btn-sm" href="app.php?page=editpayment&id=<?php echo $p['id']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
<?php
}
$familynames = $database->select('people', 'lastname', ['familyid' => $p['familyid']]);
echo htmlentities(implode(", ", $familynames));
?>
</td>
<td><a href="./app.php?page=viewfamily&id=<?php echo $p['familyid']; ?>"><?php echo (new Family())->load($p['familyid'])->getName(); ?></a></td>
<td>$<?php echo number_format($p['amount'], 2); ?></td>
<td>$<?php echo number_format($p['amountpaid'], 2); ?></td>
<td><?php echo date("Y-m-d H:i:s", strtotime($p['date'])); ?></td>
<td><?php $p['paid'] ? $Strings->get("Paid") : $Strings->get("Unpaid"); ?></td>
<td><?php $Strings->get($p["type"]); ?></td>
</tr>
<?php
@ -63,10 +59,10 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount
<tr>
<th data-priority="0"></th>
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
<th data-priority="1"><i class="fas fa-users hidden-sm"></i> <?php $Strings->get('Family'); ?></th>
<th data-priority="1"><i class="fas fa-dollar-sign hidden-sm"></i> <?php $Strings->get('Amount'); ?></th>
<th data-priority="1"><i class="fas fa-users hidden-sm"></i> <?php $Strings->get('Last Name'); ?></th>
<th data-priority="1"><i class="fas fa-dollar-sign hidden-sm"></i> <?php $Strings->get('Total'); ?></th>
<th data-priority="1"><i class="fas fa-dollar-sign hidden-sm"></i> <?php $Strings->get('Paid'); ?></th>
<th data-priority="2"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Date'); ?></th>
<th data-priority="2"><i class="far fa-check-square hidden-sm"></i> <?php $Strings->get('Status'); ?></th>
<th data-priority="3"><i class="fas fa-bars hidden-sm"></i> <?php $Strings->get('Type'); ?></th>
</tr>
</tfoot>

@ -10,7 +10,20 @@ $user = new User($_SESSION['uid']);
?>
<div>
<a href="app.php?page=editcamper" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Camper"); ?></a>
<a href="app.php?page=editperson&type=camper" class="btn btn-success mb-1"><i class="fas fa-plus"></i> <?php $Strings->get("Add Camper"); ?></a>
<a href="app.php?page=editperson&type=adult" class="btn btn-success mb-1"><i class="fas fa-plus"></i> <?php $Strings->get("Add Adult"); ?></a>
<a href="app.php?page=editperson&type=youth" class="btn btn-success mb-1"><i class="fas fa-plus"></i> <?php $Strings->get("Add Youth"); ?></a>
<?php
$where = [];
if (!empty($VARS['filter']) && preg_match("/(camper|adult|youth)/", $VARS['filter'])) {
$where = [
$VARS['filter'] . 'id[!]' => null
];
?>
<div class="alert alert-blue-grey d-inline-block mt-1 ml-md-2"><i class="fa fa-filter fa-fw"></i> <?php $Strings->build("Only showing {x}s.", ["x" => $VARS['filter']]); ?> &nbsp; <a href="app.php?page=people" class="btn btn-sm btn-blue-grey text-light"><?php $Strings->get("Remove Filter"); ?></a></div>
<?php
}
?>
</div>
<table id="campertable" class="table table-bordered table-hover table-sm">
@ -20,23 +33,22 @@ $user = new User($_SESSION['uid']);
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
<th data-priority="1"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('First'); ?></th>
<th data-priority="2"><i class="fas fa-users hidden-sm"></i> <?php $Strings->get('Last'); ?></th>
<th data-priority="2"><i class="fas fa-male hidden-sm"></i> <?php $Strings->get('Parent'); ?></th>
<th data-priority="2"><i class="fas fa-user-tag hidden-sm"></i> <?php $Strings->get('Type'); ?></th>
<th data-priority="3"><i class="fas fa-phone hidden-sm"></i> <?php $Strings->get('Phone'); ?></th>
<th data-priority="4"><i class="fas fa-at hidden-sm"></i> <?php $Strings->get('Email'); ?></th>
<th data-priority="5"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Unit'); ?></th>
<th data-priority="5"><i class="fas fa-certificate hidden-sm"></i> <?php $Strings->get('Rank'); ?></th>
<th data-priority="5"><i class="fas fa-tshirt hidden-sm"></i> <?php $Strings->get('Shirt'); ?></th>
<th data-priority="5"><i class="fas fa-restroom hidden-sm"></i> <?php $Strings->get('Sex'); ?></th>
</tr>
</thead>
<tbody>
<?php
$campers = $database->select(
$people = $database->select(
"people", [
"[>]campers" => [
"camperid" => "camperid"
]
], [
'personid (id)',
'camperid',
'adultid',
'youthid',
'firstname',
'lastname',
'address',
@ -46,28 +58,31 @@ $user = new User($_SESSION['uid']);
'email',
'unit',
'shirt',
'sex',
'parentname',
'rank'
], [
'people.camperid[!]' => null
]);
'sex'
], $where);
foreach ($campers as $person) {
foreach ($people as $person) {
?>
<tr>
<td></td>
<td>
<a class="btn btn-info btn-sm" href="app.php?page=viewperson&id=<?php echo $person['id']; ?>"><i class="fas fa-eye"></i> <?php $Strings->get("View"); ?></a>
<a class="btn btn-primary btn-sm" href="app.php?page=editperson&id=<?php echo $person['id']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
</td>
<td><?php echo $person['firstname']; ?></td>
<td><?php echo $person['lastname']; ?></td>
<td><?php echo $person['parentname']; ?></td>
<td><?php
if (!is_null($person['camperid'])) {
$Strings->get("Camper");
} else if (!is_null($person['adultid'])) {
$Strings->get("Adult");
} else if (!is_null($person['youthid'])) {
$Strings->get("Youth");
}
?></td>
<td><?php echo $person['phone1']; ?></td>
<td><?php echo $person['email']; ?></td>
<td><?php echo $person['unit']; ?></td>
<td><?php echo $person['rank']; ?></td>
<td><?php echo $person['shirt']; ?></td>
<td><?php echo $person['sex']; ?></td>
</tr>
<?php
@ -80,11 +95,11 @@ $user = new User($_SESSION['uid']);
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
<th data-priority="1"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('First'); ?></th>
<th data-priority="2"><i class="fas fa-users hidden-sm"></i> <?php $Strings->get('Last'); ?></th>
<th data-priority="2"><i class="fas fa-male hidden-sm"></i> <?php $Strings->get('Parent'); ?></th>
<th data-priority="2"><i class="fas fa-user-tag hidden-sm"></i> <?php $Strings->get('Type'); ?></th>
<th data-priority="3"><i class="fas fa-phone hidden-sm"></i> <?php $Strings->get('Phone'); ?></th>
<th data-priority="4"><i class="fas fa-at hidden-sm"></i> <?php $Strings->get('Email'); ?></th>
<th data-priority="5"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Unit'); ?></th>
<th data-priority="5"><i class="fas fa-certificate hidden-sm"></i> <?php $Strings->get('Rank'); ?></th>
<th data-priority="5"><i class="fas fa-tshirt hidden-sm"></i> <?php $Strings->get('Shirt'); ?></th>
<th data-priority="5"><i class="fas fa-restroom hidden-sm"></i> <?php $Strings->get('Sex'); ?></th>
</tr>
</tfoot>

@ -1,224 +0,0 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
redirectIfNotLoggedIn();
$user = new User($_SESSION['uid']);
if (!$user->hasPermission("HACHEPORTAL_VIEW")) {
header("Location: ./app.php?msg=no_permission");
die();
}
$writeaccess = $user->hasPermission("HACHEPORTAL_EDIT");
if (empty($VARS['id']) || !$database->has('families', ['familyid' => $VARS['id']])) {
header("Location: ./app.php?page=families&msg=family_doesnt_exist");
}
$famid = $VARS['id'];
$family = (new Family())->load($famid);
?>
<div class="card">
<div class="card-body">
<div class="card-title d-flex flex-wrap justify-content-between">
<h3>
<a href="app.php?page=families" class="text-body">
<i class="fas fa-arrow-left"></i>
</a>
<?php echo $family->getName(); ?> <?php $Strings->get("Family"); ?>
</h3>
<div>
<?php
if ($writeaccess) {
?>
<a href="app.php?page=editfamily&id=<?php echo $family->getID(); ?>&source=viewfamily" class="btn btn-primary"><i class="fas fa-edit"></i> <?php $Strings->get('Edit Family'); ?></a>
<?php
}
?>
</div>
</div>
<?php
if ($family->getPrivate()) {
?>
<div class="alert alert-indigo">
<i class="fas fa-users"></i> <i class="fas fa-shield-alt"></i> <i class="fas fa-info-circle"></i> <?php $Strings->get("This family wishes to remain private. Do not share this information, even with other HACHE members."); ?>
</div>
<?php
}
?>
<div class="d-flex justify-content-around flex-wrap">
<?php
$newsletter = "Email";
switch ($family->getNewsletter()) {
case 1:
$newsletter = $Strings->get("Email", false);
break;
case 2:
$newsletter = $Strings->get("Print", false);
break;
case 3:
$newsletter = $Strings->get("Email and Print", false);
break;
}
$items = [
[
"value" => $family->getFather(),
"icon" => "fas fa-male",
"label" => "Father"
],
[
"value" => $family->getMother(),
"icon" => "fas fa-female",
"label" => "Mother"
],
[
"value" => $family->getPhone(),
"icon" => "fas fa-phone",
"label" => "Phone"
],
[
"value" => $family->getEmail(),
"icon" => "fas fa-at",
"label" => "Email"
],
[
"value" => $family->getAddress(),
"icon" => "fas fa-home",
"label" => "Address"
],
[
"value" => $family->getCity(),
"icon" => "fas fa-city",
"label" => "City"
],
[
"value" => $family->getState(),
"icon" => "fas fa-flag",
"label" => "State"
],
[
"value" => $family->getZip(),
"icon" => "fas fa-mail-bulk",
"label" => "ZIP Code"
],
[
"value" => $family->getPhotoPermission() ? $Strings->get("Yes", false) : $Strings->get("No", false),
"icon" => "fas fa-camera",
"label" => "Photo Permission"
],
[
"value" => $newsletter,
"icon" => "fas fa-newspaper",
"label" => "Newsletter"
],
[
"value" => date("M j Y", $family->getExpires()),
"icon" => "fas fa-calendar",
"label" => "Expires"
],
];
foreach ($items as $i) {
?>
<div class="list-group-item h5 mb-2">
<i class="<?php echo $i['icon']; ?>"></i> <?php
$Strings->get($i['label']);
echo ": ";
echo $i['value'];
?>
</div>
<?php
}
?>
</div>
<h4 class="mt-4"><?php $Strings->get("Children"); ?></h4>
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th><i class="fas fa-user-graduate"></i> <?php $Strings->get("Name"); ?></th>
<th><i class="fas fa-birthday-cake"></i> <?php $Strings->get("Born"); ?></th>
<th><i class="fas fa-graduation-cap"></i> <?php $Strings->get("Graduated"); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($family->getChildren() as $c) {
?>
<tr>
<td><?php echo $c->getName(); ?></td>
<td><?php echo date("F Y", $c->getBirthday()); ?></td>
<td><?php $c->isGraduated() ? $Strings->get("Yes") : $Strings->get("No"); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<h4 class="mt-4"><?php $Strings->get("Interests"); ?></h4>
<?php
$events = $database->select('events', ["[>]interests" => ['eventid' => 'eventid']], ['event (name)'], ['familyid' => $family->getID()]);
$eventcount = count($events);
if ($eventcount > 0) {
$cola = [];
$colb = [];
for ($i = 0; $i < $eventcount; $i++) {
if ($i % 2 === 0) {
$cola[] = $events[$i];
} else {
$colb[] = $events[$i];
}
}
?>
<div class="row">
<div class="col-12 col-md-6">
<ul class="list-group">
<?php
foreach ($cola as $ev) {
?>
<li class="list-group-item">
<?php echo $ev['name']; ?>
</li>
<?php
}
?>
</ul>
</div>
<div class="col-12 col-md-6">
<ul class="list-group">
<?php
foreach ($colb as $ev) {
?>
<li class="list-group-item">
<?php echo $ev['name']; ?>
</li>
<?php
}
?>
</ul>
</div>
</div>
<?php
} else {
?>
<i class="fas fa-info-circle"></i> <?php $Strings->get("No interests selected."); ?>
<?php
}
?>
</div>
</div>
Loading…
Cancel
Save