|
|
@ -1,4 +1,4 @@ |
|
|
|
##parameters=sessao,imagem,dat_ordem,lst_splen,lst_pauta,dic_cabecalho,lst_rodape |
|
|
|
# parameters=sessao,imagem,dat_ordem,lst_splen,lst_pauta,dic_cabecalho,lst_rodape |
|
|
|
|
|
|
|
"""relatorio_ordem.py |
|
|
|
External method para gerar o arquivo rml da ordem do dia |
|
|
@ -8,7 +8,6 @@ |
|
|
|
""" |
|
|
|
import os |
|
|
|
import time |
|
|
|
from cStringIO import StringIO |
|
|
|
|
|
|
|
from trml2pdf import parseString |
|
|
|
|
|
|
@ -17,14 +16,17 @@ def cabecalho(dic_cabecalho,dat_ordem,imagem): |
|
|
|
"""Gera o codigo rml do cabecalho""" |
|
|
|
|
|
|
|
tmp = '' |
|
|
|
tmp+='\t\t\t\t<image x="2.1cm" y="25.7cm" width="59" height="62" file="' + imagem + '"/>\n' |
|
|
|
tmp += '\t\t\t\t<image x="2.1cm" y="25.7cm" width="59" height="62" file="' + \ |
|
|
|
imagem + '"/>\n' |
|
|
|
tmp += '\t\t\t\t<lines>2cm 25cm 19cm 25cm</lines>\n' |
|
|
|
tmp += '\t\t\t\t<setFont name="Helvetica" size="12"/>\n' |
|
|
|
#tmp+='\t\t\t\t<drawString x="4cm" y="27.2cm">' + str(dic_cabecalho['nom_casa']) + '</drawString>\n' |
|
|
|
#tmp+='\t\t\t\t<setFont name="Helvetica" size="14"/>\n' |
|
|
|
tmp+='\t\t\t\t<drawString x="5cm" y="27.2cm">' + str(dic_cabecalho['nom_estado']) + '</drawString>\n' |
|
|
|
tmp += '\t\t\t\t<drawString x="5cm" y="27.2cm">' + \ |
|
|
|
str(dic_cabecalho['nom_estado']) + '</drawString>\n' |
|
|
|
tmp += '\t\t\t\t<setFont name="Helvetica" size="14"/>\n' |
|
|
|
tmp+='\t\t\t\t<drawString x="5cm" y="26.5cm">' + str(dic_cabecalho['nom_casa']) + '</drawString>\n' |
|
|
|
tmp += '\t\t\t\t<drawString x="5cm" y="26.5cm">' + \ |
|
|
|
str(dic_cabecalho['nom_casa']) + '</drawString>\n' |
|
|
|
tmp += '\t\t\t\t<setFont name="Helvetica" size="14"/>\n' |
|
|
|
#tmp+='\t\t\t\t<drawString x="5cm" y="27.9cm">' + "Palacio 11 de Outubro" + '</drawString>\n' |
|
|
|
#tmp+='\t\t\t\t<setFont name="Helvetica" size="10"/>\n' |
|
|
@ -33,19 +35,24 @@ def cabecalho(dic_cabecalho,dat_ordem,imagem): |
|
|
|
|
|
|
|
return tmp |
|
|
|
|
|
|
|
|
|
|
|
def rodape(lst_rodape): |
|
|
|
""" Gera o codigo rml do rodape""" |
|
|
|
|
|
|
|
tmp = '' |
|
|
|
tmp += '\t\t\t\t<lines>2cm 3.2cm 19cm 3.2cm</lines>\n' |
|
|
|
tmp += '\t\t\t\t<setFont name="Helvetica" size="8"/>\n' |
|
|
|
tmp+='\t\t\t\t<drawString x="2cm" y="3.3cm">' + lst_rodape[2] + '</drawString>\n' |
|
|
|
tmp += '\t\t\t\t<drawString x="2cm" y="3.3cm">' + \ |
|
|
|
lst_rodape[2] + '</drawString>\n' |
|
|
|
tmp += '\t\t\t\t<drawString x="17.9cm" y="3.3cm">Página <pageNumber/></drawString>\n' |
|
|
|
tmp+='\t\t\t\t<drawCentredString x="10.5cm" y="2.7cm">' + lst_rodape[0] + '</drawCentredString>\n' |
|
|
|
tmp+='\t\t\t\t<drawCentredString x="10.5cm" y="2.3cm">' + lst_rodape[1] + '</drawCentredString>\n' |
|
|
|
tmp += '\t\t\t\t<drawCentredString x="10.5cm" y="2.7cm">' + \ |
|
|
|
lst_rodape[0] + '</drawCentredString>\n' |
|
|
|
tmp += '\t\t\t\t<drawCentredString x="10.5cm" y="2.3cm">' + \ |
|
|
|
lst_rodape[1] + '</drawCentredString>\n' |
|
|
|
|
|
|
|
return tmp |
|
|
|
|
|
|
|
|
|
|
|
def paraStyle(): |
|
|
|
""" Gera o codigo rml que define o estilo dos paragrafos""" |
|
|
|
|
|
|
@ -66,6 +73,8 @@ def paraStyle(): |
|
|
|
return tmp |
|
|
|
|
|
|
|
# def splen(lst_splen): |
|
|
|
|
|
|
|
|
|
|
|
def pauta(lst_splen, lst_pauta): |
|
|
|
""" Funcao que gera o codigo rml da sessao plenaria """ |
|
|
|
|
|
|
@ -88,13 +97,15 @@ def pauta(lst_splen, lst_pauta): |
|
|
|
|
|
|
|
# sessao plenaria |
|
|
|
if dicsp['sessao'] != None: |
|
|
|
tmp+='\t\t<para style="P1">' + dicsp['sessao'].replace('&','&') + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P1">' + \ |
|
|
|
dicsp['sessao'].replace('&', '&') + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P1">\n' |
|
|
|
tmp += '\t\t\t<font color="white"> </font>\n' |
|
|
|
tmp += '\t\t</para>\n' |
|
|
|
|
|
|
|
if dicsp['datasessao'] != None: |
|
|
|
tmp+='\t\t<para style="P1">' + dicsp['datasessao'].replace('&','&') + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P1">' + \ |
|
|
|
dicsp['datasessao'].replace('&', '&') + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P1">\n' |
|
|
|
tmp += '\t\t\t<font color="white"> </font>\n' |
|
|
|
tmp += '\t\t</para>\n' |
|
|
@ -124,25 +135,31 @@ def pauta(lst_splen, lst_pauta): |
|
|
|
|
|
|
|
# pauta |
|
|
|
if dic['num_ordem'] != None: |
|
|
|
tmp+='\t\t<para style="P2">Item nº ' + str(dic['num_ordem']) + '</para>' |
|
|
|
tmp += '\t\t<para style="P2">Item nº ' + \ |
|
|
|
str(dic['num_ordem']) + '</para>' |
|
|
|
if dic['id_materia'] != None: |
|
|
|
tmp += '\t\t<para style="P1">' + dic['id_materia'] + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P1">\n' |
|
|
|
tmp += '\t\t\t<font color="white"> </font>\n' |
|
|
|
tmp += '\t\t</para>\n' |
|
|
|
if dic['txt_ementa'] != None: |
|
|
|
tmp+='\t\t<para style="P3">' + dic['txt_ementa'].replace('&','&') + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P3">' + \ |
|
|
|
dic['txt_ementa'].replace('&', '&') + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P3">\n' |
|
|
|
tmp += '\t\t\t<font color="white"> </font>\n' |
|
|
|
tmp += '\t\t</para>\n' |
|
|
|
if dic['des_numeracao'] != None: |
|
|
|
tmp+='\t\t<para style="P2"><b>Processo:</b> ' + dic['des_numeracao'] + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P2"><b>Processo:</b> ' + \ |
|
|
|
dic['des_numeracao'] + '</para>\n' |
|
|
|
if dic['des_turno'] != None: |
|
|
|
tmp+='\t\t<para style="P2"><b>Turno:</b> ' + dic['des_turno'] + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P2"><b>Turno:</b> ' + \ |
|
|
|
dic['des_turno'] + '</para>\n' |
|
|
|
if dic['nom_autor'] != None: |
|
|
|
tmp+='\t\t<para style="P2"><b>Autor:</b> ' + dic['nom_autor'] + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P2"><b>Autor:</b> ' + \ |
|
|
|
dic['nom_autor'] + '</para>\n' |
|
|
|
if dic['des_situacao'] != None: |
|
|
|
tmp+='\t\t<para style="P2"><b>Situação:</b> ' + dic['des_situacao'] + '</para>\n' |
|
|
|
tmp += '\t\t<para style="P2"><b>Situação:</b> ' + \ |
|
|
|
dic['des_situacao'] + '</para>\n' |
|
|
|
# if dic['des_numeracao']!=None: |
|
|
|
# tmp+='\t\t<para style="P2"><b>Processo Nº:</b> ' + dic['des_numeracao'] + '</para>\n' |
|
|
|
|
|
|
@ -159,6 +176,7 @@ def pauta(lst_splen, lst_pauta): |
|
|
|
tmp += '\t</story>\n' |
|
|
|
return tmp |
|
|
|
|
|
|
|
|
|
|
|
def principal(sessao, imagem, dat_ordem, lst_splen, lst_pauta, dic_cabecalho, lst_rodape): |
|
|
|
"""Funcao principal que gera a estrutura global do arquivo rml contendo o relatorio de uma ordem do dia. |
|
|
|
ordem_dia_[data da ordem do dia do relatório].pdf |
|
|
@ -190,21 +208,22 @@ def principal(sessao,imagem,dat_ordem,lst_splen,lst_pauta,dic_cabecalho,lst_roda |
|
|
|
# tmp+=splen(lst_splen) |
|
|
|
tmp += pauta(lst_splen, lst_pauta) |
|
|
|
tmp += '</document>\n' |
|
|
|
|
|
|
|
tmp_pdf = parseString(tmp) |
|
|
|
|
|
|
|
return tmp_pdf |
|
|
|
|
|
|
|
# try: |
|
|
|
# tmp_pdf=parseString(unicode(tmp, 'utf-8')) |
|
|
|
# except: |
|
|
|
# tmp_pdf=parseString(unicode(tmp, 'utf-8')) |
|
|
|
# # try: |
|
|
|
# # tmp_pdf=parseString(unicode(tmp, 'utf-8')) |
|
|
|
# # except: |
|
|
|
# # tmp_pdf=parseString(unicode(tmp, 'utf-8')) |
|
|
|
|
|
|
|
if hasattr(context.temp_folder,arquivoPdf): |
|
|
|
context.temp_folder.manage_delObjects(ids=arquivoPdf) |
|
|
|
context.temp_folder.manage_addFile(arquivoPdf) |
|
|
|
arq=context.temp_folder[arquivoPdf] |
|
|
|
arq.manage_edit(title='Arquivo PDF temporário.',filedata=tmp_pdf,content_type='application/pdf') |
|
|
|
# if hasattr(context.temp_folder, arquivoPdf): |
|
|
|
# context.temp_folder.manage_delObjects(ids=arquivoPdf) |
|
|
|
# context.temp_folder.manage_addFile(arquivoPdf) |
|
|
|
# arq = context.temp_folder[arquivoPdf] |
|
|
|
# arq.manage_edit(title='Arquivo PDF temporário.', |
|
|
|
# filedata=tmp_pdf, content_type='application/pdf') |
|
|
|
|
|
|
|
return "/temp_folder/"+arquivoPdf |
|
|
|
# return "/temp_folder/" + arquivoPdf |
|
|
|
|
|
|
|
return principal(sessao,imagem,dat_ordem,lst_splen,lst_pauta,dic_cabecalho,lst_rodape) |
|
|
|
# return principal(sessao, imagem, dat_ordem, lst_splen, lst_pauta, dic_cabecalho, lst_rodape) |
|
|
|