Ejemplo n.º 1
0
class AccessReport(UDSGeraldoReport):
    header_elements = []

    class band_detail(ReportBand):
        height = 400 * mm  # Height bigger than a page, so a new page is launched
        # auto_expand_height = True
        elements = (
            Label(text=_('Users access by date'), top=0.6 * cm, left=0, width=BAND_WIDTH,
                  style={'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER}),
            UDSImage(left=4 * cm, top=1 * cm,
                     width=GERALDO_WIDTH, height=GERALDO_HEIGHT,
                     get_image=lambda x: x.instance['image']),

            Label(text=_('Users access by day of week'), top=GERALDO_HEIGHT + 1.2 * cm, left=0, width=BAND_WIDTH,
                  style={'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER}),
            UDSImage(left=4 * cm, top=GERALDO_HEIGHT + 1.6 * cm,
                     width=GERALDO_WIDTH, height=GERALDO_HEIGHT,
                     get_image=lambda x: x.instance['image2']),

            Label(text=_('Users access by hour'), top=2 * GERALDO_HEIGHT + 2 * cm, left=0, width=BAND_WIDTH,
                  style={'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER}),
            UDSImage(left=4 * cm, top=2 * GERALDO_HEIGHT + 2.4 * cm,
                     width=GERALDO_WIDTH, height=GERALDO_HEIGHT,
                     get_image=lambda x: x.instance['image3']),
        )

    subreports = [
        SubReport(
            queryset_string='%(object)s["data"]',
            band_header=ReportBand(
                height=1 * cm,
                auto_expand_height=True,
                elements=(
                    Label(text=_('Users access by date'), top=0.2 * cm, left=0, width=BAND_WIDTH,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 12, 'alignment': TA_CENTER}),
                    Label(text=_('Date range'), top=1.0 * cm, left=1.2 * cm,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 10}),
                    Label(text=_('Users'), top=1.0 * cm, left=14 * cm,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 10}),
                ),
                # borders={'bottom': True}
            ),
            band_detail=ReportBand(
                height=0.5 * cm,
                elements=(
                    ObjectValue(attribute_name='date', top=0, left=1.2 * cm, width=12 * cm, style={'fontName': 'Helvetica', 'fontSize': 9}),
                    ObjectValue(attribute_name='users', top=0, left=14 * cm, style={'fontName': 'Helvetica', 'fontSize': 9}),
                )
            ),
        )
    ]
Ejemplo n.º 2
0
class CountersPoolsReport(UDSGeraldoReport):
    title = ''
    author = 'UDS'

    header_elements = []

    header_height = 2.5 * cm

    class band_detail(ReportBand):
        height = 400 * mm  # Height bigger than a page, so a new page is launched for listings
        elements = (
            Label(text=_('Services Asignation'), top=0.6 * cm, left=0, width=BAND_WIDTH,
                  style={'fontName': 'Helvetica-Bold', 'fontSize': 10, 'alignment': TA_CENTER}),
            UDSImage(left=4 * cm, top=1 * cm,
                     width=GERALDO_WIDTH, height=GERALDO_HEIGHT,
                     get_image=lambda x: x.instance['image']),
        )

    subreports = [
        SubReport(
            queryset_string='%(object)s["data"]',
            band_header=ReportBand(
                height=1 * cm,
                auto_expand_height=True,
                elements=(
                    Label(text=_('Service asignation by hour'), top=0.2 * cm, left=0, width=BAND_WIDTH,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 12, 'alignment': TA_CENTER}),
                    Label(text=_('Pool'), top=1.0 * cm, left=1.2 * cm,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 10}),
                    Label(text=_('Hour'), top=1.0 * cm, left=10 * cm,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 10}),
                    Label(text=_('Services'), top=1.0 * cm, left=14 * cm,
                          style={'fontName': 'Helvetica-Bold', 'fontSize': 10}),
                ),
                # borders={'bottom': True}
            ),
            band_detail=ReportBand(
                height=0.5 * cm,
                elements=(
                    ObjectValue(attribute_name='name', top=0, left=1.2 * cm, width=8.8 * cm, style={'fontName': 'Helvetica', 'fontSize': 9}),
                    ObjectValue(attribute_name='time', top=0, left=10 * cm, width=4 * cm, style={'fontName': 'Helvetica', 'fontSize': 9}),
                    ObjectValue(attribute_name='value', top=0, left=14 * cm, width=4 * cm, style={'fontName': 'Helvetica', 'fontSize': 9}),
                )
            ),
        )
    ]
