<?php

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

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

if (isset($_REQUEST["oldtable"])) {
    $oldtable = $_REQUEST['oldtable'];


    $getkot = mysqli_query($conn, "SELECT * FROM `kotmain` where `tableno` = '$oldtable' and billdone != 'Y' limit 0,1 ") or die(mysqli_error($conn));
    $fetkot = mysqli_fetch_array($getkot);
    $kotno = $fetkot['vouchno'];
    echo "$kotno";
}
