<?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];

if (isset($_REQUEST[itemname])) {
    $type = $_REQUEST[type];
    $itemname = $_REQUEST[itemname];

    if ($type == 'R') {
        $getm = mysqli_query($conn, "SELECT * FROM `item` WHERE `name` = '$itemname'")or die(mysqli_error($conn));
        $m = mysqli_fetch_array($getm);
    } else {
        $getm = mysqli_query($conn, "SELECT * FROM `packing` WHERE `name` = '$itemname'")or die(mysqli_error($conn));
        $m = mysqli_fetch_array($getm);
    }
    $iperc = $m[gstperc];


    $cgst = $iperc / 2;
    $sgst = $iperc / 2;



    $rows = array();


    $rows = array('hsncode' => "$hsncode",
        'gstperc' => "$iperc",
        'cgstperc' => "$cgst",
        'sgstperc' => "$sgst",
        'discperc' => "$discperc"
    );
    header("Content-type: application\json");
    echo json_encode($rows);
}