<?php include "../../root.class.php";

$html = new html();
$html->add_styles_page();

$po = new input();
$po->name("po_number");
$po->id("po_number");
$po->type("text");
$po->placeholder("PO NUMBER");
$po->class("search_inputs");
$po->onkeyup("search_stock_control()");

$jc = new input();
$jc->name("jc_number");
$jc->id("jc_number");
$jc->type("text");
$jc->placeholder("JC NUMBER");
$jc->class("search_inputs");
$jc->onkeyup("search_stock_control()");


$status = new input();
$status->name("status");
$status->id("status");
$status->type("hidden");

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

?>
<h1> STOCK RECEIVING </h1>
<div class="search_form"
    style="width: 100%;border-radius: 1vw;padding: 1.5vw;display: flex;flex-direction: row;flex-wrap: wrap;align-items: center;background-color: grey;align-content: flex-start;justify-content: space-evenly;overflow-x: scroll;">
    <?php
    $po->add();
    $jc->add();
    $status->add();
    $supplier->add();
    ?>
</div>



<?php 
// echo $html->html_form_ajax("search_stock_control", "SELECT", "orders", '', false, ['po_number', 'jc_number', 'supplier_id', 'user_id', 'date_time_created'], "received_stock.php"); 
$ajax = new js_ajax();
$ajax->function_name("search_stock_control");
$ajax->select("orders");
$ajax->return_columns(['po_number', 'jc_number', 'supplier_id', 'date_time_created']);
$ajax->redirect("received_stock.php");
$ajax->run_on_load();

?>

<script>
    setInterval(function () {
        search_stock_control();
    }, 10000);

    search_stock_control();
</script>