{% extends "base.html" %}
{% set currentPage = "allFiles" %}

{% block body %}

<h1> Download all Project Files </h1>
<!--Menu-->
<ul class="nav nav-tabs">
  {% for menuItem in cfg["committee"] %}
    <li role="presentation"><a href="{{menuItem['link']}}">{{menuItem['title']}}</a></li>
  {% endfor %}
</ul>
<p></p>
{% if fac is not none %}
<form 
        class = "form-horizontal"
        action = "/committee/allFiles"
        method = "POST">
   <input id = "submit" 
              type = "submit" 
              value = "Download all project files"
              class="form-control btn btn-block btn-success"
              data-toggle="tooltip" 
              title = "Download all project files"
              /> 
    </input>

</form>  
{% endif %}
<div class = "row">
  <table class = "table table-striped table-hover table-sm">
    <tr>
      <th>Faculty/Proj. Title</th>
      {% for header in ["Narrative", "Vitae", "IRB"]%}
      <th>
        {{header}}
      </th>
      {% endfor %}
    </tr>
    {% if fac is not none %}
    {% for person in fac %}
      <tr id="row{{loop.index0}}">
        <td>
          {{person.username.firstname}} {{person.username.lastname}} <span class = "small">({{person.programID.name}})</span>
          <br />
          <span class = "small">{{person.pID.title|truncate(50, True)}}</span>
        </td>
        {% for uploadType in ['narrative', 'vitae', 'irb'] %}
        <td>
          {% if files[person.username.username][uploadType] %}<a href = "/document/{{person.username.username}}/{{files[person.username.username][uploadType]}}"
             target = "_blank">
            <button type="button" class="btn btn-default btn-md btn-success">  Download  <span class="glyphicon glyphicon-download-alt"></button>
            
          </a>
          {% else %}
          No file
          {% endif %}
        </td>
        {% endfor %}
      </tr>
    
    {% endfor %}
    {% endif %}
    
  </table>
</div>

{% endblock %}
