<?php

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

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

$chrate = $_REQUEST[chrate];
$ctr = $_REQUEST[count];

if (isset($chrate) != "") {
//    browse($ctr);
    for ($i = 0; $i < $ctr; $i++) {
        $code = $chrate[$i]["code"];
        $cost = $chrate[$i]["cost"];
        $selling = $chrate[$i]["selling"];
        $hsncode = $chrate[$i]["hsncode"];
        $gstperc = $chrate[$i]["gstperc"];

        
        mysqli_query($conn, "UPDATE `item` SET `gstperc`='$gstperc' , `hsncode`='$hsncode', `selling`='$selling',
                    `cost`='$cost' WHERE `code`='$code'")or die(mysqli_error($conn));
    }

    $success = true;
    $show = ["success" => $success];
    header("Content-type: application\json");
    echo json_encode($show);
}
    