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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);
$zroot = $_SESSION["zdbroot"];

$file = 'multipleinv_fr.php';
$maindb = 'salemain';
$trandb = 'saletran';

$fseries = $_SESSION["series"];
$keycond = "AND series = '$fseries'";

$print = $_POST["print"];
$mfrmdate = trim($_POST["frmdt"]);
$mtodate = trim($_POST["todt"]);


if (empty($_POST["frmdt"])) {
    browse("From Date Cannot Be Empty");
    header("refresh:1; multipleinv.php");
}
// if (empty($_POST["todt"])) {
//     browse("To Date Cannot Be Empty");
//     header("refresh:1; salereg.php");
// }
if ($print == 2) {
    $printcond = "AND prnnum <= 0";
} else {
    $printcond = "AND prnnum > 0";
}


$getpmain2 = mysqli_query($conn, "SELECT vouchno FROM `$maindb` WHERE `vouchdt` = '$mfrmdate' 
                                   $printcond $keycond order by vouchno") or die(mysqli_error($conn));
$getno2 = mysqli_num_rows($getpmain2);


if (isset($_POST["view"]) || ($_GET["view"])) {


    include("includes/linkshead.php");
?>
    <style type="text/css">
        #tabital {
            font-style: italic;
        }

        #font1 {
            font-style: italic;
        }

        #boldfont {
            font-weight: bold;
        }
    </style>
    </head>

    <body>


        <div class="container-fluid">
            <?php

            if ($getno2 > 0) {
                while ($gettran = mysqli_fetch_array($getpmain2)) {
                    $mvouchno = $gettran['vouchno'];

                    $isInclude = true;
                    $printfile = "sale_print.php";
                    include($printfile);
                }
            } else {
                browse("No Record Found");
                echo "<script>window.close();</script>";
            }
            ?>
        </div>
        <?php include("includes/linksfoot.php");
        ?>
    </body>

    </html>
<?php
}

?>