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

$formname = "Bill Summary";
$action = "billreg_fr.php";
$fuser = $_SESSION["usertype"];
$society = $_SESSION["society_" . $dbname];

if (empty($society)) {
    browse("Invalid Society Credentials Forced Logout.");
    print '<script type="text/javascript">';
    print " top.window.location = 'index.php'";
    PRINT '</script>';
}


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

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

$getsoc = mysqli_query($conn, "SELECT * FROM `company` WHERE `code` = '$society' ") or die(mysqli_error($conn));
$fetsoc = mysqli_fetch_array($getsoc);
$billcycle = $fetsoc['billcycle'];


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

$para = $_REQUEST['para'];
if ($para == 'D') {
    $formname = "Bill Register";
} else {
    $formname = "Bill Summary";
}

include("includes/linkshead.php");
?>
</head>
<script src="MyScript/billreg.js" type="text/javascript"></script>

<body>
    <form method='POST' action="<?= $action; ?>?para=<?=$para?>" target="_blank">
        <!-- Default box -->
        <div class="col-lg-6 col-md-62 col-sm-12 col-xs-12  pad">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title" style="color:black;"><?php Echo $formname; ?></h3>
                    <div class="actions pull-right">
                    </div>
                </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">Billing Period</label>
                                            </div>
                                            <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5 pad">
                                                <select class='billcycle form-control select2' name='billcode'>
                                                    <option value=''></option>
                    <?php
                    $getbill = mysqli_query($conn, "SELECT `code`,`descrip` FROM $zroot.`billingcycle` Where `billcycle` = '$billcycle' ORDER BY `orderby`") or die(mysqli_error($conn));
                    while ($fetbill = mysqli_fetch_assoc($getbill)) {
                        Echo "<option value='$fetbill[code]'>$fetbill[descrip]</option>";
                    }
                    ?>
                                                </select>
                                            </div>
                                        </div>-->
                    <div class="row pad">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                            <label class="label-control">Flat No.</label>
                        </div>
                        <div class="col-lg-5 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class='form-control select2 flatno' name='flatno'>
                                <option value=""></option>
                                <?php
                                $ct = mysqli_query($conn, "SELECT flatno FROM $zdb.`accmast` WHERE flatno != '' 
                                                           group by flatno ORDER BY `flatno`") or die(mysqli_error($conn));
                                while ($ctro = mysqli_fetch_array($ct)) {
                                    echo "<option value='$ctro[flatno]'>$ctro[flatno]</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 marg">Member</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-6 col-xs-6 pad">
                            <select class='member form-control select2' id='party' name='member'>
                                <option value=''></option>
                                <?php
                                $getmem = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` Where `grpcode`='010' ORDER BY `name`") or die(mysqli_error($conn));
                                while ($fetmem = mysqli_fetch_assoc($getmem)) {
                                    Echo "<option value='$fetmem[accode]'>$fetmem[name]</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-3 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="date" class="form-control" name="frmdt" value="<? echo $mfrdate; ?>" >
                        </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-3 col-md-2 col-sm-2 col-xs-2 pad">
                            <input type="date" class="form-control" name="todt" value="<? echo $mtodate; ?>" >
                        </div>
                    </div>
                    <?php
                    // if ($para == 'D') {
                        ?>
                        <!-- <div class = "row">
                            <div class = "col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class = "label-control">Report Type</label>
                            </div>
                            <div class = "col-lg-3 col-md-5 col-sm-8 col-xs-8 pad">
                                <select name = "dtype" class = "form-control select2 dtype">
                                    <option value = "1">Summary</option>
                                    <option value = "2">Detail</option>
                                </select>
                            </div>
                        </div> -->
                        <?php
                    // }
                    ?>

                </div>
                <div class="panel-footer text-center">
                    <!--<input class=" buttonform tooltip-bottom" id="sspdf" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Pdf">-->
                    <!--                <button id='subpdf' type='submit' name='subpdf' formtarget="_blank" name='pdf' class="btn btn-pad btn-square" style="background-color:white;border: 1px solid red">
                                        <i class="fa fa-file-pdf-o" style="color:red; font-size: 15px;"></i>
                                    </button>
                                <input class=" buttonform tooltip-bottom" id="ssubmit" style="display: <? Echo $savedisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Excel">
                                    <button id='excel' type='submit' name='excel' class="btn btn-pad btn-square" style="background-color:#34a853; ">
                                        <i class="fa fa-file-excel-o" style="color:#ffffff;" title="Excel"></i>
                                    </button>
                                        <input type="submit" name="submit" value="Print" class="btn btn-pad btn-square" style="background-color:#0098DA;color: white">
                                        <input type="submit" name="submit" value="Proceed" class="btn btn-pad btn-square" style="background-color:#0098DA;color: white">
                                            <button id='cancel' type="reset" class="btn btn-pad btn-square" style="background-color:red;color: white;" onclick="window.location.href = 'default.php'">
                                                Exit
                                            </button>-->

                    <?php include("includes/but_rep.php"); ?>
                </div>

            </div>
        </div>

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