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

$booking_label = new label();
$booking_label->for("booking_id");
$booking_label->value("Booking ID");

$booking_no = new input();
$booking_no->type("text");
$booking_no->name("booking_no");
$booking_no->id("booking_no");
$booking_no->value_from_db("bookings", "booking_no", "record_id = {$_GET['record_id']}");
$booking_no->readonly();

$date_booked_label = new label();
$date_booked_label->for("date_booked");
$date_booked_label->value("Date Booked");

$date_booked = new input();
$date_booked->type("datetime-local");
$date_booked->name("date_booked");
$date_booked->id("date_booked");
$date_booked->value_from_db("bookings", "date_booked", "record_id = {$_GET['record_id']}");

$date_done = new input();
$date_done->type("hidden");
$date_done->name("date_done");
$date_done->id("date_done");
$date_done->value_from_db("bookings", "date_done", "record_id = {$_GET['record_id']}");

$assigned_to_label = new label();
$assigned_to_label->for("assigned_to");
$assigned_to_label->value("Assigned To");

$assigned_to = new input();
$assigned_to->type("text");
$assigned_to->name("assigned_to");
$assigned_to->id("assigned_to");
$assigned_to->placeholder("Assigned To");
$assigned_to->value_from_db("bookings", "assigned_to", "record_id = {$_GET['record_id']}");

$test_id_label = new label();
$test_id_label->for("test_id");
$test_id_label->value("Test");

$test_id = new select();
$test_id->name("test_id");
$test_id->id("test_id");
$test_id->fill_from_db("tests", "record_id", "name");

$submit_btn = new button();
$submit_btn->value("ADD BOOKING");
$submit_btn->onclick("add_booking()");

?>

<div class="form_down">
    <h1>EDIT BOOKING</h1>
    <?php
    $booking_label->add();
    $booking_no->add();
    $date_booked_label->add();
    $date_booked->add();
    $date_done->add();
    $assigned_to_label->add();
    $assigned_to->add();
    $test_id_label->add();
    $test_id->add();
    $submit_btn->add();
    ?>
</div>

<?php

$ajax = new js_ajax();
$ajax->function_name("add_booking");
$ajax->submit_btn_id("submit");
$ajax->update("bookings");
$ajax->on_success("BOOKING ADDED SUCCESSFULLY");