<?php $__env->startSection('main-container'); ?>
<main id="main" class="main">
<?php echo $__env->make('cdn', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div class="row page-titles mx-0">

    <div class="col-sm-6 p-md-0">

        <div class="breadcrumb-range-picker">

             <h3>Users</h3>

        </div>

    </div>

    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">

         <a href="<?php echo e(url('/addnewuser')); ?>" class="btn btn-rounded bg-grad-4 ml-4">

            <span class="btn-icon-left text-primary">

                <i class="fa fa-arrow-left color-primary"></i>

            </span>+ Add User

        </a>

    </div>

</div>

<div class="container-fluid" style="margin-top: 15px">

    <?php echo $__env->make('flash_msg', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <div class="row">

        <div class="col-12">

            <div class="card">

                <div class="card-body">

                    <form method="GET" action="">

                        <div class="row text-right">

                            <div class="col-md-6"></div>

                            <div class="col-md-4">

                                 <input type="text" class="form-control right-search" name="search" value="<?php echo e($request->search); ?>" placeholder="Search by User">

                            </div>

                             <div class="col-md-2">

                                <label class="">&nbsp;</label>

                                <button type="submit" class="btn btn-outline-info bg-grad-4 btn-ft">Search</button>

                            </div>

                        </div>

                    </form>

                    <hr>

                    <div class="table-responsive">

                        <table class="table table-border table-hover table-sm" >
                            <thead>

                                <tr>

                                    <th>#</th>

                                    <th>NAME</th>

                                    <th>EMAIL</th>

                                    <th>ROLE</th>

                                    <th>MOBILE</th>

                                    <th>ACTION</th>

                                    <th>LOGIN WITH USER</th>

                                </tr>

                            </thead>

                            <tbody>
                                <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                 <tr>
                                   <td></td>
                                   <td><?php echo e($value->name); ?></td>
                                   <td><?php echo e($value->email); ?></td>
                                   <td><?php echo e($value->role); ?></td>
                                   <td><?php echo e($value->mobile); ?></td>
                                   <td>
                                         <a class="btn " role="button" data-toggle="modal" data-target="#edituser-<?php echo e($value); ?>-<?php echo e($roles); ?>" style="color:black;"><i class="bi bi-pencil-fill" style="color:navy;"></i></a>
                                   </td>
                                           <!-- Modal foe edit user-->
                                           <div class="modal fade" id="edituser-<?php echo e($value); ?>-<?php echo e($roles); ?>" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
                                           <div class="modal-dialog" role="document">
                                           <div class="modal-content">
                                             <div class="modal-header bg-info bg-gradient">
                                               <h5 class="modal-title" id="editModalLabel">Edit User</h5>
                                               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                 <span aria-hidden="true">&times;</span>
                                               </button>
                                             </div>

                                              <form action="<?php echo e(url('user-edit/'.$value->id)); ?>" method="post">
                                               <?php echo e(csrf_field()); ?>


                                             <div class="modal-body">
                                               <div class="row mb-3">
                                                     <strong for="inputText" class="col-sm-2 col-form-label">Name<span style="color:red;">*</span></strong>
                                                     <div class="col-sm-7">
                                                       <input type="text" name="name" value="<?php echo e($value->name); ?>" class="form-control" required>
                                                     </div>
                                               </div>
                                                <div class="row mb-3">
                                                     <strong for="inputText" class="col-sm-2 col-form-label">Email<span style="color:red;">*</span></strong>
                                                     <div class="col-sm-7">
                                                       <input type="email" name="email" value="<?php echo e($value->email); ?>" class="form-control" required/>
                                                     </div>
                                               </div>
                                               <div class="row mb-3">
                                                     <strong for="inputText" class="col-sm-2 col-form-label">Mobile<span style="color:red;">*</span></strong>
                                                     <div class="col-sm-7">
                                                       <input type="text" name="mobile" minlength="10" maxlength="10" value="<?php echo e($value->mobile); ?>" class="form-control" required/>
                                                     </div>
                                               </div>
                                                <div class="row mb-3">
                                                     <strong for="inputText" class="col-sm-2 col-form-label">Role<span style="color:red;">*</span></strong>
                                                     <div class="col-sm-7">
                                                       <select name="role" class="custom-select form-control" style="text-transform:capitalize;">
                                                         <option>Select Role</option>
                                                          <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                          <?php if($role->name==$value->role): ?>
                                                         <option value="<?php echo e($value->role); ?>" selected><?php echo e($value->role); ?></option>
                                                         <?php else: ?>
                                                           <option value="<?php echo e($role->name); ?>"><?php echo e($role->name); ?></option>
                                                         <?php endif; ?>
                                                         <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                       </select>
                                                     </div>
                                               </div>
                                               <div class="row mb-3">
                                                   <strong for="inputText" class="col-sm-2 col-form-label">DOB<span style="color:red;">*</span></strong>
                                                     <div class="col-sm-7">
                                                       <input type="date" name="dob"  value="<?php echo e($value->DOB); ?>" class="form-control" required/>
                                                     </div>

                                               </div>
                                             </div>
                                             <div class="modal-footer">
                                               <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                               <button type="submit" class="btn btn-primary">Edit</button>
                                             </div>
                                           </form>
                                           </div>
                                           </div>
                                           </div>

                                     <td>
                                       <?php if(Auth::user()->role=='Admin'): ?>
                                       <form action="<?php echo e(route('login-with-user',$value->id)); ?>" method="POST">
                                         <?php echo e(csrf_field()); ?>

                                         <button type="submit" class="btn btn-primary rounded-pill">Login with User</button>
                                       </form>
                                       <?php endif; ?>
                                     </td>

                                 </tr>
                               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                               </tbody>

                            <tfoot>

                                <tr>
                                    <th>#</th>

                                    <th>Name</th>

                                    <th>Email</th>

                                    <th>Role</th>

                                    <th>Mobile</th>

                                    <th>Action</th>

                                    <th>Login With User</th>

                                </tr>


                            </tfoot>

                        </table>

                    </div>

                      <div class="text-left float-left mt-1">

                       <p>Displaying <?php echo e($users->count()); ?> of <?php echo e($users->total()); ?> Add Users.</p>

                    </div>

                    <div class="text-right float-right">

                         

                    </div>

                </div>

            </div>

        </div>

    </div>

</div>
</main><!-- End #main -->
<script type="text/javascript">
   $(document).ready(function () {
    var table = $('#tabl').DataTable({
      order: [],
      columnDefs: [ { orderable: false, targets: [0,1,2,3,4,5,6] } ],
      responsive: true
    });

    new $.fn.dataTable.FixedHeader( table );
});
</script>
<script type="text/javascript">
       $("document").ready(function(){
        setTimeout(function()
        {
            $("div.alert").remove();

        }, 3000);

       });

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

<?php echo $__env->make('frontend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\TADA\resources\views/frontend/users-view.blade.php ENDPATH**/ ?>