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

$formname = "Customer No Sale - Datewise";
$action = "custnosale_fr.php";

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

$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');
//browse($mfrdate);
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

include("includes/linkshead.php");
?>
<script type="text/javascript">
    $(document).ready(function () {
        $("#logac").click(function () {
            if ($("#logac").prop("checked") == true) {
                var party = $("#acname").val();
                var fromdate = $("#frmdt").val();
                var todate = $("#todt").val();
                var ledgto = $("#ledgto").val();
                $.post('log_ac_details.php', {party: party, fromdate: fromdate, todate: todate, ledgto: ledgto, para: 1}, function (data) {
                    $("#logdata").html(data);
                });
            }
        });

        $("#acname").change(function () {
            var mparty = $(this).val();
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: "log_ac_details.php",
                data: "party=" + mparty + "&para=2",
                success: function (response) {
                    var fromdate = response.fromdate;
                    var todate = response.todate;
                    $("#frmdt").val('');
                    $("#frmdt").val(fromdate);
                    $("#todt").val('');
                    $("#todt").val(todate);
                    $("#ledgto").val('');
                    $("#lastdate").val(todate);
                },
                error: function (request, textStatus, errorThrown) {
                    alert(errorThrown);
                }
            });
        });


    });

</script>
</head>
<body>
    <form method='POST' action="<?= $action; ?>">
        <!-- Default box -->
        <div>
            <div class="col-lg-5 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                            <i class="fa fa-times"></i>
                        </div>
                    </div>
                    <div class="panel-body">


                        <div class="row">
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">City</label>
                            </div>
                            <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 ">
                                <input type="text" class="form-control city" name="city" >
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">State</label>
                            </div>
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 ">
                                <select class="form-control select2 " name="state">
                                    <option value=""></option>
                                    <?php
                                    $getst = mysqli_query($conn, "SELECT * FROM `state` order by name")or die(mysqli_error($conn));
                                    While ($st = mysqli_fetch_array($getst)) {
                                        Echo "<option value='$st[name]'>$st[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>

                        <div class="row pad">
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right">
                                <label class="label-control">From Date</label>
                            </div>
                            <div class="col-lg-5 col-md-5 col-sm-8 col-xs-8">
                                <input type="date" id="frmdt" name="frmdt" class="form-control" value="<?php echo $mfrdate; ?>" />  
                            </div>
                        </div>
                        <div class="row pad">
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right">
                                <label class="label-control">To Date</label>
                            </div>
                            <div class="col-lg-5 col-md-5 col-sm-8 col-xs-8">
                                <input type="date" id="todt" name="todt" class="form-control" value="<?php echo date("Y-m-d"); ?>" />
                            </div>
                        </div>
                        <div class="row pad">
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right">
                                <label class="label-control">Remove Not Found</label>
                            </div> 
                            <div class="col-lg-3 col-md-3 col-sm-2 col-xs-2">
                                <select class="form-control" name="notfnd">
                                    <option value=""></option>
                                    <option value="Y">Yes</option>
                                    <option value="N">No</option>
                                </select
                            </div>
                        </div>
                    </div>
                    <div class="panel-footer">
                        <div class="text-center pad">
                            <div class="panel-footer">

                                <?php include("includes/but_rep.php"); ?>
                            </div>
                        </div>                       
                    </div>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
