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.

91 lines
4.2 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_VIEW")) {
header("Location: ./app.php?msg=no_permission");
die();
}
$writeaccess = $user->hasPermission("HACHEPORTAL_EDIT");
?>
<div>
<?php if ($writeaccess) { ?>
<a href="app.php?page=editfamily" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Family"); ?></a>
<?php } ?>
<?php
$expiringfilter = false;
if (!empty($_GET['filter']) && $_GET['filter'] == 'expiring') {
$expiringfilter = true;
?>
<div class="alert alert-blue-grey d-inline-block mt-1 ml-md-2"><i class="fa fa-filter fa-fw"></i> <?php $Strings->get("Only showing expired or expiring memberships."); ?> &nbsp; <a href="app.php?page=families" class="btn btn-sm btn-blue-grey text-light"><?php $Strings->get("Remove Filter"); ?></a></div>
<?php
}
?>
</div>
<table id="famtable" 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('Name'); ?></th>
<th data-priority="3"><i class="fas fa-male hidden-sm"></i> <?php $Strings->get('Father'); ?></th>
<th data-priority="3"><i class="fas fa-female hidden-sm"></i> <?php $Strings->get('Mother'); ?></th>
<th data-priority="2"><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-calendar hidden-sm"></i> <?php $Strings->get('Expires'); ?></th>
</tr>
</thead>
<tbody>
<?php
$where = [];
if ($expiringfilter) {
$where = ["expires[<]" => date("Y-m-d", strtotime("+1 month"))];
}
$families = $database->select("families", ['familyid (id)', 'familyname', 'phone', 'email', 'father_name (father)', 'mother_name (mother)', 'expires'], $where);
foreach ($families as $f) {
?>
<tr>
<td></td>
<td>
<a class="btn btn-info btn-sm" href="app.php?page=viewfamily&id=<?php echo $f['id']; ?>"><i class="fas fa-eye"></i> <?php $Strings->get("View"); ?></a>
<?php
if ($writeaccess) {
?>
<a class="btn btn-primary btn-sm" href="app.php?page=editfamily&id=<?php echo $f['id']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
<?php
}
?>
</td>
<td><?php echo $f['familyname']; ?></td>
<td><?php echo $f['father']; ?></td>
<td><?php echo $f['mother']; ?></td>
<td><?php echo $f['phone']; ?></td>
<td><?php echo $f['email']; ?></td>
<td class="<?php echo strtotime($f['expires']) < time() ? "text-red" : ""; ?>"><?php echo $f['expires']; ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<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('Name'); ?></th>
<th data-priority="3"><i class="fas fa-male hidden-sm"></i> <?php $Strings->get('Father'); ?></th>
<th data-priority="3"><i class="fas fa-female hidden-sm"></i> <?php $Strings->get('Mother'); ?></th>
<th data-priority="2"><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-calendar hidden-sm"></i> <?php $Strings->get('Expires'); ?></th>
</tr>
</tfoot>
</table>