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

$maindb = 'item';
//$trandb = 'saletran';
mysqli_select_db($conn, $zdb);

$tran = mysqli_query($conn, "select * from `visatran` order by srl") or die(mysqli_error($conn));

$ctr = 0;
while ($gettran = mysqli_fetch_array($tran)) {
    $ctr++;
    $srl = $gettran['srl'];
    $manualno = $gettran['manualno'];
    $myvouch = $gettran['myvouch'];

    if ($myvouch == $oldvouch) {
        mysqli_query($conn, "update `Sheet1` set `manualno` = '$olmanualno', myvouch='$olmyvouch' WHERE  srl='$srl'") or die(mysqli_error($conn));
    }else{
        mysqli_query($conn, "update `visatran` set `srno` = '$ctr' WHERE  myvouch='$myvouch'") or die(mysqli_error($conn));
        
    }
}
browse('success');
?>
