Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Numeração de página em relatório tabular e relatório de consulta Boa noite. Alguém sabe como incluir um código para numeração de páginas no Relatório Tabular e no Relatório de Consulta? Poderia ser no footer mesmo, tipo: "Pág. 1 de 8". Grato...
CM
Numeração de página em relatório tabular e relatório de consulta  
Boa noite.
Alguém sabe como incluir um código para numeração de páginas no Relatório Tabular e no Relatório de Consulta?
Poderia ser no footer mesmo, tipo: "Pág. 1 de 8".
Grato

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (5)


NR

Veja a função footer do link abaixo:
https://www.adianti.com.br/forum/pt/view_851?criando-cabecalhos-e-rodapes-nos-re
CM

Bom dia Natalie.
Conheço esse post.
Mas dá para aplicar em relatórios tabulares e de consulta?

Tentei mas sempre ocorre erro.
Obrugado
CM

Desculpe o erro no seu nome. Corretor de telefone.
NR

Sim, pode aplicar em qualquer classe que utilize a FPDF para geração dos relatórios. Lembrando que isso só funciona para o formato pdf.

Você pode usar a função setHeaderCallback. Veja os comentários do Pablo nos posts abaixo:
www.adianti.com.br/forum/pt/view_833?cabecalho-de-relatorio-usando-t
https://www.adianti.com.br/forum/pt/view_1368?como-alterar-o-header-e-footer-em-
CM

Boa tarde Nataniel.

Infelizmente não consegui aplicar de forma alguma.

Tenho esta classe de cabeçalho e rodapé:

  1. <?php
  2. class TReportHeaderFooter extends TPDFDesigner
  3. {
  4.     public function Header()
  5.     {
  6.         $this->SetY(5);
  7.         $this->Cell(010utf8_decode('NOME DA SUA EMPRESA'),0,0,'C');
  8.     }
  9.     
  10.     
  11.     public function Footer()
  12.     {
  13.         $this->SetY(-12);
  14.         $this->Cell(010utf8_decode('PÁGINA ').$this->PageNo().' / {nb}',0,0,'C');
  15.     }    
  16. }
  17. ?>