Ejemplo n.º 3
0
class InfoCasaLegislativa(ReportDefault):
    title = _(u'Casa Legislativa')

    class band_summary(ReportBand):
        pass

    class band_page_footer(ReportBand):
        height = 1 * cm

        elements = [
            SystemField(expression=_(u'%(now:%d/%m/%Y)s às %(now:%H:%M)s'),
                        top=0.3 * cm),
        ]

    class band_detail(ReportDefault.band_detail):

        posicao_left = [
            0,
            1.3,  # Tipo
            0,
            1.8,  # Regiao
            5.5,
            6.8,  # U.F.
            0,
            2.3,  # Municipio
            0,
            2.4,  # Endereco
            0,
            1.6,  # Bairro
            0,
            1.3,  # CEP
            0,
            1.6,  # CNPJ
            0,
            2.3,  # Telefone
            0,
            2.7,  # Presidente
        ]
        posicao_top = [
            0.5,  # Tipo
            1.3,  # Regiao
            1.3,  # U.F.
            2.1,  # Municipio
            2.9,  # Logradouro
            3.7,  # Bairro
            4.5,  # CEP
            5.3,  # CNPJ
            6.1,  # Telefone
            6.9,  # Presidente
        ]

        height = 30 * cm

        display_inline = True
        default_style = {'fontName': 'Helvetica', 'fontSize': 14}

        elements = [
            Label(
                text=label_text(_(u"Tipo")),
                left=posicao_left[0] * cm,
                top=posicao_top[0] * cm,
            ),
            ObjectValue(
                attribute_name='tipo.nome',
                left=posicao_left[1] * cm,
                top=posicao_top[0] * cm,
                width=6 * cm,
            ),
            Label(
                text=label_text(_(u"Região")),
                left=posicao_left[2] * cm,
                top=posicao_top[1] * cm,
            ),
            ObjectValue(attribute_name='municipio.uf.regiao',
                        left=posicao_left[3] * cm,
                        top=posicao_top[1] * cm,
                        get_value=lambda instance: {
                            'SL': _(u'Sul'),
                            'SD': _(u'Sudeste'),
                            'CO': _(u'Centro-Oeste'),
                            'NE': _(u'Nordeste'),
                            'NO': _(u'Norte'),
                        }[instance.municipio.uf.regiao]),
            Label(
                text=label_text(_(u"UF")),
                left=posicao_left[4] * cm,
                top=posicao_top[2] * cm,
            ),
            ObjectValue(
                attribute_name='municipio.uf',
                left=posicao_left[5] * cm,
                top=posicao_top[2] * cm,
            ),
            Label(
                text=label_text(_(u"Município")),
                left=posicao_left[6] * cm,
                top=posicao_top[3] * cm,
            ),
            ObjectValue(
                attribute_name='municipio.nome',
                left=posicao_left[7] * cm,
                top=posicao_top[3] * cm,
                width=20 * cm,
            ),
            # Linha 3
            Label(
                text=label_text(_(u"Endereço")),
                left=posicao_left[8] * cm,
                top=posicao_top[4] * cm,
            ),
            ObjectValue(
                attribute_name='logradouro',
                left=posicao_left[9] * cm,
                top=posicao_top[4] * cm,
                width=20 * cm,
            ),
            Label(
                text=label_text(_(u"Bairro")),
                left=posicao_left[10] * cm,
                top=posicao_top[5] * cm,
            ),
            ObjectValue(
                attribute_name='bairro',
                left=posicao_left[11] * cm,
                top=posicao_top[5] * cm,
            ),
            Label(
                text=label_text(_(u"CEP")),
                left=posicao_left[12] * cm,
                top=posicao_top[6] * cm,
            ),
            ObjectValue(
                attribute_name='cep',
                left=posicao_left[13] * cm,
                top=posicao_top[6] * cm,
            ),
            Label(
                text=label_text(_(u"CNPJ")),
                left=posicao_left[14] * cm,
                top=posicao_top[7] * cm,
            ),
            ObjectValue(
                attribute_name='cnpj',
                left=posicao_left[15] * cm,
                top=posicao_top[7] * cm,
            ),
            Label(
                text=label_text(_(u"Telefone")),
                left=posicao_left[16] * cm,
                top=posicao_top[8] * cm,
            ),
            ObjectValue(
                attribute_name='telefone',
                left=posicao_left[17] * cm,
                top=posicao_top[8] * cm,
            ),
            Label(
                text=label_text(_(u"Presidente")),
                left=posicao_left[18] * cm,
                top=posicao_top[9] * cm,
            ),
            ObjectValue(
                attribute_name='presidente',
                left=posicao_left[19] * cm,
                top=posicao_top[9] * cm,
                width=20 * cm,
            ),
        ]

    # Telefones
    tel_top = 2 * cm
    tel_left = [0, 3, 5]
    # Contato
    cont_top = 2 * cm
    cont_left = [0, 6, 9]
    # Convenios
    convenio_top = 2 * cm
    convenio_left = [0, 1.8, 4.5, 8, 10.5, 13, 15.5, 18]
    subreports = [
        # Telefones
        SubReport(
            queryset_string='%(object)s.telefones.all()',
            band_header=ReportBand(
                default_style={
                    'fontName': 'Helvetica',
                    'fontSize': 12
                },
                height=2.5 * cm,
                elements=[
                    Label(
                        text=_(u"Telefone(s)"),
                        style={
                            'fontSize': 14,
                            'alignment': TA_CENTER
                        },
                        width=BAND_WIDTH,
                        top=1 * cm,
                    ),
                    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"Nota"), left=tel_left[2] * cm, top=tel_top),
                ],
                borders={'bottom': True},
            ),
            band_detail=ReportBand(
                default_style={
                    'fontName': 'Helvetica',
                    'fontSize': 11
                },
                height=0.5 * cm,
                elements=[
                    ObjectValue(attribute_name='__unicode__',
                                left=tel_left[0] * cm),
                    ObjectValue(
                        attribute_name='tipo',
                        left=tel_left[1] * cm,
                        get_value=lambda instance: {
                            'F': _(u'Fixo'),
                            'M': _(u'Móvel'),
                            'X': _(u'Fax'),
                            'I': _(u'Indefinido')
                        }[instance.tipo],
                    ),
                    ObjectValue(attribute_name='nota', left=tel_left[2] * cm),
                ],
                #borders = {'all':True},
            ),
        ),
        # Contatos
        SubReport(
            queryset_string='%(object)s.funcionario_set.all()',
            band_header=ReportBand(
                default_style={
                    'fontName': 'Helvetica',
                    'fontSize': 12
                },
                height=2.5 * cm,
                elements=[
                    Label(
                        text=_(u"Contato(s)"),
                        style={
                            'fontSize': 14,
                            'alignment': TA_CENTER
                        },
                        width=BAND_WIDTH,
                        top=1 * cm,
                    ),
                    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"E-mail"),
                          left=cont_left[2] * cm,
                          top=cont_top),
                ],
                borders={
                    'bottom': True,
                    'top': True
                },
            ),
            band_detail=ReportBand(
                default_style={
                    'fontName': 'Helvetica',
                    'fontSize': 11
                },
                height=0.5 * cm,
                elements=[
                    ObjectValue(attribute_name='nome', left=cont_left[0] * cm),
                    ObjectValue(attribute_name='nota', left=cont_left[1] * cm),
                    ObjectValue(attribute_name='email',
                                left=cont_left[2] * cm),
                ],
                #borders = {'all':True},
            ),
        ),
        # Convenios
        SubReport(
            queryset_string='%(object)s.convenio_set.all()',
            band_header=ReportBand(default_style={
                'fontName': 'Helvetica',
                'fontSize': 12
            },
                                   height=2.5 * cm,
                                   elements=[
                                       Label(
                                           text=_(u"Convênio(s)"),
                                           style={
                                               'fontSize': 14,
                                               'alignment': TA_CENTER
                                           },
                                           width=BAND_WIDTH,
                                           top=1 * cm,
                                       ),
                                       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º 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"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"Data D.O."),
                                             left=convenio_left[6] * cm,
                                             top=convenio_top),
                                   ],
                                   borders={'bottom': True}),
            band_detail=ReportBand(
                default_style={
                    'fontName': 'Helvetica',
                    'fontSize': 11
                },
                height=0.5 * cm,
                elements=[
                    ObjectValue(attribute_name='projeto.sigla',
                                left=convenio_left[0] * 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='data_adesao',
                                left=convenio_left[3] * cm,
                                get_value=lambda instance: instance.data_adesao
                                .strftime('%d/%m/%Y')
                                if instance.data_adesao is not None else '-'),
                    ObjectValue(attribute_name='data_retorno_assinatura',
                                left=convenio_left[4] * cm,
                                get_value=lambda instance: instance.
                                data_retorno_assinatura.strftime('%d/%m/%Y')
                                if instance.data_retorno_assinatura is not None
                                else '-'),
                    ObjectValue(
                        attribute_name='data_termo_aceite',
                        left=convenio_left[5] * cm,
                        get_value=lambda instance: instance.data_termo_aceite.
                        strftime('%d/%m/%Y')
                        if instance.data_termo_aceite is not None else '-'),
                    ObjectValue(
                        attribute_name='data_pub_diario',
                        left=convenio_left[6] * cm,
                        get_value=lambda instance: instance.data_pub_diario.
                        strftime('%d/%m/%Y')
                        if instance.data_pub_diario is not None else '-'),
                ],
                #borders = {'all':True},
            ),
        )
    ]
