<?php
session_start();
include "../../classes/html_items.php";
include "../../classes/db.class.php";
include "../../functions.class.php";
include "../../classes/dashboard.class.php";
$functions = new functions();
$dash = new dash_items();
$functions = new functions();
function get_day_of_the_week($date)
{
    $date = date('w', strtotime($date));
    switch ($date) {
        case 0:
            return 'Sunday';
        case 1:
            return 'Monday';
        case 2:
            return 'Tuesday';
        case 3:
            return 'Wednesday';
        case 4:
            return 'Thursday';
        case 5:
            return 'Friday';
        case 6:
            return 'Saturday';
    }
}

echo DashboardWidget::includeAssets();
?>

<style>
    body {
        margin-top: 1em;
        display: flex;
        flex-direction: column;
        flex-wrap: wrap;
        align-content: center;
        justify-content: flex-start;
        align-items: center;
    }
</style>
<!-- <img src="/assets/logo_<?php echo $_SESSION['company_id']; ?>.jpg" alt="logo" style="width: 30em;"> -->
<!-- <div class="small_line"></div> -->
<?php

$fuel_movement_res_table = $db->query("fuel_movement", "SELECT * FROM fuel_movement as fm LEFT JOIN clients as c ON fm.client_id = c.record_id WHERE (fm.status = 'RFID' AND fm.tank_id = {$_GET['tank_id']} AND fm.company_id = {$_SESSION['company_id']} AND fm.amount > 100 AND c.company_id = {$_SESSION['company_id']} AND c.exclude_from_reports != 1) OR (fm.status = 'MANUAL OVERRIDE' AND fm.tank_id = {$_GET['tank_id']}  AND fm.company_id = {$_SESSION['company_id']} AND fm.amount > 100 AND fm.client_id = 0) ORDER BY fm.date_time_closed DESC LIMIT 50");
$table_data = [];

while ($fuel_movement = $fuel_movement_res_table->fetch_assoc()) {
    $table_data[] = [
        $functions->get_tank_name($fuel_movement['tank_id']),
        $functions->get_client_name($fuel_movement['client_id']),
        number_format(($fuel_movement['amount'] / 1000), 3),
        $fuel_movement['date_time_closed'],
        //$functions->get_username($fuel_movement['user_id']),
        'diesel/slip.pdf.php?record_id=' . $fuel_movement['record_id']
    ];
}
echo "<h2>RECENT MOVEMENTS FOR {$functions->get_tank_name($_GET['tank_id'])}</h2>";
echo DashboardWidget::tableBlock('', ['PUMP', 'TAG', 'AMOUNT', "DATE"], $table_data, '90vw');
?>





<div class="spacer"></div>
<div class="spacer"></div>