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

$formname = 'Installation - Item Alot';
$maindb = 'estimain';
$trandb = 'estitran';
$printfile = "";
$file = 'instalot.php';
//$fileadd = 'visaedit.php';
$trandbexist = 1;
$grid = '';
$keyfld = "vouchno";
$keycond = " ";
$focusfield = "name";
//$mgrpcode = '009';

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


$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];
//browse($user);

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

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

//    $result = mysqli_query($conn,"SELECT * FROM `$maindb` WHERE $keyfld='$getvouch'") or die(mysqli_error($conn));
//    $get = mysqli_fetch_array($result);
}

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


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

include("includes/linkshead.php");
?>
<!--<script src="MyScript/leadenq.js" type="text/javascript"></script>-->
<script type="text/javascript">

</script>
<script type="text/javascript">
//    $(document).keydown(function (event) {
//        if (!(String.fromCharCode(event.which).toLowerCase() == 'a' && event.altKey) && !(event.which == 19))
//            return true;
//        $("#add").click();
//        event.preventDefault();
//        return false;
//    });
//
//    $(document).keydown(function (event) {
//        //19 for Mac Command+S
//        if (!(String.fromCharCode(event.which).toLowerCase() == 's' && event.altKey) && !(event.which == 19))
//            return true;
//        //alert("Ctrl-s pressed");
//        $("#update").click();
//        event.preventDefault();
//        return false;
//    });
//
//    $(document).keydown(function (event) {
//        //19 for Mac Command+S
//        if (!(String.fromCharCode(event.which).toLowerCase() == 'f' && event.altKey) && !(event.which == 19))
//            return true;
//        //alert("Ctrl-s pressed");
//        $("#btsearch").click();
//        event.preventDefault();
//        return false;
//    });
</script>

</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> 
                                            <input type='button' style="float: right;" name='exit' value='Exit' class="btn btn-danger" onClick="window.location.href = '<? Echo $file; ?>'">
                    
                                        </div> -->
                    <!--                    <div style="padding-left: 0px;">
                                            <input id='add' value="Add Visa Entry" type="button"  class="btn btn-pad btn-square button" style="background-color:#64CCFC;" onclick="window.location.href = '<?= $fileadd . "?mode=true" ?>'" class="btn btn-labeled btn-success">
                                            <i class="fa fa-plus" style="color:#ffffff"></i>    
                    
                                            </button>
                    
                                            <input style="float: right;padding-right: 15px;"  type='submit' id="update" name='update' value='Save' class="btn btn-primary" tabindex="4">
                    
                                            <input type='button' class="btn btn-warning search" id='btsearch'  style="float: right;" value="Search" tabindex="3">
                                            <input type='text' style="width:150px;float: right;" name='search' class="form-control tsearch"  tabindex="2">
                                            <select class="form-control field" style="float:right;width:150px;" autofocus="autofocus" tabindex="1">
                    <?php
                    if ($usertype == 1) {
                        ?>
                                                            <option value="9">Staff</option>
                    <?php } ?>
                                                <option value="1">Name</option>
                                                <option value="2">Last Name</option>
                                                <option value="3">Book No.</option>
                                                <option value="4">Mobile</option>
                                                <option value="5">Date</option>
                                                <option value="6">Destination</option>
                                                <option value="7">Status</option>
                                                <option value="8">Remark</option>
                                            </select>
                                            <label style="float:right;padding-top: 9px;padding-right: 7px;">Search By</label>
                                            <label style="float:right;padding-right: 30px;"></label>
                    
                                            <input type='button' class="btn btn-default btsort" id='btsort'  style="float: right;" value="Sort">
                                            <select class="form-control sorderby" style="float:right;width:120px;">
                                                <option value="1">ASCENDING</option>
                                                <option value="2">DESCENDING</option>
                                            </select>
                                            <label style="float:right;padding-top: 9px;padding-right: 7px;color: #64CCFC;">Order By</label>
                                            <select class="form-control sortby" style="float:right;width:100px;">
                    <?php
                    if ($usertype == 1) {
                        ?>
                                                            <option value="9">Staff</option>
                    <?php } ?>
                                                <option value="1">Name</option>
                                                <option value="2">Last Name</option>
                                                <option value="3">Book No.</option>
                                                <option value="4">Mobile</option>
                                                <option value="5">Date</option>
                                                <option value="6">Destination</option>
                                                <option value="7">Status</option>
                                                <option value="8">Remark</option>
                                            </select>
                                            <label style="float:right;padding-top: 9px;padding-right: 7px;color: #64CCFC;">Sort By</label>
                                            <label style="float:right;">Search By</label>
                                        </div>-->
                    <br>
                    <div class="panel-body table-responsive" style="width:100%">
                        <table id="example1" class="table table-bordered" width="100%">
                            <thead>
                                <tr style="background-color: #1ABC9C">
                                    <th>Sr.</th>
                                    <th>Voucher</th>
                                    <th>Date</th>
                                    <th>Name</th>
                                    <th>Mobile</th>
                                    <th>Technician</th>
                                    <th>Ton</th>
                                    <th>Location</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody class="mytable table-bordered">
                                <?php
