diff --git a/database.mwb b/database.mwb index 0d55c98..af3129d 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/langs/en/labels.json b/langs/en/labels.json index b137f74..429fd9a 100644 --- a/langs/en/labels.json +++ b/langs/en/labels.json @@ -34,5 +34,14 @@ "DOCX": "DOCX", "Amount": "Amount", "Date": "Date", - "Paid": "Paid" + "Status": "Status", + "Paid": "Paid", + "Unpaid": "Unpaid", + "Type": "Type", + "Online": "Online", + "Cash": "Cash", + "Check": "Check", + "Other": "Other", + "Free": "Free", + "Expires": "Expires" } diff --git a/lib/Family.lib.php b/lib/Family.lib.php index 384de00..96aa626 100644 --- a/lib/Family.lib.php +++ b/lib/Family.lib.php @@ -21,6 +21,7 @@ class Family { private $photo = false; private $newsletter = 1; private $children = []; + private $expires = 0; public function __construct() { @@ -53,7 +54,8 @@ class Family { 'zip', 'father_name (father)', 'mother_name (mother)', - 'photo_permission (photo)' + 'photo_permission (photo)', + 'expires' ], [ "familyid" => $this->id ]); @@ -71,6 +73,7 @@ class Family { $this->zip = $f['zip']; $this->photo = $f['photo'] == 1; $this->newsletter = $f['newsletter']; + $this->expires = $f['expires']; foreach ($children as $c) { $this->children[] = (new Child())->load($c); @@ -93,7 +96,8 @@ class Family { "state" => $this->getState(), "zip" => $this->getZip(), "photo_permission" => $this->getPhotoPermission(), - "newsletter_method" => $this->getNewsletter() + "newsletter_method" => $this->getNewsletter(), + "expires" => date("Y-m-d", $this->getExpires()) ], [ "familyid" => $this->id ]); @@ -109,7 +113,8 @@ class Family { "state" => $this->getState(), "zip" => $this->getZip(), "photo_permission" => $this->getPhotoPermission(), - "newsletter_method" => $this->getNewsletter() + "newsletter_method" => $this->getNewsletter(), + "expires" => date("Y-m-d", $this->getExpires()) ]); $this->id = $database->id(); } @@ -172,6 +177,10 @@ class Family { return $this->children; } + public function getExpires(): int { + return $this->expires; + } + public function setName(string $name) { @@ -252,4 +261,18 @@ class Family { $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; + } + } + } diff --git a/pages/families.php b/pages/families.php index 5367ce0..4ddb6ea 100644 --- a/pages/families.php +++ b/pages/families.php @@ -14,7 +14,7 @@ if (!$user->hasPermission("HACHEPORTAL_VIEW")) { $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']); ?>
@@ -32,6 +32,7 @@ $families = $database->select("families", ['familyid (id)', 'familyname', 'phone get('Mother'); ?> get('Phone'); ?> get('Email'); ?> + get('Expires'); ?> @@ -55,6 +56,7 @@ $families = $database->select("families", ['familyid (id)', 'familyname', 'phone + "> select("families", ['familyid (id)', 'familyname', 'phone get('Mother'); ?> get('Phone'); ?> get('Email'); ?> + get('Expires'); ?> \ No newline at end of file diff --git a/pages/payments.php b/pages/payments.php index 7148f98..e517f61 100644 --- a/pages/payments.php +++ b/pages/payments.php @@ -14,7 +14,7 @@ if (!$user->hasPermission("HACHEPORTAL_VIEW")) { $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']); ?>
@@ -26,11 +26,12 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount - get('Actions'); ?> + get('Family'); ?> get('Amount'); ?> get('Date'); ?> - get('Paid'); ?> + get('Status'); ?> + get('Type'); ?> @@ -39,7 +40,7 @@ $payments = $database->select("payments", ['paymentid (id)', 'familyid', 'amount ?> - + load($p['familyid'])->getName(); ?> $ - get("Yes") : $Strings->get("No"); ?> + get("Paid") : $Strings->get("Unpaid"); ?> + get($p["type"]); ?> select("payments", ['paymentid (id)', 'familyid', 'amount - get('Actions'); ?> + get('Family'); ?> get('Amount'); ?> get('Date'); ?> - get('Paid'); ?> + get('Status'); ?> + get('Type'); ?> \ No newline at end of file diff --git a/public/actions/submitmembership.php b/public/actions/submitmembership.php index c1ff37f..7b225fc 100644 --- a/public/actions/submitmembership.php +++ b/public/actions/submitmembership.php @@ -112,6 +112,12 @@ $database->action(function($database) { } $family->setPhotoPermission($photopermission); + if ($renewal) { + $family->setExpires(strtotime("+1 year", $family->getExpires())); + } else { + $family->setExpires(strtotime("+1 year")); + } + $family->save(); // @@ -215,7 +221,8 @@ $database->action(function($database) { "familyid" => $family->getID(), "amount" => ($membership_cost / 100.0), "paid" => 1, - "date" => date("Y-m-d H:i:s") + "date" => date("Y-m-d H:i:s"), + "type" => "Online" ]); try { diff --git a/public/parts/verify.php b/public/parts/verify.php index 64744f0..2d294b6 100644 --- a/public/parts/verify.php +++ b/public/parts/verify.php @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +require_once __DIR__ . "/../../lib/Email.lib.php"; + $badcode = false; if (!empty($_POST['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->send(); } catch (Exception $e) { - + } } else if (!empty($_POST['code'])) { if (empty($_SESSION['code'])) {