<?php
include "../../root.class.php";
$db = new db_safeguard();

if (isset($_POST['item_name']) && $_POST['item_name'] !== '') {

    $item_name = $_POST['item_name'];

    $stock_data_res = $db->query("stock","SELECT * FROM stock WHERE item_name = '$item_name' LIMIT 1");

    if ($stock_data_res && $stock_data_res->num_rows > 0) {
        $stock_data = $stock_data_res->fetch_assoc();

        $stock_trans_res = $db->query("stock_trans","SELECT * FROM stock_trans WHERE item_name = '$item_name' LIMIT 1");
        $stock_trans = $stock_trans_res->fetch_assoc();

        // quantity|cost
        echo $stock_trans['quantity'] . "|" . $stock_data['item_price'] . "|" . $stock_data['stock_no'];
    } else {
        echo "0|0";
    }

} else {
    echo "0|0";
}
