Add membership expiration dates and payment status

master
Skylar Ittner 5 years ago
parent 5bab3580bf
commit 270ece840d

Binary file not shown.

@ -34,5 +34,14 @@
"DOCX": "DOCX", "DOCX": "DOCX",
"Amount": "Amount", "Amount": "Amount",
"Date": "Date", "Date": "Date",
"Paid": "Paid" "Status": "Status",
"Paid": "Paid",
"Unpaid": "Unpaid",
"Type": "Type",
"Online": "Online",
"Cash": "Cash",
"Check": "Check",
"Other": "Other",
"Free": "Free",
"Expires": "Expires"
} }

@ -21,6 +21,7 @@ class Family {
private $photo = false; private $photo = false;
private $newsletter = 1; private $newsletter = 1;
private $children = []; private $children = [];
private $expires = 0;
public function __construct() { public function __construct() {
@ -53,7 +54,8 @@ class Family {
'zip', 'zip',
'father_name (father)', 'father_name (father)',
'mother_name (mother)', 'mother_name (mother)',
'photo_permission (photo)' 'photo_permission (photo)',
'expires'
], [ ], [
"familyid" => $this->id "familyid" => $this->id
]); ]);
@ -71,6 +73,7 @@ class Family {
$this->zip = $f['zip']; $this->zip = $f['zip'];
$this->photo = $f['photo'] == 1; $this->photo = $f['photo'] == 1;
$this->newsletter = $f['newsletter']; $this->newsletter = $f['newsletter'];
$this->expires = $f['expires'];
foreach ($children as $c) { foreach ($children as $c) {
$this->children[] = (new Child())->load($c); $this->children[] = (new Child())->load($c);
@ -93,7 +96,8 @@ class Family {
"state" => $this->getState(), "state" => $this->getState(),
"zip" => $this->getZip(), "zip" => $this->getZip(),
"photo_permission" => $this->getPhotoPermission(), "photo_permission" => $this->getPhotoPermission(),
"newsletter_method" => $this->getNewsletter() "newsletter_method" => $this->getNewsletter(),
"expires" => date("Y-m-d", $this->getExpires())
], [ ], [
"familyid" => $this->id "familyid" => $this->id
]); ]);
@ -109,7 +113,8 @@ class Family {
"state" => $this->getState(), "state" => $this->getState(),
"zip" => $this->getZip(), "zip" => $this->getZip(),
"photo_permission" => $this->getPhotoPermission(), "photo_permission" => $this->getPhotoPermission(),
"newsletter_method" => $this->getNewsletter() "newsletter_method" => $this->getNewsletter(),
"expires" => date("Y-m-d", $this->getExpires())
]); ]);
$this->id = $database->id(); $this->id = $database->id();
} }
@ -172,6 +177,10 @@ class Family {
return $this->children; return $this->children;
} }
public function getExpires(): int {
return $this->expires;
}
public function setName(string $name) { public function setName(string $name) {
@ -252,4 +261,18 @@ class Family {
$this->children[] = $child; $this->children[] = $child;
} }
/**
* Set the membership expiration date to either a UNIX timestamp or a date
* string.
* @param int $timestamp
* @param string $date A string parseable by strtotime().
*/
public function setExpires(int $timestamp = null, string $date = null) {
if (is_null($timestamp) && !is_null($date)) {
$this->expires = strtotime($date);
} else if (!is_null($timestamp) && is_null($date)) {
$this->expires = $timestamp;
}
}
} }

