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

$formname = 'Cash Receipt';
$maindb = 'prevcsrecp';
$file = 'prevcsrecp_fr.php';
$source = "CRPV";

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

$mht = 'height:20px;';
$zroot = $_SESSION["zdbroot"];
$admin = $_SESSION["admin_" . $dbname];
$vouchno = $_REQUEST["vouchno"];
$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) or die(mysqli_error($conn));


$gexam = mysqli_query($conn, "SELECT `code`,`name` FROM `exam` WHERE `code` = '$getmdata[examcode]'") or die(mysqli_error($conn));
$exam = mysqli_fetch_array($gexam);



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);
?>

<!DOCTYPE HTML>
<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: 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: 240mm;        
        }
        .page {

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

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

    table td{
        font-family: serif;
    }
</style>

<body id="main_container">
    <div class="book">
        <div class="page">

            <!--   ************Header************  -->
            <?php
            for ($i = 0; $i <= 1; $i++) {
                ?>
                <?php
                require("includes/dbconnect.php");
                $comp = mysqli_query($conn, "SELECT * FROM `company`") or die(mysql_errno());
                $zcomp = mysqli_fetch_assoc($comp);
                ?>
                <!--Header-->
                <table width="100%" style="border:1px solid black;padding:5px">
                    <tr>
                        <td style="font-size:19px;padding:5px;font-family: serif"><b><center><?php echo $zcomp['compname']; ?></center></b></td>
                    </tr>
                    <tr>
                        <td style="font-size:12px"><center>
                        REG.NO. BOMBAY P.T.ACT 1950/F 17203 PUNE /SOCIETY'S REG.ACT 1860 MAHARASHTRA/ 330 - 2000/ PUNE
                    </center></td>
                    </tr>
                    <tr>
                        <td style="font-size:15px;font-family: serif;padding-top:5px"><center><?php echo $zcomp['add1'] . $zcomp['add2']; ?></center></td>
                    </tr>
                    <tr>
                        <td style="font-size:15px;font-family: serif"><center><?php echo $zcomp['add3'] . "&nbsp;" . "&nbsp;" . "&nbsp;" . $zcomp['tel']; ?></center></td>
                    </tr>
                </table>
                <!--Header End-->

                <!--Main Content-->
                <table width="100%" class="border2" style="padding:0px 0px 0px 55px">
                    <tr>
                        <td colspan="4" style="font-size:18px"><center><b><?php echo $formname; ?></b></center></td>
                    </tr>
                    <tr>
                        <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="2" style="text-align: left;">
                            <b>Receipt.No:</b>
                            <?php echo $getmdata['vouchno'] . '/' . $myyear; ?> 
                        </td>
                        <td colspan="2" style="text-align: center;">
                            <b>Date:</b> 
                            <?php echo $getmdata['vouchdt']; ?> 
                        </td>                                
                    </tr>
                    <tr>
                        <td colspan="4">&nbsp;</td>
                    </tr>
                    <tr>

                        <td colspan="4" style="text-align: left;" colspan="2">
                            Received with thanks from&nbsp;&nbsp;<b><?php echo $cust['custcode'] . "-" . $cust['name']; ?></b>
                        </td>
                    </tr>                            
                    <tr>

                        <td colspan="4" style="text-align: left;"><span style="padding-right:180px"></span>
                            <?php echo "$cust[city]" . "-" . $cust['pin']; ?>
                        </td>
                    </tr>   
                    
                    <tr>                      
                        <td style="text-align: left;" colspan="4">
                            <br>The Sum of <b>Rs.<?php echo $getmdata['amount']; ?>
                                <b>(Rupees <?php echo rsword(round($getmdata["amount"])); ?>&nbsp;Only.)</b>
                        </td>
                    </tr>    
                    <tr>
                        <td colspan="4">&nbsp;</td>
                    </tr>


                    <tr>
                        <td colspan="4" style="text-align:left"><?php echo $getmdata['remark1']; ?>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="4" style="text-align:left"><?php echo $getmdata['remark2']; ?>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align:left;font-family: serif">Exam&nbsp;:- &nbsp;<b><?php echo $exam['name']; ?></b>
                        </td>
                    </tr>
                    <tr>
                        <td width="44%">
                            <table>


                                <tr>
                                    <td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                </tr>
                                
                            </table>
                        </td>
                        <td width="21%" ></td>
                        <td width="15%" style="border:1px solid black"></td>
                        <td width="20%" ></td>
                    </tr>

                    <tr>
<!--                        <td colspan="1" style="text-align:left; width:45%;">
                        </td>-->
                        <td colspan="4" style="text-align:right; width:55%;">
                            MAHARASHTRA BHARATEEYA SHIKSHAN MANDAL
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">&nbsp;</td>
                        <td colspan="2">&nbsp;</td>
                    </tr>

                    <tr>
                        <?php if ($i == 0) { ?>
                            <td colspan="4" style='font-family: serif'><b>School Copy</b></td>
                        <?php } elseif ($i == 1) { ?>
                            <td colspan="4" style='font-family: serif'><b>Office Copy</b></td>
                        <?php } ?>

                    </tr>                    
                </table>

                <!--Main Content End-->
                <?php if ($i == 0) { ?>
                    <hr style="border :dotted 1px ;margin:18px 0px 18px 0px">

                    <?php
                }
            }
            ?>

        </div>
    </div>

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