{% 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.crossconnection' %}">Lista de Cross Conexões</a>
    </div>
{% endblock %}
{% block extrastyle %}
<style type="text/css">
  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;}
  
  .td_titulo, thead th {
     background: lightgray;
     border-bottom: 1px black solid;
     text-align: left;
     font-size: 12px;
     font-weight: bold;
     border-top: 1px black solid;
  }
  .td_bottom {
     border-top: 1px black solid;
     border-bottom:0;
  }
  #blocos td {
     vertical-align: middle;
  }
  .col1 {border-left: 1px black solid;}
  .obs {border-right: 1px black solid;}

</style>
{% endblock %}
{% block content %}
<div id="report_title">
    <h1>Cross Conexões</h1>
</div>
<div id="div_filtro">
    <fieldset>
        <legend>Filtro</legend>
        <form method="GET">
        <label for="id_rack">Rack:</label>
        <select name="rack" id="id_rack">
          <option value="0" selected>Todos</option>
          {% for rack in filtro_rack %}
             <option value="{{ rack }}" {% if rack|striptags == request.GET.rack|striptags %}selected{% endif %}>{{ rack }}</option>
          {% endfor %}
        </select>
        <br />
        <label for="id_shelf">Shelf:</label>
        <select name="shelf" id="id_shelf">
          <option value="0" selected>Todos</option>
          {% for shelf in filtro_shelf %}
             <option value="{{ shelf }}" {% if shelf|striptags == request.GET.shelf|striptags %}selected{% endif %}>{{ shelf }}</option>
          {% endfor %}
        </select>
        <br />
        <label for="id_conector">Conector:</label>
        <select name="conector" id="id_conector">
          <option value="0" selected>Todos</option>
          {% for conector in filtro_conector %}
             <option value="{{ conector }}" {% if conector|striptags == request.GET.conector|striptags %}selected{% endif %}>{{ conector }}</option>
          {% endfor %}
        </select>
        <br />
        <label for="id_projeto">OS/Projeto:</label>
        <select name="projeto" id="id_projeto">
          <option value="0" selected>Todos</option>
          {% for projeto in filtro_projeto %}
             <option value="{{ projeto }}" {% if projeto|striptags == request.GET.projeto|striptags %}selected{% endif %}>{{ projeto }}</option>
          {% endfor %}
        </select>
        <br />
        <input type="submit" value="Enviar">
        </form>
    </fieldset>
</div>
<div id="report_toolbar">
    {% if cross %}
    <form action="{% url 'rede.views.crossconnection' %}" method="GET" id="id_form_recurso_xls">
        <input type="hidden" name="rack" value="{{request.GET.rack}}" />
        <input type="hidden" name="shelf" value="{{request.GET.shelf}}" />
        <input type="hidden" name="conector" value="{{request.GET.conector}}" />
        <input type="hidden" name="projeto" value="{{request.GET.projeto}}" />
        <input type="hidden" name="xls" value="1" />
        <div title="Exportar para Excel" class="btn_excel">
           <input type="submit" value="" />
        </div>
    </form>
    {% endif %}
</div>

{% if cross|length_is:"0" %}
    <div style="border:1px solid lightgray; padding: 15px;">
        <strong>Não foram encontrados Cross Conexões que satisfaçam os filtros selecionados.</strong>
    </div>
{% endif %}
{% if cross %}
    <div id="blocos">
    <table>
        <thead>
           <td class="col1 td_titulo">Rack 1</td>
           <td class="colunas td_titulo">Shelf</td>
           <td class="colunas td_titulo">Porta</td>
           <td class="colunas td_titulo">Conector</td>
           <td class="colunas td_titulo">Rack 2</td>
           <td class="colunas td_titulo">Shelf</td>
           <td class="colunas td_titulo">Porta</td>
           <td class="colunas td_titulo">Conector</td>
           <td class="colunas td_titulo">Circuito</td>
           <td class="colunas td_titulo">OS/Projeto</td>
           <td class="obs td_titulo">Obs</td>
        </thead>
        
        {% for b in cross %}
           <tr id="tr_blocos_{{forloop.counter}}">
              <td id="td_blocos_{{forloop.counter}}_col1" class="">{{b.origem.rack}}</td>
              <td id="td_blocos_{{forloop.counter}}_col2" class="">{{b.origem.shelf}}</td>
              <td id="td_blocos_{{forloop.counter}}_col3" class="">{{b.origem.porta}}</td>
              <td id="td_blocos_{{forloop.counter}}_col4" class="">{{b.origem.tipoConector.sigla}}</td>
              
              <td id="td_blocos_{{forloop.counter}}_col5" class="">{{b.destino.rack}}</td>
              <td id="td_blocos_{{forloop.counter}}_col6" class="">{{b.destino.shelf}}</td>
              <td id="td_blocos_{{forloop.counter}}_col7" class="">{{b.destino.porta}}</td>
              <td id="td_blocos_{{forloop.counter}}_col8" class="">{{b.destino.tipoConector.sigla}}</td>
              
              <td id="td_blocos_{{forloop.counter}}_col9" class="">{{b.circuito}}</td>
              <td id="td_blocos_{{forloop.counter}}_col10" class="">{{b.ordemDeServico}}</td>
              <td id="td_blocos_{{forloop.counter}}_col11" class="">{{b.obs}}</td>
           </tr>
        {% endfor %}
    </table>
    </div>
{% endif %}
{% endblock %}
