{% 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 admin_modify admin_static %}
{% block extrahead %}
<link rel="stylesheet" type="text/css" href="{% static "css/base-print.css" %}" />
<style>
 .patr a:link,
 .patr a:visited,
 .patr a:hover,
 .patr a:active {
   color:inherit;
   line-height:inherit;  
} 
 .level1 {
    color:#102BB2; 
 }
 .level1 .level_btn {
    display:list-item;
    list-style:square inside;
 }
 .level2 {
     color:#FF6500; 
 }
 .level2 .level_btn {
    display:list-item;
    list-style:circle inside;
    padding-left:15px;
 }
 .level3 {
    color:#56B209; 
 }
 .level3 .level_btn {
    display:list-item;
    list-style:disc inside;
    padding-left:30px;
 }
 .level0.tr_border {
    border-top:1px darkgray solid;
 }
 .level0 {
 }
 /*
 .level1.tr_border .clickable {
    border-bottom:1px #102BB2 solid;
 }
 .level2.tr_border .clickable {
    border-bottom:1px #FF6500 solid;
 }
 .level3.tr_border .clickable {
    border-bottom:1px #56B209 solid;
 }
 */
 #tbl_content {
    margin: 0;
    width: 100%;
    word-break: break-all;
 }
 
 /* Descricao */
 #tbl_content td:nth-child(9) {
    word-break: break-word;
 } 
 
 /* ID */
  #tbl_content td:nth-child(1) { width:33px; }
 /* PROCESSO */
  #tbl_content td:nth-child(2) { width:65px; }
 /* FMUSP */
  #tbl_content td:nth-child(3) { width:50px; }
 /* NF */
  #tbl_content td:nth-child(4) { width:90px; }
 /* MODELO */
  #tbl_content td:nth-child(5) { width:105px; }
 /* PART NUMBER */
  #tbl_content td:nth-child(6) { width:105px; }
 /* NS */
  #tbl_content td:nth-child(7) { width:105px; }
 /* APELIDO */
  #tbl_content td:nth-child(8) { width:60px; }
  /* DESCRICAO com largura variável*/
  /*#tbl_content td:nth-child(9) { width:50px; }*/
 /* POSICAO */
  #tbl_content td:nth-child(10) { width:85px; }
 /* ESTADO */
  #tbl_content td:nth-child(11) { width:75px; }
