<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');
header('Content-Type: text/html; charset=utf-8');

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

if ($_REQUEST["itemcode"]) {

    $delvcomp = $_REQUEST["delvcomp"];
    $itemcode = $_REQUEST["itemcode"];

    $result = mysqli_query($conn, "SELECT `comprate` FROM `itemtran` WHERE code = '$itemcode' and `delvcomp`='$delvcomp'")or die(mysqli_error($conn));
    $r = mysqli_fetch_assoc($result);

    $rows = "";
    if ($r['comprate'] > 0) {
        $rows = $r['comprate'];
    }

    header("Content-type: application\json");
    echo json_encode($rows);
} else {
    echo "ERROR";
}
?>