//                                if ($usertype == 1) {
                                $srchresult = mysqli_query($conn,"SELECT vouchno, DATE_FORMAT(`vouchdt`, '%d-%m-%Y')as vouchdt, name, mobile, inspname,
                                                            ton, location  FROM `$maindb` where `airsis`= '' ") or die(mysqli_error($conn));
//                                } else {
//                                    $srchresult = mysqli_query($conn,"SELECT *, DATE_FORMAT(`deptdate`, '%d-%m-%Y')as deptdate FROM `$maindb`
//                                              WHERE `username` ='$user' ") or die(mysqli_error($conn));
//                                }

                                $ctr = 1;

                                while ($row = mysqli_fetch_array($srchresult)) {
                                    $gettech = mysqli_query($conn,"SELECT * FROM `technician` WHERE `code` ='$row[inspname]' ") or die(mysqli_error($conn));
                                    $tech = mysqli_fetch_array($gettech);

                                    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=\"visaedit.php?mode=edit&vouchno=$row[vouchno]\"><input type='text' value='$row[vouchno]' name='vouchno_$ctr' style='border : none;width : 30px; padding : 0px;text-align:center;' readonly class='vouchno'></a></td>";
                                    Echo "<td class=''><input type='date' value='$row[vouchdt]' name='vouchdt_$ctr' style='border : none;width : 120px; padding : 0px;text-align:center;' readonly class='vouchdt'></td>";
                                    Echo "<td class=''><input type='text'value='$row[name]' name='name_$ctr' style='border : none; padding : 0px;text-align:left;width:110px;' readonly class='name'></td>";
                                    Echo "<td class=''><input type='text'value='$row[mobile]' name='mobile_$ctr' style='border : none; padding : 0px;text-align:left;width:80px;' readonly class='mobile'></td>";
                                    Echo "<td class=''><input type='text'value='$tech[name]' name='inspname_$ctr' style='border : none; padding : 0px;text-align:left;width:90px;' readonly class='inspname'></td>";
                                    Echo "<td class=''><input type='text' value='$row[ton]' name='ton_$ctr' style='border : none; padding : 0px;text-align:left;width:100px;' readonly class='ton'></td>";
                                    Echo "<td class=''><input type='text' value='$row[location]' name='location_$ctr' style='border : none; padding : 0px;text-align:left;width:100px;' readonly class='location'></td>";
                                    echo "<td align=center><a href=\"visaedit.php?mode=edit&vouchno=$row[vouchno]\"><img class='' src='images/edit.png'></a>";
                                    echo "</tr>";
                                    $ctr++;
                                }
                                ?>
                            <input type = "text" style="display: none;" name = "count" value = "<? Echo $ctr; ?>">
                            </tbody> 
                        </table>

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

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

</body>
</html>
