Add member editing and deleting (close #5)
parent
c5f8b57b40
commit
b1fafb57dc
@ -1,4 +1,9 @@
|
||||
{
|
||||
"You do not have permission to do that.": "You do not have permission to do that.",
|
||||
"That family ID does not exist.": "That family ID does not exist."
|
||||
"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.",
|
||||
"To remove a child, delete the contents of the Name box.": "To remove a child, delete the contents of the Name box."
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
<?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/.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . "/../required.php";
|
||||
|
||||
$childinfo = ['name' => '', 'month' => 1, 'year' => date('Y', strtotime('now - 10 years')), 'graduated' => false];
|
||||
|
||||
if (isset($childid) && $database->has('people', ['personid' => $childid])) {
|
||||
$randomid = $childid;
|
||||
$chinfo = $database->get('people', ['name', 'birthday', 'graduated'], ['personid' => $childid]);
|
||||
$childinfo['name'] = $chinfo['name'];
|
||||
$childinfo['graduated'] = $chinfo['graduated'] == true;
|
||||
$childinfo['month'] = date('m', strtotime($chinfo['birthday']));
|
||||
$childinfo['year'] = date('Y', strtotime($chinfo['birthday']));
|
||||
} else {
|
||||
do {
|
||||
$randomid = mt_rand(0, 9999999999);
|
||||
} while ($database->has('people', ['personid' => $randomid]));
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="list-group-item">
|
||||
<input type="hidden" name="child[ids][]" value="<?php echo $randomid; ?>" />
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-4">
|
||||
<div class="form-group">
|
||||
<label>Name:</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-user-graduate"></i></span>
|
||||
</div>
|
||||
<input type="text" name="child[name][<?php echo $randomid; ?>]" class="form-control" value="<?php echo htmlspecialchars($childinfo['name']); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-3">
|
||||
<div class="form-group">
|
||||
<label>Birth month:</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-calendar"></i></span>
|
||||
</div>
|
||||
<select name="child[month][<?php echo $randomid; ?>]" class="form-control" value="<?php echo $childinfo['month']; ?>" >
|
||||
<?php
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$selected = "";
|
||||
if ($childinfo['month'] == $i) {
|
||||
$selected = " selected";
|
||||
}
|
||||
echo "<option value=$i$selected>" . date("F", mktime(0, 0, 0, $i, 2)) . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-3">
|
||||
<div class="form-group">
|
||||
<label>Birth year:</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-calendar-alt"></i></span>
|
||||
</div>
|
||||
<input type="number" name="child[year][<?php echo $randomid; ?>]" class="form-control" min="1980" max="<?php echo date('Y'); ?>" value="<?php echo $childinfo['year']; ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-2">
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="1" name="child[graduate][<?php echo $randomid; ?>]"<?php
|
||||
if ($childinfo['graduated']) {
|
||||
echo " checked";
|
||||
}
|
||||
?>>
|
||||
<label class="form-check-label mt-1">Graduated</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,59 @@
|
||||
<?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/. */
|
||||
|
||||
require_once __DIR__ . "/../required.php";
|
||||
|
||||
redirectifnotloggedin();
|
||||
|
||||
if (!is_empty($VARS['id'])) {
|
||||
if ($database->has('families', ['familyid' => $VARS['id']])) {
|
||||
$family = (new Family())->load($VARS['id']);
|
||||
} else {
|
||||
header('Location: app.php?page=families&msg=family_doesnt_exists');
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
header('Location: app.php?page=families&msg=family_doesnt_exists');
|
||||
die();
|
||||
}
|
||||
?>
|
||||
<div class="row justify-content-center">
|
||||
<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"); ?>
|
||||
</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>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item">
|
||||
<i class="fas fa-fw fa-users"></i> <?php echo $family->getName(); ?>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<i class="fas fa-fw fa-male"></i> <?php echo $family->getFather(); ?>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<i class="fas fa-fw fa-female"></i> <?php echo $family->getMother(); ?>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,318 @@
|
||||
<?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>
|
||||
<div class="ml-auto btn btn-outline-info btn-sm" id="cancelbtn">
|
||||
<i class="fas fa-times"></i> <?php $Strings->get("Cancel"); ?>
|
||||
</div>
|
||||
</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",
|
||||
"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)"
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
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="action" value="editfamily" />
|
||||
<input type="hidden" name="source" value="families" />
|
||||
|
||||
<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>
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
$("input[name=familyname]").on("input propertychange paste", function () {
|
||||
$('#name_title').text($(this).val());
|
||||
});
|
||||
|
||||
$("#add_child_row").click(function () {
|
||||
$.get("lib/template_child_entry.php", {}, function (resp) {
|
||||
$("#child_list").append(resp);
|
||||
});
|
||||
});
|
||||
|
||||
$("#cancelbtn").click(function () {
|
||||
history.back();
|
||||
});
|
Loading…
Reference in New Issue