<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

if (isset($_REQUEST['itemcode'])) {
    $itemcode = $_REQUEST['itemcode'];
//    browse($itemcode);
    $prodtype = $_REQUEST['prodtype'];
    $prodcond = '';
    if (!empty($prodtype)) {
        $prodcond = " and `prodtype`='$prodtype'";
    }
//    $series = $_REQUEST['series'];

    $getitm = mysqli_query($conn, "SELECT `code`, `barcode`, `name` FROM `item` WHERE `barcode`='$itemcode'  ORDER BY `name`")or die(mysqli_error($conn));
    $itm = mysqli_fetch_array($getitm);
    $count = mysqli_num_rows($getitm);

    if ($count > 0) {
        Echo "<option value='$itm[code]'>$itm[name]</option>";
        $getitm2 = mysqli_query($conn, "SELECT code, name FROM `item` where code != ''  ORDER BY `name`")or die(mysqli_error($conn));
        while ($itm2 = mysqli_fetch_array($getitm2)) {
            Echo "<option value='$itm2[code]'>$itm2[name]</option>";
        }
    }
}
?>