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

$formname = 'Cancelled Records';
$maindb = 'leadenq';
$printfile = "";
$file = 'canclead.php';
$trandbexist = 0;
$grid = '';
$keyfld = "vouchno";
$keycond = " ";
$focusfield = "name";
$mgrpcode = '009';
$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];

mysqli_select_db($conn,$zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");


if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}

include("includes/linkshead.php");
?>
</head>
<body>
    <!--    <div id="preloader" class="col-lg-12 text-center">
            <h3 class="text-center">Loading</h3>
            <div id="status">&nbsp;</div>
        </div>-->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                            <!--<i class="fa fa-times"></i>-->
                        </div> 
                    </div>
                    <div class="panel-body" style="">
                        <table id="example1" class="table-bordered" width="100%">
                            <thead>
                                <tr style="background-color: #64CCFC;padding-right: 5px;">
                                    <th style="width:5%;">Sr.</th>
                                    <th style="width:10%;">Book No.</th>
                                    <th style="width:15%;">Name</th>
                                    <th style="width:15%;">Last Name</th>
                                    <th style="width:15%;">Mobile</th>
                                    <th style="width:15%;">Destination</th>
                                    <th style="width:10%;">Travel Date</th>
                                </tr>
                            </thead>  
                            <tbody>
                                <?php
                                if ($usertype == 1) {
                                    $srchresult = mysqli_query($conn,"SELECT *, DATE_FORMAT(`deptdate`, '%d-%m-%Y')as deptdate, DATE_FORMAT(`billdate`, '%d-%m-%Y')as billdate 
                                                               FROM `$maindb` WHERE `status` = 'Cancelled' order by vouchno desc") or die(mysqli_error($conn));
                                } else {
                                    $srchresult = mysqli_query($conn,"SELECT *, DATE_FORMAT(`deptdate`, '%d-%m-%Y')as deptdate, DATE_FORMAT(`billdate`, '%d-%m-%Y')as billdate
                                                               FROM `$maindb` WHERE `username`='$user' and `status` = 'Cancelled' order by vouchno desc") or die(mysqli_error($conn));
                                }

                                $ctr = 1;

                                while ($row = mysqli_fetch_array($srchresult)) {
//                                    browse($row[deptdate]);
                                    echo "<tr>";
                                    Echo "<td class='text-right'><input type='text' value='$ctr' name='srno_$ctr' style='border : none;width : 30px;text-align:center;' readonly></td>";
                                    Echo "<td class=''><a href=\"canclead.php?mode=edit&vouchno=$row[vouchno]\"><input type='text 'value='$row[vouchno]' name='vouchno_$ctr' style='border : none;width : 30px; padding : 0px;text-align:left;' readonly class='vouchno'></a></td>";
                                    Echo "<td class=''><input type='text 'value='$row[name]' name='name_$ctr' style='border : none; padding : 0px;text-align:left;' readonly class='name'></td>";
                                    Echo "<td class=''><input type='text 'value='$row[lastname]' name='lastname_$ctr' style='border : none; padding : 0px;text-align:left;' readonly class='lastname'></td>";
                                    Echo "<td class=''><input type='text 'value='$row[mobile]' name='mobile_$ctr' style='border : none; padding : 0px;text-align:left;' readonly class='mobile'></td>";
                                    Echo "<td class=''><input type='text 'value='$row[destination]' name='destination_$ctr' style='border : none; padding : 0px;text-align:left;' readonly class='destination'></td>";
                                    Echo "<td class=''><input type='text' value='$row[deptdate]' name='deptdate_$ctr' style='width : 100px;border : none; padding : 0px;text-align:left;' readonly class='deptdate'></td>";

                                    echo "</tr>";
                                    $ctr++;
                                }
                                ?>
                            <!--<input type = "hidden" name = "count" value = "<? Echo $ctr; ?>">-->
                            </tbody> 
                        </table>

                    </div>
                    <!--                    <div class="panel-footer">
                    <?php // include("includes/buttons.php");    ?>
                                        </div>-->
                </div>
            </div>
        </div>
    </form>

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