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

$formname = 'BANK RECIEPT';

$fromdate = $_POST["fromdate"];
$todate = $_POST["todate"];
$fromcust = $_POST["fromcust"];
$tocust = $_POST["tocust"];



if (empty($fromcust)) {
    browse("From Customer Code Cannot Be Empty");
    echo "<script>window.close()</script>";
};

if (empty($tocust)) {
    browse("To Customer Code Cannot Be Empty");
    echo "<script>window.close()</script>";
};

if ($fromcust > $tocust) {
    browse("To Customer Code Cannot Be Less Than From Customer Code");
    echo "<script>window.close()</script>";
};

$maindb = 'bankrecp';
$file = 'recmulti_fr.php';
// $source = "BR";

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
// $mht = 'height:20px;';

// $admin    = $_SESSION["admin_" . $dbname];
// $vouchno  = $_REQUEST["vouchno"];
// browse($vouchno);
$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 !=''") or die(mysqli_error($conn));
$getmdata  = mysqli_fetch_array($mainqry) or die(mysqli_error($conn));


$bank =  mysqli_query($conn,"SELECT name from accmast where accode = $getmdata[bankname]")or die(mysqli_error($conn));
$bankname =  mysqli_fetch_array($bank) or die(mysqli_error($conn));
?>

<html lang="en-US">

</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;
    }

    .page {
        width: 210mm;
        min-height: 140mm;
        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: 1px solid;
    }
</style>

<body id="main_container">
    <div class="book">
        <div class="page">
            <!--<div class="subpage">-->
            <!--   ************Header************  -->
            <div class="col-md-12">
                <?php
                require("includes/dbconnect.php");
                $comp = mysqli_query($conn, "SELECT * FROM `company`") or die(mysqli_errno());
                $zcomp = mysqli_fetch_assoc($comp);
                ?>
                <b style="font-size: 20px;">
                    <center><?php echo $zcomp['compname']; ?></center>
                </b>
                <h5>
                    <center> <?php echo $zcomp['hoadd1'] . $zcomp['hoadd2'] . $zcomp['hoadd3']; ?> </center>
                </h5>
                <h3>
                    <center><?php echo $formname; ?></center>
                </h3>

            </div>
            <hr style="border-top: dotted 1px;" />
            <!--<div style="border:solid 1px;" class="col-md-12" style="padding-left: 1px ; padding-right: 1px">-->
            <?php
            mysqli_select_db($conn, $zdb);

            // $gcust = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`=$getmdata[party]") or die(mysqli_error($conn));
            // $cust = mysqli_fetch_array($gcust);
            ?>
            <table width="100%">
                <tr>

                    <td colspan="2" style="text-align: center;">
                        <b></b>
                    </td>
                </tr>
                <tr>

                    <td style="text-align: left;">
                        Receipt.No:
                        <b><?php echo "$getmdata[vouchno]"; ?>
                    </td>
                    <td style="text-align: right;">
                        Date:
                        <b><?php echo " $getmdata[vouchdt]"; ?>
                    </td>
                </tr>
                <br>
                <tr>

                    <td style="text-align: left;">
                        Received thanks from <b><?php echo "$cust[name]"; ?>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <br>The Sum of rupees towards <b><?php echo "Rs.$getmdata[amount]"; ?>
                    </td>
                </tr>
                <tr style="height:40px">
                    <td colspan="2"><? echo "Amount in words "; ?>
                        <b><em>(Rupees <?php echo   rsword(round($getmdata["amount"])); ?>) </em></b>
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="text-align: left;">
                        <br>Paid by rtgs no. / cheque no. <?php echo "<b>$getmdata[chqno] </b>
                         dated <b> $getmdata[chqdate] </b> as payment on A/c of <b>$bankname[name]</b>"; ?>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <b><?php echo "$getmdata[narration]"; ?>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left;">
                        <br>*Cheque subject to realisation.
                    </td>
                </tr>
                <tr style="height:40px">
                    <td>
                        <div></div>
                        </br>
                        </br>
                        </br>
                        </br>

                    </td>
                </tr>
                <tr>
                    <td style="text-align: left; width:50%;">
                        <hr align="left" style="border: 1px solid black; width:50%" />
                        <b>Authorised Signatory</b>
                    </td>
                    <td style="text-align: center; width:50%;">
                        <hr style="border: 1px solid black; width:70%" />
                        <b>Received By/Account Holder</b>
                    </td>
                </tr>

            </table>
            <!--<div>-->

            </table>
        </div>


    </div>
    <?php
    include("includes/linksfoot.php");
    ?>
    <script>
        $(function() {
            formGeneral();
        });
    </script>
</body>

</html>