@extends('layouts.master')
@section('page-title') 
    Admin | {{ $page_title }}
@endsection
@section('page-css')
	<link rel="stylesheet" href="{{ url('public/assets/libs/select2/dist/css/select2.css') }}">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.19/css/intlTelInput.css"/>
  
@endsection
@section('page-content')
@include('admin.partials.create-user')


<div class="container py-4">
  <div class="main">
    <div class="row">
      <div class="col-md-12">
        <h3>Users</h3>
        <!-- <a href="" class="float-end">Add User</a> -->
        <div class="float-end pb-2" >
        <button type="button" class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#addUserModal">
        <img src="{{ url('public/assets/libs/bootstrap-icons/person-plus.svg') }}" alt="person-plus" width="16" height="16"> Add User</button>
        </div>
        <table class="table table-hover table-bordered table-condensed">
           <thead class="">
            <tr class="table-active">
              <th scope="col">Fullname</th>
              <th scope="col">Username</th>
              <th scope="col">Email</th>
              <th scope="col">Phone</th>
              <th scope="col">Position</th>
              <th scope="col">Allowed Apps</th>
              <th scope="col">Action</th>
            </tr>
          </thead>
          <tbody>
            <?php if (count($users_arr) < 1): ?>
              <tr>
              <td colspan="7">No users found</td>
              
            </tr>
            <?php else: ?>
              <?php foreach ($users_arr as $row): ?>
                <?php $ua_id = $row['ua_id']; ?>
                <tr>
                <td><?php echo $row['full_name'] ?></td>
                <td><?php echo $row['username'] ?></td>
                <td><?php echo $row['email'] ?></td>
                <td><?php echo $row['phone'] ?></td>
                <td><?php echo $row['ua_position'] ?></td>
                <td><?php echo $row['allowed_apps'] ?></td>
                <td>
                  @csrf
                  <input type="hidden" class="userIdinput" value="<?php echo $row['user_id'] ?>" name="userId">
                  
                  <!-- <a href="" data-bs-toggle="modal" data-bs-target="#viewUserModal" ><img src="{{ url('public/assets/libs/bootstrap-icons/eye.svg') }}" alt="view icon" width="16" height="16"></a> -->
                  <a href="" class="editUserBtn" data-bs-toggle="modal" data-bs-target="#editUserModal">
                    <img src="{{ url('public/assets/libs/bootstrap-icons/pencil-square.svg') }}" alt="edit icon" width="16" height="16">
                  </a>
                </td>
              </tr>
              <?php endforeach ?>
            <?php endif; ?>
          </tbody>
        </table>
      </div>
      
    </div>
  </div>
  <footer class="py-5">
    <div class="row">
      
    </div>
  </footer>
</div>

@endsection
@section('page-js')
	<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.19/js/intlTelInput.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.19/js/utils.js"></script>
  <script src="{{ url('public/assets/libs/select2/dist/js/select2.full.min.js') }}" type="text/javascript" ></script>
	<script src="{{ url('public/assets/js/usermgt.js') }}" type="text/javascript" ></script>

@endsection