@ -14,7 +14,7 @@ if (!$user->hasPermission("HACHEPORTAL_VIEW")) {
$writeaccess = $user->hasPermission("HACHEPORTAL_EDIT"); $writeaccess = $user->hasPermission("HACHEPORTAL_EDIT");
$families = $database->select("families", ['familyid (id)', 'familyname', 'phone', 'email', 'father_name (father)', 'mother_name (mother)']); $families = $database->select("families", ['familyid (id)', 'familyname', 'phone', 'email', 'father_name (father)', 'mother_name (mother)', 'expires']);
?> ?>
<div class="btn-group"> <div class="btn-group">
@ -32,6 +32,7 @@ $families = $database->select("families", ['familyid (id)', 'familyname', 'phone
<th data-priority="3"><i class="fas fa-female hidden-sm"></i> <?php $Strings->get('Mother'); ?></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="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="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> </tr>
</thead> </thead>
<tbody> <tbody>
@ -55,6 +56,7 @@ $families = $database->select("families", ['familyid (id)', 'familyname', 'phone
<td><?php echo $f['mother']; ?></td> <td><?php echo $f['mother']; ?></td>
<td><?php echo $f['phone']; ?></td> <td><?php echo $f['phone']; ?></td>
<td><?php echo $f['email']; ?></td> <td><?php echo $f['email']; ?></td>
<td class="<?php echo strtotime($f['expires']) < time() ? "text-red" : ""; ?>"><?php echo $f['expires']; ?></td>
</tr> </tr>
<?php <?php
} }
@ -69,6 +71,7 @@ $families = $database->select("families", ['familyid (id)', 'familyname', 'phone
<th data-priority="3"><i class="fas fa-female hidden-sm"></i> <?php $Strings->get('Mother'); ?></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="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="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> </tr>
</tfoot> </tfoot>
</table> </table>

@ -14,7 +14,7 @@ if (!$user->hasPermission("HACHEPORTAL_VIEW")) {
$writeaccess = $user->hasPermission("HACHEPORTAL_EDIT"); $writeaccess = $user->hasPermission("HACHEPORTAL_EDIT");
$payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount', 'paid', 'date']); $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount', 'paid', 'date', 'type']);
?> ?>
<div class="btn-group"> <div class="btn-group">
@ -26,11 +26,12 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount
<thead> <thead>
<tr> <tr>
<th data-priority="0"></th> <th data-priority="0"></th>
<th data-priority="1"><?php $Strings->get('Actions'); ?></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-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-dollar-sign hidden-sm"></i> <?php $Strings->get('Amount'); ?></th>
<th data-priority="2"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Date'); ?></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('Paid'); ?></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> </tr>
</thead> </thead>
<tbody> <tbody>
@ -39,7 +40,7 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount
?> ?>
<tr> <tr>
<td></td> <td></td>
<td> <!-- <td>
<?php <?php
if ($writeaccess) { if ($writeaccess) {
?> ?>
@ -47,11 +48,12 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount
<?php <?php
} }
?> ?>
</td> </td>-->
<td><a href="./app.php?page=viewfamily&id=<?php echo $p['familyid']; ?>"><?php echo (new Family())->load($p['familyid'])->getName(); ?></a></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['amount'], 2); ?></td>
<td><?php echo date("Y-m-d H:i:s", strtotime($p['date'])); ?></td> <td><?php echo date("Y-m-d H:i:s", strtotime($p['date'])); ?></td>
<td><?php $p['paid'] ? $Strings->get("Yes") : $Strings->get("No"); ?></td> <td><?php $p['paid'] ? $Strings->get("Paid") : $Strings->get("Unpaid"); ?></td>
<td><?php $Strings->get($p["type"]); ?></td>
</tr> </tr>
<?php <?php
} }
@ -60,11 +62,12 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount
<tfoot> <tfoot>
<tr> <tr>
<th data-priority="0"></th> <th data-priority="0"></th>
<th data-priority="1"><?php $Strings->get('Actions'); ?></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-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-dollar-sign hidden-sm"></i> <?php $Strings->get('Amount'); ?></th>
<th data-priority="2"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Date'); ?></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('Paid'); ?></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> </tr>
</tfoot> </tfoot>
</table> </table>

@ -112,6 +112,12 @@ $database->action(function($database) {
} }
$family->setPhotoPermission($photopermission); $family->setPhotoPermission($photopermission);
if ($renewal) {
$family->setExpires(strtotime("+1 year", $family->getExpires()));
} else {
$family->setExpires(strtotime("+1 year"));
}
$family->save(); $family->save();
// //
@ -215,7 +221,8 @@ $database->action(function($database) {
"familyid" => $family->getID(), "familyid" => $family->getID(),
"amount" => ($membership_cost / 100.0), "amount" => ($membership_cost / 100.0),
"paid" => 1, "paid" => 1,
"date" => date("Y-m-d H:i:s") "date" => date("Y-m-d H:i:s"),
"type" => "Online"
]); ]);
try { try {

@ -5,6 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
require_once __DIR__ . "/../../lib/Email.lib.php";
$badcode = false; $badcode = false;
if (!empty($_POST['email'])) { if (!empty($_POST['email'])) {
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
@ -29,7 +31,7 @@ if (!empty($_POST['email'])) {
$verification->setBody("The verification code for renewing your HACHE membership is $code."); $verification->setBody("The verification code for renewing your HACHE membership is $code.");
$verification->send(); $verification->send();
} catch (Exception $e) { } catch (Exception $e) {
} }
} else if (!empty($_POST['code'])) { } else if (!empty($_POST['code'])) {
if (empty($_SESSION['code'])) { if (empty($_SESSION['code'])) {

Loading…
Cancel
Save