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

$formname = 'Bank Payment Voucher';
$maindb = 'bankpay';
$trandb = 'bptran';
/* $accdb = 'actran'; */
$file = 'bankrecp.php';
$source = "BP";
/* $grid = 'salemain.php'; */

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

$mht = 'height:20px;';

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

<!DOCTYPE HTML>
<html lang="en-US">
    <?php
    include("includes/linkshead.php");
    ?>
    <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: 148mm;
            padding: 2mm;
            margin: 6mm auto;
            /*border: 1px #D3D3D3 solid;*/
            border-radius: 2px;
            /*background: white;*/

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

        @page {
            size: A5;
            margin: 0;
        }
        @media print {
            html, body {
                width: 210mm;
                height: 148mm;        
            }
            .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>
</head>
<body id="main_container">
    <div class="book">
        <div class="page">
            <!--<div class="subpage">-->
            <!--   ************Header************  -->
            <?php
            $gcust = mysqli_query($conn,"SELECT a.*, b.name FROM `$trandb` a, accmast b WHERE a.`vouchno` = '$getmdata[vouchno]' and a.accode = b.accode") or die(mysqli_error($conn));

            $getgodown = mysqli_query($conn,"SELECT * FROM `accmast` WHERE  `accode`='$getmdata[bankname]' ORDER BY  `name`") or die(mysqli_error($conn));
            $gdwn = mysqli_fetch_object($getgodown);

            $getparty = mysqli_query($conn,"SELECT * FROM `accmast` WHERE  `accode`='$getmdata->accode' ORDER BY  `name`") or die(mysqli_error($conn));
            $party = mysqli_fetch_object($getparty);
            ?>
            <div class="row">
                <div class="col-md-12 text-center">
                    <?php
                    require("includes/dbconnect.php");
                    $comp = mysqli_query($conn,"SELECT * FROM `company`") or die(mysql_errno());
                    $zcomp = mysql_fetch_assoc($comp);
                    ?>
                    <b><?php echo $zcomp[name]; ?></b><br>
                    <?php echo $zcomp[add1] . ' ' . $zcomp[add2] . ' ' . $zcomp[add3]; ?><br>
                    <b><?php echo $formname; ?></b>
                </div>
            </div>
            <table width="100%" class="table-hover" style="margin-top:30px">
                <tr> 
                    <td class="text-center">
                        <b>Voucher No. :</b>
                        <?php echo "$getmdata[vouchno]"; ?> 
                    </td>
                    <td class="text-center">
                        <b>Receipt No.:</b>
                        <?php echo "$getmdata[vouchno]"; ?> 
                    </td>
                    <td class="text-center">
                        <b>Date:</b>
                        <?php echo "$getmdata[vouchdt]"; ?> 
                    </td>
                </tr>
            </table>
            <br>
            <table class="" align='center' style="height:35%;width:90%;border:1px solid black;">
                <thead style="border:1px solid black;" class="mySearchTr">
                <th style="width:10%;border-right:1px solid black;">Sr.</th>
                <th style="width:50%;border-right:1px solid black;">Particular</th>
                <th style="width:20%;text-align: right;border-right:1px solid black;">Debit</th>
                <th style="width:20%;text-align: right;border-right:1px solid black;">Credit</th>
                </thead>
                <?php
                $ctr = 0;
                ?>
                <tbody>
                    <tr style="height:35px;">
                        <?php
                        $ctr++;
                        echo "<td align='left' style='border-right:1px solid black;'>1</td>";
                        echo "<td align='left' style='border-right:1px solid black;'>$gdwn->name</td>";
                        echo "<td align='right' style='border-right:1px solid black;'></td>";
                        echo "<td align='right' style='border-right:1px solid black;'>$getmdata[amount]</td>";
                        echo "</tr>";
                        while($custdtl = mysqli_fetch_array($gcust)){
                            $pname = $custdtl[name];
                        echo "<tr style='height :35px;'>";
                        echo "<td align='left' style='border-right:1px solid black;'></td>";
                        echo "<td align='right' style='border-right:1px solid black;'>$pname</td>";
                        echo "<td align='right' style='border-right:1px solid black;'>$custdtl[amount]</td>";
                        echo "<td align='right' style='border-right:1px solid black;'></td>";
                        echo "</tr>";
                        $totamt = $totamt + $custdtl[amount];
                        }
                        echo "<tr style='height :14px;border-top:1px solid black;' >";
                        echo "<td align='right' style='border-right:1px solid black;'></td>";
                        echo "<td align='right' style='border-top:1px solid black;border-right:1px solid black;'><b>Total</b></td>";
                        echo "<td align='right' style='border-right:1px solid black;'><b>$totamt</b></td>";
                        echo "<td align='right' ><b>$totamt</b></td>";
                        ?>

                    </tr>

                </tbody>
            </table>
            <table align='left' style='width:100%'>
<!--                <tr style="height:40px">
                    <td>Received with thanks from&nbsp&nbsp
                        <b><?php echo "$cust[name]"; ?> </b>
                    </td>
                </tr>-->
                <tr style="height:40px;width:30%;">
                    <td style="text-align:right;"><b>Amount In Words :   </b>
                    </td>
                    <td style='width:60%'>
<?php echo rsword(round($getmdata["amount"])); ?>
                    </td>
                    <td style=width:20%;">

                    </td>
                </tr>
<?php
if ($getmdata[narration] == '') {
    ?>

                    <?php
                } else {
                    ?>
                    <tr style="height:40px">
                        <td style="text-align:right;width:20%;"><b>Narration :   </b>
                        </td>
                        <td style="width:60%;">
    <? echo "$getmdata[narration]"; ?>    

                        </td>
                        <td style="width:20%;">

                        </td>
                    </tr>
    <?php
}
?>
                <tr style="height:50px;">

                </tr>
                <!--
                </tr>
                <tr style="height:40px">
                    <td>
                
                    </td>
                </tr>

                <tr style="height:40px">
                    <td>
                        <div></div>
                -->                      <!--
                
                                    </td>
                                </tr>
                
                -->                
                <tr> 
                    <td style="text-align: center; width:25%;">
                        <div style="width:0px;height:0px;"></div>       

                        <hr   align="left" style="border: 1px solid black;  width:100%"/>
                        <b>Prepared By</b>
                    </td>
                    <td style="text-align: center; width:50%;">
                        <div style="width:0px;height:0px;"></div>       

                        <hr   align="center" style="border: 1px solid black; width:40%"/>
                        <b>Authorised By</b>
                    </td>
                    <td style="text-align: right; width:25%;">

                        <hr style="border: 1px solid black; width:150%"/>
                        <b>Received By</b>
                    </td>
                </tr>  
            </table>
            <!--            </div>-->

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