563 lines
28 KiB
PHP
563 lines
28 KiB
PHP
<?php
|
|
$headerStyle = 'light';
|
|
include_once(dirname(dirname(dirname(__DIR__))) . '/header.php');
|
|
|
|
// Ensure the user is logged in
|
|
if (!isset($_SESSION['user_id'])) {
|
|
die("User not logged in.");
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
checkMembershipApplication2($user_id);
|
|
// Fetch the user's membership details
|
|
$sql = "SELECT membership_start_date, membership_end_date, payment_status, payment_amount, payment_id FROM membership_fees WHERE user_id = ?";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("i", $user_id);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
// Fetch single record
|
|
$membership = $result->fetch_assoc();
|
|
|
|
// Fetch membership application data using mysqli
|
|
$query = "SELECT * FROM membership_application WHERE user_id = ?";
|
|
$stmt = $conn->prepare($query);
|
|
$stmt->bind_param("i", $user_id);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$application = $result->fetch_assoc();
|
|
|
|
// Close statement
|
|
$stmt->close();
|
|
|
|
if (empty($application['id_number'])) {
|
|
$_SESSION['message'] = 'Please update your details below to complete your application.';
|
|
}
|
|
?>
|
|
<style>
|
|
table {
|
|
width: 100%;
|
|
border-collapse: separate;
|
|
border-spacing: 0;
|
|
margin: 10px 0;
|
|
}
|
|
|
|
thead th {
|
|
cursor: pointer;
|
|
text-align: left;
|
|
padding: 10px;
|
|
font-weight: bold;
|
|
position: relative;
|
|
}
|
|
|
|
thead th::after {
|
|
content: '\25B2';
|
|
/* Up arrow */
|
|
font-size: 0.8em;
|
|
position: absolute;
|
|
right: 10px;
|
|
opacity: 0;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
thead th.asc::after {
|
|
content: '\25B2';
|
|
/* Up arrow */
|
|
opacity: 1;
|
|
}
|
|
|
|
thead th.desc::after {
|
|
content: '\25BC';
|
|
/* Down arrow */
|
|
opacity: 1;
|
|
}
|
|
|
|
tbody tr:nth-child(odd) {
|
|
background-color: transparent;
|
|
}
|
|
|
|
tbody tr:nth-child(even) {
|
|
background-color: rgb(255, 255, 255);
|
|
border-radius: 10px;
|
|
}
|
|
|
|
tbody td {
|
|
padding: 5px;
|
|
}
|
|
|
|
tbody tr:nth-child(even) td:first-child {
|
|
border-top-left-radius: 10px;
|
|
border-bottom-left-radius: 10px;
|
|
}
|
|
|
|
tbody tr:nth-child(even) td:last-child {
|
|
border-top-right-radius: 10px;
|
|
border-bottom-right-radius: 10px;
|
|
}
|
|
|
|
.filter-input {
|
|
width: 100%;
|
|
padding: 5px;
|
|
/* margin-bottom: 20px; */
|
|
font-size: 16px;
|
|
background-color: rgb(255, 255, 255);
|
|
border-radius: 25px;
|
|
}
|
|
|
|
.infobox {
|
|
color: #484848;
|
|
background: #f9f9f7;
|
|
border: 1px solid #d8d8d8;
|
|
border-radius: 10px;
|
|
margin-top: 15px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.message-box {
|
|
text-align: center;
|
|
position: relative;
|
|
padding: 10px;
|
|
padding-right: 35px;
|
|
/* Ensures text doesn't overlap with the close button */
|
|
}
|
|
|
|
.close-btn {
|
|
position: absolute;
|
|
right: 10px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
/* Centers vertically */
|
|
cursor: pointer;
|
|
font-size: 20px;
|
|
font-weight: bold;
|
|
color: #333;
|
|
background: none;
|
|
border: none;
|
|
}
|
|
|
|
.close-btn:hover {
|
|
color: red;
|
|
}
|
|
</style>
|
|
|
|
<!-- Account Settings Area start -->
|
|
<section class="account-settings-area py-70 rel z-1">
|
|
<div class="container">
|
|
<div class="row align-items-center">
|
|
<div class="col-lg-12">
|
|
<div class="comment-form bgc-lighter z-1 rel mb-30 rmb-55">
|
|
<div class="section-title py-20">
|
|
<h2>Membership Details</h2>
|
|
<div id="responseMessage"></div> <!-- Message display area -->
|
|
<?php if (isset($_SESSION['message'])): ?>
|
|
<div class="alert alert-success message-box">
|
|
<?php echo $_SESSION['message']; ?>
|
|
<span class="close-btn" onclick="this.parentElement.style.display='none'">×</span>
|
|
</div>
|
|
<?php unset($_SESSION['message']); ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- Table Display -->
|
|
<div style='padding:10px;'>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Start Date</th>
|
|
<th>Renewal Date</th>
|
|
<th>Indemnity</th>
|
|
<th>Amount</th>
|
|
<th>Payment Reference</th>
|
|
<th>Payment Status</th>
|
|
<th>Membership Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($membership): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($membership['membership_start_date']); ?></td>
|
|
<td><?php echo htmlspecialchars($membership['membership_end_date']); ?></td>
|
|
<?php if (hasAcceptedIndemnity($user_id)) { ?>
|
|
<td><a href='view_indemnity.php' class='theme-btn style-two style-three' style='padding: 0px 14px;'><span data-hover='VIEW INDEMNITY'>VIEW INDEMNITY</span></a></td>
|
|
<?php } else { ?>
|
|
<td><a href='indemnity.php' class='theme-btn style-two style-three' style='padding: 0px 14px;'><span data-hover='SIGN INDEMNITY'>SIGN INDEMNITY</span></a></td>
|
|
<?php } ?>
|
|
|
|
|
|
<td><?php echo htmlspecialchars($membership['payment_amount']); ?></td>
|
|
<td><?php echo htmlspecialchars($membership['payment_id']); ?></td>
|
|
<?php if ($membership['payment_status'] == "PENDING") { ?>
|
|
<td><a href='membership_payment' class='theme-btn style-two style-three' style='padding: 0px 14px;'><span data-hover='VIEW PAYMENT INFO'>AWAITING PAYMENT</span></a></td>
|
|
<?php } else { ?>
|
|
<td><?php echo htmlspecialchars($membership['payment_status']); ?></td>
|
|
<?php } ?>
|
|
|
|
<td><?php echo getUserMemberStatus($user_id) ? 'ACTIVE' : 'INACTIVE'; ?></td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<tr>
|
|
<td colspan="6">No membership records found.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
// Check if membership has expired
|
|
$membership_end_date = $membership ? $membership['membership_end_date'] : null;
|
|
$today = date('Y-m-d');
|
|
|
|
if ($membership_end_date && strtotime($today) > strtotime($membership_end_date)) {
|
|
echo '
|
|
<a href="renew_membership" class="theme-btn style-two bgc-secondary" style="width:100%; margin-top: 20px; background-color: #63ab45; padding: 10px 20px; color: white; text-decoration: none; border-radius: 25px;">
|
|
<span data-hover="Renew Membership">Renew Membership</span>
|
|
<i class="fal fa-arrow-right"></i>
|
|
</a>';
|
|
}
|
|
?>
|
|
<form id="infoForm" name="registerForm" action="update_application" method="post" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">
|
|
<div class="section-title">
|
|
<div id="responseMessage"></div> <!-- Message display area -->
|
|
</div>
|
|
<!-- Personal Details Section -->
|
|
<h3>Main Member</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="first_name">First Name*</label>
|
|
<input type="text" id="first_name" name="first_name" class="form-control" value="<?php echo htmlspecialchars($application['first_name'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="last_name">Surname*</label>
|
|
<input type="text" id="last_name" name="last_name" class="form-control" value="<?php echo htmlspecialchars($application['last_name'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="id_number">ID Number / Passport Number*</label>
|
|
<input type="text" id="id_number" name="id_number" class="form-control" value="<?php echo htmlspecialchars($application['id_number'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="dob">Date of Birth*</label>
|
|
<input type="date" id="dob" name="dob" class="form-control" value="<?php echo htmlspecialchars($application['dob'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="form-group">
|
|
<label for="occupation">Occupation*</label>
|
|
<input type="text" id="occupation" name="occupation" class="form-control" value="<?php echo htmlspecialchars($application['occupation'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="form-group">
|
|
<label for="tel_cell">Cell Phone*</label>
|
|
<input type="text" id="tel_cell" name="tel_cell" class="form-control" value="<?php echo htmlspecialchars($application['tel_cell'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="form-group">
|
|
<label for="email">Email Address*</label>
|
|
<input type="email" id="email" name="email" class="form-control" value="<?php echo htmlspecialchars($application['email'] ?? ''); ?>" required>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Spouse / Partner Details Section -->
|
|
<h3>Spouse / Life Partner / Other Details</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="spouse_first_name">First Name</label>
|
|
<input type="text" id="spouse_first_name" name="spouse_first_name" class="form-control" value="<?php echo htmlspecialchars($application['spouse_first_name'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="spouse_last_name">Surname</label>
|
|
<input type="text" id="spouse_last_name" name="spouse_last_name" class="form-control" value="<?php echo htmlspecialchars($application['spouse_last_name'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="spouse_id_number">ID Number / Passport Number</label>
|
|
<input type="text" id="spouse_id_number" name="spouse_id_number" class="form-control" value="<?php echo htmlspecialchars($application['spouse_id_number'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="spouse_dob">Date of Birth</label>
|
|
<input type="date" id="spouse_dob" name="spouse_dob" class="form-control" value="<?php echo htmlspecialchars($application['spouse_dob'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="form-group">
|
|
<label for="spouse_occupation">Occupation</label>
|
|
<input type="text" id="spouse_occupation" name="spouse_occupation" class="form-control" value="<?php echo htmlspecialchars($application['spouse_occupation'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="form-group">
|
|
<label for="spouse_phone_numbers">Cell Phone</label>
|
|
<input type="text" id="spouse_tel_cell" name="spouse_tel_cell" class="form-control" value="<?php echo htmlspecialchars($application['spouse_tel_cell'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="form-group">
|
|
<label for="spouse_email">Email Address</label>
|
|
<input type="email" id="spouse_email" name="spouse_email" class="form-control" value="<?php echo htmlspecialchars($application['spouse_email'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Children Section -->
|
|
<h3>Children's Names</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="child_name1">Child 1 Name</label>
|
|
<input type="text" id="child_name1" name="child_name1" class="form-control" value="<?php echo htmlspecialchars($application['child_name1'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="child_dob1">Child 1 DOB</label>
|
|
<input type="date" id="child_dob1" name="child_dob1" class="form-control" value="<?php echo htmlspecialchars($application['child_dob1'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="child_name2">Child 2 Name</label>
|
|
<input type="text" id="child_name2" name="child_name2" class="form-control" value="<?php echo htmlspecialchars($application['child_name2'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="child_dob2">Child 2 DOB</label>
|
|
<input type="date" id="child_dob2" name="child_dob2" class="form-control" value="<?php echo htmlspecialchars($application['child_dob2'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="child_name3">Child 3 Name</label>
|
|
<input type="text" id="child_name3" name="child_name3" class="form-control" value="<?php echo htmlspecialchars($application['child_name3'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="child_dob3">Child 3 DOB</label>
|
|
<input type="date" id="child_dob3" name="child_dob3" class="form-control" value="<?php echo htmlspecialchars($application['child_dob3'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<!-- Repeat for other children if needed -->
|
|
</div>
|
|
|
|
<!-- Address Section -->
|
|
<h3>Address</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="physical_address">Physical Address</label>
|
|
<textarea id="physical_address" name="physical_address" class="form-control" value="<?php echo htmlspecialchars($application['physical_address'] ?? ''); ?>"></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="postal_address">Postal Address</label>
|
|
<textarea id="postal_address" name="postal_address" class="form-control" pvalue="<?php echo htmlspecialchars($application['postal_address'] ?? ''); ?>"></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Interests Section -->
|
|
<h3>Interests and Hobbies</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<textarea id="interests_hobbies" name="interests_hobbies" class="form-control" value="<?php echo htmlspecialchars($application['interests_hobbies'] ?? ''); ?>"></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Vehicle Section -->
|
|
<h3>Primary Vehicle</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="vehicle_make">Make</label>
|
|
<input type="text" id="vehicle_make" name="vehicle_make" class="form-control" value="<?php echo htmlspecialchars($application['vehicle_make'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="vehicle_model">Model</label>
|
|
<input type="text" id="vehicle_model" name="vehicle_model" class="form-control" value="<?php echo htmlspecialchars($application['vehicle_model'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="vehicle_year">Year</label>
|
|
<input type="text" id="vehicle_year" name="vehicle_year" class="form-control" value="<?php echo htmlspecialchars($application['vehicle_year'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="vehicle_registration">Registration</label>
|
|
<input type="text" id="vehicle_registration" name="vehicle_registration" class="form-control" value="<?php echo htmlspecialchars($application['vehicle_registration'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<h3>Secondary Vehicle</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="secondary_vehicle_make">Make</label>
|
|
<input type="text" id="secondary_vehicle_make" name="secondary_vehicle_make" class="form-control" value="<?php echo htmlspecialchars($application['secondary_vehicle_make'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="secondary_vehicle_model">Model</label>
|
|
<input type="text" id="secondary_vehicle_model" name="secondary_vehicle_model" class="form-control" value="<?php echo htmlspecialchars($application['secondary_vehicle_model'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="secondary_vehicle_year">Year</label>
|
|
<input type="text" id="secondary_vehicle_year" name="secondary_vehicle_year" class="form-control" value="<?php echo htmlspecialchars($application['secondary_vehicle_year'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="secondary_vehicle_registration">Registration</label>
|
|
<input type="text" id="secondary_vehicle_registration" name="secondary_vehicle_registration" class="form-control" value="<?php echo htmlspecialchars($application['secondary_vehicle_registration'] ?? ''); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Submit Section -->
|
|
<div class="col-md-12">
|
|
<div class="form-group mb-0">
|
|
<button type="submit" class="theme-btn style-two" style="width:100%;">Update Info</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<!-- Account Settings Area end -->
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Clear the responseMessage when the user changes any form input
|
|
$('#accountForm input, #changePasswordForm input').on('input', function() {
|
|
$('#responseMessage').html(''); // Clear the message
|
|
$('#responseMessage2').html(''); // Clear the message
|
|
});
|
|
// Profile Picture Upload
|
|
$('#uploadPictureBtn').click(function() {
|
|
$('#profile_picture').click();
|
|
});
|
|
|
|
$('#profile_picture').on('change', function() {
|
|
var formData = new FormData();
|
|
formData.append('profile_picture', $('#profile_picture')[0].files[0]);
|
|
|
|
$.ajax({
|
|
url: 'upload_profile_picture',
|
|
type: 'POST',
|
|
data: formData,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function(response) {
|
|
// Parse response if needed
|
|
if (typeof response === "string") {
|
|
response = JSON.parse(response);
|
|
}
|
|
|
|
if (response.status === 'success') {
|
|
// Update the profile picture source with cache-busting query string
|
|
// Reload the current page
|
|
window.location.reload();
|
|
|
|
$('#responseMessage').html('<div class="alert alert-success">' + response.message + '</div>');
|
|
} else {
|
|
$('#responseMessage').html('<div class="alert alert-danger">' + response.message + '</div>');
|
|
}
|
|
},
|
|
error: function() {
|
|
$('#responseMessage').html('<div class="alert alert-danger">Error uploading profile picture.</div>');
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
// Account Info Update
|
|
$('#accountForm').on('submit', function(event) {
|
|
event.preventDefault(); // Prevent default form submission
|
|
|
|
$.ajax({
|
|
url: 'update_user',
|
|
type: 'POST',
|
|
data: $(this).serialize(),
|
|
success: function(response) {
|
|
// Parse response if needed
|
|
if (typeof response === "string") {
|
|
response = JSON.parse(response);
|
|
}
|
|
|
|
if (response.status === 'success') {
|
|
$('#responseMessage').html('<div class="alert alert-success">' + response.message + '</div>');
|
|
} else {
|
|
$('#responseMessage').html('<div class="alert alert-danger">' + response.message + '</div>');
|
|
}
|
|
},
|
|
error: function() {
|
|
$('#responseMessage').html('<div class="alert alert-danger">Error updating information.</div>');
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
// Change Password
|
|
$('#changePasswordForm').on('submit', function(event) {
|
|
event.preventDefault(); // Prevent default form submission
|
|
|
|
$.ajax({
|
|
url: 'change_password',
|
|
type: 'POST',
|
|
data: $(this).serialize(),
|
|
success: function(response) {
|
|
// Parse response if needed
|
|
if (typeof response === "string") {
|
|
response = JSON.parse(response);
|
|
}
|
|
|
|
if (response.status === 'success') {
|
|
$('#responseMessage2').html('<div class="alert alert-success">' + response.message + '</div>');
|
|
} else {
|
|
$('#responseMessage2').html('<div class="alert alert-danger">' + response.message + '</div>');
|
|
}
|
|
},
|
|
error: function() {
|
|
$('#responseMessage2').html('<div class="alert alert-danger">Error changing password.</div>');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<?php include_once(dirname(dirname(dirname(__DIR__))) . '/components/insta_footer.php'); ?>
|