<!DOCTYPE html>
<html lang="en">
<head>
  <%- include('./partials/_head'); %>
  <style type="text/css">
  a.active {
    background-color: #1b5e20 !important
  };
  </style>

  <title>OAMS ADMIN</title>
</head>
<body style="background-color: #555;">
<div class="">
  <nav class="navbar navbar-expand-sm navbar-dark green darken-4">
    <a class="navbar-brand" href="#"><strong>OAMS</strong></a>
      <a class="text-light" href="#"><strong>ONLINE ATTACHMENT MANAGEMENT SYSTEM</strong></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent-6"
      aria-controls="navbarSupportedContent-6" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    
    <div class="collapse navbar-collapse" id="navbarSupportedContent-6">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink-6" data-toggle="dropdown" aria-haspopup="false"
            aria-expanded="false"><%= user.first_name%> <%= user.last_name%></a>
          <div class="dropdown-menu dropdown-secondary" aria-labelledby="navbarDropdownMenuLink-6">
            <a class="dropdown-item" data-toggle="modal" href="#askmodal">
              <% if(user.is2faEnabled){ %>
                Disable 2-Factor Authentication
              <% }else{ %>
                Enable 2-Factor Authentication
              <% } %>  
            </a>
            <a class="dropdown-item" href="/dashboard/logout">Logout</a> 
          </div>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">JKUAT</a>
        </li>
      </ul>
    </div>
  </nav>
</div>

<!-- <div class="menu">
  <ul>
      <li><a class="item" href="/">Home</a></li>
    
  </ul>
</div> -->
<section class="container board2">
  <!-- <header class="container transparent header2">
    <em class="icon"></em>
  </header> -->
  <ul class="nav nav-tabs" id="myTab" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" id="all-tab" data-toggle="tab" href="#all" role="tab" aria-controls="all" aria-selected="true" aria-disabled="true"><h4 class="display-4 text-light">All Students</h4></a>
    </li>
    <li class="nav-item">
        <a class="nav-link" id="applied-tab" data-toggle="tab" href="#applied" role="tab" aria-controls="applied" aria-selected="false"><h4 class="display-4 text-light">Applied Students</h4></a>
    </li>
</ul>
  

<div class="tab-content" id="myTabContent">
  <div class="tab-pane fade show active" id="all" role="tabpanel" aria-labelledby="all-tab">
  <div class="table-responsive ">
    <table class="table text-white ">
      <thead>
        <tr>
          <th scope="col">#</th>
          <th scope="col">Names</th>
          <th scope="col">Email</th>
          <th scope="col">Programme</th>
          <th scope="col">Academic_year</th>
          <th scope="col">Action</th>
        </tr>
      </thead>
      <tbody>
        <% for(let i in data){ %>
          <% if(data[i].role_id !== 1 & data[i].role_id !== 2) { %>
        <tr>
          <th scope="row"><%= i %></th>

          <td> <a class="text-white" href="/dashboard/admin/profileView/<%= data[i].user_id%>"><%= data[i].first_name %> <%= data[i].last_name %></a> </td>
          <td><%= data[i].user_email %>
          </td>
          <td><%= data[i].programme_name %></td>
          <td><%= data[i].academic_year %></td>
          <td>
            
            <a href="/dashboard/admin/profileView/<%= data[i].user_id%>" class="btn btn-sm btn-success">View Profile</a>
            <% if(data[i].approved){ %>
              <a href="" class="btn btn-sm btn-info disabled">Approved</a>
            <% } %>

            
          </td>
          <% } %>

          <!-- <td>
            <% if(data[i].is_requested) { %>
              <div class="btn-group btn-group-sm">
              <a href="/dashboard/admin/approve/<%= data[i].user_id%>"><button type="button" class="btn btn-sm btn-success"><em class="approve"></em></button></a> 
              <a href="/dashboard/admin/disApprove/<%= data[i].user_id%>"><button type="button" class="btn btn-sm btn-warning"><em class="disApprove"></em></button></a>
              </div>
            <% }else if(data[i].is_approved) { %>
              <div class="btn-group btn-group-sm">
              <button type="button" class="btn btn-sm btn-success" disabled><em class="approve"></em></button>
              <button type="button" class="btn btn-sm btn-warning" disabled><em class="disApprove"></em></button>
              </div>
            <% }else if(data[i].is_attached) { %>
              <button type="button" class="btn btn-sm btn-block btn-info" disabled>ATTACHED</button>
            <% }else { %>
              <button type="button" class="btn btn-sm btn-block btn-outline-light" disabled>...</button>
            <% } %>

          </td> -->
        </tr>
        <% } %>
        
      </tbody>
    </table>
  </div>
  </div>
  <!-- ============================================APPLIED STUDENTS=========================== -->
  <div class="tab-pane fade show" id="applied" role="tabpanel" aria-labelledby="applied-tab">
    <div class="table-responsive ">
      <table class="table text-white ">
        <thead>
          <tr>
              <th scope="col">#</th>
              <th scope="col">Names</th>
              <th scope="col">Email</th>
            <th scope="col">Programme</th>
            <th scope="col">Academic_year</th>
            <th scope="col">Action</th>
          </tr>
        </thead>
        <tbody>
          
          <!-- <% if(data.institution_id == null){ %>
            <h3 class="text-success">No student had applied yet</h3>
          <% } %> -->
          <% for(i in data){ %>
            <% if(data[i].role_id !== 1 & data[i].role_id !== 2 & data[i].institution_id !== null) { %>
          <tr>
            <th scope="row"><%= i %></th>
  
            <td> <a class="text-white" href="/dashboard/admin/profileView/<%= data[i].user_id%>"><%= data[i].first_name %> <%= data[i].last_name %></a> </td>
            <td><%= data[i].user_email %>
            </td>
            <td><%= data[i].programme_name %></td>
            <td><%= data[i].academic_year %></td>
            <td>

            <a href="/dashboard/admin/profileView/<%= data[i].user_id%>" class="btn btn-sm btn-success">View Profile</a>
            <% if(data[i].approved){ %>
              <a href="#" class="btn btn-sm btn-info disabled">Attached</a>
            <% } %>

            </td>
            <% } %>
  
            <!-- <td>
              <% if(data[i].is_requested) { %>
                <div class="btn-group btn-group-sm">
                <a href="/dashboard/admin/approve/<%= data[i].user_id%>"><button type="button" class="btn btn-sm btn-success"><em class="approve"></em></button></a> 
                <a href="/dashboard/admin/disApprove/<%= data[i].user_id%>"><button type="button" class="btn btn-sm btn-warning"><em class="disApprove"></em></button></a>
                </div>
              <% }else if(data[i].is_approved) { %>
                <div class="btn-group btn-group-sm">
                <button type="button" class="btn btn-sm btn-success" disabled><em class="approve"></em></button>
                <button type="button" class="btn btn-sm btn-warning" disabled><em class="disApprove"></em></button>
                </div>
              <% }else if(data[i].is_attached) { %>
                <button type="button" class="btn btn-sm btn-block btn-info" disabled>ATTACHED</button>
              <% }else { %>
                <button type="button" class="btn btn-sm btn-block btn-outline-light" disabled>...</button>
              <% } %>
  
            </td> -->
          </tr>
          <% } %>
        </tbody>
      </table>
    </div>

  </div>
</div>
</section>
</body>
<footer>
  <%- include('2-F-A') %>
  <%- include('./partials/_foot'); %>
</footer>
</html>