Ejemplo n.º 4
0
 class MyReport(Report):
     def __init__(self, queryset=None, db=None):
         " Initialise parent class & make any necessary modifications "
         Report.__init__(self, queryset)
         self.db = db
     # can't use T() here!
     title = "Kits"
     page_size = landscape(A4)
     class band_page_header(ReportBand):
         height = 1.3*cm
         elements = [
             SystemField(expression="%(report_title)s", top=0.1*cm,
                 left=0, width=BAND_WIDTH, style={"fontName": "Helvetica-Bold",
                 "fontSize": 14, "alignment": TA_CENTER}
                 ),
             Label(text="Code", top=0.8*cm, left=0.2*cm),
             Label(text="Description", top=0.8*cm, left=2*cm),
             Label(text="Cost", top=0.8*cm, left=10*cm),
             Label(text="Monthly", top=0.8*cm, left=12*cm),
             Label(text="per Minute", top=0.8*cm, left=14*cm),
             Label(text="per Megabyte", top=0.8*cm, left=16*cm),
             Label(text="Comments", top=0.8*cm, left=18*cm),
         ]
         borders = {"bottom": True}
     class band_page_footer(ReportBand):
         height = 0.5*cm
         elements = [
             Label(text="%s" % request.utcnow.date(), top=0.1*cm, left=0),
             SystemField(expression="Page # %(page_number)d of %(page_count)d", top=0.1*cm,
                 width=BAND_WIDTH, style={"alignment": TA_RIGHT}),
         ]
         borders = {"top": True}
     class band_detail(ReportBand):
         height = 0.5*cm
         auto_expand_height = True
         elements = (
                 ObjectValue(attribute_name="code", left=0.2*cm, width=1.8*cm),
                 ObjectValue(attribute_name="description", left=2*cm, width=8*cm),
                 ObjectValue(attribute_name="total_unit_cost", left=10*cm, width=2*cm),
                 ObjectValue(attribute_name="total_monthly_cost", left=12*cm, width=2*cm),
                 ObjectValue(attribute_name="total_minute_cost", left=14*cm, width=2*cm),
                 ObjectValue(attribute_name="total_megabyte_cost", left=16*cm, width=2*cm),
                 ObjectValue(attribute_name="comments", left=18*cm, width=6*cm),
                 )
     subreports = [
         SubReport(
             #queryset_string = "db((db.budget_kit_item.kit_id == %(object)s.id) & (db.budget_item.id == db.budget_kit_item.item_id)).select(db.budget_item.code, db.budget_item.description, db.budget_item.unit_cost)",
             #queryset_string = "db(db.budget_kit_item.kit_id == %(object)s.id).select()",
             band_header = ReportBand(
                     height=0.5*cm,
                     elements=[
                         Label(text="Item ID", top=0, left=0.2*cm, style={"fontName": "Helvetica-Bold"}),
                         Label(text="Quantity", top=0, left=2*cm, style={"fontName": "Helvetica-Bold"}),
                         #Label(text="Unit Cost", top=0, left=4*cm, style={"fontName": "Helvetica-Bold"}),
                         ],
                     borders={"top": True, "left": True, "right": True},
                     ),
             detail_band = ReportBand(
                     height=0.5*cm,
                     elements=[
                         ObjectValue(attribute_name="item_id", top=0, left=0.2*cm),
                         ObjectValue(attribute_name="quantity", top=0, left=2*cm),
                         #ObjectValue(attribute_name="unit_cost", top=0, left=4*cm),
                         ]
                     ),
             ),
         ]
