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

$user_record_id = new input();
$user_record_id->type("hidden");
$user_record_id->name("record_id");
$user_record_id->id("record_id");
$user_record_id->value($_GET['record_id']);
// HTML FORM ELEMENTS

$username = new input();
$username->class("inputs");
$username->type("text");
$username->placeholder("username");
$username->name("username");
$username->required();
$username->id("username");
$username->value_from_db("users", "username", "record_id = {$_GET['record_id']}");

$password = new input();
$password->class("inputs");
$password->type("text");
$password->placeholder("password");
$password->name("user_password");
$password->id("user_password");

$user_type = new select();
$user_type->class("inputs");
$user_type->name("user_type");
$user_type->id("user_type");
$user_type->required();
$user_type->fill_from_db("user_types", "name", "name");

$user_type_label = new label();
$user_type_label->for("user_type");
$user_type_label->value("User Type");

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

?>

<div class="form_down">
    <h1>EDIT USER</h1>
    <?php
    $user_record_id->add();
    $username->add();
    $password->add();
    $user_type_label->add();
    $user_type->add();
    $submit_btn->add();
    ?>

</div>

<?php
$ajax = new js_ajax();
$ajax->function_name("edit_user");
$ajax->submit_btn_id("submit");
$ajax->update("users");
$ajax->on_success("SUCCESSFULLY UPDATED THE USER");
?>