</style>
{% endblock %}
{% block breadcrumbs %}
    <div class="breadcrumbs">Você está em: 
      <a href="../../">{% trans "Home" %}</a> &rsaquo; 
      <a href="{% url 'patrimonio.views.por_local_termo' %}">Patrimônio por localização (com Termo)</a>
    </div>
{% endblock %}
{% block content %}
    <h1 repeat="1">Patrimônio por localização (com Termo)</h1>
    
    <div id="report_toolbar">
        <form action="{% url 'patrimonio.views.por_local_termo' 1 %}" method="GET" id="id_form_recurso">
            <input type="hidden" name="entidade" value="{{ request.GET.entidade }}" />
            <input type="hidden" name="endereco" value="{{ request.GET.endereco }}" />
            <input type="hidden" name="detalhe" value="{{ request.GET.detalhe }}" />
            <input type="hidden" name="com_fmusp" value="{{ request.GET.com_fmusp }}" />
            <input type="hidden" name="nivel1" value="{{ request.GET.nivel1 }}" />
            <input type="hidden" name="nivel2" value="{{ request.GET.nivel2 }}" />
            <input type="hidden" name="nivel3" value="{{ request.GET.nivel3 }}" />
            <div title="Imprimir" class="btn_print">
               <input type="submit" title="Versão para impressão A4" class="btn_print" name="acao" value="1"  />
            </div>
        </form>
    </div>
    <div style="clear:both;"></div>
    {% for end in enderecos %}
        <h4>
            {% if end.endereco %}
                {{ end.endereco }}
            {% else %}
                {{ end.detalhe }}
            {% endif %}
        </h4>
        {% if end.detalhes %}
        {% endif %}
        {% for d in end.detalhes %}
        <table border="0" repeat="1" cellpadding="5" id="tbl_content" style="margin-top: 15px;">
            <tr class="" id="" style="background-color:;font-weight:bold; border:1px black solid;">
                <td colspan='11'>{{ d.detalhe }}</td>
            </tr>
            <tr style="background-color:lightgray;font-weight:bold; border:1px black solid;">
                <th>ID</th>
                <th>Processo</th>
                <th>Patr. Oficial</th>
                <th>NF</th>
                <th>Modelo</th>
                <th>Part number</th>
                <th>NS</th>
                <th>Apelido</th>
                <th>Descrição</th>
                <th>Posição</th>
                <th>Estado</th>
            </tr>    
               {% for p in d.patrimonio %}
                  <tr class="patr level0 tr_border" id="tr_{{p.id}}">
                    <td><div class="level_btn"></div><a href="{% url 'admin:patrimonio_patrimonio_change' p.id %}">{{ p.id }}</a></td>
                    <td class="clickable">{{ p.termo|default:'' }}</td>
                    <td class="clickable">{{ p.fmusp|default:'' }}</td>
                    <td class="clickable">{{ p.num_documento|default:'' }}</td>
                    <td class="clickable">{{ p.modelo|default:'' }}</td>
                    <td class="clickable">{{ p.part_number|default:'' }}</td>
                    <td class="clickable">{{ p.ns|default:'' }}</td>
                    <td class="clickable">{{ p.apelido|default:'' }}</td>
                    <td class="clickable">{{ p.descricao|default:'' }} - {{ p.complemento|default:'' }}</td>
                    <td class="clickable">{{ p.posicao|default:'' }}</td>
                    <td class="clickable">{{ p.estado|default:'' }}</td>
                  </tr>
                  {% if nivel1 == 'on' %}
                  {% for f in p.contido %}
                     <tr class="patr level1 {% if forloop.last %} tr_border{% endif %}" id="tr_{{f.id}}">
                        <td><div class="level_btn"></div><a href="{% url 'admin:patrimonio_patrimonio_change' f.id %}"></a></td>
                        <td class="clickable">{{ f.termo|default:'' }}</td>
                        <td class="clickable">{{ f.fmusp|default:'' }}</td>
                        <td class="clickable">{{ f.num_documento|default:'' }}</td>
                        <td class="clickable">{{ f.modelo|default:'' }}</td>
                        <td class="clickable">{{ f.part_number|default:'' }}</td>
                        <td class="clickable">{{ f.ns|default:'' }}</td>
                        <td class="clickable">{{ f.apelido|default:'' }}</td>
                        <td class="clickable">{{ f.descricao|default:'' }}</td>
                        <td class="clickable">{{ f.posicao|default:'' }}</td>
                        <td class="clickable">{{ f.estado|default:'' }}</td>
                      </tr>
                      {% if nivel2 == 'on' %}
                      {% for g in f.contido %}
                         <tr class="patr level2 {% if forloop.last %} tr_border{% endif %}" id="tr_{{g.id}}">
                            <td><div class="level_btn"></div><a href="{% url 'admin:patrimonio_patrimonio_change' g.id %}"></a></td>
                            <td class="clickable">{{ g.termo|default:'' }}</td>
                            <td class="clickable">{{ g.fmusp|default:'' }}</td>
                            <td class="clickable">{{ g.num_documento|default:'' }}</td>
                            <td class="clickable">{{ g.modelo|default:'' }}</td>
                            <td class="clickable">{{ g.part_number|default:'' }}</td>
                            <td class="clickable">{{ g.ns|default:'' }}</td>
                            <td class="clickable">{{ g.apelido|default:'' }}</td>
                            <td class="clickable">{{ g.descricao|default:'' }}</td>
                            <td class="clickable">{{ g.posicao|default:'' }}</td>
                            <td class="clickable">{{ g.estado|default:'' }}</td>
                          </tr>
                         {% if nivel3 == 'on' %}
                         {% for h in g.contido %}
                            <tr class="patr level3 {% if forloop.last %} tr_border{% endif %}" id="tr_{{h.id}}">
                                <td><div class="level_btn"></div><a href="{% url 'admin:patrimonio_patrimonio_change' h.id %}"></a></td>
                                <td class="clickable">{{ h.termo|default:'' }}</td>
                                <td class="clickable">{{ h.fmusp|default:'' }}</td>
                                <td class="clickable">{{ h.num_documento|default:'' }}</td>
                                <td class="clickable">{{ h.modelo|default:'' }}</td>
                                <td class="clickable">{{ h.part_number|default:'' }}</td>
                                <td class="clickable">{{ h.ns|default:'' }}</td>
                                <td class="clickable">{{ h.apelido|default:'' }}</td>
                                <td class="clickable">{{ h.descricao|default:'' }}</td>
                                <td class="clickable">{{ h.posicao|default:'' }}</td>
                                <td class="clickable">{{ h.estado|default:'' }}</td>
                             </tr>
                         {% endfor %}
                         {% endif %}
                     {% endfor %}
                     {% endif %}
                  {% endfor %}
                  {% endif %}
               {% endfor %}
        </table>
        {% endfor %}
    {% endfor %}
    
    <script>
    $('.patr').each(function(i, v) {
        var href = $(this).find("a").attr("href");
        $(this).find(".clickable").each(function(i, v) {
            v = $(v);
            var txt = v.html();
            txt = '<a href="' + href + '">' + txt + '</a>';
            v.html(txt);
        });
    
    });
    
    </script>
{% endblock %}
