Files
4WDCSA.co.za/admin_web_users.php
twotalesanimation 4bdfbff0b6 Member info update
2025-06-08 16:29:50 +02:00

281 lines
11 KiB
PHP

<?php include_once('header02.php');
checkSuperAdmin();
// SQL query to fetch data
$sql = "SELECT user_id, first_name, last_name, email, member, date_joined, token, is_verified, profile_pic FROM users";
$result = $conn->query($sql);
?>
<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;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.querySelector("table");
const headers = table.querySelectorAll("thead th");
const rows = Array.from(table.querySelectorAll("tbody tr"));
const filterInput = document.getElementById("filterInput");
headers.forEach((header, index) => {
header.addEventListener("click", () => {
const sortedRows = rows.sort((a, b) => {
const aText = a.cells[index].textContent.trim().toLowerCase();
const bText = b.cells[index].textContent.trim().toLowerCase();
if (aText < bText) return -1;
if (aText > bText) return 1;
return 0;
});
if (header.classList.contains("asc")) {
header.classList.remove("asc");
header.classList.add("desc");
sortedRows.reverse();
} else {
headers.forEach(h => h.classList.remove("asc", "desc"));
header.classList.add("asc");
}
const tbody = table.querySelector("tbody");
tbody.innerHTML = "";
sortedRows.forEach(row => tbody.appendChild(row));
});
});
filterInput.addEventListener("input", function() {
const filterValue = filterInput.value.trim().toLowerCase();
rows.forEach(row => {
const rowText = row.textContent.trim().toLowerCase();
row.style.display = rowText.includes(filterValue) ? "" : "none";
});
});
});
</script>
<!-- Page Banner Start -->
<?php
$bannerFolder = 'assets/images/banners/';
$bannerImages = glob($bannerFolder . '*.{jpg,jpeg,png,webp}', GLOB_BRACE);
$randomBanner = 'assets/images/base4/camping.jpg'; // default fallback
if (!empty($bannerImages)) {
$randomBanner = $bannerImages[array_rand($bannerImages)];
}
?>
<section class="page-banner-area pt-50 pb-35 rel z-1 bgs-cover" style="background-image: url('<?php echo $randomBanner; ?>');">
<div class="banner-overlay"></div>
<div class="container">
<div class="banner-inner text-white mb-50">
<h2 class="page-title mb-10" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">4WDCSA Site Users</h2>
<nav aria-label="breadcrumb">
<ol class="breadcrumb justify-content-center mb-20" data-aos="fade-right" data-aos-delay="200" data-aos-duration="1500" data-aos-offset="50">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item active">4WDCSA Site Users</li>
</ol>
</nav>
</div>
</div>
</section>
<?php if (isset($_SESSION['message'])): ?>
<div class="alert alert-warning message-box">
<?php echo $_SESSION['message']; ?>
<span class="close-btn" onclick="this.parentElement.style.display='none'">&times;</span>
</div>
<?php unset($_SESSION['message']); ?>
<?php endif; ?>
<!-- Tour List Area start -->
<section class="tour-list-page py-10 rel z-1">
<div class="container">
<div class="row">
<div id="response-message" style="margin-top: 1rem;"></div>
<div class="col-lg-12">
<div class='infobox' data-aos='fade-up' data-aos-duration='1500' data-aos-offset='50'>
<div style='padding:10px;'>
<input type="text" id="filterInput" class="filter-input" placeholder="Filter results...">
<table>
<thead>
<tr>
<th></th>
<!-- <th></th> -->
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Member</th>
<th>Indemnity</th>
<th>Date Joined</th>
<th>Verified</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
// Output data of each row
while ($row = $result->fetch_assoc()) {
if (getUserMemberStatus($row['user_id'])) {
$member = "\u{2713}";
} else {
$member = "\u{2717}";
}
$indemnityPending = false;
$userId = $row['user_id'];
$stmt = $conn->prepare("SELECT user_id FROM membership_application WHERE user_id = ? AND accept_indemnity = 0 LIMIT 1");
$stmt->bind_param("i", $userId);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$indemnityPending = true;
}
$stmt->close();
echo "<tr>
<td><img src=" . $row['profile_pic'] . " alt='Profile Picture' class='profile-pic'></td>
<td>" . htmlspecialchars($row['first_name']) . "</td>
<td>" . htmlspecialchars($row['last_name']) . "</td>
<td>" . htmlspecialchars($row['email']) . "</td>
<td>" . $member . "</td>
<td>" . $indemnityPending . "</td>
<td>" . htmlspecialchars($row['date_joined']) . "</td>
<td>";
if ($row['is_verified'] != 1) {
echo "
<button class='resend-btn'
data-email=" . htmlspecialchars($row['email'] ?? '') . "
data-name=" . htmlspecialchars($row['first_name'] ?? '') . " " . htmlspecialchars($row['last_name'] ?? '') . "
data-token=" . htmlspecialchars($row['token'] ?? '') . ">
Resend Email
</button>";
} else {
echo "\u{2713}";
}
// echo "</td>
// <td><a href='linkmembership.php?user_id=".$row['user_id']."'>Link Membership</a></td>
// </tr>";
}
} else {
echo '<tr><td colspan="5">No records found</td></tr>';
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Tour List Area end -->
<script>
document.querySelectorAll('.resend-btn').forEach(button => {
button.addEventListener('click', function() {
const email = this.dataset.email;
const name = this.dataset.name;
const token = this.dataset.token;
fetch('resend_verification.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email,
name,
token
})
})
.then(response => response.json())
.then(data => {
const messageDiv = document.getElementById('response-message');
messageDiv.textContent = data.message;
messageDiv.style.color = data.success ? 'green' : 'red';
})
.catch(error => {
console.error('Error:', error);
});
});
});
</script>
<?php include_once("insta_footer.php"); ?>