Ejemplo n.º 5
0
    class MyFamilyReport(Report):
        title = 'NCS_CS'

        class band_detail(DetailBand):
            height = 0.7 * cm
            elements = [
                ObjectValue(expression='name', left=0.5 * cm),
                ObjectValue(expression='c',
                            left=3.5 * cm,
                            get_value=lambda instance: "%.5f" % instance.c),
                ObjectValue(expression='s',
                            left=6.5 * cm,
                            get_value=lambda instance: "%.5f" % instance.s),
                ObjectValue(expression='user', left=9.5 * cm),
                ObjectValue(expression='mdate', left=12.5 * cm),
            ]
            borders = {'top': True, 'bottom': .3}

        class band_page_header(ReportBand):
            height = 1.3 * cm
            elements = [
                SystemField(expression='%(report_title)s',
                            top=0.1 * cm,
                            left=0,
                            width=BAND_WIDTH,
                            style={
                                'fontName': 'Helvetica-Bold',
                                'fontSize': 14,
                                'alignment': TA_CENTER
                            }),
                SystemField(
                    expression=u'Page %(page_number)d of %(page_count)d',
                    top=0.1 * cm,
                    width=BAND_WIDTH,
                    style={'alignment': TA_RIGHT}),
                Label(text="Name", top=0.8 * cm, left=0.5 * cm),
                Label(text="c", top=0.8 * cm, left=3.5 * cm),
                Label(text="s", top=0.8 * cm, left=6.5 * cm),
                Label(text="user", top=0.8 * cm, left=9.5 * cm),
                Label(text="time", top=0.8 * cm, left=12.5 * cm),
            ]
            #borders = {'all': True}

        class band_page_footer(ReportBand):
            height = 0.5 * cm
            elements = [
                Label(text='Geraldo Reports', top=0.1 * cm),
                SystemField(
                    expression='Printed in %(now:%Y, %b %d)s at %(now:%H:%M)s',
                    top=0.1 * cm,
                    width=BAND_WIDTH,
                    style={'alignment': TA_RIGHT}),
            ]
            borders = {'top': True}

        subreports = [
            SubReport(
                queryset_string='%(object)s.singles',
                # band_header = ReportBand(
                # height=0.9*cm,
                # elements=[
                # Label(text='id', top=0.2*cm, left=0.2*cm, style={'fontName': 'Helvetica-Bold'}),
                # Label(text='name', top=0.2*cm, left=4*cm, style={'fontName': 'Helvetica-Bold'}),
                # ],
                # ),
                band_detail=ReportBand(
                    height=0.5 * cm,

                    # This is a new attribute to force the band width
                    # width = 6*cm,

                    # # This attribute forces a distance at right and bottom sides of the band
                    # margin_right = 0.2*cm,
                    # margin_bottom = 0.2*cm,

                    # # With this attribute as True, the band will try to align in
                    # # the same line
                    # display_inline = True,
                    elements=[
                        ObjectValue(
                            attribute_name='c',
                            left=3.5 * cm,
                            get_value=lambda instance: "%.5f" % instance.c),
                        ObjectValue(
                            attribute_name='s',
                            left=6.5 * cm,
                            get_value=lambda instance: "%.5f" % instance.s),
                    ],
                    #borders={'all': True},
                ),
                # band_footer = ReportBand(
                # height=0.9*cm,
                # elements=[
                # ObjectValue(attribute_name='id', top=0.2*cm, left=4*cm,\
                # action=FIELD_ACTION_COUNT, display_format='%s permissions found',
                # style={'fontName': 'Helvetica-Bold'}),
                # ],
                # ),
            ),
        ]