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

$maindb     = "salemain";
$trandb     = "saletran";
$formname   = "Pending Fast Bill Report";
$file       = "fastrep_fr.php";

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

$getpmain = mysqli_query($conn, "SELECT a.*, DATE_FORMAT(a.`vouchdt`, '%d-%m-%Y') as mydt,b.*, c.name as partyname FROM `$maindb` a LEFT JOIN `$trandb` b ON a.vouchno=b.vouchno
    LEFT JOIN accmast c ON a.party=c.accode WHERE b.item ='' group by a.`vouchno` ") or die(mysqli_error($conn));
$get = mysqli_num_rows($getpmain);
include("includes/linkshead.php");
?>
<style type="text/css">
    #tabital {
        font-style: italic;
    }

    #font1 {
        font-style: italic;
    }

    #boldfont {
        font-weight: bold;
    }
</style>

</head>

<body>
    <div class="container">
        <?php include("includes/head_rep.php"); ?>
        <div class="row">
            <div class="col-lg-12 pad">
                <table style="background: white;width: 100%" class="table table-condensed table-hover">
                    <thead class="mySearchTr">
                        <tr>
                            <th style="width:5%"> Sr</th>
                            <th style="width:10%"> Voucher No</th>
                            <th style="width:10%"> Date</th>
                            <th style="width:35%"> Party</th>
                            <th style="width:20%;" class="text-right">Qty</th>
                            <th style="width:20%" class="text-right">Amount</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $ctr = 0;
                        $mtqty = 0;
                        $mgtot = 0;

                        while ($pmain = mysqli_fetch_array($getpmain)) {
                            $ctr++;
                            echo "<tr id='boldfont' class='clickable-row2' data-href='mainmenu.php?action=sale&vouchno=$pmain[vouchno]&mode=edit' data-target='_blank'>";
                            echo "<td>$ctr</td>";
                            echo "<td>$pmain[vouchno]</td>";
                            echo "<td>$pmain[mydt]</td>";
                            echo "<td>$pmain[partyname]</td>";
                            echo "<td class='text-right'>$pmain[totqty]</td>";
                            echo "<td class='text-right'>$pmain[totalamount]</td>";

                            $mtqty += $pmain['totqty'];
                            $mgtot += $pmain['totalamount'];

                            echo "</tr>";
                        }

                        echo "<tr> ";
                        echo "<th class='text-right' colspan='4' style='color: red;'>Grand Total</td>";
                        echo "<th class='text-right' style='color: red;'>$mtqty</td>";
                        echo "<th class='text-right' style='color: red;'>$mgtot</td>";
                        echo "<td></td>";
                        echo "</tr>";
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

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

</html>