{% extends 'base.html' %}
{% load ftp_tags %}

{% block top %}
  <p>
    utente che sta effettuando gli aggiornamenti {{ utenteautorizzato.mail }}@{{ utenteautorizzato.domain.nome }}
  </p>
  {% if dominio %}
    <p>
      Dominio su cui si sta' lavorando: {{ dominio.nome }}
    </p>
  {% endif %}
  {% if ftp %}
    <p>
      si stanno effettuando aggiornamenti su: {{ ftp.user }}@{{ ftp.domain.nome }}
    </p>
  {% endif %}
{% endblock %}

{% block body %}
  <form name='newftp' method='post'>
    {% csrf_token %}
    {% if 'FTPADD' in securitylist %}
    <button class="btn btn-primary" type="submit" name='Nuovo Accesso FTP' value="Nuovo ftp">Nuovo Accesso FTP</button>
    {% endif %}
    {% if 'FTPBACK' in securitylist %}
    <button type 'submit' class='btn btn-secondary' name='BackupAllFTPHTTP'>Backup Tutti Gli Spazi FTP e HTTP</button>
    {% endif %}
    <button type 'submit' class='btn btn-secondary' name='Ritorna'>Ritorna</button>
  </form>
  <table class='table'>
    <thead>
      <tr>
        <th scope='col'>#</th>
        <th scope='col'>Account</th>
        <th scope='col'>Tipo</th>
        <th scope='col'>E</th>
	<th scope='col'>M</th>
        <th scope='col'>l</th>
        <th scope='col'>quota</th>
        <th scope='col'>Attivit<C3><A0></th>
      </tr>
    </thead>
    <tbody>
      <form name="ftplist" method="POST">
      {% csrf_token %}
      {% for u in ftplist %}
        <tr>
          <th scope='row'>{{ u.id }}</th>
          <td> {{ u.utente }}@{{ u.dominio.nome }} </td>
	  <td> {{ u.ftpgroup.nomegruppo }} </td>
	  <!--<td>
		  {% spaceless %}
		  {{ u.ftpgroup.home }}
		  {% if u.ftpgroup.l3 %}{{ u.utente }}.{% endif %}
		  {{ u.dominio.nome }} 
		  {% if u.ftpgroup.sub|llen %}
		  {{ u.ftpgroup.sub }}{{ u.utente }}
		  {% endif %}
		  {% endspaceless %}

		  </td>-->
          <td>{% if u.enabled %}*{% else %}-{% endif %}</td>
	  <td>{% if u.ftpgroup.master %}M{% else %}-{% endif %}</td>
          <td>{{ u.securitylevel.id }}</td>
	  <td>{{ u.quota }}Mb {% if u.warning_ftp_quota %} /{{ u.warning_ftp_quota }}Mb{% else %}{% endif %}
		  <td>{% if 'FTPEDIT' in securitylist %}<button class="btn btn-primary" type="submit" name='Edit' value="{{ u.id }}"{% if not u.enabled %} disabled {% endif %}>Edit</button>{% endif %}
              <button class='btn btn-primary' type='button' data-toggle='modal' data-target='#ConfirmEnableDisable{{ u.id }}' name='enabledisablebutton' value='{{ u.id }}'>{% if u.enabled %}Disabilita{% else %}Abilita{% endif %}</button>
	      {% if 'FTPBACK' in securitylist %}<button type 'submit' class='btn btn-secondary' name='BackupFTPHTTP' value='{{ u.id }}'>Backup FTP e HTTP</button>{% endif %}</td>
   </tr>

   <!-- Modal -->
      <div class="modal fade" id="ConfirmEnableDisable{{ u.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-title" 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">
              {% if u.enabled %}
              Sei sicuro di voler disattivare questo indirizzo Ftp?
              {% else %}
              Vuoi riattivare questo indirizzo Ftp?
              {% endif %}
            </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="enabledisablebutton" value="{{ u.id }}">Conferma</button>
            </div>
          </div>
        </div>

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

