2 Commits

Author SHA1 Message Date
d1dc0b4ad0 Pop submit ready 2025-06-13 10:22:14 +02:00
488e3c156d New POP Uploads 2025-05-23 14:19:25 +02:00
39 changed files with 407 additions and 1387 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
.env .env
/vendor/ /vendor/
.htaccess
/uploads/pop/

View File

@@ -1,5 +1,5 @@
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

@@ -1,6 +1,6 @@
<?php include_once('connection.php'); <?php include_once('connection.php');
include_once('functions.php'); include_once('functions.php');
require_once("env.php");
session_start(); session_start();
$user_id = $_SESSION['user_id']; // assuming you're storing it like this $user_id = $_SESSION['user_id']; // assuming you're storing it like this

View File

@@ -1,7 +1,6 @@
<?php <?php
session_start(); session_start();
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
if (isset($_POST['tab_id']) && isset($_POST['item_id']) && isset($_POST['item_name']) && isset($_POST['item_price'])) { if (isset($_POST['tab_id']) && isset($_POST['item_id']) && isset($_POST['item_name']) && isset($_POST['item_price'])) {

View File

@@ -197,6 +197,10 @@ if (!empty($bannerImages)) {
if (($row['status']) == 'AWAITING PAYMENT') { if (($row['status']) == 'AWAITING PAYMENT') {
echo "<td><a href='process_eft.php?token=" . encryptData($row['eft_id'], $salt) . "' class='theme-btn style-two style-three'> echo "<td><a href='process_eft.php?token=" . encryptData($row['eft_id'], $salt) . "' class='theme-btn style-two style-three'>
<span data-hover='PAYMENT RECEIVED'>" . htmlspecialchars($row['status']) . "</span> <span data-hover='PAYMENT RECEIVED'>" . htmlspecialchars($row['status']) . "</span>
</a></td></tr>";
} elseif (($row['status']) == 'PROCESSING') {
echo "<td><a href='process_payments.php' class='theme-btn style-two style-three'>
<span data-hover='PROCESS'>PROCESS</span>
</a></td></tr>"; </a></td></tr>";
} else { } else {
echo "<td>" . htmlspecialchars($row['status']) . "</td>"; echo "<td>" . htmlspecialchars($row['status']) . "</td>";

View File

@@ -82,10 +82,6 @@ $result = $conn->query($sql);
margin-top: 15px; margin-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
.theme-btn,
a.theme-btn {
padding: 0px 14px;
}
</style> </style>
<script> <script>
@@ -141,7 +137,7 @@ if (!empty($bannerImages)) {
} }
?> ?>
<section class="page-banner-area pt-50 pb-35 rel z-1 bgs-cover" style="background-image: url('<?php echo $randomBanner; ?>');"> <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="banner-overlay"></div>
<div class="container"> <div class="container">
<div class="banner-inner text-white mb-50"> <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 Members</h2> <h2 class="page-title mb-10" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">4WDCSA Members</h2>
@@ -172,7 +168,6 @@ if (!empty($bannerImages)) {
<th>Email</th> <th>Email</th>
<th>Date of Birth</th> <th>Date of Birth</th>
<th>Membership</th> <th>Membership</th>
<th>View Info</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -193,7 +188,6 @@ if (!empty($bannerImages)) {
echo 'INACTIVE'; echo 'INACTIVE';
}; };
echo "</td> echo "</td>
<td><a href='member_info.php?token=" . encryptData($row['user_id'], $salt) . "' class='theme-btn style-two style-three'><span data-hover='PAYMENT RECEIVED'>View Info</span></a></td>
</tr>"; </tr>";
} }
} else { } else {

View File

@@ -170,7 +170,7 @@ if (!empty($bannerImages)) {
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<!-- <th></th> --> <th></th>
<th>First Name</th> <th>First Name</th>
<th>Last Name</th> <th>Last Name</th>
<th>Email</th> <th>Email</th>
@@ -209,7 +209,7 @@ if (!empty($bannerImages)) {
echo "<tr> echo "<tr>
<td><img src=" . $row['profile_pic'] . " alt='Profile Picture' class='profile-pic'></td> <td><img src=" . $row['profile_pic'] . " alt='Profile Picture' class='profile-pic'></td>
<td>" . htmlspecialchars($row['user_id']) . "</td>
<td>" . htmlspecialchars($row['first_name']) . "</td> <td>" . htmlspecialchars($row['first_name']) . "</td>
<td>" . htmlspecialchars($row['last_name']) . "</td> <td>" . htmlspecialchars($row['last_name']) . "</td>
<td>" . htmlspecialchars($row['email']) . "</td> <td>" . htmlspecialchars($row['email']) . "</td>
@@ -228,10 +228,10 @@ if (!empty($bannerImages)) {
} else { } else {
echo "\u{2713}"; echo "\u{2713}";
} }
// echo "</td> echo "</td>
// <td><a href='linkmembership.php?user_id=".$row['user_id']."'>Link Membership</a></td> <td><a href='linkmembership.php?user_id=".$row['user_id']."'>Link Membership</a></td>
// </tr>"; </tr>";
} }
} else { } else {
echo '<tr><td colspan="5">No records found</td></tr>'; echo '<tr><td colspan="5">No records found</td></tr>';

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

5
envtest.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
ob_start();
require_once("env.php");
echo $_ENV["TEST"];

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once "vendor/autoload.php"; require_once "vendor/autoload.php";
use GuzzleHttp\Client; use GuzzleHttp\Client;
@@ -236,7 +235,7 @@ function sendAdminNotification($subject, $message)
{ {
global $mailjet; global $mailjet;
$message = [ $mail = [
'Messages' => [ 'Messages' => [
[ [
'From' => [ 'From' => [
@@ -265,7 +264,7 @@ function sendAdminNotification($subject, $message)
]); ]);
$response = $client->request('POST', 'send', [ $response = $client->request('POST', 'send', [
'json' => $message, 'json' => $mail,
'auth' => ['1a44f8d5e847537dbb8d3c76fe73a93c', 'ec98b45c53a7694c4f30d09eee9ad280'] 'auth' => ['1a44f8d5e847537dbb8d3c76fe73a93c', 'ec98b45c53a7694c4f30d09eee9ad280']
]); ]);

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
include_once('connection.php'); include_once('connection.php');
include_once('functions.php'); include_once('functions.php');
$conn = openDatabaseConnection(); $conn = openDatabaseConnection();

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
if (isset($_POST['tab_id'])) { if (isset($_POST['tab_id'])) {

View File

@@ -210,6 +210,7 @@ logVisitor();
<!-- <li><a href="admin_camp_bookings.php">Camping Bookings</a></li> --> <!-- <li><a href="admin_camp_bookings.php">Camping Bookings</a></li> -->
<!-- <li><a href="admin_payments.php">Payfast Payments</a></li> --> <!-- <li><a href="admin_payments.php">Payfast Payments</a></li> -->
<li><a href="admin_efts.php">EFT Payments</a></li> <li><a href="admin_efts.php">EFT Payments</a></li>
<li><a href="process_payments.php">Process Payments</a></li>
<!-- <li><a href="bar_tabs.php">Bar</a></li> --> <!-- <li><a href="bar_tabs.php">Bar</a></li> -->
<?php if ($role === 'superadmin') { ?> <?php if ($role === 'superadmin') { ?>
<li><a href="admin_visitors.php">Visitor Log</a></li> <li><a href="admin_visitors.php">Visitor Log</a></li>
@@ -231,6 +232,7 @@ logVisitor();
<li><a href="account_settings.php">Account Settings</a></li> <li><a href="account_settings.php">Account Settings</a></li>
<li><a href="membership_details.php">Membership</a></li> <li><a href="membership_details.php">Membership</a></li>
<li><a href="bookings.php">My Bookings</a></li> <li><a href="bookings.php">My Bookings</a></li>
<li><a href="submit_pop.php">Submit P.O.P</a></li>
<li><a href="logout.php">Log Out</a></li> <li><a href="logout.php">Log Out</a></li>
</ul> </ul>

View File

@@ -223,6 +223,7 @@ logVisitor();
<!-- <li><a href="admin_camp_bookings.php">Camping Bookings</a></li> --> <!-- <li><a href="admin_camp_bookings.php">Camping Bookings</a></li> -->
<!-- <li><a href="admin_payments.php">Payfast Payments</a></li> --> <!-- <li><a href="admin_payments.php">Payfast Payments</a></li> -->
<li><a href="admin_efts.php">EFT Payments</a></li> <li><a href="admin_efts.php">EFT Payments</a></li>
<li><a href="process_payments.php">Process Payments</a></li>
<?php if ($role === 'superadmin') { ?> <?php if ($role === 'superadmin') { ?>
<li><a href="admin_visitors.php">Visitor Log</a></li> <li><a href="admin_visitors.php">Visitor Log</a></li>
<?php } ?> <?php } ?>
@@ -237,6 +238,7 @@ logVisitor();
<li><a href="account_settings.php">Account Settings</a></li> <li><a href="account_settings.php">Account Settings</a></li>
<li><a href="membership_details.php">Membership</a></li> <li><a href="membership_details.php">Membership</a></li>
<li><a href="bookings.php">My Bookings</a></li> <li><a href="bookings.php">My Bookings</a></li>
<li><a href="submit_pop.php">Submit P.O.P</a></li>
<li><a href="logout.php">Log Out</a></li> <li><a href="logout.php">Log Out</a></li>
</ul> </ul>

View File

@@ -1,280 +0,0 @@
<?php
include_once('header02.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("insta_footer.php"); ?>

View File

@@ -105,9 +105,13 @@ if (!empty($bannerImages)) {
<?php echo <?php echo
'<h5>Membership Start Date: ' . $membership_start_date . '<br>Membership Renewal Date: ' . $membership_end_date . '</h5>'; ?> '<h5>Membership Start Date: ' . $membership_start_date . '<br>Membership Renewal Date: ' . $membership_end_date . '</h5>'; ?>
</div> </div>
<p>Your invoice has been sent to <b><?php echo htmlspecialchars($user_email); ?></b>. Please send your proof of payment to <b>info@4wdcsa.co.za</b>.</p> <p>Your invoice has been sent to <b><?php echo htmlspecialchars($user_email); ?></b>. Please upload your proof of payment below.</p>
<h5>Payment Details:</h5> <h5>Payment Details:</h5>
<p>The Four Wheel Drive Club of Southern Africa<br>FNB<br>Account Number: 58810022334<br>Branch code: 250655<br>Reference: <?php echo htmlspecialchars($eft_id); ?><br>Amount: R <?php echo number_format($payment_amount, 2); ?></p> <p>The Four Wheel Drive Club of Southern Africa<br>FNB<br>Account Number: 58810022334<br>Branch code: 250655<br>Reference: <?php echo htmlspecialchars($eft_id); ?><br>Amount: R <?php echo number_format($payment_amount, 2); ?></p>
<a href="submit_pop.php" class="theme-btn style-two style-three" style="width:100%;">
<span data-hover="Submit Proof of Payment">Submit Proof of Payment</span>
<i class="fal fa-arrow-right"></i>
</a>
</div> </div>
<div class="col-lg-6" data-aos="fade-right" data-aos-duration="1500" data-aos-offset="50"> <div class="col-lg-6" data-aos="fade-right" data-aos-duration="1500" data-aos-offset="50">

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php");?> require_once("functions.php");?>

View File

@@ -131,10 +131,14 @@ if (!empty($bannerImages)) {
</div> </div>
<p>Your invoice has been sent to <b><?php echo htmlspecialchars($user_email); ?></b>. Please send your proof of payment to <b>info@4wdcsa.co.za</b>.</p> <p>Your invoice has been sent to <b><?php echo htmlspecialchars($user_email); ?></b>. Please upload your proof of payment below.</p>
<p>Bookings not paid for within 24 hours will be forfeited.</p> <p>Bookings not paid for within 24 hours will be forfeited.</p>
<h5>Payment Details:</h5> <h5>Payment Details:</h5>
<p>The Four Wheel Drive Club of Southern Africa<br>FNB<br>Account Number: 58810022334<br>Branch code: 250655<br>Reference: <?php echo htmlspecialchars($eft_id); ?><br>Amount: R <?php echo number_format($payment_amount, 2); ?></p> <p>The Four Wheel Drive Club of Southern Africa<br>FNB<br>Account Number: 58810022334<br>Branch code: 250655<br>Reference: <?php echo htmlspecialchars($eft_id); ?><br>Amount: R <?php echo number_format($payment_amount, 2); ?></p>
<a href="submit_pop.php" class="theme-btn style-two style-three" style="width:100%;">
<span data-hover="Submit Proof of Payment">Submit Proof of Payment</span>
<i class="fal fa-arrow-right"></i>
</a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

148
process_payments.php Normal file
View File

@@ -0,0 +1,148 @@
<?php include_once('header02.php');
checkAdmin();
checkUserSession();
$user_id = $_SESSION['user_id'];
?>
<style>
.image {
width: 400px;
/* Set your desired width */
height: 350px;
/* Set your desired height */
overflow: hidden;
/* Hide any overflow */
display: block;
/* Ensure proper block behavior */
}
.image img {
width: 100%;
/* Image scales to fill the container */
height: 100%;
/* Image scales to fill the container */
object-fit: cover;
/* Fills the container while maintaining aspect ratio */
object-position: top;
/* Aligns the top of the image with the top of the container */
display: block;
/* Prevents inline whitespace issues */
}
.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>
</style>
<?php
$status = "PROCESSING";
$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">Process Payments</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">Process Payments</li>
</ol>
</nav>
</div>
</div>
</section>
<!-- Tour List Area start -->
<section class="tour-list-page py-100 rel z-1">
<div class="container">
<div class="row">
<div class="col-lg-12">
<?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; ?>
<?php
// Query to retrieve data from the bookings table
$sql = "SELECT * FROM efts WHERE status = ? ORDER BY timestamp DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $status);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
// Loop through each row
while ($row = $result->fetch_assoc()) {
$eft_id = $row['eft_id'];
$eft_user = $row['user_id'];
$eft_amount = $row['amount'];
$eft_description = $row['description'];
// Output the HTML structure with dynamic data
echo '
<div class="destination-item style-three bgc-lighter booking " data-aos="fade-up" data-aos-duration="1500" data-aos-offset="50">
<div class="p-4" >
<iframe src="uploads/pop/'.$eft_id.'.pdf#toolbar=0" width="400px" height="200px"></iframe>
<p><a href="uploads/pop/'.$eft_id.'.pdf" target="_new" class="theme-btn style-three" style="width:100%;">View Full PDF</a></p>
</div>
<div style="width:100%;" class="content">
<h5>' . htmlspecialchars($eft_description) . '</a></h5>
<h5>' . getFullName($eft_user) . '</a></h5>
<div class="destination-footer">
<span class="price"><span>Booking Total: R ' . number_format($eft_amount, 2) . '</span></span>
<a href="process_eft.php?token=' . encryptData($eft_id, $salt) . '" class="theme-btn style-three"><span data-hover="POP RECEIVED">PROCESS</span></a>
</div>
</div>';
}
} else {
echo '<p>There are no pending payments for processing.</p>';
}
// Close connection
$conn->close();
?>
</div>
</div>
</div>
</section>
<!-- Tour List Area end -->
<?php include_once("insta_footer.php"); ?>

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");
session_start(); session_start();

View File

@@ -1,5 +1,5 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");
require_once "vendor/autoload.php"; require_once "vendor/autoload.php";

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

219
submit_pop.php Normal file
View File

@@ -0,0 +1,219 @@
<?php include_once('header02.php');
checkUserSession();
$user_id = $_SESSION['user_id'] ?? null;
if (!$user_id) {
die("Not logged in.");
}
// Handle POST submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$eft_id = $_POST['eft_id'] ?? null;
$file_name = str_replace(' ', '_', $eft_id);
if (!$eft_id || !isset($_FILES['pop_file'])) {
echo "<div class='alert alert-danger'>Invalid submission: missing eft_id or file.</div>";
echo "<pre>";
echo "POST data: " . print_r($_POST, true);
echo "FILES data: " . print_r($_FILES, true);
echo "</pre>";
} else {
$file = $_FILES['pop_file'];
$target_dir = "uploads/pop/";
$target_file = $target_dir . $file_name . ".pdf";
// Check for upload errors first
if ($file['error'] !== UPLOAD_ERR_OK) {
echo "<div class='alert alert-danger'>Upload error code: " . $file['error'] . "</div>";
// You can decode error code if needed:
// https://www.php.net/manual/en/features.file-upload.errors.php
exit;
}
// Check for PDF extension
$file_type = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
if ($file_type !== "pdf") {
echo "<div class='alert alert-danger'>Only PDF files allowed. You tried uploading: .$file_type</div>";
exit;
}
// Make sure target directory exists and writable
if (!is_dir($target_dir)) {
echo "<div class='alert alert-danger'>Upload directory does not exist: $target_dir</div>";
exit;
}
if (!is_writable($target_dir)) {
echo "<div class='alert alert-danger'>Upload directory is not writable: $target_dir</div>";
exit;
}
if (move_uploaded_file($file['tmp_name'], $target_file)) {
// Update EFT and booking status
$payment_type = $_POST['payment_type'] ?? 'booking';
if ($payment_type === 'membership') {
// Update EFT and booking status
$stmt1 = $conn->prepare("UPDATE efts SET status = 'PROCESSING' WHERE eft_id = ?");
$stmt1->bind_param("s", $eft_id);
$stmt1->execute();
// Update membership fee status
$stmt = $conn->prepare("UPDATE membership_fees SET payment_status = 'PROCESSING' WHERE payment_id = ?");
$stmt->bind_param("s", $eft_id);
$stmt->execute();
} else {
// Update EFT and booking status
$stmt1 = $conn->prepare("UPDATE efts SET status = 'PROCESSING' WHERE eft_id = ?");
$stmt1->bind_param("s", $eft_id);
$stmt1->execute();
$stmt2 = $conn->prepare("UPDATE bookings SET status = 'PROCESSING' WHERE eft_id = ?");
$stmt2->bind_param("s", $eft_id);
$stmt2->execute();
}
// Notify n8n and send the path to the uploaded file
$webhook_url = 'https://n8n.4wdcsa.co.za/webhook/process-pop';
$postData = [
'eft_id' => $eft_id,
'payment_type' => $payment_type,
];
$ch = curl_init($webhook_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
$response = curl_exec($ch);
$error = curl_error($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($error) {
error_log("Webhook Error: $error");
$_SESSION['message'] = $error;
header("Location: bookings.php");
} else {
$_SESSION['message'] = "Thank you! We are busy processing your payment!";
header("Location: bookings.php");
}
exit;
} else {
echo "<div class='alert alert-danger'>Unable to move uploaded file.</div>";
echo "<pre>Tmp file exists? " . (file_exists($file['tmp_name']) ? "Yes" : "No") . "</pre>";
echo "<pre>Tmp file path: " . htmlspecialchars($file['tmp_name']) . "</pre>";
exit;
}
}
}
// Fetch bookings for dropdown
$stmt = $conn->prepare("
SELECT eft_id AS id, 'booking' AS type FROM bookings WHERE user_id = ? AND status = 'AWAITING PAYMENT'
UNION
SELECT payment_id AS id, 'membership' AS type FROM membership_fees WHERE user_id = ? AND payment_status = 'PENDING'
");
$stmt->bind_param("ii", $user_id, $user_id);
$stmt->execute();
$result = $stmt->get_result();
$items = $result->fetch_all(MYSQLI_ASSOC);
$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">Submit Proof of Payment</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">Submit Proof of Payment</li>
</ol>
</nav>
</div>
</div>
</section>
<!-- Tour List Area start -->
<section class="tour-list-page py-100 rel z-1">
<div class="container" style="max-width:600px;">
<div class="row">
<div class="comment-form bgc-lighter z-1 rel mb-30 rmb-55" data-aos="fade-up" data-aos-duration="1500" data-aos-offset="50">
<div class="widget widget-booking" data-aos="fade-up" data-aos-duration="1500" data-aos-offset="50">
<div class="section-title">
<h3>Submit Proof of Payment</h3>
<div style="text-align: center;" id="responseMessage"></div>
<p>To finalise your booking/membership, select the payment reference below, and then upload your PDF proof of payment.</p> <!-- Message display area -->
</div>
<?php if (count($items) > 0) {?>
<form enctype="multipart/form-data" method="POST">
<div class="row mt-35">
<ul class="tickets clearfix">
<li>
Select Payment Reference:
<select name="eft_id" id="eft_id" required onchange="updatePaymentType(this)">
<?php
if (count($items) > 0) {
foreach ($items as $item) {
$label = strtoupper($item['type']) . ' - ' . htmlspecialchars($item['id']);
echo '<option value="' . htmlspecialchars($item['id']) . '" data-type="' . $item['type'] . '">' . $label . '</option>';
}
} else {
echo '<option value="" disabled selected>No payments available</option>';
}
?>
</select>
<input type="hidden" name="payment_type" id="payment_type">
</li>
</ul>
<li>
<input style="border-radius:30px;" type="file" name="pop_file" id="pop_file" accept="application/pdf" class="form-control" required>
</li>
</div>
<div class="mt-10 mb-0">
<button type="submit" class="theme-btn style-two" style="width:100%;">Submit POP</button>
</div>
</form>
<?php
}else{
echo 'No unpaid bookings';
}?>
</div>
</div>
</div>
</div>
</section>
<script>
function updatePaymentType(selectEl) {
const selectedOption = selectEl.options[selectEl.selectedIndex];
const type = selectedOption.getAttribute('data-type');
document.getElementById('payment_type').value = type;
}
window.onload = function() {
const dropdown = document.getElementById('eft_id');
updatePaymentType(dropdown); // set default value on page load
};
</script>
<?php include_once("insta_footer.php"); ?>

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("session.php"); require_once("session.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");

View File

@@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
include_once('connection.php'); // DB connection file include_once('connection.php'); // DB connection file
require_once("env.php");
$response = array('status' => 'error', 'message' => 'Something went wrong'); $response = array('status' => 'error', 'message' => 'Something went wrong');
// Check if the user is logged in // Check if the user is logged in

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -1,5 +1,4 @@
<?php <?php
require_once("env.php");
require_once("connection.php"); require_once("connection.php");
require_once("functions.php"); require_once("functions.php");