<?php

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

$client_id = new select();
$client_id->name('client_id');
$client_id->id('client_id');
$client_id->class('inputs');
$client_id->add_option("", "SELECT CLIENT");
$client_id->fill_from_db("clients", "record_id", "client_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']);
    }

}


$type = new select();
$type->name('cash_type');
$type->id('cash_type');
$type->class('inputs');
$type->add_option("", "SELECT CASH TYPE");
$type->add_option(0, "N/A");
$type->add_option(1, "CASH");
$type->add_option(2, "CARD");
$type->add_option(3, "EFT");

$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
        $client_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();
        echo "<label>TYPE</label>";
        $type->add();
        $submit->add();
        ?>
    </div>
</form>