Add renewal ability to signup form
This commit is contained in:
parent
6af2fb753a
commit
144685b31f
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -18,6 +18,8 @@ if (!DEBUG) {
|
|||||||
ini_set('display_errors', 'On');
|
ini_set('display_errors', 'On');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
// Unicode, solves almost all stupid encoding problems
|
// Unicode, solves almost all stupid encoding problems
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
|
||||||
|
@ -17,7 +17,12 @@ if (empty($_POST['agree_terms'])) {
|
|||||||
errorBack("You must agree to HACHE's policy.");
|
errorBack("You must agree to HACHE's policy.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($_SESSION['familyid']) && $database->has("families", ['familyid' => $_SESSION['familyid']])) {
|
||||||
|
$familyid = $_SESSION['familyid'];
|
||||||
|
}
|
||||||
|
|
||||||
$database->action(function($database) {
|
$database->action(function($database) {
|
||||||
|
global $familyid;
|
||||||
$lastname = $_POST['familyname'];
|
$lastname = $_POST['familyname'];
|
||||||
$father = $_POST['fathername'];
|
$father = $_POST['fathername'];
|
||||||
$mother = $_POST['mothername'];
|
$mother = $_POST['mothername'];
|
||||||
@ -89,21 +94,39 @@ $database->action(function($database) {
|
|||||||
$photopermission = false;
|
$photopermission = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$database->insert("families", [
|
if (isset($familyid)) {
|
||||||
"familyname" => $lastname,
|
$database->update("families", [
|
||||||
"father_name" => $father,
|
"familyname" => $lastname,
|
||||||
"mother_name" => $mother,
|
"father_name" => $father,
|
||||||
"phone" => $phone,
|
"mother_name" => $mother,
|
||||||
"email" => $email,
|
"phone" => $phone,
|
||||||
"newsletter_method" => $newsletter,
|
"email" => $email,
|
||||||
"address" => $address,
|
"newsletter_method" => $newsletter,
|
||||||
"city" => $city,
|
"address" => $address,
|
||||||
"state" => $state,
|
"city" => $city,
|
||||||
"zip" => $zip,
|
"state" => $state,
|
||||||
"photo_permission" => $photopermission
|
"zip" => $zip,
|
||||||
]);
|
"photo_permission" => $photopermission
|
||||||
|
], [
|
||||||
|
'familyid' => $familyid
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$database->insert("families", [
|
||||||
|
"familyname" => $lastname,
|
||||||
|
"father_name" => $father,
|
||||||
|
"mother_name" => $mother,
|
||||||
|
"phone" => $phone,
|
||||||
|
"email" => $email,
|
||||||
|
"newsletter_method" => $newsletter,
|
||||||
|
"address" => $address,
|
||||||
|
"city" => $city,
|
||||||
|
"state" => $state,
|
||||||
|
"zip" => $zip,
|
||||||
|
"photo_permission" => $photopermission
|
||||||
|
]);
|
||||||
|
|
||||||
$familyid = $database->id();
|
$familyid = $database->id();
|
||||||
|
}
|
||||||
|
|
||||||
$children = $_POST['child'];
|
$children = $_POST['child'];
|
||||||
|
|
||||||
@ -124,14 +147,26 @@ $database->action(function($database) {
|
|||||||
errorBack("Invalid birth year chosen for " . htmlentities($children['name'][$cid]) . ".");
|
errorBack("Invalid birth year chosen for " . htmlentities($children['name'][$cid]) . ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
$database->insert("people", [
|
if ($database->has('people', ["AND" => [
|
||||||
"familyid" => $familyid,
|
'familyid' => $familyid,
|
||||||
"name" => $children['name'][$cid],
|
'personid' => $cid
|
||||||
"birthday" => $children['year'][$cid] . "-" . $children['month'][$cid] . "-00",
|
]])) {
|
||||||
"graduated" => empty($children['graduate'][$cid]) ? 0 : 1
|
$database->update('people', [
|
||||||
]);
|
"name" => $children['name'][$cid],
|
||||||
|
"birthday" => $children['year'][$cid] . "-" . $children['month'][$cid] . "-00",
|
||||||
|
"graduated" => empty($children['graduate'][$cid]) ? 0 : 1
|
||||||
|
], ['personid' => $cid]);
|
||||||
|
} else {
|
||||||
|
$database->insert("people", [
|
||||||
|
"familyid" => $familyid,
|
||||||
|
"name" => $children['name'][$cid],
|
||||||
|
"birthday" => $children['year'][$cid] . "-" . $children['month'][$cid] . "-00",
|
||||||
|
"graduated" => empty($children['graduate'][$cid]) ? 0 : 1
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$database->delete('interests', ['familyid' => $familyid]);
|
||||||
$interests = [];
|
$interests = [];
|
||||||
foreach ($_POST['events'] as $evt) {
|
foreach ($_POST['events'] as $evt) {
|
||||||
if ($database->has("events", ['eventid' => $evt])) {
|
if ($database->has("events", ['eventid' => $evt])) {
|
||||||
@ -151,7 +186,6 @@ $database->action(function($database) {
|
|||||||
'source' => $_POST['stripeToken'],
|
'source' => $_POST['stripeToken'],
|
||||||
'statement_descriptor' => 'HACHE Membership 1yr',
|
'statement_descriptor' => 'HACHE Membership 1yr',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Stripe\Error\Card $e) {
|
} catch (\Stripe\Error\Card $e) {
|
||||||
$body = $e->getJsonBody();
|
$body = $e->getJsonBody();
|
||||||
$err = $body['error'];
|
$err = $body['error'];
|
||||||
|
@ -4,6 +4,34 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$familyname = "";
|
||||||
|
$fathername = "";
|
||||||
|
$mothername = "";
|
||||||
|
$streetaddress = "";
|
||||||
|
$city = "";
|
||||||
|
$state = "";
|
||||||
|
$zip = "";
|
||||||
|
$phone = "";
|
||||||
|
$email = "";
|
||||||
|
$newsletter_method = "";
|
||||||
|
|
||||||
|
$children = [];
|
||||||
|
|
||||||
|
if (isset($_SESSION['familyid']) && $database->has('families', ['familyid' => $_SESSION['familyid']])) {
|
||||||
|
$familyinfo = $database->get("families", ['familyname', 'phone', 'email', 'address', 'city', 'state', 'zip', 'father_name (fathername)', 'mother_name (mothername)', 'newsletter_method'], ['familyid' => $_SESSION['familyid']]);
|
||||||
|
$children = $database->select("people", 'personid', ['familyid' => $_SESSION['familyid']]);
|
||||||
|
$familyname = $familyinfo['familyname'];
|
||||||
|
$fathername = $familyinfo['fathername'];
|
||||||
|
$mothername = $familyinfo['mothername'];
|
||||||
|
$streetaddress = $familyinfo['address'];
|
||||||
|
$city = $familyinfo['city'];
|
||||||
|
$state = $familyinfo['state'];
|
||||||
|
$zip = $familyinfo['zip'];
|
||||||
|
$phone = $familyinfo['phone'];
|
||||||
|
$email = $familyinfo['email'];
|
||||||
|
$newsletter_method = $familyinfo['newsletter_method'];
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<form action="actions/submitmembership.php" method="post" id="membershipform">
|
<form action="actions/submitmembership.php" method="post" id="membershipform">
|
||||||
@ -13,7 +41,13 @@
|
|||||||
<div class="d-flex flex-wrap justify-content-around">
|
<div class="d-flex flex-wrap justify-content-around">
|
||||||
<img class="img-fluid" style="max-height: 100px; min-width: 100px;" src="static/hachelogo.svg" alt="HACHE: Helena Area Christian Home Educators"/>
|
<img class="img-fluid" style="max-height: 100px; min-width: 100px;" src="static/hachelogo.svg" alt="HACHE: Helena Area Christian Home Educators"/>
|
||||||
<div class="ml-auto mr-auto pl-4 align-self-center text-center">
|
<div class="ml-auto mr-auto pl-4 align-self-center text-center">
|
||||||
<h1>Membership Application</h1>
|
<?php
|
||||||
|
if (isset($_SESSION['familyid'])) {
|
||||||
|
echo "<h1>Membership Renewal</h1>";
|
||||||
|
} else {
|
||||||
|
echo "<h1>Membership Application</h1>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -45,38 +79,44 @@
|
|||||||
"label" => "Family Name (Last Name)",
|
"label" => "Family Name (Last Name)",
|
||||||
"icon" => "fas fa-users",
|
"icon" => "fas fa-users",
|
||||||
"name" => "familyname",
|
"name" => "familyname",
|
||||||
"maxlength" => 100
|
"maxlength" => 100,
|
||||||
|
"value" => $familyname
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Father's Name",
|
"label" => "Father's Name",
|
||||||
"icon" => "fas fa-male",
|
"icon" => "fas fa-male",
|
||||||
"name" => "fathername",
|
"name" => "fathername",
|
||||||
"maxlength" => 255
|
"maxlength" => 255,
|
||||||
|
"value" => $fathername
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Mother's Name",
|
"label" => "Mother's Name",
|
||||||
"icon" => "fas fa-female",
|
"icon" => "fas fa-female",
|
||||||
"name" => "mothername",
|
"name" => "mothername",
|
||||||
"maxlength" => 255
|
"maxlength" => 255,
|
||||||
|
"value" => $mothername
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Street Address",
|
"label" => "Street Address",
|
||||||
"icon" => "fas fa-home",
|
"icon" => "fas fa-home",
|
||||||
"name" => "streetaddress",
|
"name" => "streetaddress",
|
||||||
"maxlength" => 500
|
"maxlength" => 500,
|
||||||
|
"value" => $streetaddress
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "City",
|
"label" => "City",
|
||||||
"icon" => "fas fa-city",
|
"icon" => "fas fa-city",
|
||||||
"name" => "city",
|
"name" => "city",
|
||||||
"maxlength" => 255,
|
"maxlength" => 255,
|
||||||
"width" => 3
|
"width" => 3,
|
||||||
|
"value" => $city
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "State",
|
"label" => "State",
|
||||||
"icon" => "fas fa-flag",
|
"icon" => "fas fa-flag",
|
||||||
"name" => "state",
|
"name" => "state",
|
||||||
"type" => "select",
|
"type" => "select",
|
||||||
|
"value" => $state,
|
||||||
"options" => [
|
"options" => [
|
||||||
'MT' => 'Montana',
|
'MT' => 'Montana',
|
||||||
'AL' => 'Alabama',
|
'AL' => 'Alabama',
|
||||||
@ -138,13 +178,15 @@
|
|||||||
"icon" => "fas fa-mail-bulk",
|
"icon" => "fas fa-mail-bulk",
|
||||||
"name" => "zip",
|
"name" => "zip",
|
||||||
"maxlength" => 10,
|
"maxlength" => 10,
|
||||||
"width" => 3
|
"width" => 3,
|
||||||
|
"value" => $zip
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Phone Number",
|
"label" => "Phone Number",
|
||||||
"icon" => "fas fa-phone",
|
"icon" => "fas fa-phone",
|
||||||
"name" => "phone",
|
"name" => "phone",
|
||||||
"maxlength" => 20
|
"maxlength" => 20,
|
||||||
|
"value" => $phone
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Email",
|
"label" => "Email",
|
||||||
@ -152,12 +194,14 @@
|
|||||||
"name" => "email",
|
"name" => "email",
|
||||||
"maxlength" => 255,
|
"maxlength" => 255,
|
||||||
"type" => "email",
|
"type" => "email",
|
||||||
|
"value" => $email
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Newsletter Preference",
|
"label" => "Newsletter Preference",
|
||||||
"icon" => "fas fa-newspaper",
|
"icon" => "fas fa-newspaper",
|
||||||
"name" => "newsletter_method",
|
"name" => "newsletter_method",
|
||||||
"type" => "select",
|
"type" => "select",
|
||||||
|
"value" => $newsletter_method,
|
||||||
"options" => [
|
"options" => [
|
||||||
"1" => "Email ($25)",
|
"1" => "Email ($25)",
|
||||||
"2" => "Paper ($35)",
|
"2" => "Paper ($35)",
|
||||||
@ -185,7 +229,9 @@
|
|||||||
maxlength="<?php echo $item['maxlength']; ?>"
|
maxlength="<?php echo $item['maxlength']; ?>"
|
||||||
<?php
|
<?php
|
||||||
if (!empty($item['value'])) {
|
if (!empty($item['value'])) {
|
||||||
echo "value=\"$item[value]\" ";
|
?>
|
||||||
|
value="<?php echo htmlspecialchars($item['value']); ?>"
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
?>required />
|
?>required />
|
||||||
<?php } else if ($item['type'] == "select") { ?>
|
<?php } else if ($item['type'] == "select") { ?>
|
||||||
@ -195,7 +241,11 @@
|
|||||||
required>
|
required>
|
||||||
<?php
|
<?php
|
||||||
foreach ($item['options'] as $value => $label) {
|
foreach ($item['options'] as $value => $label) {
|
||||||
echo "<option value=\"$value\">$label</option>";
|
$selected = "";
|
||||||
|
if (!empty($item['value']) && $value == $item['value']) {
|
||||||
|
$selected = " selected";
|
||||||
|
}
|
||||||
|
echo "<option value=\"$value\"$selected>$label</option>\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
@ -241,7 +291,13 @@
|
|||||||
|
|
||||||
<div class="list-group" id="child_list">
|
<div class="list-group" id="child_list">
|
||||||
<?php
|
<?php
|
||||||
include __DIR__ . "/template_child_entry.php";
|
if (count($children) > 0) {
|
||||||
|
foreach ($children as $childid) {
|
||||||
|
include __DIR__ . "/template_child_entry.php";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
include __DIR__ . "/template_child_entry.php";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -5,8 +5,22 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Use a random ID for each child, so we can tell 100% which inputs go together
|
require_once __DIR__ . "/../../lib/requiredpublic.php";
|
||||||
$randomid = mt_rand(0, 9999999999);
|
|
||||||
|
$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">
|
<div class="list-group-item">
|
||||||
@ -19,7 +33,7 @@ $randomid = mt_rand(0, 9999999999);
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fas fa-user-graduate"></i></span>
|
<span class="input-group-text"><i class="fas fa-user-graduate"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" name="child[name][<?php echo $randomid; ?>]" class="form-control" />
|
<input type="text" name="child[name][<?php echo $randomid; ?>]" class="form-control" value="<?php echo htmlspecialchars($childinfo['name']); ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -31,19 +45,16 @@ $randomid = mt_rand(0, 9999999999);
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fas fa-calendar"></i></span>
|
<span class="input-group-text"><i class="fas fa-calendar"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<select name="child[month][<?php echo $randomid; ?>]" class="form-control">
|
<select name="child[month][<?php echo $randomid; ?>]" class="form-control" value="<?php echo $childinfo['month']; ?>" >
|
||||||
<option value=1>January</option>
|
<?php
|
||||||
<option value=2>February</option>
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
<option value=3>March</option>
|
$selected = "";
|
||||||
<option value=4>April</option>
|
if ($childinfo['month'] == $i) {
|
||||||
<option value=5>May</option>
|
$selected = " selected";
|
||||||
<option value=6>June</option>
|
}
|
||||||
<option value=7>July</option>
|
echo "<option value=$i$selected>" . date("F", mktime(0, 0, 0, $i, 2)) . "</option>\n";
|
||||||
<option value=8>August</option>
|
}
|
||||||
<option value=9>September</option>
|
?>
|
||||||
<option value=10>October</option>
|
|
||||||
<option value=11>November</option>
|
|
||||||
<option value=12>December</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -56,17 +67,21 @@ $randomid = mt_rand(0, 9999999999);
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fas fa-calendar-alt"></i></span>
|
<span class="input-group-text"><i class="fas fa-calendar-alt"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" name="child[year][<?php echo $randomid; ?>]" class="form-control" min="1980" max="<?php echo date('Y'); ?>" value="<?php echo date('Y', strtotime('now - 10 years')); ?>"/>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-sm-2">
|
<div class="col-12 col-sm-2">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Graduated?</label>
|
<label> </label>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" value="1" name="child[graduate][<?php echo $randomid; ?>]">
|
<input class="form-check-input" type="checkbox" value="1" name="child[graduate][<?php echo $randomid; ?>]"<?php
|
||||||
<label class="form-check-label mt-1">Yes</label>
|
if ($childinfo['graduated']) {
|
||||||
|
echo " checked";
|
||||||
|
}
|
||||||
|
?>>
|
||||||
|
<label class="form-check-label mt-1">Graduated</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,10 +14,21 @@
|
|||||||
|
|
||||||
<h1>Thank You!</h1>
|
<h1>Thank You!</h1>
|
||||||
|
|
||||||
<img class="img-fluid mb-4" style="max-height: 150px;" src="static/bigcheck.svg" alt="Checkmark"/>
|
<img class="img-fluid mb-4 mt-2" style="max-height: 150px;" src="static/bigcheck.svg" alt="Checkmark"/>
|
||||||
|
|
||||||
<h4>Your membership has been submitted and paid for. We'll be in touch soon!</h4>
|
<?php
|
||||||
|
if (isset($_SESSION['familyid'])) {
|
||||||
|
echo "<h2 class=\"h3\">Your membership has been renewed.</h2>";
|
||||||
|
} else {
|
||||||
|
echo "<h2 class=\"h3\">Your membership has been submitted and paid for. We'll be in touch soon!</h2>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<h3 class="h5 mt-4">You may now close this page.</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$_SESSION['familyid'] = null;
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user