{% extends "admin/base_site.html" %}
{% comment %}
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
{% endcomment %}
{% load proto_tags %}
{% load i18n %}
{% block breadcrumbs %}
    <div class="breadcrumbs">Você está em: 
      <a href="../../">{% trans "Home" %}</a> &rsaquo; 
      <a href="{% url 'rede.views.blocosip_inst_ansp' %}">Lista de Blocos IP - Instituições ANSP</a>
    </div>
{% endblock %}
{% block extrastyle %}
<style type="text/css">
  div.col1 {float:left;}
  div.col2 {float:right;}
  div.colunas {float:left; width:140px;}
  div.obs {float:left; width:230px; white-space:normal;}
  ins {float:left;}
  div#theader {font-weight:bold; clear:both;}
  div#div_filtro {margin-bottom:15px;}
  div#div_filtro label {width:85px; display:inline-block;}
  
  thead th {
     background: lightgray;
     border-bottom: 1px black solid;
     text-align: left;
     font-size: 12px;
     font-weight: bold;
  }
</style>
{% endblock %}
{% block content %}
<div id="report_title">
	<h1>Blocos IP - Instituições ANSP</h1>
</div>
<div id="div_filtro">
    <fieldset>
        <legend>Filtro</legend>
        <form method="GET">
        <label for="id_anunciante">Anunciante:</label>
        <select name="anunciante" id="id_anunciante">
          <option value="0" selected>Todos</option>
          {% for asn in filtro_asns %}
             <option value="{{ asn.id }}" {% if asn.id|striptags == request.GET.anunciante|striptags %}selected{% endif %}>{{ asn }}</option>
          {% endfor %}
        </select>
        <br />
        <label for="id_usuario">Usuário:</label>
        <select name="usuario" id="id_usuario">
          <option value="0" selected>Todos</option>
          {% for u in filtro_usuarios %}
             <option value="{{ u.id }}" {% if u.id|striptags == request.GET.usuario|striptags %}selected{% endif %}>{{ u }}</option>
          {% endfor %}
        </select>
        <br />
        <input type="submit" value="Enviar">
        </form>
    </fieldset>
</div>
<div id="report_toolbar">
    {% if blocos %}
    <form action="{% url 'rede.views.blocosip_inst_ansp' %}" method="GET" id="id_form_recurso_xls">
        <input type="hidden" name="anunciante" value="{{request.GET.anunciante}}" />
        <input type="hidden" name="proprietario" value="{{request.GET.proprietario}}" />
        <input type="hidden" name="usuario" value="{{request.GET.usuario}}" />
        <input type="hidden" name="designado" value="{{request.GET.designado}}" />
        <input type="hidden" name="xls" value="1" />
        <div title="Exportar para Excel" class="btn_excel">
           <input type="submit" value="" />
        </div>
    </form>
    {% endif %}
</div>
{% if blocos|length_is:"0" %}
    <div style="border:1px solid lightgray; padding: 15px;">
        <strong>Não foram encontrados Blocos IP que satisfaçam os filtros selecionados.</strong>
    </div>
{% endif %}
{% if blocos %}
    <div id="blocos">
    <table border="1" repeat="1" cellpadding="5">
    <thead>
       <tr>
          <th class="col1">Instituição/Projeto</th>
          <th class="colunas">Bloco IP</th>
          <th class="colunas">Máscara IP</th>
          <th class="colunas">ASN Anunciante</th>
          <th class="colunas">Anunciante</th>
          <th class="obs">Obs</th>
       </tr>
    </thead>
    {% for b in blocos %}
       <tr>
           <td class="col1">
                {{ b.obj.usuario.sigla|default_if_none:"" }}
           </td>
           <td class="colunas"><a href="{% url "admin:rede_blocoip_change" b.id %}" >{{ b.obj }}</a></td>
           <td class="colunas">{{ b.netmask }}</td>
           <td class="colunas">{{ b.obj.asn.numero|default_if_none:"-" }}</td>
           <td class="colunas">{{ b.obj.asn.entidade|default_if_none:"-" }}</td>
           <td class="obs">{{ b.obj.obs }}</td>
       </tr>
    {% endfor %}
    </table>
    </div>
{% endif %}
{% endblock %}
