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

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

$fuel_price = new input();
$fuel_price->type("number");
$fuel_price->addAttribute("step", "0.01");
$fuel_price->name("fuel_price");
$fuel_price->id("fuel_price");
$fuel_price->value_from_db("companies", "fuel_price", "record_id = {$_SESSION['company_id']}");

$email = new input();
$email->type("text");
$email->name("email");
$email->id("email");
$email->value_from_db("companies", "email", "record_id = {$_SESSION['company_id']}");


$name = new input();
$name->type("text");
$name->name("name");
$name->id("name");
$name->value_from_db("companies", "name", "record_id = {$_SESSION['company_id']}");


$contact_number = new input();
$contact_number->type("text");
$contact_number->name("contact_number");
$contact_number->id("contact_number");
$contact_number->value_from_db("companies", "contact_number", "record_id = {$_SESSION['company_id']}");

$address = new input();
$address->type("text");
$address->name("address");
$address->id("address");
$address->value_from_db("companies", "address", "record_id = {$_SESSION['company_id']}");

$logo = new file_upload();
$logo->name("logo_file");
$logo->id( "logo_file");
$logo->style("padding:1em;");
$logo->class("inputs");
$logo->file_save_path("app/company/logos/");

$submit_btn = new button();
$submit_btn->value("UPDATE");
$submit_btn->onclick("edit_company()");

?>

<div class="form_down">
    <h1>EDIT COMPANY DETAILS</h1>
    <?php
    $company_id->add();
    echo "<label for='fuel_price'>Fuel Price</label>";
    $fuel_price->add();
    echo "<label for='name'>Company Name</label>";
    $name->add();
    echo "<label for='email'>Email</label>";
    $email->add();
    echo "<label for='contact_number'>Contact Number</label>";
    $contact_number->add();
    echo "<label for='address'>Address</label>";
    $address->add();
    echo "<label for='logo'>Logo</label>";
    $logo->add();

    $submit_btn->add();
    ?>

</div>

<?php
$ajax = new js_ajax();
$ajax->function_name("edit_company");
$ajax->submit_btn_id("submit");
$ajax->update("companies");
$ajax->on_success("SUCCESSFULLY UPDATED THE DETAILS");
?>