Fix issues with renewal/signup

master
Skylar Ittner 6 years ago
parent a76b3907a3
commit b838fcace4

Binary file not shown.

@ -23,7 +23,7 @@ if (empty($_POST['agree_terms'])) {
$family = new Family(); $family = new Family();
if (!empty($_SESSION['familyid']) && $database->has("families", ['familyid' => $_SESSION['familyid']])) { if (!empty($_SESSION['familyid']) && $database->has("families", ['familyid' => $_SESSION['familyid']])) {
$family = (new Family())->load($familyid); $family = (new Family())->load($_SESSION['familyid']);
} else if (!empty($_POST['renewing'])) { } else if (!empty($_POST['renewing'])) {
// Session expired, but we're renewing, so kick them back to verification // Session expired, but we're renewing, so kick them back to verification
header("Location: ../?page=renew&msg=sessionexpired"); header("Location: ../?page=renew&msg=sessionexpired");
@ -147,7 +147,6 @@ $database->action(function($database) {
foreach ($childObjects as $child) { foreach ($childObjects as $child) {
$child->save(); $child->save();
} }
} catch (Exception $ex) { } catch (Exception $ex) {
errorBack($ex->getMessage()); errorBack($ex->getMessage());
} }
@ -156,15 +155,16 @@ $database->action(function($database) {
// //
// Interests // Interests
// //
$database->delete('interests', ['familyid' => $familyid]); $database->delete('interests', ['familyid' => $family->getID()]);
$interests = []; if (!empty($_POST['events']) && is_array($_POST['events'])) {
foreach ($_POST['events'] as $evt) { $interests = [];
if ($database->has("events", ['eventid' => $evt])) { foreach ($_POST['events'] as $evt) {
$interests[] = ["familyid" => $familyid, "eventid" => $evt]; if ($database->has("events", ['eventid' => $evt])) {
$interests[] = ["familyid" => $family->getID(), "eventid" => $evt];
}
} }
$database->insert("interests", $interests);
} }
$database->insert("interests", $interests);
// //
@ -199,12 +199,13 @@ $database->action(function($database) {
} }
$database->insert("payments", [ $database->insert("payments", [
"familyid" => $familyid, "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")
]); ]);
header("Location: ../?page=thanks"); header("Location: ../?page=thanks");
return true; return true;
}); });

@ -21,7 +21,7 @@ if (!empty($_POST['email'])) {
$_SESSION['maybefamily'] = $database->get('families', 'familyid', ['email' => strtolower($_POST['email'])]); $_SESSION['maybefamily'] = $database->get('families', 'familyid', ['email' => strtolower($_POST['email'])]);
// TODO: send email // TODO: send email
echo $code; file_put_contents("/var/www/html/code.txt", $code);
} else if (!empty($_POST['code'])) { } else if (!empty($_POST['code'])) {
if (empty($_SESSION['code'])) { if (empty($_SESSION['code'])) {
header("Location: ./?page=renew&msg=sessionexpired"); header("Location: ./?page=renew&msg=sessionexpired");

Loading…
Cancel
Save