<?php

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

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

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

    $mo = mysqli_query($conn, "SELECT user FROM `kotmain` where `tableno`='$oldtable' and billdone != 'Y' limit 0,1") or die(mysqli_error($conn));
    $to = mysqli_fetch_array($mo);
    
    $mown1 = mysqli_query($conn,"SELECT code,user FROM $zroot.`passmain` where `usertype`!='W' order by `user`") or die(mysqli_error($conn));
    echo "<option value='$to[user]'>$to[user]</option>";
    while ($trow1 = mysqli_fetch_array($mown1)) {
        echo "<option value='$trow1[user]'>$trow1[user]</option>";
    }
}
?>
