<% include ../partials/header %>

    
<!--NAVIGATION BAR FOR ADMIN-->
<% include ../partials/userNav %>
<% include ../partials/alerts %>
<header id="main-header" class="py-2 bg-light text-black">
    <h1><i class="fa fa-pencil"></i> Project Inventory</h1>
</header>

<!--ACTIONS-->
<section id="search_bar">
  <div class="container mt-5">
    <div class="row">
      <div class="col-md-6 offset-md-3">
        <div class="card transparent-container">
          <div class="card-header text-center login-card-header">
   <form action="/user/1/projectInventory/all/all/1" method="POST">
    <div class="form-group">
          <select name="filter" class="form-control">
            <option selected disabled>Select Option</option>
            <option  name="name">Title</option>
            <option  name="mentor">Mentor</option>
            <option  name="domain">Domain</option>
            <!-- <option  name="ISBN">By ISBN</option> -->
          </select>
        </div>
        
         <div class="form-group">
          <input name="searchName"  type="text" class="form-control" placeholder="Search Projects">
        </div>
        
         <div class="form-group">
          <input type="submit" class="addc-btn" value="Search">
        </div>
      </div>
    </div>
    </form>
</div>
</div>
</div>
</div>
</section>

<!-- BOOK INVENTORY -->
<section id="projectInventory" class="mt-5">
  <div class="container">
    <div class="row justify-content-center">
        <div class="card transparent-container">
          <div class="card-header text-center login-card-header">
          <table class="table table-striped">
            <thead class="thead-inverse">
              <tr>
                
                <th>Project Title</th>
                <th>Project Mentor</th>
                <th>Project Domain</th>
                <th>Project Period</th>
                <th>Edit</th>
              </tr>
            </thead>
            <tbody>
              
          <% project.forEach(project => { %>         
         
              <tr>
              
                
                <td><%= project.name %></td>
                <td><%= project.mentor %></td>
                <td><%= project.domain %></td>
                <td><%= project.period %></td>
                <td>
                    <span>
                        <a href="/user/1/project/update/<%=project._id%>" class="addup-btn">Update</a>
                        <a href="/user/1/project/delete/<%=project._id%>" class="adddl-btn">Delete</a>
                    </span>
                </td>
              </tr>
          <% }); %>
              
            </tbody>
          </table>

          <% if (pages > 0) { %>
            <nav class="ml-3 mb-2">
              <ul class="pagination offset-md-3">
            
            <% if (current == 1) { %>
                <li class="page-item disabled"><a class="page-link">First</a></li>
            <% } else { %>
                <li class="page-item"><a href="/user/1/projectInventory/<%=filter%>/<%=value%>/1" class="page-link">First</a></li>
            <% } %>
            
            <% var i = (Number(current) > 5 ? Number(current) - 4 : 1) %>
                <% if (i !== 1) { %>
                  <li class="page-item disabled"><a class="page-link">...</a></li>
                <% } %>
                <% for (; i <= (Number(current) + 4) && i <= pages; i++) { %>
                    <% if (i == current) { %>
                      <li class="page-item active"><a class="page-link"><%= i %></a></li>
                    <% } else { %>
                      <li class="page-item"><a class="page-link" href="/user/1/projectInventory/<%=filter%>/<%=value%>/<%=i%>"> <%=i%></a> </li>
                    <% } %>
                    <% if (i == Number(current) + 4 && i < pages) { %>
                          <li class="page-item disabled"><a class="page-link">...</a></li>
                      <% } %>
                    <% } %>
                    <% if (current == pages) { %>
                        <li class="page-item disabled"><a class="page-link">Last</a></li>
                    <% } else { %>
                        <li class="page-item"><a href="/user/1/projectInventory/<%=filter%>/<%=value%>/<%=pages%>" class="page-link">Last</a></li>
                <% } %>
            </ul>
          </nav>
          <% } %>
        </div>
      </div>
    </div>
  </div>
</section>

<% include ../partials/footer %>