|
|
|
@ -17,7 +17,12 @@ if (empty($_POST['agree_terms'])) {
|
|
|
|
|
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) {
|
|
|
|
|
global $familyid;
|
|
|
|
|
$lastname = $_POST['familyname'];
|
|
|
|
|
$father = $_POST['fathername'];
|
|
|
|
|
$mother = $_POST['mothername'];
|
|
|
|
@ -89,21 +94,39 @@ $database->action(function($database) {
|
|
|
|
|
$photopermission = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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
|
|
|
|
|
]);
|
|
|
|
|
if (isset($familyid)) {
|
|
|
|
|
$database->update("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' => $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'];
|
|
|
|
|
|
|
|
|
@ -124,14 +147,26 @@ $database->action(function($database) {
|
|
|
|
|
errorBack("Invalid birth year chosen for " . htmlentities($children['name'][$cid]) . ".");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$database->insert("people", [
|
|
|
|
|
"familyid" => $familyid,
|
|
|
|
|
"name" => $children['name'][$cid],
|
|
|
|
|
"birthday" => $children['year'][$cid] . "-" . $children['month'][$cid] . "-00",
|
|
|
|
|
"graduated" => empty($children['graduate'][$cid]) ? 0 : 1
|
|
|
|
|
]);
|
|
|
|
|
if ($database->has('people', ["AND" => [
|
|
|
|
|
'familyid' => $familyid,
|
|
|
|
|
'personid' => $cid
|
|
|
|
|
]])) {
|
|
|
|
|
$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 = [];
|
|
|
|
|
foreach ($_POST['events'] as $evt) {
|
|
|
|
|
if ($database->has("events", ['eventid' => $evt])) {
|
|
|
|
@ -143,7 +178,7 @@ $database->action(function($database) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
\Stripe\Stripe::setApiKey(STRIPE_SECKEY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$charge = \Stripe\Charge::create([
|
|
|
|
|
'amount' => $membership_cost,
|
|
|
|
|
'currency' => 'usd',
|
|
|
|
@ -151,7 +186,6 @@ $database->action(function($database) {
|
|
|
|
|
'source' => $_POST['stripeToken'],
|
|
|
|
|
'statement_descriptor' => 'HACHE Membership 1yr',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
} catch (\Stripe\Error\Card $e) {
|
|
|
|
|
$body = $e->getJsonBody();
|
|
|
|
|
$err = $body['error'];
|
|
|
|
|