<?php include "../../root.class.php";
$html = new html();
$db = new db_safeguard();
$html->add_styles_page();
// $html->check_user_type("ADMIN");

// HTML FORM ELEMENTS

$batch_id = $db->query('batch', " SELECT * FROM batch");
// $batch_id = $db->query('batch', " SELECT * FROM batch WHERE batch_id = {$_GET['batch_id']}");
$batch = $batch_id->fetch_assoc();

$silos_res = $db->query('silos', "SELECT * FROM silos WHERE variety_id = {$batch['variety_id']} OR variety_id = 0");

$silo_list = $silo_list . "<option></option>";

while ($silo = $silos_res->fetch_assoc()) {
    $silo_list = $silo_list . "<option value='{$silo['record_id']}'>{$silo['name']}</option>";
}

$batch_label = new label();
$batch_label->for("batch_id");
$batch_label->value("BATCH ID:");

$batch_id = new input();
$batch_id->class("inputs");
$batch_id->type("text");
$batch_id->placeholder("BATCH_ID");
$batch_id->name("batch_id");
$batch_id->id("batch_id");
$batch_id->value($_GET['batch_id']);
$batch_id->readonly();

$amount_label = new label();
$amount_label->for("amount");
$amount_label->value("AMOUNT TO MOVE (Kg):");

$amount = new input();
$amount->class("inputs");
$amount->type("number");
$amount->placeholder($batch['weight']);
$amount->name("amount");
$amount->id("amount");

$silo_label = new label();
$silo_label->for("silo");
$silo_label->value("MOVE TO SILO:");

$submit_btn = new button();
$submit_btn->value("SUBMIT");
$submit_btn->onclick("search_drying_bins()");

?>
<div class="form_down">
    <h1>MOVE TO SILOS</h1>

    <?php
    $batch_label->add();
    $batch_id->add();
    $amount_label->add();
    $amount->add();
    $silo_label->add();
    ?>

    <select name="silo_id" id="silo_id" class="inputs" required class="form_input">
        <?php echo $silo_list; ?>
    </select>

    <?php
    $submit_btn->add();
    ?>

</div>

<!-- <php
$ajax = new js_ajax();
$ajax->run_on_load();
$ajax->function_name("search_drying_bins");
// $ajax->submit_btn_id("submit");
// $ajax->select("drying_bins");
$ajax->redirect("edit_bin.php");
?> -->