{% extends 'base.html' %}

{% block top %}
  <p>
    utente che sta effettuando gli aggiornamenti {{ utenteautorizzato.mail }}@{{ utenteautorizzato.domain.nome }}
  </p>
{% endblock %}

{% block body %}
  <form name='newfiltro' method='post'>
    {% csrf_token %}
    <button class="btn btn-primary" type="submit" name='Nuovo Filtro' value="Nuovo Filtro">Nuovo Filtro</button>
  </form>
  <table class='table'>
    <thead>
      <tr>
        <th scope='col'>Filtro</th>
        <th scope='col'>Status</th>
	<th scope='col'>Rcpt</th>
	<th scope='col'>Redirect</th>
	<th scope='col'>I</th>
	<th scope='col'>O</th>
	<th scope='col'>H</th>
	<th scope='col'>B</th>
        <th scope='col'>*</th>
      </tr>
    </thead>
    <tbody>
      <form name="filtrolist" method="POST">
      {% csrf_token %}
      {% for f in filtro %}
        <tr>
          <th scope='row'>{{ f.filtro }}</th>
          <td> {{ f.status }} </td>
          <td> {{ f.destination }} </td>
	  <td> {{ f.redirect }} </td>
          <td>{% if f.dinput %}*{% else %}-{% endif %}</td>
          <td>{% if f.doutput %}*{% else %}-{% endif %}</td>
          <td>{% if f.header %}*{% else %}-{% endif %}</td>
          <td>{% if f.body %}*{% else %}-{% endif %}</td>
          <td>{% if f.enabled %}*{% else %}-{% endif %}</td>
          <td><button class="btn btn-primary" type="submit" name='edit' value="{{ f.id }}">Edit</button>
              <button class="btn btn-primary" type="button" data-toggle="modal" data-target="#ConfirmDisable{{ f.id }}" name='disable' value="{{ f.id }}" {% if not f.enabled %} disabled {% endif %}>Disabilita</button>
              <button class="btn btn-primary" type="submit" name='enable' value="{{ f.id }}" {% if f.enabled %} disabled {% endif %}>Abilita</button>
              <button class="btn btn-primary" type="button" data-toggle="modal" data-target="#ConfirmDelete{{ f.id }}" name='delete' value="{{ f.id }}" {% if not f.enabled %} disabled {% endif %}>Cancella</button></td>
       </tr>

        <!-- Modal -->
        <div class="modal fade" id="ConfirmDisable{{ f.id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal fade" id="exampleModalLongTitle">Conferma Disattivazione</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                Sei sicuro di voler disattivare questo Filtro? 
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
		<button type="submit" class="btn btn-primary" name="disable" value="{{ f.id }}">Conferma</button>
              </div>
            </div>  
          </div>  
        </div>
        <!-- Modal -->
        <div class="modal fade" id="ConfirmDelete{{ f.id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal fade" id="exampleModalLongTitle">Conferma cancellazione</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                Sei sicuro di voler Cancellare Questa Regola? 
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
		<button type="submit" class="btn btn-primary" name="delete" value="{{ f.id }}">Conferma</button>
              </div>
            </div>  
          </div>  
        </div>

      {% endfor %}
      </form>
    </tbody>
{% endblock %}
