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

$formname = "Payment Received Register";
$action = "payreg_fr.php";

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

$zyear = right($zdb, 4);
$mfrdate = getzdates($zyear, 'S');
$mtodate = getzdates($zyear, 'E');
$ztit = $_SESSION["tit_" . $dbname];
$custdb = $cust . $ztit;
$tourcode = $_SESSION['tourcode'];
$tourname = $_SESSION['tourname'];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

include("includes/linkshead.php");
?>
<script type="text/javascript">
    $(document).ready(function() {
        $("#sspdf").hide();
        $("body").on("change", '.paytype', getType);
        $("body").on("change", '.recpagnst', showTour);

        $(".tourdiv").hide();
        $(".classdiv").hide();

        function showTour() {
            var recpagnst = $(".recpagnst").val();
            if (recpagnst == "U") {
                $(".tourdiv").show();
                $(".classdiv").show();
            } else {
                $(".tourdiv").hide();
                $(".classdiv").hide();
                $(".tour").val('');
                $(".class").val('');
            }
        }

        function getType() {
            var type = $(".paytype").val();
            $.post('getPaytype.php', {
                type: type
            }, function(data) {
                $(".bankname").html(data);
            });
        }
    });
</script>
<style>
    .bg {
        background-color: #bde0fe;
    }
</style>
</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>
                    <div class="panel-body">
<!--                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Tour</label>
                            </div>
                            <div class="col-lg-3 col-md-5 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2 tour" name="tour" required>
                                    <option value="<?= $tourcode ?>"><?= $tourname ?></option>
                                </select>
                            </div>
                        </div>-->
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">Payment Type</label>
                            </div>
                            <div class="col-lg-2 pad">
                                <select class="form-control select2 paytype" name="paytype" required>
                                    <option value="">All</option>
                                    <option value="B">Bank</option>
                                    <option value="C">Cash</option>

                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">Bank / Cash</label>
                            </div>
                            <div class="col-lg-6 pad">
                                <select class="form-control select2 bankname" name="bankname">
                                    <option value=""></option>
                                    <?php
                                    $gsales2 = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `grpcode`='001' or grpcode = '002' order by name") or die(mysqli_error($conn));
                                    while ($sales2 = mysqli_fetch_array($gsales2)) {
                                        echo "<option value='$sales2[accode]'>$sales2[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>


                        <div class="row bg">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">Receipt Against</label>
                            </div>
                            <div class="col-lg-3 pad">
                                <select class="form-control select2 recpagnst" name="recpagnst">
                                    <option value="">All</option>
                                    <option value="F">FIT</option>
                                    <option value="U">HAJ / UMRAH</option>

                                </select>
                            </div>
                        </div>
                        <div class="row bg tourdiv">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">Tour</label>
                            </div>
                            <div class="col-lg-3 pad">
                                <select class="form-control select2 tour" name="tour">
                                    <option value=""></option>
                                    <?php
                                    $gettour = mysqli_query($conn, "SELECT `code`,`name` FROM `tour` order by `name`") or die(mysqli_error($conn));
                                    while ($fettour = mysqli_fetch_array($gettour)) {
                                        echo "<option value='$fettour[code]'>$fettour[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row bg classdiv">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">Class</label>
                            </div>
                            <div class="col-lg-3 pad">
                                <select class="form-control select2 class" name="class">
                                    <option value=""></option>
                                    <?php
                                    $getclass = mysqli_query($conn, "SELECT batchno FROM `bookform` group by `batchno` order by `batchno` ") or die(mysqli_error($conn));
                                    while ($fetclass = mysqli_fetch_array($getclass)) {
                                        echo "<option value='$fetclass[batchno]'>$fetclass[batchno]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>


                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">From</label>
                            </div>
                            <div class="col-lg-5 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control" name="fdate" value="<? echo date("Y-m-d"); ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control">To</label>
                            </div>
                            <div class="col-lg-5 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control" name="tdate" value="<? 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>