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

$formname = "BANK RECONCILATION";
$file = "bankreco_rep_fr.php";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
$zroot = $_SESSION["zdbroot"];
mysqli_select_db($conn,$zdb);

if (isset($_POST["submit"])) {

    $acname = $_POST["acname"];
    $mfrmdate = $_POST['frmdate'];
    $mtodate = $_POST['todate'];
    $dtype = $_POST['dtype'];
    $scope = $_POST['scope'];

    $dtypecond = '';
    $accodecond = '';

    if (!empty($acname)) {
        $acnamecond = " AND `accode`='$acname'";
    }
    if (!empty($dtype)) {
        $dtypecond = " AND `source`='$dtype' ";
    }
    if (!empty($scope)) {
        switch ($scope) {
            case 'A':
                $scopecond = "";
                break;
            case 'C':
                $scopecond = " AND `clrdate`!='0000-00-00' ";
                break;
            case 'N':
                $scopecond = " AND `clrdate`='0000-00-00' ";
                break;
            default:
                "";
        }
    }

    $result = mysqli_query($conn,"SELECT vouchno,accode, source, date, chqno, chqdate, clrdate, amount FROM `actran` where `date` >= '$mfrmdate'
               and `date` <= '$mtodate' $acnamecond $dtypecond $scopecond group by source,vouchno order by source,vouchno ") or die(mysqli_error($conn));
    $ont = mysqli_num_rows($result);

    $mycomp = $_SESSION["comp_" . $dbname];
    $getcomp = mysqli_query($conn,"SELECT *,UCASE(name)as cname FROM $zroot.`company` WHERE `code`='$mycomp'")or die(mysqli_error($conn));
    $comp = mysqli_fetch_array($getcomp);

    $mfdt = date("d-m-Y", strtotime($mfrmdate));
    $mtdt = date("d-m-Y", strtotime($mtodate));
    include("includes/linkshead.php");
    ?>
    <link href="MyStyle/rep_format.css" rel="stylesheet">
    <style>
        @media print {
            .noPrint {
                display:none;
            }
        }

    </style>
    </head>
    <body>
        <div class="page">
            <div class="subpage" style="margin-top: 1px; margin-left: 25px; margin-right: 25px;">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center">
                        <?php echo "<label>$comp[cname]</label>" ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-11 col-md-5 col-sm-5 col-xs-5">

                        <label class="label-control marg"><?php Echo $formname; ?></label>
                    </div>
                    <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
                        <a onclick="window.close()" class="btn btn-primary noPrint">GO Back</a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        From Date - 
                        <?php Echo $mfdt; ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        To Date - 
                        <?php Echo $mtdt; ?>
                    </div>
                </div>
                <div class="row">

                    <div class="row">
                        <div class="col-lg-12 pad">
                            <table style="width:100%;background: white" class="table table-bordered table-condensed table-hover">
                                <thead>
                                    <tr style="height:10px;background-color: #64CCFC">
                                        <td style="width:5%">SR.NO.</td>
                                        <td style="widtd:10%">TYPE</td>
                                        <td style="widtd:10%">VOUCHER</td>
                                        <td style="widtd:15%">CHEQUE NO.</td>
                                        <td style="widtd:15%">CHEQUE DATE</td>
                                        <td style="widtd:15%">CLEAR DATE</td>
                                        <td class="text-right" style="widtd:20%">AMOUNT</td>

                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $mctr = 0;
                                    while ($row = mysqli_fetch_array($result)) {
                                        $amount = $row[amount];
                                        $amt = abs($amount);

                                        $mctr++;
                                        echo "<tr>";
                                        echo "<td>$mctr</td>";
                                        echo "<td>$row[source]</td>";
                                        echo "<td>$row[vouchno]</td>";
                                        echo "<td>$row[chqno]</td>";
                                        echo "<td>$row[chqdate]</td>";
                                        echo "<td>$row[clrdate]</td>";
                                        echo "<td class='text-right'>$amt</td>";
                                        echo "</tr>";
                                    }
                                    ?>

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

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



