Browse Source

adicionando relatorios de ssadm

stable/1.0
Felipe Vieira 13 years ago
parent
commit
4810f9a415
  1. 33
      sigi/apps/servidores/views.py
  2. 20
      sigi/templates/admin/servidores/servidor/change_list.html
  3. 84
      sigi/templates/base_report.html
  4. 50
      sigi/templates/servidores/servidores_por_cargo.html
  5. 50
      sigi/templates/servidores/servidores_por_funcao.html
  6. 5
      sigi/urls.py

33
sigi/apps/servidores/views.py

@ -0,0 +1,33 @@
# -*- coding: utf8 -*-
import new
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.db.models import Avg, Max, Min, Count
from sigi.apps.servidores.models import Servidor, Funcao
from sigi.shortcuts import render_to_pdf
def servidores_por_funcao(request):
report = Funcao.objects.values('funcao').annotate(funcao__count=Count('funcao')).order_by('funcao__count')
total = Funcao.objects.count()
context = RequestContext(request, {
'pagesize':'A4',
'report': report,
'total': total
})
return render_to_pdf('servidores/servidores_por_funcao.html', context)
def servidores_por_cargo(request):
report = Funcao.objects.values('cargo').annotate(cargo__count=Count('cargo')).order_by('cargo__count')
total = Funcao.objects.count()
context = RequestContext(request, {
'pagesize':'A4',
'report': report,
'total': total
})
return render_to_pdf('servidores/servidores_por_cargo.html', context)

20
sigi/templates/admin/servidores/servidor/change_list.html

@ -0,0 +1,20 @@
{% extends 'admin/change_list.html' %}
{% load i18n reporting_tags %}
{% block object-tools %}
<ul class="object-tools">
<li>
<a href="/sigi/servidores/servidores_por_cargo.pdf" class="historylink">Relatório por cargo</a>
</li>
<li>
<a href="/sigi/servidores/servidores_por_funcao.pdf" class="historylink">Relatório por função</a>
</li>
{% if has_add_permission %}
<li>
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
</a>
</li>
{% endif %}
</ul>
{% endblock %}

84
sigi/templates/base_report.html

@ -0,0 +1,84 @@
{% load smart_if %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Title</title>
<style type="text/css">
td.logo {
text-align: center;
}
td.header_text p {
margin: 0px;
font-size: 1.4em;
}
td.header_text {
width: 550px;
}
h1 {
font-size: 2em;
text-align: center;
}
h2 {
font-size: 1.7em;
}
h3 {
margin-top: 10px;
margin-bottom: 0px;
}
body {
font-family: "Helvetica, Arial, sans-serif";
font-size: 1.3em;
line-height: 1em;
}
div.new_page {
page-break-before: always;
}
div.same_page {
-pdf-keep-with-next: true;
}
@page {
size: {{ pagesize }};
margin: 4cm 1cm 1cm 2cm;
font-family: "Helvetica, Arial, sans-serif";
font-size: 2em;
@frame header {
-pdf-frame-content: header;
top: 1cm;
}
@frame footer {
-pdf-frame-content: footer;
bottom: 0cm;
margin-left: 9cm;
margin-right: 9cm;
height: 1cm;
}
}
</style>
{% block extra_head %}
{% endblock %}
</head>
<body>
<div id="header">
<table>
<tr>
<td class="logo"><img src="{{MEDIA_URL}}images/logo-senado.jpg"/></td>
<td class="header_text">
<p><strong>SENADO FEDERAL</strong></p>
<p><strong>SECRETARIA ESPECIAL DO INTERLEGIS – SINTER</strong></p>
<p>{% block subsecretaria %}{% endblock %}</p>
</td>
<td class="logo"><img src="{{MEDIA_URL}}images/logo-interlegis.jpg"/></td>
</tr>
</table>
</div>
{% block report %}
{% endblock %}
<div id="footer">
{%block page_foot%}
Página <pdf:pagenumber>
{%endblock%}
</div>
</body>
</html>

50
sigi/templates/servidores/servidores_por_cargo.html

@ -0,0 +1,50 @@
{% extends "base_report.html" %}
{% block extra_head %}
<style type="text/css">
tr.title {
text-align: center;
font-size: 1.2em;
border-bottom: 2px black solid;
}
tr.data {
padding: 2px 5px;
border-bottom: 1px gray solid;
}
tr.total {
font-weight: bold;
}
td.index {
width: 50px;
}
</style>
{% endblock %}
{% block subsecretaria %}
SUBSECRETARIA DE ADMINISTRAÇÃO – SSADM
{% endblock %}
{% block report %}
<div>
<h1>Relatório de Servidores por Cargo</h1>
<table class="report">
<tr class="title">
<td class="index"></td>
<td>Cargo</td>
<td>Servidores</td>
</tr>
{% for r in report %}
<tr class="data">
<td>{{ forloop.counter }}</td>
<td>{{ r.cargo }}</td>
<td>{{ r.cargo__count }}</td>
</tr>
{% endfor %}
<tr class="data total">
<td></td>
<td>Total</td>
<td>{{ total }}</td>
</tr>
</table>
</div>
{% endblock %}

50
sigi/templates/servidores/servidores_por_funcao.html

@ -0,0 +1,50 @@
{% extends "base_report.html" %}
{% block extra_head %}
<style type="text/css">
tr.title {
text-align: center;
font-size: 1.2em;
border-bottom: 2px black solid;
}
tr.data {
padding: 2px 5px;
border-bottom: 1px gray solid;
}
tr.total {
font-weight: bold;
}
td.index {
width: 50px;
}
</style>
{% endblock %}
{% block subsecretaria %}
SUBSECRETARIA DE ADMINISTRAÇÃO – SSADM
{% endblock %}
{% block report %}
<div>
<h1>Relatório de Servidores por Função</h1>
<table class="report">
<tr class="title">
<td class="index"></td>
<td>Função</td>
<td>Servidores</td>
</tr>
{% for r in report %}
<tr class="data">
<td>{{ forloop.counter }}</td>
<td>{{ r.funcao }}</td>
<td>{{ r.funcao__count }}</td>
</tr>
{% endfor %}
<tr class="data total">
<td></td>
<td>Total</td>
<td>{{ total }}</td>
</tr>
</table>
</div>
{% endblock %}

5
sigi/urls.py

@ -41,6 +41,11 @@ urlpatterns = patterns(
# reports diagnosticos # reports diagnosticos
(r'^sigi/diagnosticos/diagnostico/(?P<id_diagnostico>\w+).pdf', (r'^sigi/diagnosticos/diagnostico/(?P<id_diagnostico>\w+).pdf',
'sigi.apps.diagnosticos.views.diagnostico_pdf'), 'sigi.apps.diagnosticos.views.diagnostico_pdf'),
# reports servidores
(r'^sigi/servidores/servidores_por_funcao.pdf',
'sigi.apps.servidores.views.servidores_por_funcao'),
(r'^sigi/servidores/servidores_por_cargo.pdf',
'sigi.apps.servidores.views.servidores_por_cargo'),
#Carrinho Casa #Carrinho Casa
(r'^sigi/casas/casalegislativa/carrinho/deleta_itens_carrinho', (r'^sigi/casas/casalegislativa/carrinho/deleta_itens_carrinho',
'sigi.apps.casas.views.deleta_itens_carrinho'), 'sigi.apps.casas.views.deleta_itens_carrinho'),

Loading…
Cancel
Save