282 lines
12 KiB
PHP
282 lines
12 KiB
PHP
<?php
|
|
$headerStyle = 'light';
|
|
include_once(dirname(dirname(dirname(__DIR__))) . '/header.php');
|
|
checkAdmin();
|
|
if (!isset($_GET['token']) || empty($_GET['token'])) {
|
|
die("Invalid request.");
|
|
}
|
|
$token = $_GET['token'];
|
|
// echo $token;
|
|
|
|
// Use ?user_id=... in the URL to view another user's info
|
|
$viewing_user_id = isset($_GET['token']) ? decryptData($token, $salt) : $_SESSION['user_id'];
|
|
checkMembershipApplication2($viewing_user_id);
|
|
|
|
// Fetch 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", $viewing_user_id);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$membership = $result->fetch_assoc();
|
|
|
|
// Fetch application data
|
|
$query = "SELECT * FROM membership_application WHERE user_id = ?";
|
|
$stmt = $conn->prepare($query);
|
|
$stmt->bind_param("i", $viewing_user_id);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$application = $result->fetch_assoc();
|
|
$stmt->close();
|
|
?>
|
|
<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;
|
|
}
|
|
</style>
|
|
<section class="account-settings-area py-70 rel z-1">
|
|
<div class="container">
|
|
<button onclick="downloadMembershipPDF()">📄 Open as PDF</button>
|
|
|
|
|
|
<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 id="membership-info">
|
|
<div class="section-title py-20">
|
|
<h2>Member Information: <?php echo getFullName($viewing_user_id); ?></h2>
|
|
</div>
|
|
|
|
<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>
|
|
<td><?php echo hasAcceptedIndemnity($viewing_user_id) ? 'SIGNED' : 'NOT SIGNED'; ?></td>
|
|
<td><?php echo htmlspecialchars($membership['payment_amount']); ?></td>
|
|
<td><?php echo htmlspecialchars($membership['payment_id']); ?></td>
|
|
<td><?php echo htmlspecialchars($membership['payment_status']); ?></td>
|
|
<td><?php echo getUserMemberStatus($viewing_user_id) ? 'ACTIVE' : 'INACTIVE'; ?></td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<tr>
|
|
<td colspan="7">No membership records found.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<h3>Main Member</h3>
|
|
<div class="row mt-35">
|
|
<?php
|
|
$fields = [
|
|
'first_name' => 'First Name',
|
|
'last_name' => 'Surname',
|
|
'id_number' => 'ID Number / Passport Number',
|
|
'dob' => 'Date of Birth',
|
|
'occupation' => 'Occupation',
|
|
'tel_cell' => 'Cell Phone',
|
|
'email' => 'Email Address'
|
|
];
|
|
foreach ($fields as $key => $label): ?>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label><?php echo $label; ?></label>
|
|
<p class="form-control-static"><?php echo htmlspecialchars($application[$key] ?? ''); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<h3>Spouse / Life Partner / Other Details</h3>
|
|
<div class="row mt-35">
|
|
<?php
|
|
$spouse_fields = [
|
|
'spouse_first_name' => 'First Name',
|
|
'spouse_last_name' => 'Surname',
|
|
'spouse_id_number' => 'ID Number / Passport Number',
|
|
'spouse_dob' => 'Date of Birth',
|
|
'spouse_occupation' => 'Occupation',
|
|
'spouse_tel_cell' => 'Cell Phone',
|
|
'spouse_email' => 'Email Address'
|
|
];
|
|
foreach ($spouse_fields as $key => $label): ?>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label><?php echo $label; ?></label>
|
|
<p class="form-control-static"><?php echo htmlspecialchars($application[$key] ?? ''); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<h3>Children's Names</h3>
|
|
<div class="row mt-35">
|
|
<?php for ($i = 1; $i <= 3; $i++): ?>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label>Child <?php echo $i; ?> Name</label>
|
|
<p class="form-control-static"><?php echo htmlspecialchars($application['child_name' . $i] ?? ''); ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label>Child <?php echo $i; ?> DOB</label>
|
|
<p class="form-control-static"><?php echo htmlspecialchars($application['child_dob' . $i] ?? ''); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endfor; ?>
|
|
</div>
|
|
|
|
<h3>Address</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label>Physical Address</label>
|
|
<p class="form-control-static"><?php echo nl2br(htmlspecialchars($application['physical_address'] ?? '')); ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label>Postal Address</label>
|
|
<p class="form-control-static"><?php echo nl2br(htmlspecialchars($application['postal_address'] ?? '')); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h3>Interests and Hobbies</h3>
|
|
<div class="row mt-35">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<p class="form-control-static"><?php echo nl2br(htmlspecialchars($application['interests_hobbies'] ?? '')); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h3>Primary Vehicle</h3>
|
|
<div class="row mt-35">
|
|
<?php
|
|
$vehicle_fields = [
|
|
'vehicle_make' => 'Make',
|
|
'vehicle_model' => 'Model',
|
|
'vehicle_year' => 'Year',
|
|
'vehicle_registration' => 'Registration'
|
|
];
|
|
foreach ($vehicle_fields as $key => $label): ?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label><?php echo $label; ?></label>
|
|
<p class="form-control-static"><?php echo htmlspecialchars($application[$key] ?? ''); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<!-- You can add secondary vehicle and other custom sections in the same way -->
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
|
|
|
<script>
|
|
function downloadMembershipPDF() {
|
|
const element = document.getElementById('membership-info');
|
|
|
|
// Temporarily shrink element for PDF
|
|
element.style.transform = 'scale(0.8)';
|
|
element.style.transformOrigin = 'top left';
|
|
|
|
const opt = {
|
|
margin: 0.5,
|
|
filename: 'membership-info.pdf',
|
|
image: { type: 'jpeg', quality: 0.98 },
|
|
html2canvas: { scale: 2 },
|
|
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' }
|
|
};
|
|
|
|
html2pdf().from(element).set(opt).outputPdf('bloburl').then((pdfUrl) => {
|
|
window.open(pdfUrl, '_blank');
|
|
// Restore original size
|
|
element.style.transform = '';
|
|
element.style.transformOrigin = '';
|
|
});
|
|
}
|
|
</script>
|
|
|
|
|
|
<?php include_once(dirname(dirname(dirname(__DIR__))) . '/components/insta_footer.php'); ?>
|