<?php

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

$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');

$trandb = $_GET["trandb"];
mysqli_select_db($conn, $zdb);
browse($trandb);


$getitem = mysqli_query($conn, "SELECT hsncode, prodcode,barcode from `product` where prodcode in (Select itemcode from `$trandb` ) order by name") or die(mysqli_error($conn));
//print table($getitem);
//die();
while ($fitem = mysqli_fetch_array($getitem)) {

    $code = $fitem['prodcode'];
    $hsncode = $fitem['hsncode'];
    $barcode = $fitem['barcode'];

    mysqli_query($conn, "UPDATE `$trandb` SET `hsncode`='$hsncode' where `itemcode` = '$code'") or die(mysqli_error($conn));
    
}
browse("$trandb  completed successfully"); 
//$getsale = mysqli_query($conn, "SELECT vouchno, total,srno from saletran order by vouchno, srno") or die(mysqli_error($conn));
//while ($fsale = mysqli_fetch_array($getsale)) {
//
//    $netamt = $fsale['total'];
//    $vouchno = $fsale['vouchno'];
//    $srno = $fsale['srno'];
//
//    mysqli_query($conn, "UPDATE `transacn` SET `netamt`='$netamt' where `vouchno` = '$vouchno' and source = 'SL' and srno = '$srno' ") or die(mysqli_error($conn));
//    
//}
//browse("Sale completed successfully"); 

//$getsale_de = mysqli_query($conn, "SELECT vouchno, total, srno from deextran order by vouchno, srno") or die(mysqli_error($conn));
//while ($fsale_de = mysqli_fetch_array($getsale_de)) {
//
//    $netamt2 = $fsale_de['total'];
//    $vouchno2 = $fsale_de['vouchno'];
//    $srno2 = $fsale_de['srno'];
//
//    mysqli_query($conn, "UPDATE `transacn` SET `netamt`='$netamt2' where `vouchno` = '$vouchno2' and source = 'SLDE' and srno = '$srno2'") or die(mysqli_error($conn));
//    
//}
//browse("Deemed Sale completed successfully");
?>
