<?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['item'])) {
    $item = $_REQUEST['item'];

    $getm = mysqli_query($conn, "SELECT * FROM `item` WHERE `code`='$item'")or die(mysqli_error($conn));
    $m = mysqli_fetch_array($getm);

    $hsn = $m['hsncode'];
    $gstperc = $m['gstperc'];
    $srate = $m['selling'];
    $prate = $m['cost'];
    
    $cgst = $gstperc / 2;
    $sgst = $gstperc / 2;

    $rows = array();


    $rows = array('hsn' => $hsn,
        'cgst'  => "$cgst",
        'sgst'  => "$sgst",
        'igst'  => "$gstperc",
        'srate' => "$srate",
        'prate' => "$prate"
    );
    header("Content-type: application\json");
    echo json_encode($rows);
}