Meu Relatório está assim:

  1. <?php
  1. <?php
  2. /**
  3.  * Tabular Query Report
  4.  *
  5.  * @version    1.0
  6.  * @package    samples
  7.  * @subpackage tutor
  8.  * @author     Pablo Dall'Oglio
  9.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10.  * @license    http://www.adianti.com.br/framework-license
  11.  */
  12. class RelatorioVisitas extends TPage
  13. {
  14.     private $form// form
  15.     
  16.     /**
  17.      * Class constructor
  18.      * Creates the page and the registration form
  19.      */
  20.     function __construct()
  21.     {
  22.         parent::__construct();
  23.         
  24.         // creates the form
  25.         $this->form = new BootstrapFormBuilder('form_RelatorioVisitas_report');
  26.         $this->form->setFormTitle'Relatório de Visitas' );
  27.         
  28.         // create the form fields
  29.         
  30.         
  31.         $visitante_id = new TDBCombo('visitante_id''grao7''SystemUser''id''name');
  32.         
  33.         $this->form->addFields( [new TLabel('Visitante ''red')],     [$visitante_id] );
  34.         $visitante_id->addValidation('Visitante Id ', new TRequiredValidator);
  35.         
  36.         $output_type  = new TRadioGroup('output_type');
  37.         $this->form->addFields( [new TLabel('Tipo')],   [$output_type] );
  38.         
  39.         // define field properties
  40.         $output_type->setUseButton();
  41.         $options = ['html' =>'HTML''pdf' =>'PDF''rtf' =>'RTF''xls' =>'XLS'];
  42.         $output_type->addItems($options);
  43.         $output_type->setValue('pdf');
  44.         $output_type->setLayout('horizontal');
  45.         
  46.         
  47.         $btn $this->form->addAction('Gerar Relatório', new TAction(array($this'onGenerate')), 'fa:download white');
  48.         $btn->class 'btn btn-sm btn-primary';
  49.         
  50.         
  51.         // wrap the page content using vertical box
  52.         $vbox = new TVBox;
  53.         $vbox->style 'width: 100%';
  54.         // $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  55.         $vbox->add($this->form);
  56.         
  57.         parent::add($vbox);
  58.     }
  59.     /**
  60.      * method onGenerate()
  61.      * Executed whenever the user clicks at the generate button
  62.      */
  63.     function onGenerate()
  64.     {
  65.         try
  66.         {
  67.             // get the form data into an active record Customer
  68.             $data $this->form->getData();
  69.             $this->form->setData($data);
  70.             
  71.             $format $data->output_type;
  72.             
  73.             // open a transaction with database 'grao7'
  74.             $source TTransaction::open('grao7');
  75.             
  76.             // define the query
  77.             $query ' SELECT clientes_visitas.cliente_txt as "cliente_nome_curto",
  78.                        clientes_visitas.data_visita as "data_visita", system_user.name as "name", 
  79.                        clientes_visitas.sellout as "sellout", clientes_visitas.estoque_saida as "estoque_saida",
  80.                        clientes_visitas.estoque_alto_baixo as "estoque_alto_baixo", clientes_visitas.display_local as "display_local"
  81.                      FROM clientes_visitas, system_user
  82.                     WHERE visitante_id = system_user.id
  83.                     AND clientes_visitas.visitante_id = :visitante_id
  84.                     ORDER BY data_visita asc';
  85.             
  86.             $filters = [];
  87.             $filters['visitante_id'] = $data->visitante_id;
  88.             
  89.             $data TDatabase::getData($source$querynull$filters );
  90.             
  91.             if ($data)
  92.             {
  93.                 $widths = [300,70,50,40,150,100,100];
  94.                 
  95.                 switch ($format)
  96.                 {
  97.                     case 'html':
  98.                         $table = new TTableWriterHTML($widths);
  99.                         break;
  100.                     case 'pdf':
  101.                         $table = new TTableWriterPDF($widths);
  102.                         break;
  103.                     case 'rtf':
  104.                         $table = new TTableWriterRTF($widths);
  105.                         break;
  106.                     case 'xls':
  107.                         $table = new TTableWriterXLS($widths);
  108.                         break;
  109.                 }
  110.                 
  111.                 if (!empty($table))
  112.                 {
  113.                     // create the document styles
  114.                     $table = new TTableWriterPDF($widths,'L');
  115.                     $table->addStyle('header''Helvetica''16''B''#ffffff''#4B8E57');
  116.                     $table->addStyle('title',  'Helvetica''9''B''#ffffff''#6CC361');
  117.                     $table->addStyle('datap',  'Helvetica''8''',  '#000000''#E3E3E3''LR');
  118.                     $table->addStyle('datai',  'Helvetica''8''',  '#000000''#ffffff''LR');
  119.                     $table->addStyle('footer''Helvetica''10''',  '#2B2B2B''#B5FFB4');
  120.                     
  121.                     $table->setHeaderCallback( function($table) {
  122.                         $table->addRow();
  123.                         $table->addCell('Grão Chocolates - Relatório de Visitas''center''header'7);
  124.                         
  125.                         $table->addRow();
  126.                         $table->addCell('Cliente''center''title');
  127.                         $table->addCell('Data Visita''center''title');
  128.                         $table->addCell('Sellout''center''title');
  129.                         $table->addCell('A/B''center''title');
  130.                         $table->addCell('Saída''center''title');
  131.                         $table->addCell('Local''center''title');
  132.                         $table->addCell('Visitante''center''title');
  133.                     });
  134.                     
  135.                         $table->setFooterCallback( function($table) {
  136.                         $table->addRow();
  137.                         $table->addCell(date('d/m/Y - H:i:s '), 'center''footer'7);
  138.                                          
  139.                   });
  140.                     
  141.                     // controls the background filling
  142.                     $colourFALSE;
  143.                     
  144.                     // data rows
  145.                     foreach ($data as $row)
  146.                     {
  147.                         $style $colour 'datap' 'datai';
  148.                         
  149.                         $table->addRow();
  150.                         $table->addCell($row['cliente_nome_curto'], 'center'$style);
  151.                         $table->addCell(TDate::date2br($row['data_visita']), 'center'$style);
  152.                         $table->addCell(number_format($row['sellout'], 2',''.'), 'right'$style);
  153.                         $table->addCell($row['estoque_alto_baixo'], 'center'$style);
  154.                         $table->addCell($row['estoque_saida'], 'center'$style);
  155.                         $table->addCell($row['display_local'], 'center'$style);
  156.                         $table->addCell($row['name'], 'center'$style);
  157.                         
  158.                         $colour = !$colour;
  159.                     }
  160.         
  161.                     $output "app/output/tabular.{$format}";
  162.                     
  163.                     // stores the file
  164.                     if (!file_exists($output) OR is_writable($output))
  165.                     {
  166.                         $table->save($output);
  167.                         parent::openFile($output);
  168.                     }
  169.                     else
  170.                     {
  171.                         throw new Exception(_t('Permission denied') . ': ' $output);
  172.                     }
  173.                     
  174.                     // shows the success message
  175.                     //new TMessage('info', 'Relatório gerado com Sucesso! Por favor, habilite janelas popup no navegador.');
  176.                 }
  177.             }
  178.             else
  179.             {
  180.                 new TMessage('error''Nenhum registro encontrado para o Visitante.');
  181.             }
  182.     
  183.             // close the transaction
  184.             TTransaction::close();
  185.         }
  186.         catch (Exception $e// in case of exception
  187.         {
  188.             new TMessage('error'$e->getMessage());
  189.             TTransaction::rollback();
  190.         }
  191.     }
  192. }
  193. ?>


Obrigado