{% 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 %}
{% load static from staticfiles %}
{% block extrastyle %}
<style type="text/css">
  div.col1 {float:left; min-width:200px;}
  div.col2 {float:right;}
  div.menor {float:left; width:60px;}
  div.medio {float:left; width:153px;}
  div.maior {float:left; width:250px; white-space:normal; margin-right:5px;}
  ins {float:left;}
  div#theader {font-weight:bold;}
  div#blocos {overflow:hidden;}
  
  div#blocos ul ul ul .jstree-icon {
    display:none;
  }
  div#blocos ul ul ul li {
    background: inherit;
  }
  div.col2 table {
    width: 1162px;
	line-height: 4px;
	margin: 0;
	padding: 0;
	font-size: 8px;
	border: 1px gray solid;
    border-collapse: collapse;
  }
  div.col2 table th {
    border-bottom:1px gray solid;
    background-color:#f1f1f1;
    border-collapse: collapse;
  }
  div.col2 table .th_1 div{
    width:80px;
  }
  div.col2 table .th_2 div{
    width:180px;
  }
  div.col2 table .th_3 div{
    width:55px;
  }
  div.col2 table .th_4 div{
    width:130px;
  }
  div.col2 table .th_5 div{
    width:90px;
  }
  div.col2 table .th_6 div{
    width:90px;
  }
  div.col2 table .th_7 div{
    width:80px;
  }
  div.col2 table .th_8 div{
    width:60px;
  }
  div.col2 table a {
    height:inherit;
    line-height:inherit;
	display: block;
	text-decoration: none;
	padding: 0;
	margin: 0;
  }
  </style>
{% endblock %}
{% block extrahead %}
<script type="text/javascript" src="{% static "js/jstree/_lib/jquery.js" %}"></script>
<script type="text/javascript" src="{% static "js/jstree/jquery.jstree.js" %}"></script>
<script type="text/javascript" src="{% static "js/jstree.js" %}"></script>
{% endblock %}
{% block breadcrumbs %}
    <div class="breadcrumbs">Você está em: 
      <a href="../../">{% trans "Home" %}</a> &rsaquo; 
      <a href="{% url 'patrimonio.views.por_tipo_equipamento2' %}">Patrimônio por tipo de equipamento</a>
    </div>
{% endblock %}
{% block content %}
    <h1>Patrimônio por tipo de equipamento</h1>
    <div id="theader">
        <div style="clear:both;"> </div>
    </div>
    <div id="blocos"> </div>
    <script type="text/javascript">
        $(function() {
            $("#blocos").jstree({
                json_data : {
                    ajax: {
                        url: function(node) {
                             if (node == -1){
                                 return '{% url "patrimonio.views.ajax_abre_arvore_tipo" %}';
                             } else if (node.attr("o_id")) {
                                 return '{% url "patrimonio.views.ajax_abre_arvore_tipo" %}?id='+node.attr("o_id")+'&model='+node.attr("o_model");
                             }
                             return 'http://#'; // invalidando o disparo da URL se não houver atributo válido para a chamada AJAX.
                        },
                        type:"get",
                        success: function(ops) {
                        data = [];
                            for (opnum in ops) {
                                var op = ops[opnum];
                                node = {"data":op["data"], "attr":op["attr"], "state":"closed"};
                                data.push(node);
                            }
                            if (ops && ops.length == 0) {
                                data.push('Não foram encontrados dados para a exibição.');
                            }
                            return data;
                        }
                    }
                },
                core : {"html_titles" : true,  "load_open" : true },
                plugins : [ "themes", "json_data"]
            });
        });
    </script>
{% endblock %}
