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


$para = $_GET["para"];
$series = $_GET["series"];

if ($para != "C") {
    $formname = 'Multiple E-Invoice Generation';
} else {
    $formname = 'Multiple E-Invoice Generation - Credit Note';
}
$action = "einvoicegen_fr.php";

$zseries = $_SESSION['user_series'];

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];

$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');

$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

include("includes/linkshead.php");
?>
<script type="text/javascript">
    $(document).ready(function () {
        $("#printbut").click(function () {
            var para = $(".para").val(),
                    date = $("#date").val();
            if (date != '0000-00-00') {
                $.post('getDInv.php', {date: date, para: para}, function (data) {
                    $(".tbody").html(data);
                    $("#printmodal").modal('show');
                });
            } else {
                alert("Date Cannot be Empty");
            }
        });

        $(".checkAll").click(function () {
            if ($(this).is(':checked')) {
                $(".chk").prop('checked', true);
            } else {
                $(".chk").prop('checked', false);
            }
        });
        $("#excel").hide();
        $("#subpdf").hide();
    });
</script>


</head>
<body>
    <form action='<?= $action ?>' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-9 pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title" style="color :#05B2EA;"><?php Echo $formname; ?></h3>
                    </div>
                    <div class="panel-body">

                        <!--                        <div class='row'>
                                                    <div class='col-lg-5 col-md-3 col-sm-3 col-xs-3 pad text-right'>
                                                        <label class='label-control tmarg'>Series</label>
                                                    </div>
                                                    <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 pad">
                        
                        <?php
                        if ($series != "") {
                            ?>
                                                                        <input type = "text" class = "form-control series" id = "series" name = "series" value = "<?php echo $series; ?>" readonly tabindex="-1">
                        <?php } else {
                            ?>
                                                                            <select name="series" id="series" class="form-control select2" required>
                                                                                <option></option>
                                                                                <option value="LO">LOCAL</option>                                    
                                                                                <option value="DE">DEEMED</option>
                                                                                <option value="ON">ONLINE</option>
                                        
                                                                            </select>
                                        
                        <?php } ?>
                                                    </div>
                                                </div>-->
                        <div class='row'>
                            <div class='col-lg-5 col-md-3 col-sm-3 col-xs-3 pad text-right'>
                                <label class='label-control tmarg'>Invoice Date</label>
                            </div>
                            <div class='col-lg-2 col-md-3 col-sm-3 col-xs-3 pad'>
                                <input type="date" class="form-control " id="date" name="invdate" value="<?php echo date("Y-m-d"); ?>" >
                                <input type="hidden" class="form-control para" id="para" name="para" value="<?php echo $para; ?>" >
                            </div>
                        </div>

                    </div>
                    <div class="panel-footer">
                        <div class="text-center pad">
                            <!--<div class="col-lg-1 pad">-->
                            <input type="button" id="printbut" class="btn btn-primary" style="color: #fff;background-color: #05B2EA;" value="Proceed">
                            <!--</div>-->
                            <!--                                <button id="printbut" class="btn btn-pad btn-square " style="background-color:#05B2EA; ">
                                                                <i class="fa fa-television" style="color:#ffffff"></i>
                                                            </button>-->
                            <button id='cancel' type="reset" class="btn btn-pad btn-square " style="background-color:red;"  onclick="window.location.href = '<?= 'default.php' ?>'">
                                <i class="fa fa-power-off" style="color:#ffffff"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" tabindex="-1" role="dialog" id="printmodal" aria-labelledby="myLargeModalLabel">
            <div class="modal-dialog modal-lg" style="margin-top: 10%;width: 50%">
                <div class="modal-content">
                    <div class="modal-header">
                        <button class="close" data-dismiss="modal"><span>&times;</span></button>
                        <h4 class="modal-title" id="myLargeModalLabel"></h4>
                    </div>
                    <div class="modal-body" id="">
                        <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                            <table id="" class="table table-striped table-condensed table-bordered sizeTable" width="50%">
                                <thead>
                                    <tr class="mySearchTr">

                                        <th style="width:20%;padding-bottom:5%;" class="text-center"><input type="checkbox" name="checkAll" class="checkAll" style="width: 25px;height: 25px"></th>
                                        <th style="width:10%">Invoice No.</th>
                                        <th style="width:40%">Party</th>
                                        <th style="width:10%">Date</th>
                                        <th style="width:10%">Bill Amount</th>
                                    </tr>
                                </thead>

                                <tbody class="tbody">

                                </tbody>
                            </table>     
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button id="view" name='view' formtarget='_blank'  class="btn btn-pad btn-square " style="background-color:#05B2EA; ">
                            <i class="fa fa-desktop" style="color:#ffffff"></i>
                        </button>
    <!--                    <a id='print' class="btn btn-pad btn-square " style="background-color:#5BC0DE;" href='<?= $printfile ?>?vouchno=<?= $qvouch; ?>&buycopy' + document.invoice.buycopy.value + '' target="_blank">
                            <i class="fa fa-print" style="color:#ffffff"></i>
                        </a>-->
                    </div>
                </div>
            </div>
        </div>
    </form>    
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
