<?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']);

$name = new input();
$name->type("text");
$name->name("name");
$name->id("name");
$name->placeholder("Name");
$name->value_from_db("clients", "name", "record_id = {$_GET['record_id']}");

$co_ordinates = new input();
$co_ordinates->class("inputs");
$co_ordinates->name("co_ordinates");
$co_ordinates->id("co_ordinates");
$co_ordinates->required();
$co_ordinates->value_from_db("clients", "co_ordinates", "record_id = {$_GET['record_id']}");

$contact_number = new input();
$contact_number->class("inputs");
$contact_number->type("text");
$contact_number->placeholder("CONTACT NUMBER");
$contact_number->name("contact_number");
$contact_number->id("contact_number");
$contact_number->value_from_db("clients", "contact_number", "record_id = {$_GET['record_id']}");

$location = new input();
$location->type("text");
$location->name("location");
$location->id("location");
$location->placeholder("User Responsible");
$location->value_from_db("clients", "location", "record_id = {$_GET['record_id']}");

$status = new select();
$status->class("inputs");
$status->name("status");
$status->id("status");
$status->add_option("", "STATUS");
$status->fill_from_db("status", "name", "name");

$name_label = new label();
$name_label->for("NAME");
$name_label->value("NAME");

$status_label = new label();
$status_label->for("STATUS");
$status_label->value("STATUS");

$location_label = new label();
$location_label->for("LOCATION");
$location_label->value("LOCATION");

$co_ordinates_label = new label();
$co_ordinates_label->for("CO_ORDINATES");
$co_ordinates_label->value("CO_ORDINATES");

$contact_number_label = new label();
$contact_number_label->for("CONTACT_NUMBER");
$contact_number_label->value("CONTACT NUMBER");

$submit_btn = new button();
$submit_btn->value("UPDATE");
$submit_btn->onclick("edit_asset()");

?>

<div class="form_down">
    <h1>EDIT CLIENTS</h1>
    <?php
    $user_record_id->add();
    $name_label->add();
    $name->add();
    $contact_number_label->add();
    $contact_number->add();
    $location_label->add();
    $location->add();
    $co_ordinates_label->add();
    $co_ordinates->add();

    $status_label->add();
    $status->add();

    $submit_btn->add();
    ?>
</div>

<?php
$ajax = new js_ajax();
$ajax->function_name("edit_clients");
$ajax->submit_btn_id("submit");
$ajax->update("clients");
$ajax->on_success("CLIENTS SUCCESSFULLY UPDATED");
?>

<script>
    function open_pdf(value) {
        window.open("documents/" + value, "_blank");
    }
</script>