<?php

include "../../root.class.php";
$barcode_reader = new barcodeReader();

$html = new html();
$html->add_styles_page();

$name = new input();
$name->id("name");
$name->name("name");
$name->type("text");
$name->placeholder("Asset Name");
$name->class();
$name->required();

$fleet_number = new input();
$fleet_number->id("fleet_number");
$fleet_number->name("fleet_number");
$fleet_number->type("text");
$fleet_number->placeholder("Fleet Number");
$fleet_number->class();

$fuel_size = new input();
$fuel_size->id("fuel_size");
$fuel_size->name("fuel_size");
$fuel_size->addAttribute("step", "0.01");
$fuel_size->type("number");
$fuel_size->placeholder("");
$fuel_size->class();


$barcode = new input();
$barcode->id("barcode");
$barcode->name("barcode");
$barcode->type("text");
$barcode->placeholder("BarCode");
$barcode->class();
// $client_email->required();

$site = new select();
$site->id("site_id");
$site->name("site_id");
$site->class();
$site->fill_from_db("sites", "record_id", 'name', "company_id = '{$_SESSION['company_id']}'");
// $client_address->required();

$company_id = new input();
$company_id->id("company_id");
$company_id->name("company_id");
$company_id->type("hidden");
$company_id->value($_SESSION['company_id']);
$company_id->class();


$status = new select();
$status->id("status");
$status->name("status");
$status->class();
$status->add_option("1", "Active");
$status->add_option("0", "Inactive");


$add_asset = new button();
$add_asset->id("add_asset");
$add_asset->name("add_asset");
$add_asset->value("Add Asset");
$add_asset->class();
$add_asset->onclick("add_asset()");


?>

<div class="form_down">
    <?php
    echo "<label>Asset Name</label>";
    $name->add();
    echo "<label>Asset Fleet Number</label>";
    $fleet_number->add();
    echo "<label>Asset Site</label>";
    $site->add();
    echo "<label>Asset Tank Size</label>";
    $fuel_size->add();
    echo "<label>Asset Status</label>";
    $status->add();
    $company_id->add();
    echo "<label>BarCode</label>";
    $barcode_reader->add_button("barcode", 0);
    $barcode->add();
    $add_asset->add();
    ?>
</div>

<?php

$ajax = new js_ajax();
$ajax->function_name("add_asset");
$ajax->insert("assets");
$ajax->on_success("ASSET ADDED SUCCESSFULLY");
$ajax->redirect("home.php");