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

$formname = 'Cash Receipt';
$maindb = 'cashrecp';
$file = 'cashrecp_fr.php';
$source = "CR";

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$zroot = $_SESSION["zdir"];
$mht = 'height:20px;';
$admin = $_SESSION["admin_" . $dbname];

$vouchno = $_REQUEST["vouchno"];
$mvouch = $_GET["mvouch"];
$society = $_SESSION["society_" . $dbname];
$compcode = $_SESSION["comp_" . $dbname];

$para = $_REQUEST["para"];
$keycond = " ";
$crbrcpbpnp = $_SESSION["crbrcpbpnp"];
$tourcode = $_SESSION['tourcode'];

$getcomp = mysqli_query($conn, "SELECT * FROM $zroot.`company` WHERE code = '$compcode' ") or die(mysqli_error($conn));
$company = mysqli_fetch_array($getcomp);

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

    $getbook = mysqli_query($conn, "SELECT voucher, DATE_FORMAT(`depdate`, '%d-%m-%Y') AS depdate, batchno FROM `bookform` WHERE regnno = '$getmdata[regnno]' and tourno='$tourcode' ") or die(mysqli_error($conn));
    $fetbook = mysqli_fetch_array($getbook);
    if ($crbrcpbpnp == 1) {
        $bkvch = $fetbook['voucher'];
    } else {

        $bkvch = $getmdata['regnno'];
    }
} else {
    $bkvch = $getmdata['regnno'];
}

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

$gettenant = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE  flatno = '$getmdata[flatno]' Order by accode DESC LIMIT 0,1") or die(mysqli_error($conn));
$tenant = mysqli_fetch_array($gettenant);
$headerimg = $company['reportheadimg'];

// browse($company['crbrcpbpnp']);
?>


<!DOCTYPE HTML>
<html lang="en-US">
    <title><?= $formname ?></title>
