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

/* if ($admin == 1) {
  } else {
  browse("This Report Only For Admin / Higher Authority");
  header("refresh: 1; ledger.php");
  exit();

  } */

$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');

mysqli_select_db($conn, $zdb);
?>
<!DOCTYPE HTML>
<html lang="en-US">

    <head>
        <meta charset="UTF-8">
        <title>Ledger</title>
        <meta name="msapplication-TileColor" content="#5bc0de"/>
        <meta name="msapplication-TileImage" content="assets/img/metis-tile.png"/>

        <link rel="stylesheet" href="assets/lib/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="assets/css/main.css"/>
        <link rel="stylesheet" href="assets/lib/Font-Awesome/css/font-awesome.css"/>

        <link rel="stylesheet" href="assets/css/theme.css">


        <link rel="stylesheet" href="assets/lib/uniform/themes/default/css/uniform.default.css">
        <link rel="stylesheet" href="assets/lib/inputlimiter/jquery.inputlimiter.1.0.css">
        <link rel="stylesheet" href="assets/lib/chosen/chosen.min.css">
        <link rel="stylesheet" href="assets/lib/colorpicker/css/colorpicker.css">
        <link rel="stylesheet" href="assets/lib/tagsinput/jquery.tagsinput.css">
        <link rel="stylesheet" href="assets/lib/daterangepicker/daterangepicker-bs3.css">
        <link rel="stylesheet" href="assets/lib/datepicker/css/datepicker.css">
        <link rel="stylesheet" href="assets/lib/timepicker/css/bootstrap-timepicker.min.css">
        <link rel="stylesheet" href="assets/lib/switch/static/stylesheets/bootstrap-switch.css">
        <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/flick/jquery-ui.css">


        <script>
            (function (i, s, o, g, r, a, m) {
                i['GoogleAnalyticsObject'] = r;
                i[r] = i[r] || function () {
                    (i[r].q = i[r].q || []).push(arguments)
                }, i[r].l = 1 * new Date();
                a = s.createElement(o),
                        m = s.getElementsByTagName(o)[0];
                a.async = 1;
                a.src = g;
                m.parentNode.insertBefore(a, m)
            })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

            ga('create', 'UA-1669764-16', 'onokumus.com');
            ga('send', 'pageview');

        </script>
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript">
            $(document).keydown(function (event) {
                //19 for Mac Command+S
                if (!(String.fromCharCode(event.which).toLowerCase() == 'v' && event.ctrlKey) && !(event.which == 19))
                    return true;
                $("#view").click();
                event.preventDefault();
                return false;
            });

        </script>        

        <script src="assets/lib/modernizr-build.min.js"></script>
        <script type="text/javascript" src="../js/jquery.js"></script>
        
        <?php include('includes/combo.php'); ?>
    </head>    
    <form class="form-horizontal" action='ledger_fr.php' method='POST'>
        <div class="row">
            <div class="col-lg-12">
                <div class="box">
                    <header>
                        <div class="icons">
                            <i class="fa fa-edit"></i>
                        </div>
                        <h5>Ledger</h5>
                        <div class="toolbar">
                            <ul class="nav pull-right">
                                <li>
                                    <input type='submit' id="expexc" name='export' class='btn btn-primary' value='Export to Excel'>
                                    <input type='submit' id="view" name='view' class='btn btn-success' value='Proceed'>                                    
                                </li>
                                <li>
                                    <a class="minimize-box" data-toggle="collapse" href="#div-4">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </li>
                            </ul>
                        </div><!-- /.toolbar -->
                    </header>
                    <div id="div-4" class="accordion-body collapse in body">

                        <div class="form-group">
                            <label class="control-label col-lg-3">Group</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select class='form-control' name='group' style="width:297px;height:33px;">
                                        <option value=""></option>
                                        <?php
                                        $mown = mysqli_query($conn, "SELECT grpcode, `name` FROM `grpmast` ORDER BY `name`") or die(mysqli_error($conn));
                                        while ($trow = mysqli_fetch_array($mown)) {
                                            echo "<option value='$trow[grpcode]'>$trow[name]</option>";
                                        }
                                        ?>
                                    </select>

                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">A/c Name</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select class='form-control' name='acname' style="width:297px;height:33px;">
                                        <option value=""></option>
                                        <?php
                                        $mown1 = mysqli_query($conn, "SELECT accode, `name` FROM `accmast` ORDER BY `name`") or die(mysqli_error($conn));
                                        while ($trow1 = mysqli_fetch_array($mown1)) {
                                            echo "<option value='$trow1[accode]'>$trow1[name]</option>";
                                        }
                                        ?>
                                    </select>

                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Staff</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select style="width:300px;height:34px;" id="staff" name="staff" class="form-control">
                                        <option value=""></option>
                                        <?php
                                        $getstaff = mysqli_query($conn, "SELECT `code`, `name` FROM `staff`")or die(mysqli_error($conn));
                                        while ($staff = mysqli_fetch_array($getstaff)) {
                                            echo "<option value='$staff[code]'>$staff[name]</option>";
                                        }
                                        ?>

                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Station</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select class='form-control' name='cmbstation' style="width:220px;height:33px;">
                                        <option value=""></option>
                                        <?php
                                        $stown = mysqli_query($conn, "SELECT station FROM `accmast` WHERE station != '' group by station ORDER BY `station`") or die(mysqli_error($conn));
                                        while ($strow = mysqli_fetch_array($stown)) {
                                            echo "<option value='$strow[station]'>$strow[station]</option>";
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">City</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select class='form-control' name='city' style="width:220px;height:33px;">
                                        <option value=""></option>
                                        <?php
                                        $ctown = mysqli_query($conn, "SELECT city FROM `accmast` WHERE city != '' group by city ORDER BY `city`") or die(mysqli_error($conn));
                                        while ($ctrow = mysqli_fetch_array($ctown)) {
                                            echo "<option value='$ctrow[city]'>$ctrow[city]</option>";
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">From Date</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <input type="date" id="invdt" name="frmdt" class="form-control" value="<?php echo $mfrdate; ?>" />  
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">To Date</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <input type="date" id="invdt" name="todt" class="form-control" value="<?php echo $mtodate; ?>" />  
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Report Type</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select name="dtype" class="form-control" style="height:33px;width:297px;">
                                        <option value="2">Detail</option>
                                        <option value="1">Summary</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Order By</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select name="station" class="form-control" style="height:33px;width:297px;">
                                        <option value="1">Station</option>
                                        <option value="2">Name</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Print Narration</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select name="prinnarr" class="form-control" style="height:33px;width:297px;">
                                        <option value="2">No</option>
                                        <option value="1">Yes</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-lg-3">Print Zero Balance</label>
                            <div class="col-lg-5">
                                <div class="input-group">
                                    <select name="prinzero" class="form-control" style="height:33px;width:297px;">
                                        <option value="2">No</option>
                                        <option value="1">Yes</option>
                                    </select>
                                </div>
                            </div>
                        </div>


                    </div>
                </div>
            </div>
        </div>
    </form>