<?php

include "../../classes/app.class.php";
$app = new app();
$db = new DBMain();
?>

<div class='container flex_container'>
    <h1>SEARCH STOCK BY:</h1>
    <div class="container flex_container" style='border: 1px solid black; width:80%;padding: 10px;border-radius: 10px;'>

        <div class='flex_container_content'>
            <label>NAME</label>
                <input type="text" name="name" id="name">
        </div>
    </div>
        <br>
        <button onclick="search_stock_category()" class='font_size_2vw'>SEARCH</button>
</div>

<div class='flex_container' id='stock_category_content'>

</div>

<script>
    function search_stock_category() {

        name = document.getElementById('name').value;

        var xhttp = new XMLHttpRequest();
        xhttp.onload = function() {
            console.log(this.responseText);
            document.getElementById('stock_category_content').innerHTML = this.responseText;
        }
        xhttp.open("GET", '../../ajax/stock/search_stock_category.php?name=' + name);
        xhttp.send();
    }

    function edit_stock_category($id) {
        window.location.href = 'edit_stock_category.php?record_id=' + $id;
    }
</script>