{% extends 'base.html' %}

{% block body %}
  <form name="inputUtente" method="POST">
  <div class='form-control'>
    {% if "AMMINISTRATORE.CREA" in permesso %}
      <input type='submit' class="btn btn-primary" name='sceltanuovo' value='Nuovo Amministratore'>
    {% endif %}
    <input type='submit' class="btn btn-primary" name="indietro" value="Indietro">
  </div>
  <div class='form-control'>
    Numero di  amministratori registrati {{ amministratorelistalen }}.
  </div>

  {% csrf_token %}
  <table class='table table-striped table-hover'>
    <thead class='thead-dark'>
      <tr>
        {% if "AMMINISTRATORE.EDIT" in permesso %}<th scope='col'>*</th>{% endif %}
        <th scope='col'>Login</th>
        <th scope='col'>Nome</th>
        <th scope='col'>Mail</th>
        {% if "AMMINISTRATORE.EDIT" in permesso %}
  	  <th scope='col'>Pin</th>
        {% endif %}
      </tr>
    </thead>
    <tbody>
      {% csrf_token %}
      {% for aa in amministratorelista %}
        <tr>
          {% if "AMMINISTRATORE.EDIT" in permesso %}
	  <td> <button type='submit' class='btn btn-primary btn-block btn-lg mb-2 active' name='scelta' value='{{ aa.id }}' onchange="this.form.submit()">Edit</button></td>
          {% endif %}
          <td> {{ aa.login }} </td>
	  <td> {{ aa.nome }} </td>
          <td> {{ aa.mail }} </td>
          {% if "AMMINISTRATORE.EDIT" in permesso %}
            <td> {{ aa.pin }} </td>
          {% endif %}
	</tr>
      {% endfor %} 
    </tbody>
  </table>
  </form>

  {% if "AMMINISTRATORE.CREA" in permesso %}
  <!-- Modal -->
  <div class="modal fade" id="CaricaIndiceModal" tabindex="-1" role="dialog" aria-labelledby="CaricaIndiceLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
             <form name='formCaricaIndice' method='POST' enctype='multipart/form-data'>
               {% csrf_token %}
               <div class="modal-header">
                <h5 class="modal-title" id="CaricaIndiceLabel">Carica Elenco Dipendenti</h5>
                  <span aria-hidden="true">&times;</span>
                </button>
               </div>
               <div class="modal-body">
                 Caricamento Lista Dipendenti<br>
                 Formato File CSV - obbligatorio <br>
                 Separatore: ',' - prima riga: "Nome colonna".</br>
                 <table class='table table-striped table-hover'>
                   <tbody>
                     <tr>
                       <td>Nome Cognome</td>
                       <td>Codice Fiscale</td>
                       <td>Data di Nascita</td>
                       <td>Luogo di Nascita</td>
                       <td/email</td>
                     </tr>
                   </tbody>
                 </table><br>
                 <label for='indice'>Elenco Dipendenti:&nbsp;</label>
                 <input type='file' name='indice' id='indice' value='' accept='text/csv'>
               </div>
               <div class="modal-footer">
                 <button type="submit" name="CaricaIndice" value='Carica Lista' class="btn btn-primary">Carica Lista Dipendenti</button>
                 <button type="button" class="btn btn-primary" data-bs-dismiss="modal">Annulla</button>
               </div>
             </form>
           </div>
         </div>
       </div>
     </div>
     <!-- end modal -->
   {% endif %}

{% endblock %}

{% block bodybottom %}
  <div><br><br></div>


  {% if listaok %}
    <table class='table table-striped table-hover'>
      <thead class='thead-dark'>
      <tr>
        <th scope='col'>Documento caricato con successo</th>
      </tr>
      </thead>
      <tbody>
        {% for l in listaok %}
        <tr>
          <td> {{ l }} </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endif %}

  <div><br><br></div>
  {% if listanotok %}
    <table class='table table-striped table-hover'>
      <thead class='thead-dark'>
      <tr>
        <th scope='col'>Documento non caricato perche già presente</th>
      </tr>
      </thead>
      <tbody>
        {% for l in listanotok %}
        <tr>
          <td> {{ l }} </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endif %}

  {% if listaok %}
    {% for i in listaok %}
      {{i }}
    {% endfor %}
  {% endif %}

  {% if listanotok %}
    {% for i in listanotok %}
      {{i }}
    {% endfor %}
  {% endif %}

{% endblock %}

