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

$formname = "Karigar Payment - Datewise";
$action = "karigpay_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 pad">
                            <div class="col-lg-4 col-md-4 col-sm-3 col-xs-3 text-right">
                                <label class="label-control">A/c. Name Multiple</label>
                            </div>
                            <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
                                <select class="form-control select2" name='acnamemul[]' id='acnamemul' multiple>
                                    <option value=""></option>
                                    <?php
                                    $mown2 = mysqli_query($conn, "SELECT accode, `name` FROM `accmast` where `grpcode` = '009' and active = '1'  ORDER BY `name`") or die(mysqli_error($conn));
                                    while ($trow2 = mysqli_fetch_array($mown2)) {
                                        echo "<option value='$trow2[accode]'>$trow2[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">A/c. Name</label>
                            </div>
                            <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
                                <select class="form-control select2" name='acname' id='acname' >
                                    <option value=""></option>
                                    <?php
                                    $mown1 = mysqli_query($conn, "SELECT accode, `name` FROM `accmast` where `grpcode` = '009' 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 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>
                    <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>
