<?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');

browse($zdb);

mysqli_select_db($conn, $zdb);

$ctr = 0;
//UPDATE tranftran a
//INNER JOIN product b ON a.itemcode = b.code
//SET a.barcode = b.barcode

$getsale = mysqli_query($conn, "SELECT godown,vouchno from salemain order by vouchno") or die(mysqli_error($conn));
$totrec = mysqli_num_rows($getsale);
browse($totrec);

while ($fsale = mysqli_fetch_array($getsale)) {
    $ctr++;
    echo $ctr;

    $godown = $fsale['godown'];
    $vouchno = $fsale['vouchno'];

    mysqli_query($conn, "UPDATE `saletran` SET `godown`='$godown' where `vouchno` = '$vouchno'") or die(mysqli_error($conn));
}
browse("Update completed successfully");
?>