<?php

include "../../root.class.php";
$html = new html();
$html->add_styles_page();

$asset_id = new select();
$asset_id->name('asset_id');
$asset_id->id('asset_id');
$asset_id->class('inputs');
$asset_id->add_option("", "SELECT ASSET");
$asset_id->fill_from_db("assets", "record_id", "name", "company_id = {$_SESSION['company_id']}");


$user_id = new select();
$user_id->name('user_id');
$user_id->id('user_id');
$user_id->class('inputs');
$user_id->add_option("", "SELECT USER");
$user_id->fill_from_db("users", "record_id", "username", "company_id = {$_SESSION['company_id']}");




$tank_id = new select();
$tank_id->name('tank_id');
$tank_id->id('tank_id');
$tank_id->class('inputs');
$tank_id->add_option("", "SELECT TANK");
$db = new db_safeguard();

$all_sites_res = $db->query("sites", "SELECT * FROM sites WHERE company_id = {$_SESSION['company_id']}");

while ($site = $all_sites_res->fetch_assoc()) {
    $tank_res = $db->query("tanks", "SELECT * FROM tanks WHERE site_id = {$site['record_id']}");

    while ($tank = $tank_res->fetch_assoc()) {
        $tank_id->add_option($tank['record_id'], $tank['name']);
    }

}


$date_from = new input();
$date_from->name('date_from');
$date_from->id('date_from');
$date_from->class('inputs');
$date_from->type('date');

$date_to = new input();
$date_to->name('date_to');
$date_to->id('date_to');
$date_to->class('inputs');
$date_to->type('date');


$submit = new input();
$submit->name('submit');
$submit->id('submit');
$submit->class('submit_btn');
$submit->type('submit');
$submit->value('Search');


?>

<form action="diesel_orders.php" method="post">
    <div class="form_down">
        <?php
        $asset_id->add();
        $user_id->add();
        echo "<label>Date From</label>";
        $date_from->add();
        echo "<label>Date To</label>";
        $date_to->add();
        echo "<label>Tank</label>";
        $tank_id->add();
        $submit->add();
        ?>
    </div>
</form>