<?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["date"]) {
    $date = $_REQUEST["date"];
    $para = $_REQUEST["para"];

    if ($para != 'C') {
        $keyfld = "invno";
        $maindb = "billmain";
        $trandb = "billtran";
        $gstdb = "gsteinvoice";
        $deemexp = 'L';
        $suptype = "B2B";
        $revchg = 'N';
        $invtype = "INV";
    } else {
        $keyfld = "vouchno";

        $maindb = "credmain";
        $trandb = "credtran";
        $deemexp = $series;
        $gstdb = "gsteinvoicecred";
        $invtype = "CRN";
        $suptype = "B2B";
        $revchg = 'N';
    }
//    echo "$date";

    $mainqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d/%m/%Y') AS mydt FROM `$maindb`
                                WHERE vouchdt='$date' and party in 
                               (Select accode from accmast where gstno != '') and irn='' and `haltinv` != 'Y'") or die(mysqli_error($conn));

//print table($mainqry);
    while ($row = mysqli_fetch_array($mainqry)) {
        $getcust = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`='$row[party]'")or die(mysqli_error($conn));
        $cust = mysqli_fetch_array($getcust);
        echo "<tr>";
        echo "<td class='text-center' style='padding-bottom:5%;'><input type='checkbox' class='chk' name='check[]' style='height:25px;width:25px'  value='$row[vouchno]'></td>";
        echo "<td tabindex='-1'>$row[billno]</td>";
        echo "<td tabindex='-1'>$cust[name]<input type='hidden' name='vouchno_$ctr' value='$row[vouchno]' readonly tabindex='-1'></td>";
        echo "<td tabindex='-1'>$row[mydt]</td>";
        echo "<td tabindex='-1'>$row[billamt]</td>";
        echo "</tr>";
    }
}
?>
