
<?php $__env->startSection('main-container'); ?>
<?php echo $__env->make('cdn', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<main id="main" class="main">
     <div style="margin-top:15px ;">
        <h4 class="text-uppercase mb-3">Users</h4>
     </div>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('User.Create')): ?>
    <div class="text-end mb-1">
      <a href="<?php echo e(url('/addnewuser')); ?>"><button type="button" class="btn btn-primary"><i class="bi bi-plus-circle-fill"></i> Add User</button></a>
    </div>
    <?php endif; ?>
     <table class="table table-striped display nowrap" id="tabl" style="width:100%;">
                <thead>
                    <tr>
                        <th></th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Role</th>
                        <th>Mobile</th>
                        <th>Action</th>
                        <th></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>  
                          <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('User.Edit')): ?>
                          <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>
                          <?php endif; ?>
                    </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="number" name="mobile" minlength="15" 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(substr($value->role, strpos($value->role, '_') + 1)); ?></option>
                                          <?php else: ?>
                                            <option value="<?php echo e($role->name); ?>"><?php echo e(substr($role->name, strpos($role->name, '_') + 1)); ?></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>
      </table>
</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>
<?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\CRM\resources\views/frontend/users-view.blade.php ENDPATH**/ ?>