[Back]
@if (!Session::get("username"))
    {{-- Redirect to the main page if the user is already logged in --}}
    <script>
        window.location.href = "login";
    </script>
@endif


@if (Session::get("userlevel") === 'admin')
@extends('index')

@section("body")
<center><h1> List of User</h1></center><br><br>

<div style="display: flex; justify-content: center; margin-bottom: 20px;">
    <form style="display: flex; align-items: center;">
        <input type="text" name="searchTxt" placeholder="Search users..." style="width: 300px; padding: 5px; margin-right: 10px;">
        <input type="submit" name="btnSearch" value="Search" style="padding: 5px 10px;">
        @csrf
    </form>
</div>
<center>
<p>
    <strong>Total Users:</strong> {{ $totalUsers}}&nbsp;&nbsp;&nbsp;&nbsp;
    <strong>Active Users:</strong> {{ $ActiveCount }}&nbsp;&nbsp;&nbsp;&nbsp;
    <strong>Deactive Users:</strong> {{ $DeactiveCount }}&nbsp;&nbsp;&nbsp;&nbsp;
</p>
</center>


<br>

<div>
<table style="text-align: center;">
<tr>
        <th style="display: none;">Id</th>
        <th style="text-align: center;">Username</th>
        <th style="text-align: center;">Fullname</th>
        <th style="text-align: center;">Userlevel</th>
        <th style="text-align: center;">Status</th>
        <th colspan="2" style="text-align: center;">Action</th>
</tr>
    
@foreach($data as $d)
<tr>


        <td style="display: none;">{{$d->id}}</td>
        <td>{{$d->username}}</td>
        <td>{{$d->fullname}}</td>
        <td>{{$d->userlevel}}</td>
        <td>{{$d->status}}</td>
        
        
        
        <td>
            <form method="POST" action="listuser-action">
            <input type="submit" name="btnViewEdit" value="Edit" class="button small">
            <input type="hidden" name="id" value="{{$d->id}}">
            @csrf
            </form>
        </td>
        
        <td>
            <form method="POST" action="listuser-action" >
            <input type="submit" name="btnViewDelete" value="Delete" class="button small">
            <input type="hidden" name="id" value="{{$d->id}}">
            @csrf
            </form>
            
        </td>
</tr>
@endforeach
</table><br>


      <!-- Add New Form -->
      <div style="text-align: right;">
      <form method="POST" action="listuser-action">
            <input type="submit" name="btnViewAdd" value="Add New">
            @csrf
      </form>
      </div>


</div>



@endsection
@endif