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

$formname = 'Pending Purchase Alert';
$ztit = $_SESSION["tit_" . $dbname];
$maindb = 'purmain';
$printfile = "";
$file = 'pendpuralert.php';
$trandbexist = 1;
$grid = '';
$keyfld = "vouchno";
$keycond = "";
$bseries = $_SESSION["user_series"];
$zroot = $_SESSION["zdir"];

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

$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];



if ($addflag != 1) {
    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
}

$senable = "";
$cenable = "";


include("includes/linkshead.php");
?>
</head>

<body>

    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-11 " style="margin-left: 20px;">
                <div class="panel panel-default">
                    <div class="panel-body " style="width:100%">
                        
                        <table style="background: white;width: 100%;border-radius: 7px;" class="table table-condensed table-bordered table-hover table">
                            <thead>
                                <tr class="mySearchTr">
                                    <th width="5%;">Sr</th>
                                    <th width="15%;">Voucher</th>
                                    <th width="20%;">Date</th>
                                    <th width="30%;">Party Name</th>
                                    <th width="20%;">Paid By</th>
                                    <th width="10%;">Action</th>
                                </tr>
                            </thead>
                            <tbody class="mytable table-bordered">
                                <?php
                                $date = date("Y-m-d");
                                $srchresult = mysqli_query($conn, "SELECT *,DATE_FORMAT(`vouchdt`, '%d-%m-%Y')as mydt FROM $maindb WHERE invno='' ") or die(mysqli_error($conn));

                                $ctr = 0;
                                $mctr = 0;
                                while ($pmain = mysqli_fetch_array($srchresult)) {
                                    if ($pmain['paidby'] == "C") {
                                        $ptyped = "CASH";
                                    } else {
                                        $ptyped = "CREDIT";
                                    }

                                    $gparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` where `accode` = '$pmain[party]'") or die(mysqli_error($conn));
                                    $sparty = mysqli_fetch_array($gparty);

                                    $voucher = $pmain['vouchno'];
                                    $mydt = $pmain['mydt'];
                                    $party = $sparty['name'];

                                    $pctr++;
                                    echo "<tr data-href='purchase.php?mode=edit&vouchno=$voucher' class='clickable-row2' style='cursor: pointer;' [target]='_blank'>";
                                    echo "<td>$pctr</td>";
                                    echo "<td>$voucher</td>";
                                    echo "<td>$mydt</td>";
                                    echo "<td>$party</td>";
                                    echo "<td>$ptyped</td>";
                                    echo "<td class='text-center'><a href='purchase.php?vouchno=$voucher&mode=edit' target='_blank'><i class='fa fa-pencil fa-2x'></i></a></td>";
                                    echo "</tr>";
                                }
                                ?>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </form>

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

</body>

</html>