<?php
include('../include/db_conx.php');
isset($_SESSION['admin_login']);
if (!isset($_SESSION['admin_login'])) {
    header("location: auth-login.php");
    exit();
} else {
    include('../include/admin_head.php');


    $DeleteUserStatus = $_GET['DeleteUserStatus'];
    if ($DeleteUserStatus == 'true') {
        $msg = 'Client Successfully Deleted';
        $link = 'index.php';
        swal_success($msg, $link);
    }
?>




    <body>

        <!-- <body data-layout="horizontal"> -->

        <!-- Begin page -->
        <div id="layout-wrapper">

            <?php include('../include/admin_header.php'); ?>

            <!-- ========== Left Sidebar Start ========== -->

            <!-- Left Sidebar End -->
            <?php include('../include/admin_sidebar.php'); ?>



            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="main-content">

                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                    <h4 class="mb-sm-0 font-size-18">Clients List</h4>

                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="javascript: void(0);">Clients</a></li>
                                            <li class="breadcrumb-item active">Clients List</li>
                                        </ol>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- end page title -->




                        <div class="row">
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-body">

                                        <div class="table-responsive">
                                            <table class="table align-middle datatable dt-responsive table-check nowrap" style="border-collapse: collapse; border-spacing: 0 8px; width: 100%;">
                                                <thead>
                                                    <tr class="bg-transparent">

                                                        <th> ID</th>
                                                        <th style="width: 120px;">File Reference</th>
                                                        <th>Surname</th>
                                                        <th>First Name </th>
                                                        <th>Middle Name </th>
                                                        <th>Mailing Address </th>
                                                        <th> Telephone </th>
                                                        <th style="width: 90px;">View Client</th>
                                                        <th style="width: 90px;">Delete Client</th>
                                                    </tr>
                                                </thead>
                                                <tbody>

                                                    <?php
                                                    $sql_wp = "SELECT * FROM work_permit ";
                                                    $query_wp = $db_conx->query($sql_wp);

                                                    $total_wp = mysqli_fetch_assoc($query_wp);
                                                    while ($row_wp = mysqli_fetch_assoc($query_wp)) {
                                                        $id = $row_wp['id'];
                                                        $file_reference = $row_wp['file_reference'];
                                                        $surname = $row_wp['surname'];
                                                        $firstName = $row_wp['firstName'];
                                                        $middleName = $row_wp['middleName'];
                                                        $mailingAddress = $row_wp['mailingAddress'];
                                                        $telephoneNumber = $row_wp['telephoneNumber'];




                                                    ?>

                                                        <tr>
                                                            <td> <?php echo $id ?> </td>
                                                            <td> <?php echo $file_reference ?> </td>
                                                            <td> <?php echo $surname ?> </td>
                                                            <td> <?php echo $firstName ?> </td>
                                                            <td> <?php echo $middleName ?> </td>
                                                            <td> <?php echo $mailingAddress ?> </td>
                                                            <td> <?php echo $telephoneNumber ?> </td>

                                                            <td> <a class="dropdown-item" href="permit.php?userID=<?php echo $id ?>"><i class="fas fa-address-book"></i>&nbsp Details </a></td>
                                                            <td> <a class="dropdown-item" href="delete.php?userID=<?php echo $id ?>"><i class="fas fa-address-book"></i>&nbsp Delete </a></td>

                                                        </tr>
                                                    <?php } ?>

                                                </tbody>
                                            </table>
                                        </div>
                                        <!-- end table responsive -->
                                    </div>
                                    <!-- end card body -->
                                </div>
                                <!-- end card -->
                            </div>
                            <!-- end col -->
                        </div>
                        <!-- end row -->
                    </div> <!-- container-fluid -->
                </div>
                <!-- End Page-content -->
                <?php include('../include/admin_footer.php'); ?>
            </div>
            <!-- end main content-->

        </div>
        <!-- END layout-wrapper -->



        <!-- Right bar overlay-->
        <div class="rightbar-overlay"></div>

        <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="assets/libs/metismenu/metisMenu.min.js"></script>
        <script src="assets/libs/simplebar/simplebar.min.js"></script>
        <script src="assets/libs/node-waves/waves.min.js"></script>
        <script src="assets/libs/feather-icons/feather.min.js"></script>
        <!-- pace js -->
        <script src="assets/libs/pace-js/pace.min.js"></script>

        <!-- flatpickr js -->
        <script src="assets/libs/flatpickr/flatpickr.min.js"></script>

        <!-- Required datatable js -->
        <script src="assets/libs/datatables.net/js/jquery.dataTables.min.js"></script>
        <script src="assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script>

        <!-- Responsive examples -->
        <script src="assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
        <script src="assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>

        <!-- init js -->
        <script src="assets/js/pages/invoices-list.init.js"></script>

        <script src="assets/js/app.js"></script>
    </body>

    </html>

<?php  } ?>