<?php

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

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

$maindb = 'salemain';
$trandb = 'saletran';
$myyear = $_SESSION[$myyear];




$result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `vouchno`!= '' group by vouchno") or die(mysqli_error($conn));

$getnum = mysqli_num_rows($result);
browse($getnum);
while ($get = mysqli_fetch_array($result)) {
    $cgstamt = 0;
    $igstamt = 0;

    $vouchno = $get["vouchno"];
    
    $cgstrate = $get["cgstperc"];
    $sgstrate = $get["sgstperc"];
    $igstrate = $get["igstperc"];
    
    $gstperc = $cgstrate + $sgstrate + $igstrate;




    mysqli_query($conn, "update `$trandb` set  `gstperc`='$gstperc' where vouchno = '$vouchno' ") or die(mysqli_error($conn));
}
browse("Success");
?>
