@ -3,43 +3,46 @@ from reportlab.lib.pagesizes import A4
from reportlab . lib . units import cm
from reportlab . lib . units import cm
from reportlab . lib . enums import TA_CENTER , TA_RIGHT
from reportlab . lib . enums import TA_CENTER , TA_RIGHT
from geraldo import Report , DetailBand , Label , ObjectValue , ManyElements , \
from geraldo import Report , DetailBand , Label , ObjectValue , ManyElements , \
ReportGroup , ReportBand , landscape , SubReport , BAND_WIDTH , SystemField
ReportGroup , ReportBand , landscape , SubReport , BAND_WIDTH , SystemField
from sigi . apps . relatorios . reports import ReportDefault
from sigi . apps . relatorios . reports import ReportDefault
from geraldo . graphics import Image
from geraldo . graphics import Image
def string_to_cm ( texto ) :
def string_to_cm ( texto ) :
tamanho = 0
tamanho = 0
minEspeciais = {
minEspeciais = {
' f ' : 0.1 ,
' f ' : 0.1 ,
' i ' : 0.05 ,
' i ' : 0.05 ,
' j ' : 0.05 ,
' j ' : 0.05 ,
' l ' : 0.05 ,
' l ' : 0.05 ,
' m ' : 0.2 ,
' m ' : 0.2 ,
' r ' : 0.1 ,
' r ' : 0.1 ,
' t ' : 0.15 ,
' t ' : 0.15 ,
}
}
maiuEspeciais = {
maiuEspeciais = {
' I ' : 0.05 ,
' I ' : 0.05 ,
' J ' : 0.15 ,
' J ' : 0.15 ,
' L ' : 0.15 ,
' L ' : 0.15 ,
' P ' : 0.15 ,
' P ' : 0.15 ,
}
}
for c in texto :
for c in texto :
if c > ' a ' and c < ' z ' :
if c > ' a ' and c < ' z ' :
if c in minEspeciais :
if c in minEspeciais :
tamanho + = minEspeciais [ c ]
tamanho + = minEspeciais [ c ]
else :
else :
tamanho + = 0.17
tamanho + = 0.17
else :
else :
if c in maiuEspeciais :
if c in maiuEspeciais :
tamanho + = maiuEspeciais [ c ]
tamanho + = maiuEspeciais [ c ]
else :
else :
tamanho + = 0.2
tamanho + = 0.2
return tamanho
return tamanho
class ParlamentaresLabels ( Report ) :
class ParlamentaresLabels ( Report ) :
"""
"""
Usage example : :
Usage example : :
@ -54,26 +57,26 @@ class ParlamentaresLabels(Report):
largura_etiqueta = 7
largura_etiqueta = 7
altura_etiqueta = 3.3
altura_etiqueta = 3.3
tamanho_fonte = 6.4
tamanho_fonte = 6.4
altura_dados = 0.3 #logradouro, bairro, municipio, cep
altura_dados = 0.3 # logradouro, bairro, municipio, cep
delta = start = 0.5
delta = start = 0.5
def __init__ ( self , queryset , formato ) :
def __init__ ( self , queryset , formato ) :
super ( ParlamentaresLabels , self ) . __init__ ( queryset = queryset )
super ( ParlamentaresLabels , self ) . __init__ ( queryset = queryset )
self . formato = formato
self . formato = formato
self . page_size = A4
self . page_size = A4
if formato == ' 3x9_etiqueta ' :
if formato == ' 3x9_etiqueta ' :
self . margin_top = 0.0 * cm
self . margin_top = 0.0 * cm
self . margin_bottom = 0.0 * cm
self . margin_bottom = 0.0 * cm
self . margin_left = - 1 * cm
self . margin_left = - 1 * cm
self . margin_right = 0.0 * cm
self . margin_right = 0.0 * cm
self . delta = 0.4 # espaçamento entre as "strings/linhas" da etiqueta
self . delta = 0.4 # espaçamento entre as "strings/linhas" da etiqueta
self . start = 0.2 # valor entre a margin top e a etiqueta
self . start = 0.2 # valor entre a margin top e a etiqueta
else :
else :
self . margin_top = 0.8 * cm
self . margin_top = 0.8 * cm
self . margin_bottom = 0.8 * cm
self . margin_bottom = 0.8 * cm
self . margin_left = 0.4 * cm
self . margin_left = 0.4 * cm
self . margin_right = 0.4 * cm
self . margin_right = 0.4 * cm
self . largura_etiqueta = 9.9
self . largura_etiqueta = 9.9
self . altura_etiqueta = 5.6
self . altura_etiqueta = 5.6
self . tamanho_fonte = 11
self . tamanho_fonte = 11
@ -83,457 +86,461 @@ class ParlamentaresLabels(Report):
my_elements = [
my_elements = [
Label (
Label (
text = u ' A Sua Excelência o(a) Senhor(a) ' ,
text = u ' A Sua Excelência o(a) Senhor(a) ' ,
top = ( self . start + self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
top = ( self . start + self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' nome_completo ' ,
attribute_name = ' nome_completo ' ,
top = ( self . start + 2 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
top = ( self . start + 2 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
get_value = lambda instance :
get_value = lambda instance :
instance . nome_completo or " "
instance . nome_completo or " "
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' logradouro ' ,
attribute_name = ' logradouro ' ,
top = ( self . start + 3 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
top = ( self . start + 3 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
get_value = lambda instance :
get_value = lambda instance :
logradouro_parlamentar ( instance )
logradouro_parlamentar ( instance )
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' bairro ' ,
attribute_name = ' bairro ' ,
top = ( self . start + 4 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
top = ( self . start + 4 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
get_value = lambda instance :
get_value = lambda instance :
bairro_parlamentar ( instance )
bairro_parlamentar ( instance )
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' municipio ' ,
attribute_name = ' municipio ' ,
top = ( self . start + 5 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
top = ( self . start + 5 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
get_value = lambda instance :
get_value = lambda instance :
municipio_parlamentar ( instance )
municipio_parlamentar ( instance )
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' cep ' ,
attribute_name = ' cep ' ,
top = ( self . start + 6 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
top = ( self . start + 6 * self . delta ) * cm , left = self . y * cm , width = ( self . largura_etiqueta - self . y ) * cm ,
get_value = lambda instance :
get_value = lambda instance :
cep_parlamentar ( instance )
cep_parlamentar ( instance )
) ,
) ,
]
]
self . band_detail = DetailBand ( width = ( self . largura_etiqueta ) * cm , height = ( self . altura_etiqueta ) * cm , margin_left = 0 , margin_top = 0 , margin_bottom = 0.0 * cm , margin_right = 0 , elements = my_elements , display_inline = True , default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : self . tamanho_fonte } )
self . band_detail = DetailBand ( width = ( self . largura_etiqueta ) * cm , height = ( self . altura_etiqueta ) * cm , margin_left = 0 , margin_top = 0 , margin_bottom = 0.0 * cm , margin_right = 0 , elements = my_elements , display_inline = True , default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : self . tamanho_fonte } )
def logradouro_parlamentar ( instance ) :
def logradouro_parlamentar ( instance ) :
try :
try :
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . logradouro
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . logradouro
except :
except :
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
def bairro_parlamentar ( instance ) :
def bairro_parlamentar ( instance ) :
try :
try :
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . bairro
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . bairro
except :
except :
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
def municipio_parlamentar ( instance ) :
def municipio_parlamentar ( instance ) :
try :
try :
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . municipio
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . municipio
except :
except :
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
def cep_parlamentar ( instance ) :
def cep_parlamentar ( instance ) :
try :
try :
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . cep
return instance . mandato_set . latest ( ' inicio_mandato ' ) . legislatura . casa_legislativa . cep
except :
except :
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
return u " <<PARLAMENTAR SEM MANDATO - impossivel definir endereço>> "
class CasasLegislativasReport ( ReportDefault ) :
class CasasLegislativasReport ( ReportDefault ) :
title = u ' Relatório de Casas Legislativas '
title = u ' Relatório de Casas Legislativas '
height = 80 * cm
height = 80 * cm
page_size = landscape ( A4 )
page_size = landscape ( A4 )
class band_page_header ( ReportDefault . band_page_header ) :
class band_page_header ( ReportDefault . band_page_header ) :
label_top = ReportDefault . band_page_header . label_top
label_top = ReportDefault . band_page_header . label_top
label_left = [ 0.3 , 1 , 5.5 , 11 , 17 , 22 ]
label_left = [ 0.3 , 1 , 5.5 , 11 , 17 , 22 ]
elements = list ( ReportDefault . band_page_header . elements )
elements = list ( ReportDefault . band_page_header . elements )
elements = [
elements = [
Image ( filename = ReportDefault . band_page_header . BASE_DIR + ' /media/images/logo-interlegis.jpg ' ,
Image ( filename = ReportDefault . band_page_header . BASE_DIR + ' /media/images/logo-interlegis.jpg ' ,
left = 23.5 * cm , right = 1 * cm , top = 0.1 * cm , bottom = 1 * cm ,
left = 23.5 * cm , right = 1 * cm , top = 0.1 * cm , bottom = 1 * cm ,
width = 4.2 * cm , height = 3 * cm ,
width = 4.2 * cm , height = 3 * cm ,
) ,
) ,
Image ( filename = ReportDefault . band_page_header . BASE_DIR + ' /media/images/logo-senado.png ' ,
Image ( filename = ReportDefault . band_page_header . BASE_DIR + ' /media/images/logo-senado.png ' ,
left = 1 * cm , right = 1 * cm , top = 0.1 * cm , bottom = 1 * cm ,
left = 1 * cm , right = 1 * cm , top = 0.1 * cm , bottom = 1 * cm ,
width = 3 * cm , height = 3 * cm ,
width = 3 * cm , height = 3 * cm ,
) ,
) ,
Label ( text = u " SENADO FEDERAL " , top = 1 * cm , left = 0 , width = BAND_WIDTH ,
Label ( text = u " SENADO FEDERAL " , top = 1 * cm , left = 0 , width = BAND_WIDTH ,
style = { ' fontName ' : ' Helvetica-Bold ' , ' fontSize ' : 14 , ' alignment ' : TA_CENTER }
style = { ' fontName ' : ' Helvetica-Bold ' , ' fontSize ' : 14 , ' alignment ' : TA_CENTER }
) ,
) ,
Label ( text = u " SINTER - Secretaria Especial do Interlegis " , top = 1.5 * cm , left = 0 , width = BAND_WIDTH ,
Label ( text = u " SINTER - Secretaria Especial do Interlegis " , top = 1.5 * cm , left = 0 , width = BAND_WIDTH ,
style = { ' fontName ' : ' Helvetica-Bold ' , ' fontSize ' : 13 , ' alignment ' : TA_CENTER }
style = { ' fontName ' : ' Helvetica-Bold ' , ' fontSize ' : 13 , ' alignment ' : TA_CENTER }
) ,
) ,
SystemField (
SystemField (
expression = ' %(report_title)s ' , top = 2.5 * cm , left = 0 , width = BAND_WIDTH ,
expression = ' %(report_title)s ' , top = 2.5 * cm , left = 0 , width = BAND_WIDTH ,
style = { ' fontName ' : ' Helvetica-Bold ' , ' fontSize ' : 14 , ' alignment ' : TA_CENTER }
style = { ' fontName ' : ' Helvetica-Bold ' , ' fontSize ' : 14 , ' alignment ' : TA_CENTER }
) ,
) ,
Label (
Label (
text = u " UF " ,
text = u " UF " ,
left = label_left [ 0 ] * cm ,
left = label_left [ 0 ] * cm ,
top = label_top ,
top = label_top ,
) ,
) ,
Label (
Label (
text = u " Municipio " ,
text = u " Municipio " ,
left = label_left [ 1 ] * cm ,
left = label_left [ 1 ] * cm ,
top = label_top ,
top = label_top ,
) ,
) ,
Label (
Label (
text = u " Presidente " ,
text = u " Presidente " ,
left = label_left [ 2 ] * cm ,
left = label_left [ 2 ] * cm ,
top = label_top ,
top = label_top ,
) ,
) ,
Label (
Label (
text = u " Endereço " ,
text = u " Endereço " ,
left = label_left [ 3 ] * cm ,
left = label_left [ 3 ] * cm ,
top = label_top ,
top = label_top ,
) ,
) ,
Label (
Label (
text = u " Endereço na Internet " ,
text = u " Endereço na Internet " ,
left = label_left [ 4 ] * cm ,
left = label_left [ 4 ] * cm ,
top = label_top ,
top = label_top ,
) ,
) ,
Label (
Label (
text = u " Email " ,
text = u " Email " ,
left = label_left [ 5 ] * cm ,
left = label_left [ 5 ] * cm ,
top = label_top ,
top = label_top ,
) ,
) ,
]
]
class band_page_footer ( ReportDefault . band_page_footer ) :
class band_page_footer ( ReportDefault . band_page_footer ) :
pass
pass
class band_detail ( ReportDefault . band_detail ) :
class band_detail ( ReportDefault . band_detail ) :
label_left = [ 0.3 , 1 , 5.5 , 11 , 17 , 22 ]
label_left = [ 0.3 , 1 , 5.5 , 11 , 17 , 22 ]
elements = [
elements = [
ObjectValue (
ObjectValue (
attribute_name = ' municipio.uf.sigla ' ,
attribute_name = ' municipio.uf.sigla ' ,
left = label_left [ 0 ] * cm ,
left = label_left [ 0 ] * cm ,
width = 1 * cm ,
width = 1 * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' municipio.nome ' ,
attribute_name = ' municipio.nome ' ,
left = label_left [ 1 ] * cm ,
left = label_left [ 1 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' presidente ' ,
attribute_name = ' presidente ' ,
left = label_left [ 2 ] * cm ,
left = label_left [ 2 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' logradouro ' ,
attribute_name = ' logradouro ' ,
left = label_left [ 3 ] * cm ,
left = label_left [ 3 ] * cm ,
get_value = lambda instance : instance . logradouro + ' - ' + instance . bairro ,
get_value = lambda instance : instance . logradouro + ' - ' + instance . bairro ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' pagina_web ' ,
attribute_name = ' pagina_web ' ,
left = label_left [ 4 ] * cm ,
left = label_left [ 4 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' email ' ,
attribute_name = ' email ' ,
left = label_left [ 5 ] * cm ,
left = label_left [ 5 ] * cm ,
) ,
) ,
]
]
groups = [
groups = [
ReportGroup ( attribute_name = ' municipio.uf ' ,
ReportGroup ( attribute_name = ' municipio.uf ' ,
band_header = ReportBand (
band_header = ReportBand (
height = 0.7 * cm ,
height = 0.7 * cm ,
elements = [
elements = [
ObjectValue ( attribute_name = ' municipio.uf ' )
ObjectValue ( attribute_name = ' municipio.uf ' )
] ,
] ,
borders = { ' top ' : True } ,
borders = { ' top ' : True } ,
)
)
)
)
]
]
class InfoCasaLegislativa ( ReportDefault ) :
class InfoCasaLegislativa ( ReportDefault ) :
title = u ' Casa legislativa '
title = u ' Casa legislativa '
class band_summary ( ReportBand ) :
class band_summary ( ReportBand ) :
pass
pass
class band_page_footer ( ReportBand ) :
class band_page_footer ( ReportBand ) :
height = 1 * cm
height = 1 * cm
elements = [
elements = [
SystemField ( expression = u ' % (now: %d / % m/ % Y)s às % (now: % H: % M)s ' , top = 0.3 * cm ) ,
SystemField ( expression = u ' % (now: %d / % m/ % Y)s às % (now: % H: % M)s ' , top = 0.3 * cm ) ,
]
]
class band_detail ( ReportDefault . band_detail ) :
class band_detail ( ReportDefault . band_detail ) :
posicao_left = [
posicao_left = [
0 , 1.3 , #Tipo
0 , 1.3 , # Tipo
0 , 1.8 , #Regiao
0 , 1.8 , # Regiao
5.5 , 6.8 , #U.F.
5.5 , 6.8 , # U.F.
0 , 2.3 , #Municipio
0 , 2.3 , # Municipio
0 , 2.4 , #Endereco
0 , 2.4 , # Endereco
0 , 1.6 , #Bairro
0 , 1.6 , # Bairro
0 , 1.3 , #CEP
0 , 1.3 , # CEP
0 , 1.6 , #CNPJ
0 , 1.6 , # CNPJ
0 , 2.3 , #Telefone
0 , 2.3 , # Telefone
0 , 2.7 , #Presidente
0 , 2.7 , # Presidente
]
]
posicao_top = [
posicao_top = [
0.5 , #Tipo
0.5 , # Tipo
1.3 , #Regiao
1.3 , # Regiao
1.3 , #U.F.
1.3 , # U.F.
2.1 , #Municipio
2.1 , # Municipio
2.9 , #Logradouro
2.9 , # Logradouro
3.7 , #Bairro
3.7 , # Bairro
4.5 , #CEP
4.5 , # CEP
5.3 , #CNPJ
5.3 , # CNPJ
6.1 , #Telefone
6.1 , # Telefone
6.9 , #Presidente
6.9 , # Presidente
]
]
height = 30 * cm
height = 30 * cm
display_inline = True
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 14 }
display_inline = True
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 14 }
elements = [
elements = [
Label (
Label (
text = u " Tipo: " ,
text = u " Tipo: " ,
left = posicao_left [ 0 ] * cm ,
left = posicao_left [ 0 ] * cm ,
top = posicao_top [ 0 ] * cm ,
top = posicao_top [ 0 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' tipo.nome ' ,
attribute_name = ' tipo.nome ' ,
left = posicao_left [ 1 ] * cm ,
left = posicao_left [ 1 ] * cm ,
top = posicao_top [ 0 ] * cm ,
top = posicao_top [ 0 ] * cm ,
width = 6 * cm ,
width = 6 * cm ,
) ,
) ,
Label (
Label (
text = u " Região: " ,
text = u " Região: " ,
left = posicao_left [ 2 ] * cm ,
left = posicao_left [ 2 ] * cm ,
top = posicao_top [ 1 ] * cm ,
top = posicao_top [ 1 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' municipio.uf.regiao ' ,
attribute_name = ' municipio.uf.regiao ' ,
left = posicao_left [ 3 ] * cm ,
left = posicao_left [ 3 ] * cm ,
top = posicao_top [ 1 ] * cm ,
top = posicao_top [ 1 ] * cm ,
get_value = lambda instance :
get_value = lambda instance :
{ ' SL ' : ' Sul ' , ' SD ' : ' Sudeste ' , ' CO ' : ' Centro-Oeste ' , ' NE ' : ' Nordeste ' , ' NO ' : ' Norte ' , }
{ ' SL ' : ' Sul ' , ' SD ' : ' Sudeste ' , ' CO ' : ' Centro-Oeste ' , ' NE ' : ' Nordeste ' , ' NO ' : ' Norte ' , }
[ instance . municipio . uf . regiao ]
[ instance . municipio . uf . regiao ]
) ,
) ,
Label (
Label (
text = u " U.F.: " ,
text = u " U.F.: " ,
left = posicao_left [ 4 ] * cm ,
left = posicao_left [ 4 ] * cm ,
top = posicao_top [ 2 ] * cm ,
top = posicao_top [ 2 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' municipio.uf ' ,
attribute_name = ' municipio.uf ' ,
left = posicao_left [ 5 ] * cm ,
left = posicao_left [ 5 ] * cm ,
top = posicao_top [ 2 ] * cm ,
top = posicao_top [ 2 ] * cm ,
) ,
) ,
Label (
Label (
text = u " Município: " ,
text = u " Município: " ,
left = posicao_left [ 6 ] * cm ,
left = posicao_left [ 6 ] * cm ,
top = posicao_top [ 3 ] * cm ,
top = posicao_top [ 3 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' municipio.nome ' ,
attribute_name = ' municipio.nome ' ,
left = posicao_left [ 7 ] * cm ,
left = posicao_left [ 7 ] * cm ,
top = posicao_top [ 3 ] * cm ,
top = posicao_top [ 3 ] * cm ,
width = 20 * cm ,
width = 20 * cm ,
) ,
) ,
# Linha 3
# Linha 3
Label (
Label (
text = u " Endereço: " ,
text = u " Endereço: " ,
left = posicao_left [ 8 ] * cm ,
left = posicao_left [ 8 ] * cm ,
top = posicao_top [ 4 ] * cm ,
top = posicao_top [ 4 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' logradouro ' ,
attribute_name = ' logradouro ' ,
left = posicao_left [ 9 ] * cm ,
left = posicao_left [ 9 ] * cm ,
top = posicao_top [ 4 ] * cm ,
top = posicao_top [ 4 ] * cm ,
width = 20 * cm ,
width = 20 * cm ,
) ,
) ,
Label (
Label (
text = u " Bairro: " ,
text = u " Bairro: " ,
left = posicao_left [ 10 ] * cm ,
left = posicao_left [ 10 ] * cm ,
top = posicao_top [ 5 ] * cm ,
top = posicao_top [ 5 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' bairro ' ,
attribute_name = ' bairro ' ,
left = posicao_left [ 11 ] * cm ,
left = posicao_left [ 11 ] * cm ,
top = posicao_top [ 5 ] * cm ,
top = posicao_top [ 5 ] * cm ,
) ,
) ,
Label (
Label (
text = u " CEP: " ,
text = u " CEP: " ,
left = posicao_left [ 12 ] * cm ,
left = posicao_left [ 12 ] * cm ,
top = posicao_top [ 6 ] * cm ,
top = posicao_top [ 6 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' cep ' ,
attribute_name = ' cep ' ,
left = posicao_left [ 13 ] * cm ,
left = posicao_left [ 13 ] * cm ,
top = posicao_top [ 6 ] * cm ,
top = posicao_top [ 6 ] * cm ,
) ,
) ,
Label (
Label (
text = u " CNPJ: " ,
text = u " CNPJ: " ,
left = posicao_left [ 14 ] * cm ,
left = posicao_left [ 14 ] * cm ,
top = posicao_top [ 7 ] * cm ,
top = posicao_top [ 7 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' cnpj ' ,
attribute_name = ' cnpj ' ,
left = posicao_left [ 15 ] * cm ,
left = posicao_left [ 15 ] * cm ,
top = posicao_top [ 7 ] * cm ,
top = posicao_top [ 7 ] * cm ,
) ,
) ,
Label (
Label (
text = u " Telefone: " ,
text = u " Telefone: " ,
left = posicao_left [ 16 ] * cm ,
left = posicao_left [ 16 ] * cm ,
top = posicao_top [ 8 ] * cm ,
top = posicao_top [ 8 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' telefone ' ,
attribute_name = ' telefone ' ,
left = posicao_left [ 17 ] * cm ,
left = posicao_left [ 17 ] * cm ,
top = posicao_top [ 8 ] * cm ,
top = posicao_top [ 8 ] * cm ,
) ,
) ,
Label (
Label (
text = u " Presidente: " ,
text = u " Presidente: " ,
left = posicao_left [ 18 ] * cm ,
left = posicao_left [ 18 ] * cm ,
top = posicao_top [ 9 ] * cm ,
top = posicao_top [ 9 ] * cm ,
) ,
) ,
ObjectValue (
ObjectValue (
attribute_name = ' presidente ' ,
attribute_name = ' presidente ' ,
left = posicao_left [ 19 ] * cm ,
left = posicao_left [ 19 ] * cm ,
top = posicao_top [ 9 ] * cm ,
top = posicao_top [ 9 ] * cm ,
width = 20 * cm ,
width = 20 * cm ,
) ,
) ,
]
]
# Telefones
# Telefones
tel_top = 2 * cm
tel_top = 2 * cm
tel_left = [ 0 , 3 , 5 ]
tel_left = [ 0 , 3 , 5 ]
# Contato
# Contato
cont_top = 2 * cm
cont_top = 2 * cm
cont_left = [ 0 , 6 , 9 ]
cont_left = [ 0 , 6 , 9 ]
# Convenios
# Convenios
convenio_top = 2 * cm
convenio_top = 2 * cm
convenio_left = [ 0 , 1.8 , 4.5 , 8 , 10.5 , 13 , 15.5 , 18 ]
convenio_left = [ 0 , 1.8 , 4.5 , 8 , 10.5 , 13 , 15.5 , 18 ]
subreports = [
subreports = [
# Telefones
# Telefones
SubReport (
SubReport (
queryset_string = ' %(object)s .telefones.all() ' ,
queryset_string = ' %(object)s .telefones.all() ' ,
band_header = ReportBand (
band_header = ReportBand (
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 12 } ,
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 12 } ,
height = 2.5 * cm ,
height = 2.5 * cm ,
elements = [
elements = [
Label (
Label (
text = u " Telefone(s) " ,
text = u " Telefone(s) " ,
style = { ' fontSize ' : 14 , ' alignment ' : TA_CENTER } ,
style = { ' fontSize ' : 14 , ' alignment ' : TA_CENTER } ,
width = BAND_WIDTH ,
width = BAND_WIDTH ,
top = 1 * cm ,
top = 1 * cm ,
) ,
) ,
Label ( text = u " Número " , left = tel_left [ 0 ] * cm , top = tel_top ) ,
Label ( text = u " Número " , left = tel_left [ 0 ] * cm , top = tel_top ) ,
Label ( text = u " Tipo " , left = tel_left [ 1 ] * cm , top = tel_top ) ,
Label ( text = u " Tipo " , left = tel_left [ 1 ] * cm , top = tel_top ) ,
Label ( text = u " Nota " , left = tel_left [ 2 ] * cm , top = tel_top ) ,
Label ( text = u " Nota " , left = tel_left [ 2 ] * cm , top = tel_top ) ,
] ,
] ,
borders = { ' bottom ' : True } ,
borders = { ' bottom ' : True } ,
) ,
) ,
band_detail = ReportBand (
band_detail = ReportBand (
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 11 } ,
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 11 } ,
height = 0.5 * cm ,
height = 0.5 * cm ,
elements = [
elements = [
ObjectValue ( attribute_name = ' __unicode__ ' , left = tel_left [ 0 ] * cm ) ,
ObjectValue ( attribute_name = ' __unicode__ ' , left = tel_left [ 0 ] * cm ) ,
ObjectValue ( attribute_name = ' tipo ' , left = tel_left [ 1 ] * cm ,
ObjectValue ( attribute_name = ' tipo ' , left = tel_left [ 1 ] * cm ,
get_value = lambda instance :
get_value = lambda instance :
{ ' F ' : ' Fixo ' , ' M ' : u ' Móvel ' , ' X ' : ' Fax ' , ' I ' : ' Indefinido ' } [ instance . tipo ] ,
{ ' F ' : ' Fixo ' , ' M ' : u ' Móvel ' , ' X ' : ' Fax ' , ' I ' : ' Indefinido ' } [ instance . tipo ] ,
) ,
) ,
ObjectValue ( attribute_name = ' nota ' , left = tel_left [ 2 ] * cm ) ,
ObjectValue ( attribute_name = ' nota ' , left = tel_left [ 2 ] * cm ) ,
] ,
] ,
#borders = {'all':True},
#borders = {'all':True},
) ,
) ,
) ,
) ,
#Contatos
# Contatos
SubReport (
SubReport (
queryset_string = ' %(object)s .funcionario_set.all() ' ,
queryset_string = ' %(object)s .funcionario_set.all() ' ,
band_header = ReportBand (
band_header = ReportBand (
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 12 } ,
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 12 } ,
height = 2.5 * cm ,
height = 2.5 * cm ,
elements = [
elements = [
Label (
Label (
text = u " Contato(s) " ,
text = u " Contato(s) " ,
style = { ' fontSize ' : 14 , ' alignment ' : TA_CENTER } ,
style = { ' fontSize ' : 14 , ' alignment ' : TA_CENTER } ,
width = BAND_WIDTH ,
width = BAND_WIDTH ,
top = 1 * cm ,
top = 1 * cm ,
) ,
) ,
Label ( text = u " Nome " , left = cont_left [ 0 ] * cm , top = cont_top ) ,
Label ( text = u " Nome " , left = cont_left [ 0 ] * cm , top = cont_top ) ,
Label ( text = u " Nota " , left = cont_left [ 1 ] * cm , top = cont_top ) ,
Label ( text = u " Nota " , left = cont_left [ 1 ] * cm , top = cont_top ) ,
Label ( text = u " E-mail " , left = cont_left [ 2 ] * cm , top = cont_top ) ,
Label ( text = u " E-mail " , left = cont_left [ 2 ] * cm , top = cont_top ) ,
] ,
] ,
borders = { ' bottom ' : True , ' top ' : True } ,
borders = { ' bottom ' : True , ' top ' : True } ,
) ,
) ,
band_detail = ReportBand (
band_detail = ReportBand (
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 11 } ,
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 11 } ,
height = 0.5 * cm ,
height = 0.5 * cm ,
elements = [
elements = [
ObjectValue ( attribute_name = ' nome ' , left = cont_left [ 0 ] * cm ) ,
ObjectValue ( attribute_name = ' nome ' , left = cont_left [ 0 ] * cm ) ,
ObjectValue ( attribute_name = ' nota ' , left = cont_left [ 1 ] * cm ) ,
ObjectValue ( attribute_name = ' nota ' , left = cont_left [ 1 ] * cm ) ,
ObjectValue ( attribute_name = ' email ' , left = cont_left [ 2 ] * cm ) ,
ObjectValue ( attribute_name = ' email ' , left = cont_left [ 2 ] * cm ) ,
] ,
] ,
#borders = {'all':True},
#borders = {'all':True},
) ,
) ,
) ,
) ,
#Convenios
# Convenios
SubReport (
SubReport (
queryset_string = ' %(object)s .convenio_set.all() ' ,
queryset_string = ' %(object)s .convenio_set.all() ' ,
band_header = ReportBand (
band_header = ReportBand (
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 12 } ,
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 12 } ,
height = 2.5 * cm ,
height = 2.5 * cm ,
elements = [
elements = [
Label (
Label (
text = u " Convênio(s) " ,
text = u " Convênio(s) " ,
style = { ' fontSize ' : 14 , ' alignment ' : TA_CENTER } ,
style = { ' fontSize ' : 14 , ' alignment ' : TA_CENTER } ,
width = BAND_WIDTH ,
width = BAND_WIDTH ,
top = 1 * cm ,
top = 1 * cm ,
) ,
) ,
Label ( text = u " Projeto " , left = convenio_left [ 0 ] * cm , top = convenio_top ) ,
Label ( text = u " Projeto " , left = convenio_left [ 0 ] * cm , top = convenio_top ) ,
Label ( text = u " Nº Convenio " , left = convenio_left [ 1 ] * cm , top = convenio_top ) ,
Label ( text = u " Nº Convenio " , left = convenio_left [ 1 ] * cm , top = convenio_top ) ,
Label ( text = u " Nº Processo SF " , left = convenio_left [ 2 ] * cm , top = convenio_top ) ,
Label ( text = u " Nº Processo SF " , left = convenio_left [ 2 ] * cm , top = convenio_top ) ,
Label ( text = u " Adesão " , left = convenio_left [ 3 ] * cm , top = convenio_top ) ,
Label ( text = u " Adesão " , left = convenio_left [ 3 ] * cm , top = convenio_top ) ,
Label ( text = u " Convênio " , left = convenio_left [ 4 ] * cm , top = convenio_top ) ,
Label ( text = u " Convênio " , left = convenio_left [ 4 ] * cm , top = convenio_top ) ,
Label ( text = u " Equipada " , left = convenio_left [ 5 ] * cm , top = convenio_top ) ,
Label ( text = u " Equipada " , left = convenio_left [ 5 ] * cm , top = convenio_top ) ,
Label ( text = u " Data D.O. " , left = convenio_left [ 6 ] * cm , top = convenio_top ) ,
Label ( text = u " Data D.O. " , left = convenio_left [ 6 ] * cm , top = convenio_top ) ,
] ,
] ,
borders = { ' bottom ' : True }
borders = { ' bottom ' : True }
) ,
) ,
band_detail = ReportBand (
band_detail = ReportBand (
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 11 } ,
default_style = { ' fontName ' : ' Helvetica ' , ' fontSize ' : 11 } ,
height = 0.5 * cm ,
height = 0.5 * cm ,
elements = [
elements = [
ObjectValue ( attribute_name = ' projeto.sigla ' , left = convenio_left [ 0 ] * cm ) ,
ObjectValue ( attribute_name = ' projeto.sigla ' , left = convenio_left [ 0 ] * cm ) ,
ObjectValue ( attribute_name = ' num_convenio ' , left = convenio_left [ 1 ] * cm ) ,
ObjectValue ( attribute_name = ' num_convenio ' , left = convenio_left [ 1 ] * cm ) ,
ObjectValue ( attribute_name = ' num_processo_sf ' , left = convenio_left [ 2 ] * cm ) ,
ObjectValue ( attribute_name = ' num_processo_sf ' , left = convenio_left [ 2 ] * cm ) ,
ObjectValue ( attribute_name = ' data_adesao ' , left = convenio_left [ 3 ] * cm ,
ObjectValue ( attribute_name = ' data_adesao ' , left = convenio_left [ 3 ] * cm ,
get_value = lambda instance :
get_value = lambda instance :
instance . data_adesao . strftime ( ' %d / % m/ % Y ' ) if instance . data_adesao != None else ' - '
instance . data_adesao . strftime ( ' %d / % m/ % Y ' ) if instance . data_adesao != None else ' - '
) ,
) ,
ObjectValue ( attribute_name = ' data_retorno_assinatura ' , left = convenio_left [ 4 ] * cm ,
ObjectValue ( attribute_name = ' data_retorno_assinatura ' , left = convenio_left [ 4 ] * cm ,
get_value = lambda instance :
get_value = lambda instance :
instance . data_retorno_assinatura . strftime ( ' %d / % m/ % Y ' ) if instance . data_retorno_assinatura != None else ' - '
instance . data_retorno_assinatura . strftime ( ' %d / % m/ % Y ' ) if instance . data_retorno_assinatura != None else ' - '
) ,
) ,
ObjectValue ( attribute_name = ' data_termo_aceite ' , left = convenio_left [ 5 ] * cm ,
ObjectValue ( attribute_name = ' data_termo_aceite ' , left = convenio_left [ 5 ] * cm ,
get_value = lambda instance :
get_value = lambda instance :
instance . data_termo_aceite . strftime ( ' %d / % m/ % Y ' ) if instance . data_termo_aceite != None else ' - '
instance . data_termo_aceite . strftime ( ' %d / % m/ % Y ' ) if instance . data_termo_aceite != None else ' - '
) ,
) ,
ObjectValue ( attribute_name = ' data_pub_diario ' , left = convenio_left [ 6 ] * cm ,
ObjectValue ( attribute_name = ' data_pub_diario ' , left = convenio_left [ 6 ] * cm ,
get_value = lambda instance :
get_value = lambda instance :
instance . data_pub_diario . strftime ( ' %d / % m/ % Y ' ) if instance . data_pub_diario != None else ' - '
instance . data_pub_diario . strftime ( ' %d / % m/ % Y ' ) if instance . data_pub_diario != None else ' - '
) ,
) ,
] ,
] ,
#borders = {'all':True},
#borders = {'all':True},
) ,
) ,
)
)
]
]