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

$zroot = $_SESSION["zdir"];
$zdb = $_SESSION["zdbyear_" . $dbname];
$compcd = $_SESSION["comp_" . $dbname];
$username = $_SESSION["username_" . $dbname];

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


if (isset($_REQUEST["prodname"])) {
    $prodname = $_REQUEST['prodname'];
    
    $getitname = mysqli_query($conn, "SELECT `name`,`code`,rate,unit FROM `product` WHERE code ='$prodname'") or die(mysqli_error($conn));
    $fetitname = mysqli_fetch_array($getitname)or die(mysqli_error($conn));
    
    $rows = array();


    $rows = array('rate' => "$fetitname[rate]",
        'unit' => "$fetitname[unit]"
    );
    header("Content-type: application\json");
    echo json_encode($rows);
    
}