updated to add country membership

This commit is contained in:
twotalesanimation
2025-12-19 19:50:22 +02:00
parent c618fd4506
commit 782d343243
7 changed files with 306 additions and 184 deletions

View File

@@ -164,7 +164,7 @@ RewriteRule ^autosave$ src/processors/blog/autosave.php [L]
</IfModule> </IfModule>
php_flag display_errors Off php_flag display_errors On
# php_value error_reporting -1 # php_value error_reporting -1
RedirectMatch 403 ^/\.well-known RedirectMatch 403 ^/\.well-known
Options -Indexes Options -Indexes

View File

@@ -27,19 +27,35 @@ if ($showRenewModal) {
} else { } else {
$showRenewModal = false; $showRenewModal = false;
} }
$user_id = $_SESSION['user_id']; $user_id = $_SESSION['user_id'];
// Ensure we have a DB connection
if (!isset($conn) || $conn === null) {
$showRenewModal = false;
} else {
$stmt = $conn->prepare("SELECT payment_status FROM membership_fees WHERE user_id = ? LIMIT 1"); $stmt = $conn->prepare("SELECT payment_status FROM membership_fees WHERE user_id = ? LIMIT 1");
$stmt->bind_param("i", $user_id); $stmt->bind_param("i", $user_id);
$stmt->execute(); $stmt->execute();
// store_result so we can check num_rows
$stmt->store_result();
// If there's no membership_fees record for this user, don't show the renew modal
if ($stmt->num_rows === 0) {
$showRenewModal = false;
} else {
$stmt->bind_result($payment_status); $stmt->bind_result($payment_status);
$stmt->fetch(); $stmt->fetch();
$stmt->close();
if ($payment_status === 'PENDING RENEWAL') { if ($payment_status === 'PENDING RENEWAL') {
$showRenewModal = false; $showRenewModal = false;
} }
} }
$stmt->close();
}
}
if (isset($_SESSION['user_id']) && isset($conn) && $conn !== null) { if (isset($_SESSION['user_id']) && isset($conn) && $conn !== null) {
$userId = $_SESSION['user_id']; $userId = $_SESSION['user_id'];
$stmt = $conn->prepare("SELECT user_id FROM membership_application WHERE user_id = ? AND accept_indemnity = 0 LIMIT 1"); $stmt = $conn->prepare("SELECT user_id FROM membership_application WHERE user_id = ? AND accept_indemnity = 0 LIMIT 1");

View File

@@ -39,6 +39,31 @@ $user = $result->fetch_assoc();
<div class="section-title"> <div class="section-title">
<div id="responseMessage"></div> <!-- Message display area --> <div id="responseMessage"></div> <!-- Message display area -->
</div> </div>
<!-- Membership Type -->
<h3>Membership Type</h3>
<div class="row mt-35">
<div class="col-md-12">
<div class="form-group mb-3">
<div class="form-check">
<input type="checkbox" id="country_membership" name="country_membership" value="1">
<label style="margin-left:20px;" for="country_membership">Country Membership - if you reside more than 150km from BASE4 and qualify for country membership.</label>
</div>
<div class="mt-2">
<div class="form-check form-check-inline">
<input type="radio" name="membership_type" id="membership_full" value="full" checked>
<label style="margin-left:20px;" for="membership_full">Full Membership</label>
</div>
<div class="form-check form-check-inline">
<input type="radio" name="membership_type" id="membership_single" value="single">
<label style="margin-left:20px;" for="membership_single">Single Membership</label>
</div>
</div>
</div>
</div>
</div>
<!-- Personal Details Section --> <!-- Personal Details Section -->
<h3>Main Member</h3> <h3>Main Member</h3>
<div class="row mt-35"> <div class="row mt-35">
@@ -88,6 +113,7 @@ $user = $result->fetch_assoc();
</div> </div>
<!-- Spouse / Partner Details Section --> <!-- Spouse / Partner Details Section -->
<div id="spouseSection">
<h3>Spouse / Life Partner / Other Details</h3> <h3>Spouse / Life Partner / Other Details</h3>
<div class="row mt-35"> <div class="row mt-35">
<div class="col-md-6"> <div class="col-md-6">
@@ -135,7 +161,11 @@ $user = $result->fetch_assoc();
</div> </div>
</div> </div>
</div> <!-- end spouse row -->
<!-- </div> end spouseSection -->
<!-- Children Section --> <!-- Children Section -->
<div id="childrenSection">
<h3>Children's Names</h3> <h3>Children's Names</h3>
<div class="row mt-35"> <div class="row mt-35">
<div class="col-md-6"> <div class="col-md-6">
@@ -176,6 +206,7 @@ $user = $result->fetch_assoc();
</div> </div>
<!-- Repeat for other children if needed --> <!-- Repeat for other children if needed -->
</div> </div>
</div> <!-- end childrenSection -->
<!-- Address Section --> <!-- Address Section -->
<h3>Address</h3> <h3>Address</h3>
@@ -282,3 +313,43 @@ $user = $result->fetch_assoc();
<?php include_once(dirname(dirname(dirname(__DIR__))) . '/components/insta_footer.php'); ?> <?php include_once(dirname(dirname(dirname(__DIR__))) . '/components/insta_footer.php'); ?>
<script>
// Toggle spouse and children sections when 'Single Membership' is selected
(function() {
function setSectionState(isSingle) {
var spouse = document.getElementById('spouseSection');
var children = document.getElementById('childrenSection');
[spouse, children].forEach(function(sec) {
if (!sec) return;
var inputs = sec.querySelectorAll('input, select, textarea, button');
if (isSingle) {
sec.style.display = 'none';
inputs.forEach(function(i) {
i.disabled = true;
});
} else {
sec.style.display = '';
inputs.forEach(function(i) {
i.disabled = false;
});
}
});
}
document.addEventListener('DOMContentLoaded', function() {
var full = document.getElementById('membership_full');
var single = document.getElementById('membership_single');
// initialize state
setSectionState(single && single.checked);
if (full) full.addEventListener('change', function() {
if (this.checked) setSectionState(false);
});
if (single) single.addEventListener('change', function() {
if (this.checked) setSectionState(true);
});
});
})();
</script>

View File

@@ -189,7 +189,7 @@ if (empty($application['id_number'])) {
<td><?php echo htmlspecialchars($membership['payment_amount']); ?></td> <td><?php echo htmlspecialchars($membership['payment_amount']); ?></td>
<td><?php echo htmlspecialchars($membership['payment_id']); ?></td> <td><?php echo htmlspecialchars($membership['payment_id']); ?></td>
<?php if ($membership['payment_status'] == "AWAITING PAYMENT" || $membership['payment_status'] == "PENDING RENEWAL") { ?> <?php if ($membership['payment_status'] == "AWAITING PAYMENT" || $membership['payment_status'] == "PENDING RENEWAL") { ?>
<td><a href='<?= $payment_link; ?>' class='theme-btn style-two style-three' style='padding: 0px 14px;'><span data-hover='PAY NOW'>PENDING RENEWAL</span></a></td> <td><a href='<?= $payment_link; ?>' class='theme-btn style-two style-three' style='padding: 0px 14px;'><span data-hover='<?= $membership['payment_status'] ?>'><?= $membership['payment_status'] ?></span></a></td>
<?php } else { ?> <?php } else { ?>
<td><?php echo htmlspecialchars($membership['payment_status']); ?></td> <td><?php echo htmlspecialchars($membership['payment_status']); ?></td>
<?php } ?> <?php } ?>

View File

@@ -141,6 +141,17 @@ include_once($rootPath . '/header.php');
margin: 50px; margin: 50px;
padding: 20px; padding: 20px;
border-radius: 20px; border-radius: 20px;
box-sizing: border-box;
}
@media (max-width: 768px) {
#map {
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
height: 500px !important;
border-radius: 0 !important;
}
} }
.obstacle-popup h4 { .obstacle-popup h4 {

View File

@@ -4,6 +4,7 @@ require_once($rootPath . "/src/config/env.php");
require_once($rootPath . "/src/config/session.php"); require_once($rootPath . "/src/config/session.php");
require_once($rootPath . "/src/config/connection.php"); require_once($rootPath . "/src/config/connection.php");
require_once($rootPath . "/src/config/functions.php"); require_once($rootPath . "/src/config/functions.php");
require_once($rootPath . "/src/helpers/notification_helper.php");
$user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : null; $user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : null;
$payment_id = generatePaymentRef('SUBS', null, $user_id); $payment_id = generatePaymentRef('SUBS', null, $user_id);
@@ -92,6 +93,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
die('Invalid email format.'); die('Invalid email format.');
} }
//MEMBERSHIP TYPE
$country_membership = isset($_POST['country_membership']) ? 1 : 0;
$membership_type = in_array($_POST['membership_type'] ?? '', ['full', 'single']) ? $_POST['membership_type'] : 'full';
if ($country_membership) {
$membership_type = 'country';
}else{
$membership_type = $membership_type;
}
// Spouse or Partner details (optional) // Spouse or Partner details (optional)
$spouse_first_name = !empty($_POST['spouse_first_name']) ? validateName($_POST['spouse_first_name']) : null; $spouse_first_name = !empty($_POST['spouse_first_name']) ? validateName($_POST['spouse_first_name']) : null;
$spouse_last_name = !empty($_POST['spouse_last_name']) ? validateName($_POST['spouse_last_name']) : null; $spouse_last_name = !empty($_POST['spouse_last_name']) ? validateName($_POST['spouse_last_name']) : null;
@@ -136,8 +147,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
spouse_first_name, spouse_last_name, spouse_id_number, spouse_dob, spouse_occupation, spouse_tel_cell, spouse_email, spouse_first_name, spouse_last_name, spouse_id_number, spouse_dob, spouse_occupation, spouse_tel_cell, spouse_email,
child_name1, child_dob1, child_name2, child_dob2, child_name3, child_dob3, child_name1, child_dob1, child_name2, child_dob2, child_name3, child_dob3,
physical_address, postal_address, interests_hobbies, vehicle_make, vehicle_model, vehicle_year, vehicle_registration, physical_address, postal_address, interests_hobbies, vehicle_make, vehicle_model, vehicle_year, vehicle_registration,
secondary_vehicle_make, secondary_vehicle_model, secondary_vehicle_year, secondary_vehicle_registration secondary_vehicle_make, secondary_vehicle_model, secondary_vehicle_year, secondary_vehicle_registration, membership_type
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
// Check if preparation was successful // Check if preparation was successful
if (!$stmt) { if (!$stmt) {
@@ -145,7 +156,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
$stmt->bind_param( $stmt->bind_param(
"isssssssssssssssssssssssssssssss", "issssssssssssssssssssssssssssssss",
$user_id, $user_id,
$first_name, $first_name,
$last_name, $last_name,
@@ -177,7 +188,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$secondary_vehicle_make, $secondary_vehicle_make,
$secondary_vehicle_model, $secondary_vehicle_model,
$secondary_vehicle_year, $secondary_vehicle_year,
$secondary_vehicle_registration $secondary_vehicle_registration,
$membership_type
); );
if ($stmt->execute()) { if ($stmt->execute()) {
@@ -187,10 +199,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$year = (int)$today->format('Y'); $year = (int)$today->format('Y');
$payment_date = $today->format('Y-m-d'); $payment_date = $today->format('Y-m-d');
$membership_start_date = $payment_date; $membership_start_date = $payment_date;
if ($membership_type === 'country') {
$payment_amount = getPriceByDescription('country_membership');
$prorata_amount = calculateProrata(getPriceByDescription('country_prorata'));
} elseif ($membership_type === 'single') {
$payment_amount = getPriceByDescription('single');
$prorata_amount = calculateProrata(getPriceByDescription('single_prorata'));
} else {
$payment_amount = getPriceByDescription('membership_fees');
$prorata_amount = calculateProrata(getPriceByDescription('pro_rata'));
}
if ($month == 12 || $month == 1 || $month == 2) { if ($month == 12 || $month == 1 || $month == 2) {
// December, January, February: charge full fee, valid till end of next Feb // December, January, February: charge full fee, valid till end of next Feb
$payment_amount = getPriceByDescription('membership_fees'); $payment_amount = $payment_amount;
// If Dec, Jan, Feb, set end to next year's Feb // If Dec, Jan, Feb, set end to next year's Feb
$end_year = ($month == 12) ? $year + 2 : $year + 1; $end_year = ($month == 12) ? $year + 2 : $year + 1;
$membership_end_date = (new DateTime("$end_year-02-01")) $membership_end_date = (new DateTime("$end_year-02-01"))
@@ -198,7 +222,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
->format('Y-m-d'); ->format('Y-m-d');
} else { } else {
// Prorata for Mar-Nov // Prorata for Mar-Nov
$payment_amount = calculateProrata(getPriceByDescription('pro_rata')); $payment_amount = $prorata_amount;
// End of next Feb if after Feb, else this Feb // End of next Feb if after Feb, else this Feb
if ($month > 2) { if ($month > 2) {
$end_year = $year + 1; $end_year = $year + 1;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB