pre auditlog implementations

This commit is contained in:
twotalesanimation
2025-12-15 10:44:56 +02:00
parent d2c99e86b4
commit 702e04e9bf
2 changed files with 75 additions and 16 deletions

View File

@@ -19,6 +19,27 @@ if (!isset($_SESSION['updates_modal_shown'])) {
$showUpdatesModal = false; $showUpdatesModal = false;
} }
// Show renew membership modal for logged-in users and where membership_fees payment_status is not PENDING RENEWAL. only show once per session
$showRenewModal = isset($_SESSION['user_id']) ? true : false;
if ($showRenewModal) {
if (!isset($_SESSION['renew_modal_shown'])) {
$_SESSION['renew_modal_shown'] = true;
} else {
$showRenewModal = false;
}
$user_id = $_SESSION['user_id'];
$stmt = $conn->prepare("SELECT payment_status FROM membership_fees WHERE user_id = ? LIMIT 1");
$stmt->bind_param("i", $user_id);
$stmt->execute();
$stmt->bind_result($payment_status);
$stmt->fetch();
$stmt->close();
if ($payment_status === 'PENDING RENEWAL') {
$showRenewModal = false;
}
}
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");
@@ -657,34 +678,72 @@ if (countUpcomingTrips() > 0) { ?>
const modal = document.getElementById('updatesModal'); const modal = document.getElementById('updatesModal');
const closeBtn = document.querySelector('.updates-modal-close'); const closeBtn = document.querySelector('.updates-modal-close');
const showModal = <?php echo $showUpdatesModal ? 'true' : 'false'; ?>; const showModal = <?php echo $showUpdatesModal ? 'true' : 'false'; ?>;
const showRenewModal = <?php echo $showRenewModal ? 'true' : 'false'; ?>;
if (showModal) { if (showModal && modal) {
// Show modal after a short delay for better UX // Show updates modal after a short delay for better UX
setTimeout(function() { setTimeout(function() {
modal.style.display = 'flex'; modal.style.display = 'flex';
}, 500); }, 500);
} }
// Close modal when X is clicked // Close updates modal when X is clicked
closeBtn.addEventListener('click', function() { if (closeBtn) {
modal.style.display = 'none'; closeBtn.addEventListener('click', function() {
}); if (modal) modal.style.display = 'none';
});
}
// Close modal when clicking outside the modal content // Close updates modal when clicking outside the modal content
modal.addEventListener('click', function(event) { if (modal) {
if (event.target === modal) { modal.addEventListener('click', function(event) {
modal.style.display = 'none'; if (event.target === modal) {
modal.style.display = 'none';
}
});
}
// Show renew membership Bootstrap modal for logged-in users
try {
const renewModalEl = document.getElementById('renewModal');
if (showRenewModal && renewModalEl && typeof bootstrap !== 'undefined') {
setTimeout(function() {
const renewModal = new bootstrap.Modal(renewModalEl);
renewModal.show();
}, 700);
} }
}); } catch (e) {
console.warn('Renew modal show failed', e);
}
}); });
</script> </script>
<!-- Updates Modal -->
<!-- Renew Membership Modal (shown to logged-in users) -->
<div class="modal fade" id="renewModal" tabindex="-1" aria-labelledby="renewModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<!-- <div class="modal-header bg-secondary text-white">
<h5 class="modal-title" id="renewModalLabel">Membership Renewal Reminder</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div> -->
<div class="modal-body">
Your membership will be expiring soon. Click below to renew now.
<a style="width:100%; display:block;" href="renew_membership" class="theme-btn style-two style-three mt-3">Renew Now</a>
</div>
<div class="modal-footer">
<button type="button" style="width:100%; display:block;" class="theme-btn" data-bs-dismiss="modal">Remind Me Later</button>
</div>
</div>
</div>
</div>
<!-- Updates Modal --> <!-- Updates Modal -->
<div id="updatesModal" class="updates-modal"> <div id="updatesModal" class="updates-modal">
<div class="updates-modal-content"> <div class="updates-modal-content">
<span class="updates-modal-close">&times;</span> <span class="updates-modal-close">&times;</span>
<div class="updates-modal-header"> <div class="updates-modal-header">
<h2>What's New</h2> <h2>What's New on 4WDCSA.co.za</h2>
</div> </div>
<div class="updates-modal-body"> <div class="updates-modal-body">
<div class="update-item"> <div class="update-item">

View File

@@ -147,7 +147,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Send invoice and admin notification // Send invoice and admin notification
// sendInvoice(getEmail($user_id), getFullName($user_id), $eft_id, formatCurrency($payment_amount), $description); // sendInvoice(getEmail($user_id), getFullName($user_id), $eft_id, formatCurrency($payment_amount), $description);
// sendAdminNotification('New Trip Booking - '.getFullName($user_id), getFullName($user_id).' has booked for '.$description); sendAdminNotification('New Trip Booking - '.getFullName($user_id), getFullName($user_id).' has booked for '.$description);
// Redirect to payment link if available // Redirect to payment link if available
$paylink = $resp['paylinkUrl'] ?? $resp['paylinkURL'] ?? $resp['paylink_url'] ?? null; $paylink = $resp['paylinkUrl'] ?? $resp['paylinkURL'] ?? $resp['paylink_url'] ?? null;