<?php

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

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

$item = $_REQUEST['item'];
$itemcond = '';

//if (!empty($_REQUEST['item'])) {
    $itemcond = "AND `code` = '$item' ";
//}


$getitem = mysqli_query($conn, "SELECT code, name, discperc FROM `item` WHERE `code` != '' $itemcond ")or die(mysqli_error($conn));
$m = mysqli_fetch_array($getitem);

if ($item != "") {
    $it = 1;
    $discperc = $m['discperc'];
} 

$rows = array('it' => $it,
    'discperc' => "$discperc"
);

header("Content-type: application\json");
echo json_encode($rows);