<?php include "../../root.class.php";
$html = new html();
$html->add_styles_page();


// HTML FORM ELEMENTS
$username = new input();
$username->class("inputs");
$username->type("text");
$username->placeholder("username");
$username->name("username");
$username->required();
$username->id("username");

$password = new input();
$password->class("inputs");
$password->type("text");
$password->placeholder("password");
$password->name("password");
$password->required();
$password->id("password");

$company_id = new input();
$company_id->class("inputs");
$company_id->type("hidden");
$company_id->placeholder("company id");
$company_id->name("company_id");
$company_id->required();
$company_id->id("company_id");
$company_id->value($_SESSION['company_id']);

$user_type = new select();
$user_type->class("inputs");
$user_type->name("access_type");
$user_type->id("access_type");
$user_type->add_option("", "ACCESS LEVEL");
$user_type->add_option("ALL", "MANAGMENT");
$user_type->add_option("OPERATOR", "FUEL OPERATOR");
$user_type->required();

$status = new select();
$status->class("inputs");
$status->name("status");
$status->id("status");
$status->add_option("", "STATUS");
$status->add_option("1", "ACTIVE");
$status->add_option("0", "INACTIVE");


$submit_btn = new button();
$submit_btn->value("ADD");
$submit_btn->onclick("add_user()");


?>

<div class="form_down">
    <h1>ADD USER</h1>
    <?php
    $company_id->add();
    echo "<label for='username'>Username</label>";
    $username->add();
    echo "<label for='password'>Password</label>";
    $password->add();
    echo "<label for='status'>Status</label>";
    $status->add();
    echo "<label for='Access_type'>Access Level</label>";
    $user_type->add();
    $submit_btn->add();
    ?>

</div>

<?php
$ajax = new js_ajax();
$ajax->function_name("add_user");
$ajax->submit_btn_id("submit");
$ajax->insert("users");
$ajax->on_success("SUCCESSFULLY ADDED THE USER");
?>