
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3>Gatekeeper</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.list')); ?></li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->
            <div class="card">

                <div class="card-header">
                    <form action="<?php echo e(asset('gatekeeper/filter-by-info')); ?>" method="POST">
                        <?php echo csrf_field(); ?>    
                        <div class="row">

                            <div class="col-md-2">
                                <select class="form-control" name="per_page" id="per_page">
                                    <option value="25">25</option>
                                    <option value="50">50</option>
                                    <option value="100">100</option>
                                    <option  value="200">200</option>
                                </select>
                            </div>
                            <div class="col-md-3">
                                
                            </div>
                            <div class="col-md-4">
                                <input type="text" class="form-control" name="query"
                                    placeholder="Search By (name, Email, Phone)">

                            </div>

                            <div class="col-md-3">
                                <button data-toggle="tooltip" data-original-title="Search" type="submit"
                                    class="btn m-r-10 btn-primary pull-left"><i class="fa fa-search fa-lg"></i>
                                </button>
                                <a data-toggle="tooltip" data-original-title="Reset Filters"
                                    href="<?php echo e(asset('gatekeeper/gatekeeper-list')); ?>" class="btn m-r-10 btn-warning pull-left text-white">
                                    <i class="fa fa-refresh fa-lg"></i>
                                </a>
                                
                            </div>
                        </div>
                    </form>

                    <div class="row m-t-10">
                        <div class="col-md-6 py-3">
                           
                                <a data-toggle="tooltip" data-original-title="Add New Student/Employee"
                                    href="<?php echo e(asset('gatekeeper/add-user')); ?>"
                                    class="btn btn-primary text-uppercase text-white"><i
                                        class="fa fa-plus pr-2"></i>Gatekeeper</a>
                            
                        </div>
                        <div class="col-md-6 d-flex justify-content-end py-3">
                            <button type="button" class="btn btn-danger" id="delete-multiple">
                                <i class="fa fa-trash fa-lg"></i>
                            </button>
                        </div>
                    </div>
                </div>

                <div class="card-body">

                    <?php if(isset($users)): ?>

                        <div class="table-responsive">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>
                                            <input type="checkbox"  id="checkAll"  />
                                        </th>
                                        <th><?php echo e(__('message.id')); ?></th>
                                        <th><?php echo e(__('message.role')); ?></th>
                                        <th><?php echo e(__('message.date')); ?></th>
                                        <th>Name</th>
                                        <th><?php echo e(__('message.email')); ?></th>
                                        <th><?php echo e(__('message.phone')); ?></th>
                                        <th>Organization</th>
                                        <th><?php echo e(__('message.status')); ?></th>
                                        <th><?php echo e(__('message.action')); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if(!empty($users)): ?>
                                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                        <th>
                                            <input type="checkbox" name="checkbox[]" class="userids" value="<?php echo e($user->id); ?>" />
                                        </th>
                                           <td><?php echo e(++$key); ?></td>
                                           <td>
                                                    <?php $__currentLoopData = $user->roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <span class="badge badge-info"><?php echo e($role->name); ?></span>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                           </td>
                                           <td>
                                                <span class="badge badge-info">
                                                <?php echo e(\Carbon\Carbon::parse($user->created_at)->format('d-m-Y')); ?>

                                                </span>
                                            </td>
                                           <td><?php echo e($user->name); ?></td>
                                           <td><?php echo e($user->email); ?></td>
                                           <td><?php echo e($user->mobile); ?></td>
                                           <td><?php echo e($user->company ? $user->company->company_name : ''); ?></td>
                                           <td>
                                                <?php if($user->status == 1): ?>
                                                    <span class="text-success">Active</span>
                                                <?php else: ?>
                                                    <span class="text-danger">Inactive</span>
                                                <?php endif; ?>
                                            </td>
                                           <td>
                                                <div class="btn-group">   

                                                    <?php if(Auth::user()->can('edit-user') || Auth::user()->type=="superadmin" || Auth::user()->type=="admin"): ?>
                                                        <a class="btn btn-sm btn-info text-white" data-toggle="tooltip"
                                                            data-original-title="User Info"
                                                            href="<?php echo e(asset('gatekeeper/view-user/'.$user->id)); ?>"><i
                                                                class="fa fa-eye fa-lg"></i>
                                                        </a>
                                                        <a class="btn btn-sm btn-dribbble text-white"
                                                            data-toggle="tooltip" data-original-title="Change Password"
                                                            href="<?php echo e(asset('gatekeeper/gatekeeper-password-reset/' . $user->id)); ?>"><i
                                                                class="fa fa-refresh fa-lg"></i>
                                                        </a>
                                                        <a class="btn btn-sm btn-success text-white"
                                                            data-toggle="tooltip" data-original-title="Edit User"
                                                            href="<?php echo e(asset('gatekeeper/edit-user/'.$user->id)); ?>"><i
                                                                class="fa fa-edit fa-lg"></i>
                                                        </a>
                                                        <button class="btn btn-sm btn-danger text-white gatekeeper-delete-btn"
                                                            data-toggle="tooltip" data-original-title="Delete User" userid="<?php echo e($user->id); ?>"
                                                            ><i
                                                                class="fa fa-trash fa-lg"></i>
                                                        </button>                                                            

                                                    <?php endif; ?>
                                                </div>
                                            </td>
                                        </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                        <h1>No Record Found!!</h1>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                        </div>


                        
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::dataTable -->
    <script src="<?php echo e(asset('public/admin/js/examples/datatable.js')); ?>"></script>
    <!-- end::dataTable -->
    <script>

        $(document).ready(function() {
            $("#checkAll").click(function() {
                $('input:checkbox').not(this).prop('checked', this.checked);
            });

        $(".gatekeeper-delete-btn").click(function(){
            var id = $(this).attr("userid");
            var URL = "<?php echo e(asset('gatekeeper/delete-user')); ?>";
            swal({
                title: 'Are you sure?',
                text: 'Once deleted, you will not be recover!',
                icon: 'warning',
                dangerMode: true,
                buttons: ["Cancel", "Yes!"],
            }).then(function(value) {
                if (value) {
                    $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                    });

                    $.ajax({
                        type: "post",
                        data: {
                            "id": id
                        },
                        url: URL,
                        dataType: "html",
                        success: function(result) {
                            console.log(result);
                        }
                    });
                    swal("success!", "Successfully deleted!", "success");
                    window.location.reload();
                }
            });
        });


        // Delete Multiple
        $("#delete-multiple").click(function() {
            var URL = "<?php echo e(asset('gatekeeper/delete-multiple')); ?>";
            var user_ids = [];
            $('.userids:checkbox:checked').each(function() {
                user_ids.push($(this).val());
            });
          
            swal({
                title: 'Are you sure?',
                text: 'Once deleted, you will not be recover!',
                icon: 'warning',
                dangerMode: true,
                buttons: ["Cancel", "Yes!"],
            }).then(function(value) {
                if (value) {
                    $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                    });

                    $.ajax({
                        type: "post",
                        data: {
                            "ids": user_ids
                        },
                        url: URL,
                        dataType: "html",
                        success: function(result) {
                            console.log(result);
                        }
                    });
                    swal("success!", "Successfully deleted!", "success");
                    window.location.reload();
                }
            });

        });

           

        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/admin.visitorkrypt.com/resources/views/gatekeeper/gatekeeper.blade.php ENDPATH**/ ?>