
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3><?php echo e(__('message.users')); ?></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="" method="GET">
                        <div class="row">

                            <div class="col-md-2">
                                <select class="form-control" name="per_page" id="per_page">
                                    <option value="25">25</option>
                                    <option <?php echo e(isset($_GET['per_page']) && $_GET['per_page'] == 50 ? 'selected' : ''); ?>

                                        value="50">50</option>
                                    <option <?php echo e(isset($_GET['per_page']) && $_GET['per_page'] == 100 ? 'selected' : ''); ?>

                                        value="100">100</option>
                                    <option <?php echo e(isset($_GET['per_page']) && $_GET['per_page'] == 200 ? 'selected' : ''); ?>

                                        value="200">200</option>
                                </select>
                            </div>
                            <div class="col-md-3">
                                <input placeholder="Date range filter" value="<?php echo e(request()->input('datefilter')); ?>"
                                    type="text" name="datefilter" class="form-control">
                            </div>
                            <div class="col-md-4">
                                <input type="text" class="form-control" name="query"
                                    placeholder="Search By (name, UniqueID, Email, Phone)"
                                    value="<?php echo e(request()->input('query')); ?>">
                                <span class="text-danger">
                                    <?php $__errorArgs = ['query'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <?php echo e($message); ?>

                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </span>
                            </div>

                            <div class="col-md-3">
                                <button data-toggle="tooltip" data-original-title="Search" type="submit"
                                    class="btn m-r-10 btn-outline-secondary pull-left"><i class="ti ti-search fa-lg"></i>
                                </button>
                                <a data-toggle="tooltip" data-original-title="Reset Filters" href="<?php echo e(asset('/users')); ?>"
                                    class="btn m-r-10 btn-outline-secondary pull-left">
                                    <i class="ti ti-reload fa-lg"></i>
                                </a>
                                <?php if(Auth::user()->can('delete-user')): ?>
                                    <a id="deleteAll" data-toggle="tooltip" data-original-title="Multiple Delete"
                                        href="javascript:;" class="btn btn-outline-secondary pull-right">
                                        <i class="ti ti-trash fa-lg"></i>
                                    </a>
                                <?php endif; ?>
                            </div>
                        </div>
                    </form>

                    <div class="row m-t-10">
                        <div class="col-md-12">
                            <?php if(Auth::user()->can('add-user')): ?>
                                <a data-toggle="tooltip" data-original-title="Import CSV" href="<?php echo e(asset('import-user')); ?>"
                                    class="btn btn-outline-primary text-uppercase">
                                    <i class="ti ti-upload pr-2"></i> <?php echo e(__('message.import')); ?>

                                </a>

                                <a data-toggle="tooltip" data-original-title="Add New User"
                                    href="<?php echo e(asset('add-user')); ?>" class="btn btn-outline-primary text-uppercase"><i
                                        class="ti ti-plus pr-2"></i><?php echo e(__('message.users')); ?></a>
                            <?php endif; ?>
                        </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>UniqueID</th>
                                        <th><?php echo e(__('message.email')); ?></th>
                                        <th><?php echo e(__('message.phone')); ?></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 $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td>
                                                    <input class="deleteall" type="checkbox" name="delete[]"
                                                        value="<?php echo e($user->id); ?>" />
                                                </td>
                                                <td><?php echo e($user->id); ?></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(date('d-m-Y', strtotime($user->created_at))); ?>

                                                    </span>
                                                </td>

                                                <td><?php echo e($user->user_unique_id); ?></td>
                                                <td><a
                                                        href="#"><?php echo e($user->email); ?></a>
                                                </td>
                                                <td><?php echo e($user->phone); ?></td>
                                                <td>
                                                    <?php if($user->status == 1): ?>
                                                        <label for="" class="text-success">Active</label>
                                                    <?php endif; ?>
                                                    <?php if($user->status == 0): ?>
                                                        <label for="" class="text-danger">Inactive</label>
                                                    <?php endif; ?>
                                                </td>
                                                <td>
                                                    <div class="btn-group">
                                                        <?php if(Auth::user()->can('view-user-report')): ?>
                                                            <a target="_blank" class="btn btn-sm btn-instagram text-white"
                                                                data-toggle="tooltip" data-original-title="User Report"
                                                                href="<?php echo e(asset('report-dashboard/' . $user->user_unique_id)); ?>">
                                                                <i class="fa fa-bar-chart-o fa-lg"></i>
                                                            </a>
                                                        <?php endif; ?>

                                                        <a class="btn btn-sm btn-info text-white" data-toggle="tooltip"
                                                            data-original-title="User Info"
                                                            href="<?php echo e(asset('view-user/' . $user->id)); ?>"><i
                                                                class="fa fa-eye fa-lg"></i>
                                                        </a>

                                                        <?php if(Auth::user()->can('view-user-device')): ?>
                                                            <!-- <a class="btn btn-sm btn-dark text-white" data-toggle="tooltip"
                                                                data-original-title="Registerd Devices"
                                                                href="<?php echo e(asset('devices/' . $user->id)); ?>"><i
                                                                    class="fa fa-android fa-lg"></i>
                                                            </a> -->
                                                        <?php endif; ?>


                                                        <?php if(Auth::user()->can('edit-user')): ?>
                                                            <a class="btn btn-sm btn-dribbble text-white"
                                                                data-toggle="tooltip" data-original-title="Change Password"
                                                                href="<?php echo e(asset('user-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('edit-user/' . $user->id)); ?>"><i
                                                                    class="fa fa-edit fa-lg"></i>
                                                            </a>

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


                        <div class="pagination-block">
                            <?php if(isset($_GET['query'])): ?>
                                <?php echo e($users->appends(['query' => $_GET['query'], 'per_page' => $_GET['per_page'], 'datefilter' => $_GET['datefilter']])->links('includes.paginationlinks')); ?>

                            <?php else: ?>
                                <?php echo e($users->links('includes.paginationlinks')); ?>

                            <?php endif; ?>
                            <label>Total Record Found- <?php echo count($users); ?></label>
                        </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);
            });

            $('#deleteAll').click(function() {
                if (confirm("Are you sure you want to delete Users? ")) {
                    var val = [];
                    $('.deleteall:checked').each(function(i) {
                        val[i] = $(this).val();
                    });

                    if (val.length > 0) {
                        $.ajax({
                            method: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            url: "<?php echo e(asset('delete-multiple-users')); ?>",
                            data: {
                                "ids": val
                            }
                        }).done(function(data) {
                            if (data) {
                                location.reload();
                            } else {
                                alert("Something went wrong!, Try again");
                            }
                        });
                    }
                }
                //alert(<?php echo e(asset('admin/delete-multiple-users')); ?>);
            });

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

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\blurb_erp\resources\views/user/user-list.blade.php ENDPATH**/ ?>