<?php
session_start();
require_once('../connect.php');
require_once('sql_required.php');

$sql = "SELECT * FROM tbl_bigasrecord WHERE transaction_type = 'order'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "<tr>
                <td>{$row['reference_code']}</td>
                <td>{$row['rice_type']}</td>
                <td>{$row['quantity_kilo']}</td>
                <td>{$row['date_purchase']}</td>
                <td>{$row['payment_due']}</td>
                <td>₱ " . number_format($row['bigas_credit_amount'], 2) . "</td>
                <td>
                    <button class='btn btn-primary btn-sm pay-now-btn' 
                            data-reference='{$row['reference_code']}' 
                            data-amount='{$row['bigas_credit_amount']}'>
                        Pay
                    </button>
                </td>
              </tr>";
    }
} else {
    echo "<tr><td colspan='7' class='text-center'>No records found.</td></tr>";
}

$conn->close();
?>
