Begin conversion to day camp registration system
parent
5c90ae4b76
commit
326cb874e7
Binary file not shown.
@ -1,114 +0,0 @@
|
||||
<?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/.
|
||||
*/
|
||||
|
||||
class Child {
|
||||
|
||||
private $id;
|
||||
private $familyid;
|
||||
private $name;
|
||||
private $birthday;
|
||||
private $graduated;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function load(int $id): Child {
|
||||
global $database;
|
||||
$info = $database->get('people', ["familyid", "name", "birthday", "graduated"], ['personid' => $id]);
|
||||
|
||||
$this->id = $id;
|
||||
$this->familyid = $info['familyid'];
|
||||
$this->name = $info['name'];
|
||||
$this->birthday = strtotime($info['birthday']);
|
||||
$this->graduated = $info['graduated'] == 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
global $database;
|
||||
if (is_int($this->id) && $database->has("people", ['personid' => $this->id])) {
|
||||
$database->update("people", ["name" => $this->name, "birthday" => date("Y-m-d", $this->birthday), "graduated" => $this->graduated], ['personid' => $this->id]);
|
||||
} else {
|
||||
$database->insert("people", ["familyid" => $this->familyid, "name" => $this->name, "birthday" => date("Y-m-d", $this->birthday), "graduated" => $this->graduated]);
|
||||
$this->id = $database->id();
|
||||
}
|
||||
}
|
||||
|
||||
public static function exists(int $cid, int $fid = null) {
|
||||
global $database;
|
||||
if (is_null($fid)) {
|
||||
return $database->has("people", [
|
||||
'personid' => $cid
|
||||
]);
|
||||
}
|
||||
return $database->has("people", ["AND" => [
|
||||
'familyid' => $fid,
|
||||
'personid' => $cid
|
||||
]]);
|
||||
}
|
||||
|
||||
public function getID(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getFamilyID(): int {
|
||||
return $this->familyid;
|
||||
}
|
||||
|
||||
public function getFamily(): Family {
|
||||
return (new Family())->load($this->familyid);
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the person's birth date as a UNIX timestamp.
|
||||
* @return int
|
||||
*/
|
||||
public function getBirthday(): int {
|
||||
return $this->birthday;
|
||||
}
|
||||
|
||||
public function isGraduated(): bool {
|
||||
return $this->graduated == true;
|
||||
}
|
||||
|
||||
public function setName(string $name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the person's birth date to either a UNIX timestamp or a date string.
|
||||
* @param int $timestamp
|
||||
* @param string $date A string parseable by strtotime().
|
||||
*/
|
||||
public function setBirthday(int $timestamp = null, string $date = null) {
|
||||
if (is_null($timestamp) && !is_null($date)) {
|
||||
$this->birthday = strtotime($date);
|
||||
} else if (!is_null($timestamp) && is_null($date)) {
|
||||
$this->birthday = $timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
public function setGraduated(bool $graduated) {
|
||||
$this->graduated = $graduated;
|
||||
}
|
||||
|
||||
public function setFamilyID(int $id) {
|
||||
$this->familyid = $id;
|
||||
}
|
||||
|
||||
public function setFamily(Family $f) {
|
||||
$this->familyid = $f->getID();
|
||||
}
|
||||
|
||||
}
|
@ -1,291 +0,0 @@
|
||||
<?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/.
|
||||
*/
|
||||
|
||||
class Family {
|
||||
|
||||
private $id;
|
||||
private $name = "";
|
||||
private $father = "";
|
||||
private $mother = "";
|
||||
private $phone = "";
|
||||
private $email = "";
|
||||
private $address = "";
|
||||
private $city = "";
|
||||
private $state = "";
|
||||
private $zip = "";
|
||||
private $photo = false;
|
||||
private $newsletter = 1;
|
||||
private $children = [];
|
||||
private $expires = 0;
|
||||
private $private = false;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a family from the database into this object
|
||||
* @global type $database
|
||||
* @param int $familyid
|
||||
* @return \Family
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load(int $familyid): Family {
|
||||
global $database;
|
||||
if ($database->has("families", ['familyid' => $familyid])) {
|
||||
$this->id = $familyid;
|
||||
} else {
|
||||
throw new Exception("No such family exists.");
|
||||
}
|
||||
|
||||
$f = $database->get("families", [
|
||||
'familyid (id)',
|
||||
'familyname (name)',
|
||||
'phone',
|
||||
'email',
|
||||
'newsletter_method (newsletter)',
|
||||
'address',
|
||||
'city',
|
||||
'state',
|
||||
'zip',
|
||||
'father_name (father)',
|
||||
'mother_name (mother)',
|
||||
'photo_permission (photo)',
|
||||
'expires',
|
||||
'private'
|
||||
], [
|
||||
"familyid" => $this->id
|
||||
]);
|
||||
|
||||
$children = $database->select("people", 'personid', ["familyid" => $this->id]);
|
||||
|
||||
$this->name = $f['name'];
|
||||
$this->father = $f['father'];
|
||||
$this->mother = $f['mother'];
|
||||
$this->phone = $f['phone'];
|
||||
$this->email = $f['email'];
|
||||
$this->address = $f['address'];
|
||||
$this->city = $f['city'];
|
||||
$this->state = $f['state'];
|
||||
$this->zip = $f['zip'];
|
||||
$this->photo = $f['photo'] == 1;
|
||||
$this->newsletter = $f['newsletter'];
|
||||
$this->expires = strtotime($f['expires']);
|
||||
$this->private = $f['private'] == 1;
|
||||
|
||||
foreach ($children as $c) {
|
||||
$this->children[] = (new Child())->load($c);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
global $database;
|
||||
if (is_int($this->id) && $database->has("families", ['familyid' => $this->id])) {
|
||||
$database->update("families", [
|
||||
"familyname" => $this->getName(),
|
||||
"father_name" => $this->getFather(),
|
||||
"mother_name" => $this->getMother(),
|
||||
"phone" => $this->getPhone(),
|
||||
"email" => $this->getEmail(),
|
||||
"address" => $this->getAddress(),
|
||||
"city" => $this->getCity(),
|
||||
"state" => $this->getState(),
|
||||
"zip" => $this->getZip(),
|
||||
"photo_permission" => $this->getPhotoPermission(),
|
||||
"newsletter_method" => $this->getNewsletter(),
|
||||
"expires" => date("Y-m-d", $this->getExpires()),
|
||||
"private" => $this->getPrivate()
|
||||
], [
|
||||
"familyid" => $this->id
|
||||
]);
|
||||
} else {
|
||||
$database->insert("families", [
|
||||
"familyname" => $this->getName(),
|
||||
"father_name" => $this->getFather(),
|
||||
"mother_name" => $this->getMother(),
|
||||
"phone" => $this->getPhone(),
|
||||
"email" => $this->getEmail(),
|
||||
"address" => $this->getAddress(),
|
||||
"city" => $this->getCity(),
|
||||
"state" => $this->getState(),
|
||||
"zip" => $this->getZip(),
|
||||
"photo_permission" => $this->getPhotoPermission(),
|
||||
"newsletter_method" => $this->getNewsletter(),
|
||||
"expires" => date("Y-m-d", $this->getExpires()),
|
||||
"private" => $this->getPrivate()
|
||||
]);
|
||||
$this->id = $database->id();
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($this->children); $i++) {
|
||||
$this->children[$i]->setFamilyID($this->id);
|
||||
$this->children[$i]->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function getID() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getFather(): string {
|
||||
return $this->father;
|
||||
}
|
||||
|
||||
public function getMother(): string {
|
||||
return $this->mother;
|
||||
}
|
||||
|
||||
public function getPhone(): string {
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function getEmail(): string {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getAddress(): string {
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function getCity(): string {
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function getState(): string {
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function getZip(): string {
|
||||
return $this->zip;
|
||||
}
|
||||
|
||||
public function getPhotoPermission(): bool {
|
||||
return $this->photo == true;
|
||||
}
|
||||
|
||||
public function getNewsletter(): int {
|
||||
return $this->newsletter;
|
||||
}
|
||||
|
||||
public function getChildren(): array {
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function getExpires(): int {
|
||||
return $this->expires;
|
||||
}
|
||||
|
||||
public function getPrivate(): bool {
|
||||
return $this->private == true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setName(string $name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function setFather(string $name) {
|
||||
$this->father = $name;
|
||||
}
|
||||
|
||||
public function setMother(string $name) {
|
||||
$this->mother = $name;
|
||||
}
|
||||
|
||||
public function setPhone(string $phone) {
|
||||
$phone = preg_replace("/[^0-9]/", "", $phone);
|
||||
if (strlen($phone) == 11) {
|
||||
$phone = preg_replace("/^1/", "", $phone);
|
||||
}
|
||||
if (strlen($phone) != 10) {
|
||||
throw new Exception("Enter a valid 10-digit phone number.");
|
||||
}
|
||||
$this->phone = $phone;
|
||||
}
|
||||
|
||||
public function setEmail(string $email) {
|
||||
$email = strtolower($email);
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new Exception("The email address looks wrong.");
|
||||
}
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function setAddress(string $address) {
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
public function setCity(string $city) {
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state, in two-character form.
|
||||
* @param string $state
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setState(string $state) {
|
||||
$state = strtoupper($state);
|
||||
if (!preg_match("/^[A-Z]{2}$/", $state)) {
|
||||
throw new Exception("Select a valid state.");
|
||||
}
|
||||
$this->state = strtoupper($state);
|
||||
}
|
||||
|
||||
public function setZip(string $zip) {
|
||||
if (!preg_match("/^[0-9]{5}(-?[0-9]{4})?$/", $zip)) {
|
||||
throw new Exception("Enter a valid five or nine digit US ZIP code.");
|
||||
}
|
||||
$this->zip = $zip;
|
||||
}
|
||||
|
||||
public function setPhotoPermission(bool $perm) {
|
||||
$this->photo = $perm;
|
||||
}
|
||||
|
||||
public function setNewsletter(int $newsletter) {
|
||||
if (!is_int($newsletter) || !($newsletter == 1 || $newsletter == 2 || $newsletter == 3)) {
|
||||
throw new Exception("Invalid newsletter preference.");
|
||||
}
|
||||
$this->newsletter = $newsletter;
|
||||
}
|
||||
|
||||
public function setChildren(array $children) {
|
||||
$this->children = $children;
|
||||
}
|
||||
|
||||
public function addChild(Child $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;
|
||||
}
|
||||
}
|
||||
|
||||
public function setPrivate(bool $private) {
|
||||
$this->private = $private;
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
<?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/.
|
||||
*/
|
||||
|
||||
if (empty($IN_SITE)) {
|
||||
die("Access denied.");
|
||||
}
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card mb-4 col-lg-8">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="text-center">
|
||||
<img class="img-fluid mb-4" style="max-height: 100px; min-width: 100px;" src="static/hachelogo.svg" alt="HACHE: Helena Area Christian Home Educators"/>
|
||||
|
||||
<h1>Renew Your Membership</h1>
|
||||
|
||||
<div class="card-text">
|
||||
<p>
|
||||
Please enter your email address below. You'll be
|
||||
sent a verification code. This is to ensure nobody
|
||||
else can view or change your family's information.
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$msg = "";
|
||||
$alert = "danger";
|
||||
if (!empty($_GET['msg'])) {
|
||||
switch ($_GET['msg']) {
|
||||
case "sessionexpired":
|
||||
$msg = "You took too long and were automatically logged out. Please try again.";
|
||||
break;
|
||||
case "noemail":
|
||||
$msg = "We don't have that email on file for any current families.";
|
||||
break;
|
||||
case "bademail":
|
||||
$msg = "That email address doesn't look right. Please try again.";
|
||||
break;
|
||||
case "tooearly":
|
||||
$alert = "info";
|
||||
if (!empty($_GET['exp']) && is_numeric($_GET['exp']) && $_GET['exp'] * 1 > time()) {
|
||||
$msg = "<i class=\"fas fa-calendar-check\"></i> This membership isn't expiring until " . date("F j, Y", $_GET['exp'] * 1) . " and cannot be renewed yet.";
|
||||
} else {
|
||||
// Somebody is screwing with the URL
|
||||
// for some reason
|
||||
$msg = "<i class=\"fas fa-calendar-check\"></i> This membership isn't close enough to expiration and cannot be renewed yet.";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($msg != "") {
|
||||
?>
|
||||
<div class="alert alert-<?php echo $alert; ?>">
|
||||
<?php echo $msg; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="./?page=verify" method="POST">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<i class="fas fa-at fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="email" placeholder="family@example.com" autofocus />
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-primary">Continue <i class="fas fa-chevron-right"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,89 +0,0 @@
|
||||
<?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__ . "/../../lib/requiredpublic.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,267 @@
|
||||
<?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__ . "/../../lib/requiredpublic.php";
|
||||
|
||||
// Get the person type, either from the URL or a preset variable in the including script
|
||||
$type = "camper";
|
||||
if (!empty($_GET["type"]) && preg_match("/^(camper|adult|youth)$/", $_GET["type"])) {
|
||||
$type = $_GET["type"];
|
||||
} else if (!empty($persontype)) {
|
||||
$type = $persontype;
|
||||
}
|
||||
|
||||
$personinfo = ["firstname" => "", "lastname" => "", "address" => "", "zip" => "", "phone1" => "", "phone2" => "", "email" => "", "unit" => "", "shirt" => ""];
|
||||
|
||||
switch ($type) {
|
||||
case "camper":
|
||||
$personinfo["parentname"] = "";
|
||||
$personinfo["rank"] = "";
|
||||
break;
|
||||
case "youth":
|
||||
$personinfo["parentname"] = "";
|
||||
$personinfo["days"] = "";
|
||||
$personinfo["position"] = "";
|
||||
break;
|
||||
case "adult":
|
||||
$personinfo["days"] = "";
|
||||
$personinfo["position"] = "";
|
||||
$personinfo["child_care"] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($_GET as $key => $val) {
|
||||
if (array_key_exists($key, $personinfo)) {
|
||||
$personinfo[$key] = htmlentities($val);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($personid) && $database->has('people', ['personid' => $personid])) {
|
||||
$personinfo = $database->get('people', '*', ['personid' => $personid]);
|
||||
} else {
|
||||
do {
|
||||
$personid = mt_rand(0, 9999999999);
|
||||
} while ($database->has('people', ['personid' => $personid]));
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="list-group-item person-list-item" data-persontype="<?php echo $type; ?>">
|
||||
<input type="hidden" name="people[ids][]" value="<?php echo $personid; ?>" />
|
||||
<input type="hidden" name="persontype" value="<?php echo $type; ?>" />
|
||||
<div class="row">
|
||||
|
||||
<?php
|
||||
$textboxes = [
|
||||
[
|
||||
"label" => "First Name",
|
||||
"name" => "firstname",
|
||||
"maxlength" => 255,
|
||||
"width" => 6,
|
||||
"value" => $personinfo["firstname"],
|
||||
"error" => "Enter the person's first name."
|
||||
],
|
||||
[
|
||||
"label" => "Last Name",
|
||||
"name" => "lastname",
|
||||
"width" => 6,
|
||||
"maxlength" => 255,
|
||||
"value" => $personinfo["lastname"],
|
||||
"error" => "Enter the person's last name."
|
||||
]
|
||||
];
|
||||
if ($type == "camper") {
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Parent/Guardian Name",
|
||||
"name" => "parentname",
|
||||
"width" => 12,
|
||||
"maxlength" => 255,
|
||||
"value" => $personinfo["parentname"],
|
||||
"error" => "Enter the parent or guardian's full name."
|
||||
]
|
||||
]);
|
||||
}
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Address",
|
||||
"name" => "address",
|
||||
"maxlength" => 500,
|
||||
"width" => 8,
|
||||
"value" => $personinfo["address"],
|
||||
"error" => "Enter the person's home address."
|
||||
],
|
||||
[
|
||||
"label" => "ZIP Code",
|
||||
"name" => "zip",
|
||||
"maxlength" => 10,
|
||||
"width" => 4,
|
||||
"value" => $personinfo["zip"],
|
||||
"pattern" => "[0-9]{5}(-?[0-9]{4})?",
|
||||
"error" => "Enter a valid 5 or 9 digit ZIP code."
|
||||
],
|
||||
[
|
||||
"label" => "Phone Number",
|
||||
"name" => "phone1",
|
||||
"type" => "tel",
|
||||
"maxlength" => 20,
|
||||
"width" => 3,
|
||||
"value" => $personinfo["phone1"],
|
||||
"pattern" => "[0-9]{10}",
|
||||
"error" => "Enter a 10-digit phone number (numbers only)."
|
||||
],
|
||||
[
|
||||
"label" => "Email",
|
||||
"name" => "email",
|
||||
"maxlength" => 255,
|
||||
"width" => 5,
|
||||
"type" => "email",
|
||||
"value" => $personinfo["email"],
|
||||
"error" => "Enter your email address."
|
||||
]
|
||||
]);
|
||||
if ($type == "camper") {
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Pack #",
|
||||
"name" => "unit",
|
||||
"width" => 2,
|
||||
"maxlength" => 4,
|
||||
"pattern" => "[0-9]{3,4}",
|
||||
"value" => $personinfo["unit"],
|
||||
"error" => "Enter the pack number."
|
||||
],
|
||||
[
|
||||
"label" => "Rank",
|
||||
"name" => "rank",
|
||||
"type" => "select",
|
||||
"width" => 2,
|
||||
"value" => $personinfo["rank"],
|
||||
"options" => [
|
||||
"" => "Choose...",
|
||||
"Tiger" => "Tiger",
|
||||
"Wolf" => "Wolf",
|
||||
"Bear" => "Bear",
|
||||
"Webelos" => "Webelos",
|
||||
"Arrow of Light" => "Arrow of Light",
|
||||
],
|
||||
"error" => "Choose a rank."
|
||||
]
|
||||
]);
|
||||
}
|
||||
if ($type == "youth") {
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Parent Name",
|
||||
"name" => "parentname",
|
||||
"width" => 4,
|
||||
"maxlength" => 255,
|
||||
"value" => $personinfo["parentname"],
|
||||
"error" => "Enter the parent or guardian's full name."
|
||||
],
|
||||
[
|
||||
"label" => "Parent Phone",
|
||||
"name" => "phone2",
|
||||
"type" => "tel",
|
||||
"maxlength" => 20,
|
||||
"width" => 3,
|
||||
"value" => $personinfo["phone2"],
|
||||
"pattern" => "[0-9]{10}",
|
||||
"error" => "Enter a 10-digit phone number (numbers only)."
|
||||
]
|
||||
]);
|
||||
}
|
||||
if ($type == "adult" || $type == "youth") {
|
||||
// TODO: camp days selection
|
||||
// TODO: help area selection
|
||||
}
|
||||
$textboxes = array_merge($textboxes, [
|
||||
[
|
||||
"label" => "Shirt Size",
|
||||
"name" => "shirt",
|
||||
"type" => "select",
|
||||
"value" => $personinfo["shirt"],
|
||||
"options" => [
|
||||
"" => "Choose...",
|
||||
"YS" => "Youth Small",
|
||||
"YM" => "Youth Medium",
|
||||
"YL" => "Youth Large",
|
||||
"AS" => "Adult Small",
|
||||
"AM" => "Adult Medium",
|
||||
"AL" => "Adult Large",
|
||||
"AX" => "Adult Extra Large",
|
||||
"A2" => "Adult 2X Large"
|
||||
],
|
||||
"error" => "Choose a shirt size."
|
||||
]
|
||||
]);
|
||||
|
||||
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">
|
||||
<?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['pattern'])) {
|
||||
?>
|
||||
pattern="<?php echo $item['pattern']; ?>"
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if (!empty($item['value'])) {
|
||||
?>
|
||||
value="<?php echo htmlspecialchars($item['value']); ?>"
|
||||
<?php
|
||||
}
|
||||
if (empty($item['optional'])) {
|
||||
echo "required";
|
||||
}
|
||||
?> />
|
||||
<?php } else if ($item['type'] == "select") { ?>
|
||||
<select class="form-control"
|
||||
name="<?php echo $item['name']; ?>"
|
||||
aria-label="<?php echo $item['label']; ?>"
|
||||
<?php
|
||||
if (empty($item['optional'])) {
|
||||
echo "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 class="invalid-tooltip">
|
||||
<?php echo $item['error']; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -1,107 +0,0 @@
|
||||
<?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/.
|
||||
*/
|
||||
|
||||
if (empty($IN_SITE)) {
|
||||
die("Access denied.");
|
||||
}
|
||||
$badcode = false;
|
||||
if (!empty($_POST['email'])) {
|
||||
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
header("Location: ./?page=renew&msg=bademail");
|
||||
die("That email address doesn't look right. Please try again.");
|
||||
}
|
||||
if (!$database->has("families", ['email' => strtolower($_POST['email'])])) {
|
||||
header("Location: ./?page=renew&msg=noemail");
|
||||
die("We don't have that email on file for any current families.");
|
||||
}
|
||||
|
||||
$familyid = $database->get('families', 'familyid', ['email' => strtolower($_POST['email'])]);
|
||||
|
||||
// Check expiration date
|
||||
$expires = (new Family())->load($familyid)->getExpires();
|
||||
if ($expires > strtotime("+6 months")) {
|
||||
header("Location: ./?page=renew&msg=tooearly&exp=$expires");
|
||||
die("This membership isn't expiring until " . date("F j, Y", $expires) . " and cannot be renewed yet.");
|
||||
}
|
||||
|
||||
$code = mt_rand(100000, 999999);
|
||||
$_SESSION['code'] = $code;
|
||||
$_SESSION['maybefamily'] = $familyid;
|
||||
|
||||
try {
|
||||
$verification = new Email();
|
||||
$verification->addTo($SETTINGS["smtp"]["notification_to"]);
|
||||
$verification->setFrom($SETTINGS["smtp"]["fromaddress"], $SETTINGS["smtp"]["fromname"]);
|
||||
$verification->setSMTP($SETTINGS["smtp"]["host"], $SETTINGS["smtp"]["port"], $SETTINGS["smtp"]["auth"], $SETTINGS["smtp"]["user"], $SETTINGS["smtp"]["password"], $SETTINGS["smtp"]["secure"]);
|
||||
$verification->setSubject("HACHE email verification");
|
||||
$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'])) {
|
||||
header("Location: ./?page=renew&msg=sessionexpired");
|
||||
die("You took too long and were automatically logged out. Please try again.");
|
||||
}
|
||||
if (preg_replace("/[^0-9]/", "", $_POST['code']) == $_SESSION['code']) {
|
||||
$_SESSION['familyid'] = $_SESSION['maybefamily'];
|
||||
header("Location: ./?page=signup");
|
||||
die("You are verified, go to ./?page=signup");
|
||||
}
|
||||
$badcode = true;
|
||||
} else {
|
||||
header("Location: ./?page=renew&msg=bademail");
|
||||
die("That email address doesn't look right. Please try again.");
|
||||
}
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card mb-4 col-lg-8">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="text-center">
|
||||
<img class="img-fluid mb-4" style="max-height: 100px; min-width: 100px;" src="static/hachelogo.svg" alt="HACHE: Helena Area Christian Home Educators"/>
|
||||
|
||||
<h1>Renew Your Membership</h1>
|
||||
|
||||
<div class="card-text">
|
||||
<p>
|
||||
Enter the code from the email we just sent you.
|
||||
If you didn't get it, check your spam or junk folder.
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($badcode) {
|
||||
?>
|
||||
<div class="alert alert-danger">
|
||||
The code you entered is incorrect.
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="./?page=verify" method="POST">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fa-layers fa-fw mr-2">
|
||||
<i class="fas fa-2x fa-hashtag"></i>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" style="font-size: 40px; letter-spacing: 10px;" name="code" placeholder="000000" maxLength="6" autofocus />
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-primary">Verify <i class="fas fa-chevron-right"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 65 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,17 @@
|
||||
/*
|
||||
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/.
|
||||
*/
|
||||
/*
|
||||
Created on : Mar 2, 2019, 8:47:19 PM
|
||||
Author : Skylar Ittner
|
||||
*/
|
||||
|
||||
body, html {
|
||||
background-color: #004D40;
|
||||
}
|
||||
|
||||
.person-list-item {
|
||||
border: 1.5px solid var(--teal);
|
||||
}
|
Loading…
Reference in New Issue