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

// $html->check_user_type("ADMIN");
$stock = new input();
$stock->name("description");
$stock->id("description");
$stock->type("text");
$stock->placeholder("Descprition");
$stock->class("search_inputs");
$stock->onkeyup("search_stock()");

$categories = new select();
$categories->name("category_id");
$categories->id("category_id");
$categories->class("search_inputs");
$categories->add_option("", "Category");
$categories->fill_from_db("stock_categories", "record_id", "name");
$categories->onchange("search_stock()");

$suppliers = new select();
$suppliers->name("supplier_id");
$suppliers->id("supplier_id");
$suppliers->class("search_inputs");
$suppliers->add_option("", "Supplier");
$suppliers->fill_from_db("suppliers", "record_id", "name");
$suppliers->onchange("search_stock()");


$stock_type = new select();
$stock_type->name("stock_type");
$stock_type->id("stock_type");
$stock_type->class("search_inputs");
$stock_type->add_option("", "Stock Type");
$stock_type->add_option(0, "STOCK");
$stock_type->add_option(1, "NON STOCK");
$stock_type->add_option(2, "UNITS");
$stock_type->onchange("search_stock()");

?>

<div class="search_form">
    <?php
    $stock->add();
    $categories->add();
    $suppliers->add();
    $stock_type->add();
    ?>

</div>

<?php 
$ajax = new js_ajax();
$ajax->function_name("search_stock");
$ajax->select("stock");
$ajax->return_columns(['description']);
$ajax->run_on_load();
$ajax->redirect("edit_stock.php");
 ?>