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

$formname = "Sett Off";

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

$vouchno = $_REQUEST["vouchno"];



$getpmain = mysqli_query($conn, "SELECT * FROM `billsett` WHERE billno ='$vouchno'")or die(mysqli_error($conn));
include("includes/linkshead.php");
?>  
</head>
<body>
    <div class="container table-responsive" style="width: 30%;">
        <?php include("includes/head_rep.php"); ?>            
        <div class="row">
            <div class="col-lg-12 pad">
                <table class="table table-condensed table-bordered ">
                    <tr class="mySearchTr">
                        <th style="width:5%">Sr</th>
                        <th style="width:10%">Receipt Type</th>
                        <th style="width:10%">Receipt No.</th>
                        <th style="width:10%">Date</th>
                        <th  style="width:15%;text-align: right">Amount</th>

                    </tr>
                    <?php
                    $ctr = 1;
                    while ($pmain = mysqli_fetch_array($getpmain)) {
                        if ($pmain['source'] == 'CR') {
                            $recp = "Cash Receipt";
                            $cashdb = "cashrecp";
                            $callstring = "cashrecp.php?mode=edit&vouchno=$pmain[bnkvouch]";
                        } else {
                            $recp = "Bank Receipt";
                            $cashdb = "bankrecp";
                            $callstring = "bankrecp.php?mode=edit&vouchno=$pmain[bnkvouch]";
                        }
                        $getgrp = mysqli_query($conn, "SELECT date_format(`vouchdt`,'%d-%m-%Y') as mydt FROM `$cashdb` WHERE `vouchno` = '$pmain[bnkvouch]'")or die(mysqli_error($conn));
                        $grp = mysqli_fetch_array($getgrp);

                        Echo "<tr>";
                        Echo "<td>$ctr</td>";
                        Echo "<td>$recp</td>";
                        Echo "<td><a href='$callstring' target='_blank'>$pmain[bnkvouch]</td>";
                        Echo "<td>$grp[mydt]</td>";
                        Echo "<td class='text-right'>$pmain[setoff]</td>";
                        Echo "</tr>";
                        $ctr++;
                    }
                    ?>
                </table>
            </div>
        </div>
    </div>

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