<?php
include "classes/class.loader.php";
$html = new html();
$html->bacground_emoji();
$DashboardWidget = new DashboardWidget();
$calls = new functions();
$db = new db();
?>
<style>
    body {
        background-color: #bebebee7;
        color: white;
    }
</style>
<div class="header">
    <input type="text" id="username" name="username" value="<?php echo $_SESSION['username']; ?>" readonly />
    <button onclick="window.location.href='home.php'">HOME</button>
    <button onclick=" window.location.href='payments.php'" style='border: 2px solid whit'>PAYMENTS</button>
    <button onclick="window.location.href='bookings.php'">BOOKINGS</button>
    <button onclick="window.location.href='news.php'">NEWS</button>
    <button onclick="window.location.href='help.php'">HELP</button>
    <button onclick="window.location.href='services.php'">SERVICES</button>
</div>

<div class="home_container">
    <?php
    echo DashboardWidget::includeAssets();


    $table_data = [];

    $bookings_res = $db->query("SELECT * FROM `payments` WHERE 1 ORDER BY record_id DESC");
    while ($booking = $bookings_res->fetch_assoc()) {

        $table_data[] = [
            $booking['record_id'],
            $calls->get_username($booking['user_id']),
            $booking['date_time'],
            "R " . $booking['zar'],
            'payment.php?record_id=' . $booking['record_id']
        ];

    }


    echo DashboardWidget::tableBlock(
        'Latest Payments',
        ['No', 'User', 'Date', 'Zar'],
        $table_data,
        '90vw'
    );
    ?>
</div>