</head>
<style>
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        font-style: normal;
        /*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;
    }

    .box {
        width: 130px;
        height: 100px;
        border: 1px solid black;
    }

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

    .border2 {
        border-style: inset;
        border-width: 3px;
        border-color: #EFE4B0;
    }

    td {
        padding: 5px;
    }

    .center {
        text-align: center;
    }

    .left {
        text-align: left;
    }

    .right {
        text-align: right;
    }

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


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

    .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
                ?>
                <div class="border">
                    <?php
                    $t = 0;
                    if ($crbrcpbpnp == 1) {
                        $t = 1;
                    }
                    for ($i = 0; $i <= $t; $i++) {
                        if ($crbrcpbpnp < 1) {
                            ?>

                            <div class="skdiv">
                                <img style="height:auto;width:100%;" src="<?php echo $headerimg; ?>">
                            </div>
                            <table width="100%" class="">
                                <!-- <tr>
                                <td class="center"><img class="headimage" src="<?php echo $headerimg; ?>"></td>
                            </tr> -->
                                <tr>
                                    <td class="center"><?php echo $company['gstno']; ?></td>
                                </tr>
                                <tr style="font-size:14px">
                                    <td class="center"><?php echo $company['hoadd1'] . " " . $company['hoadd2'] . " " . $company['hoadd3'] . " " . $company['hocity'] . " " . "-" . " " . $company['hopin']; ?></td>
                                </tr>
                            </table>
                        <?php } ?>

                        <table class="border" width="100%">
                            <tr>
                                <td colspan="3" style="text-align: center;background-color:#159ef9"><b style="font-size:17px;color:#ffffff"><?= $formname ?>
                                    </b></td>
                                <!-- <td width="35%" class="padd"></td>
                            <td width="30%" class="padd" style="text-align: center;"><b><u>BANK RECEIPT</u></b></td>
                            <td width="35%"></td> -->
                            </tr>
                            <tr>
                                <td width="35%" class="padd"><b>Receipt No. - </b><?php echo $getmdata['vouchno']; ?></td>
                                <td width="30%" class="padd" style="text-align: center;"><b>Booking. Id. : </b><?php echo $bkvch; ?></td>
                                <td width="35%" class="right padd"><b>Receipt Date :&nbsp;</b><?php echo $getmdata['vouchdt'] ?></td>
                            </tr>

                        </table>

                        <table width="100%" class="border2">
                            <tr>
                                <?php
                                if ($getmdata['nameprint'] != "") {
                                    $printname = $getmdata['nameprint'];
                                } else {
                                    $printname = $member['name'];
                                }
                                echo "<td class='padd'><lable>Received with thanks from <b> $printname </b></lable></td>";
                                ?>
                            </tr>
                            <tr>
                                <td class='padd'>
                            <lable>the sum of &nbsp;<u><i class="fa fa-inr"></i><b>Rs. <?php echo $getmdata['amount'] ?>/-</b></u>
                                in words&nbsp;Rs.<u><i class="fa fa-inr"></i><b><?php echo rsword(round($getmdata['amount'])); ?> Only.</b></u></lable>
                            </td>
                            </tr>
                            <tr>
                                <?php
                                if ($getmdata['recpagnst'] == "U") {
                                    if ($getmdata['payfor'] == 'T') {
                                        $re = "Umrah " . "( <b>Ticket</b>)";
                                    } else {
                                        $re = "Umrah " . "(<b>Tour</b>)";
                                    }
                                } else {
                                    $re = "FIT";
                                }
                                ?>
                                <td class='padd'>
                            <lable>Against Payment for <?php echo $re; ?></lable>
                            </td>
                            </tr>

                            <?php if ($getmdata['narr1'] != '') { ?>
                                <tr>
                                    <td class='padd'>
                                <lable><?php echo $getmdata['narr1'] ?></lable>
                                </td>
                                </tr>
                            <?php } else {
                                ?>
                                <tr>
                                    <td class='padd'>
                                <lable>&nbsp;&nbsp;&nbsp;</lable>
                                </td>
                                </tr>
                            <? } ?>

                            <?php if ($getmdata['narr2'] != '') { ?>
                                <tr>
                                    <td class='padd'>
                                <lable><?php echo $getmdata['narr2'] ?></lable>
                                </td>
                                </tr>
                            <?php } else {
                                ?>
                                <tr>
                                    <td class='padd'>
                                <lable>&nbsp;&nbsp;&nbsp;</lable>
                                </td>
                                </tr>
                            <? } ?>
                            <?php
                            if ($crbrcpbpnp == 1) {
                                ?>
                                <tr>
                                    <td style='padding:10px'>Package : <b style='padding:10px'><?= $fetbook['batchno']; ?> </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Departure Date : <b style='padding:10px'><?= $fetbook['depdate'] ?></b></td>
                                </tr>
                            <?php } ?>

                            <tr>
                                <td class='padd'>&nbsp;</td>
                            </tr>
                            <tr>
                                <td style='padding:10px'><b style='border:1px solid black;border-radius: 15px;padding:10px'>Rs.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $getmdata['amount'] ?>/-</b></td>

                            </tr>

                            <tr>
                                <td class='padd'>

                                    <table width='100%'>
                                        <tr>

                                            <td width='20%' style='padding-left:3px'>
                                                <?php if ($company['crbrcpbpnp'] != '1') { ?>
                                                    Balance <b style='padding-left:10px'>
                                                        <?php echo abs($getmdata['balamt']) ?>/-</b>
                                                <?php } ?>
                                            </td>

                                                                                                                                            <!--<td width='50%' style=''>Balance <b>Rs.<?php echo abs($getmdata['balamt']) ?>/-</b></td>-->


                                            <td style="text-align: center;width: 50% !important">
                                                <hr style="border: 1px solid black; width:70%" />
                                                <b>Authorized Signatory</b>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>


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

                    <?php if ($i < 1) { ?>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <!--<hr>-->
                        <?php
                    }
                }
                ?>

            </div>

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

</html>