You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
327 lines
14 KiB
PHP
327 lines
14 KiB
PHP
<?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();
|
|
} else {
|
|
$famid = $VARS['id'];
|
|
$family = (new Family())->load($famid);
|
|
$editing = true;
|
|
}
|
|
?>
|
|
|
|
<form action="action.php" method="post">
|
|
|
|
<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()
|
|
],
|
|
[
|
|
"label" => "Father's Name",
|
|
"icon" => "fas fa-male",
|
|
"name" => "fathername",
|
|
"maxlength" => 255,
|
|
"value" => $family->getFather()
|
|
],
|
|
[
|
|
"label" => "Mother's Name",
|
|
"icon" => "fas fa-female",
|
|
"name" => "mothername",
|
|
"maxlength" => 255,
|
|
"value" => $family->getMother()
|
|
],
|
|
[
|
|
"label" => "Street Address",
|
|
"icon" => "fas fa-home",
|
|
"name" => "streetaddress",
|
|
"maxlength" => 500,
|
|
"value" => $family->getAddress()
|
|
],
|
|
[
|
|
"label" => "City",
|
|
"icon" => "fas fa-city",
|
|
"name" => "city",
|
|
"maxlength" => 255,
|
|
"width" => 3,
|
|
"value" => $family->getCity()
|
|
],
|
|
[
|
|
"label" => "State",
|
|
"icon" => "fas fa-flag",
|
|
"name" => "state",
|
|
"type" => "select",
|
|
"value" => $family->getState(),
|
|
"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()
|
|
],
|
|
[
|
|
"label" => "Phone Number",
|
|
"icon" => "fas fa-phone",
|
|
"name" => "phone",
|
|
"width" => 3,
|
|
"maxlength" => 20,
|
|
"value" => $family->getPhone()
|
|
],
|
|
[
|
|
"label" => "Email",
|
|
"icon" => "fas fa-at",
|
|
"name" => "email",
|
|
"maxlength" => 255,
|
|
"type" => "email",
|
|
"value" => $family->getEmail()
|
|
],
|
|
[
|
|
"label" => "Newsletter Preference",
|
|
"icon" => "fas fa-newspaper",
|
|
"name" => "newsletter_method",
|
|
"type" => "select",
|
|
"value" => $family->getNewsletter(),
|
|
"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())
|
|
]
|
|
];
|
|
|
|
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['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>
|
|
</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>
|
|
<p class="mb-0">
|
|
<?php $Strings->get("Okay to use photos?"); ?>
|
|
<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>
|
|
|
|
<?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">
|
|
<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>
|