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


$formname = 'Address Book';
$maindb = 'address';
$printfile = "addbook_print.php";
$file = 'addressmain.php';
$trandbexist = 0;
$grid = '';
$keyfld = "accode";
$keycond = "";
$focusfield = "name";

$adduser = $_SESSION['username_' . $dbname];
$toursele = $_SESSION['toursele'];
date_default_timezone_set("Asia/Kolkata");
$adddate = date("Y-m-d");
$addtime = date("h:i:sa");
$usertype = $_SESSION["usertype"];
$zroot = $_SESSION["zdir"];


$count = $_POST["items"];
if (isset($_POST["submit"])) {
    $count = $_POST["items"];
    for ($i = 0; $i <= $count; $i++) {
        $maccode = $_POST["accode_$i"];
        $delchk = $_POST["delchk_$i"];

        if ($delchk == '1') {
            
            mysqli_query($conn, "LOCK TABLES `$maindb` WRITE");

            $delcond = " accode = '$maccode' ";
            delnew($zroot, "$maindb", "$delcond", "$file?mode=last");

            mysqli_query($conn, "UNLOCK TABLES");
        }
    }
    header("refresh: 1; $file");
}

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

    /* CSS */
    .button-22 {
        align-items: center;
        appearance: button;
        background-color: #ff0042;
        border-radius: 8px;
        border-style: none;
        box-shadow: rgba(255, 255, 255, 0.26) 0 1px 2px inset;
        box-sizing: border-box;
        color: #fff;
        cursor: pointer;
        display: flex;
        flex-direction: row;
        flex-shrink: 0;
        font-family: "RM Neue",sans-serif;
        font-size: 100%;
        line-height: 1.15;
        margin: 0;
        padding: 10px 21px;
        text-align: center;
        text-transform: none;
        transition: color .13s ease-in-out,background .13s ease-in-out,opacity .13s ease-in-out,box-shadow .13s ease-in-out;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
    }

    /* .button-22:active {
      background-color: #006AE8;
    }
    
    .button-22:hover {
      background-color: #1C84FF;
    } */


</style>
</head>

<body>
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-11 ">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php echo $formname; ?></h3>
                    </div>

                    <div class="panel-body">

                        <div class="row">
                            <div class="col-lg-2">
                                <select class="form-control sfield">
                                    <option value="1">Name</option>
                                    <option value="2">Address</option>
                                    <option value="3">City</option>
                                    <option value="4">Mobile</option>
                                    <option value="5">GST No.</option>
                                    <option value="6">Email</option>
                                </select>
                            </div>

                            <div class="col-lg-2">
                                <select class="form-control soperator">
                                    <option value="">Type of Search</option>
                                    <option value="%">Like</option>
                                    <option value="=">Exactly</option>
                                </select>
                            </div>

                            <div class="col-lg-2">
                                <select class="form-control sortBy">
                                    <option value="">Sort By</option>
                                    <option value="1">Name</option>
                                    <option value="2">Address</option>
                                    <option value="3">City</option>
                                    <option value="4">Mobile</option>
                                    <option value="5">GST No.</option>
                                    <option value="6">Email</option>
                                </select>
                            </div>

                            <div class="col-lg-1">
                                <select class="form-control orderAs">
                                    <option value="asc">Asc</option>
                                    <option value="desc">Desc</option>
                                </select>
                            </div>

                            <div class="col-lg-2">
                                <input type="text" value="" class="form-control ssearch focusfield"  placeholder="Search Here" autofocus>
                            </div>

                            <div class="col-lg-1">
                                <input type="button" class="btn btn-primary sload" value="Search">
                            </div>

                            <div class="col-lg-1   text-center">
                                <input type="submit" class="button-22" value="Delete" name="submit">
                            </div>
                        </div>

                        <div class="col-lg-12 sloader text-center">
                            <!--<img src="images/search.gif" alt="loading">-->
                        </div>

                        <div class="col-lg-12 snoRecord text-center">
                            <h3>NO RECORDS FOUND</h3>
                        </div>

                        <div class="table-responsive" style="max-height: 500px;overflow: auto;">
                            <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                                <thead>
                                    <tr class="mySearchTr">
                                        <th width="20%">Name</th>
                                        <th width="25%">Address</th>
                                        <th width="10%">City</th>
                                        <th width="15%">State</th>
                                        <th width="7%">Mobile</th>
                                        <th width="15%">Email</th>
                                        <th width="10%">Delete</th>
                                    </tr>
                                </thead>
                                <tbody class="sTbody">
                                </tbody>
                            </table>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 text-right search-action-bar" style="margin-left:-20px;margin-top:10px">
                                <input type="hidden"  class="items" name="items" value="">

                                <input type="button" class="btn btn-primary sprev" value="Previous">
                                <input type="button" class="btn btn-primary snext" value="Next">
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer"></div>
                </div>
            </div>
        </div>
    </form>

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

</html>