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

$formname = 'Bank Payment';
$maindb = 'bankpay';
/* $accdb = 'actran'; */
$file = 'bankpay_fr.php';
$source = "BS";

/* $grid = 'salemain.php'; */
$fseries = $_SESSION["society_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$compcode = $_SESSION["comp_" . $dbname];
$zroot = $_SESSION["zdir"];
$mht = 'height:20px;';
$crbrcpbpnp = $_SESSION["crbrcpbpnp"];

//require("includes/dbconnect.php");
//browse($fseries);

$comp = mysqli_query($conn, "SELECT * FROM $zroot.`company` WHERE code = '$compcode' ") or die(mysqli_errno($conn));
$zcomp = mysqli_fetch_assoc($comp);

mysqli_select_db($conn, $zdb);
$para = $_REQUEST["para"];
$keycond = " and `frmac`='$para'";

$admin = $_SESSION["admin_" . $dbname];
$vouchno = $_REQUEST["vouchno"];

if (empty($vouchno)) {
    $vouchno = $_GET["mvouch"];
}
$mainqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') AS vouchdt, DATE_FORMAT(`chqdate`, '%d-%m-%Y') AS chqdate
                  FROM `$maindb` WHERE vouchno='$vouchno'") or die(mysqli_error($conn));
$getmdata = mysqli_fetch_array($mainqry);

$getmember = mysqli_query($conn, "SELECT `accode`,`name`,`flatno`,`wing` FROM `accmast` WHERE `grpcode` = '010' and `accode`='$getmdata[accode]'") or die(mysqli_error($conn));
$member = mysqli_fetch_array($getmember);

$getbank = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` where `grpcode` = '001' AND accode='$getmdata[bankcode]'") or die(mysqli_error($conn));
$bank = mysqli_fetch_array($getbank);
$headerimg = $zcomp['reportheadimg'];
?>

<!DOCTYPE HTML>
<html lang="en-US">
    <title><?= $formname ?></title>
</head>
<style>
    body {

        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        /*background-color: #FAFAFA;*/
        font: 12pt "Tahoma";
    }

    * {
        box-sizing: border-box;
        -moz-box-sizing: border-box;
    }

    .padd {
        padding: 5px 5px 5px 20px;
    }

    .page {
        width: 210mm;
        min-height: 120mm;
        padding: 4mm;
        margin: 10mm auto;
        border: 1px #D3D3D3 solid;
        border-radius: 5px;
        /*background: white;*/
    }

    .subpage {
        padding: 0cm;
        /*        border: 1px solid;*/
        height: 288mm;
        outline: 2cm #ffffff solid;
    }

    @page {
        size: A4;
        margin: 0;
    }

    @media print {

        html,
        body {
            width: 210mm;
            height: 297mm;
        }

        .page {
            margin: 0;
            border: initial;
            border-radius: initial;
            width: initial;
            min-height: initial;
            box-shadow: initial;
            background: initial;
            page-break-after: always;
        }
    }

    .border {
        border-right-style: solid;
        border-bottom-style: none;
        border-left-style: solid;
        border-top-style: solid;
        border-width: 1px;
    }

    .border2 {
        border-right-style: solid;
        border-bottom-style: solid;
        border-left-style: solid;
        border-top-style: none;
        border-width: 1px;
    }

    .center {
        text-align: center;
    }

    .left {
        text-align: left;
    }

    .right {
        text-align: right;
    }

    .color {
        background-color: #EFE4B0;
        -webkit-print-color-adjust: exact;
    }

    .headimage {
        max-height: 100%;
        max-width: 100%;
        width: 60%;
        height: 120px
    }
    .skdiv {
        width: 50%;
        margin: auto;
    }
</style>

<body id="main_container">
    <div class="book">
        <div class="page">
            <!--<div class="subpage">-->
            <!--   ************Header************  -->
            <?php if ($crbrcpbpnp < 1) { ?>

                <div class="skdiv">
                    <img style="height:auto;width:100%;" src="<?php echo $headerimg; ?>">
                </div>
                <table width="100%" class="border">

                    <!-- <tr>
                        <td class="center"><img class="headimage" src="<?php echo $headerimg; ?>"></td>
                    </tr> -->
                    <tr>
                        <td class="center"><?php echo $zcomp['gstno']; ?></td>
                    </tr>

                    <tr>
                        <td class="center"><?php echo $zcomp['hoadd1'] . $zcomp['hoadd2']; ?></td>
                    </tr>

                    <tr>
                        <td class="center"><?php echo $zcomp['hoadd3'] . " " . $zcomp['hocity'] . " " . "-" . " " . $zcomp['hopin']; ?></td>
                    </tr>
                </table>
            <?php } ?>
            <!--<hr style="border-top: dotted 1px;" />-->

            <?php
            $gcust = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`='$getmdata[accode]'") or die(mysqli_error($conn));
            $cust = mysqli_fetch_array($gcust);
            ?>

            <table class="border" width="100%">
                <tr>
                    <td colspan="2" style="text-align: center;background-color:#159ef9"><b style="font-size:17px;color:#ffffff"><?= $formname ?></b></td>
                </tr>
                <!--                <tr>
                    <td width="55%" class="right padd"><b><u>Payment</u></b></td>
                    <td width="45%"></td>
                </tr>-->

                <tr>
                    <td width="55%" class="right "><b>&nbsp;</b></td>
                    <td width="45%"></td>
                </tr>
                <tr>
                    <td width="55%" class="padd "><b>Voucher No. - </b><?php echo $getmdata['recpno']; ?></td>
                    <td width="45%" class="right padd"><b> Date :&nbsp;</b><?php echo $getmdata['vouchdt'] ?></td>
                </tr>
            </table>



            <table width="100%" class="border ">

                <tr>

                    <td class="padd" style="text-align: left;">

                        Paid on account of <b>
                            <?php
                            if ($getmdata['nameprint'] != "") {
                                $printname = $getmdata['nameprint'];
                            } else {
                                $printname = $cust['name'];
                            }
                            echo "$printname";
                            ?>
                        </b>

                    </td>

                </tr>

                <tr>

                    <td class="padd" style="text-align: left;">

                        The Sum of Rupees <b> <?php echo "Rs.$getmdata[amount]"; ?>

                            (<?php echo rsword(round($getmdata["amount"])); ?> Only.) </b>

                    </td>

                </tr>

                <tr>

                    <?php
                    if ($getmdata['chqdate'] == "00-00-0000") {

                        $cdate = " ";
                    } else {

                        $cdate = "Date" . " " . "<b>$getmdata[chqdate]</b>";
                    }
                    ?>

                    <td class="padd" style="text-align: left;">

                        Paid by Cheque<b> <?php echo "$getmdata[chqno]"; ?> </b><span style="padding-right: 200px"></span><?php echo "$cdate"; ?>

                    </td>

                </tr>

                <tr>

                    <td class="padd" style="text-align: left;">

                        Drawn on<b> <?php echo $bank['name']; ?></b>

                    </td>

                </tr>
                <?php if ($getmdata['rtgsno'] != '') { ?>
                    <tr>
                        <td class="padd" style="text-align: left;">
                            RTGS NO<b> <?php echo $getmdata['rtgsno']; ?></b>
                        </td> 
                    </tr>
                <?php } ?>

                <tr>

                    <td class="padd" style="text-align: left;">

                        <?php echo $getmdata['narr1'] . " " . $getmdata['narr2'] ?>

                    </td>

                </tr>

                <tr style="height:60px">

                    <td>&nbsp;</td>

                </tr>



            </table>



            <table width="100%" class="border2 ">

                <tr>

                    <td class="padd" style="text-align: left; width:50%;">

                        <hr align="left" style="border: 1px solid black; width:50%" />

                        <b>Authorised Signatory</b>

                    </td>

                    <td class="padd" style="text-align: center; width:50%;">

                        <hr style="border: 1px solid black; width:70%" />

                        <b>Received By</b>

                    </td>

                </tr>

            </table>

        </div>

    </div>



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

    <script>
        $(function () {

            formGeneral();

        });
    </script>

</body>

</html>