PHP Jasper Estou utilizando o PHPJasper junto com o Adianti. Configurei e consigo fazer a geração do relatório, porém quando tento exibir uma mensagem e abrir uma janela com o meu PDF recebo a mensagem de erro: Uncaught Error: Class "TMessage" not found in Parece que ao processar o relatório as referências às classes do Adianti são perdidas. Alguém passou pelo mesmo problema?...
JP
PHP Jasper  
Estou utilizando o PHPJasper junto com o Adianti. Configurei e consigo fazer a geração do relatório, porém quando tento exibir uma mensagem e abrir uma janela com o meu PDF recebo a mensagem de erro:

Uncaught Error: Class "TMessage" not found in


Parece que ao processar o relatório as referências às classes do Adianti são perdidas.
Alguém passou pelo mesmo problema?


Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (3)


DA

Olá Jefferson

Você está usando a versão que utiliza o Java ou a versão só com o PHP?

Eu utilizo a versão só com PHP, a rotina de execução pelo Adianti, faço dessa forma:

 
  1. <?php
  2. class RelatorioReceber extends TPage
  3. {
  4. private $form;
  5. // use Adianti\base\AdiantiStandardListTrait;
  6. use Adianti\Base\AdiantiStandardListTrait; // Standard form methods
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->setDatabase('advday'); // defines the database
  11. $this->setActiveRecord('ViewExtrato'); // defines the active record
  12. $this->form = new BootstrapFormBuilder('form_RelatorioReceber');
  13. $this->form->setFormTitle('Relatório de Contas a Receber');
  14. $this->form->setProperty('style', 'margin:0;border:0');
  15. $this->form->setFieldSizes('100%');
  16. $inicio = new TDate('inicio');
  17. $final = new TDate('final');
  18. $tipodata = new TCombo('tipodata');
  19. $situacao = new TCombo('situacao');
  20. $filtercli = new TCriteria;
  21. $filtercli->add(new TFilter('tipo_cadastro', '=', '0'));
  22. $cliente_id = new TDBCombo('cliente_id','advday','Pessoas','id','nome','nome',$filtercli);
  23. $cliente_id->setSize('55%');
  24. $inicio->setMask('dd/mm/yyyy');
  25. $inicio->setDatabaseMask('yyyy-mm-dd');
  26. $inicio->setSize('100%');
  27. $final->setMask('dd/mm/yyyy');
  28. $final->setDatabaseMask('yyyy-mm-dd');
  29. $final->setSize('100%');
  30. $tipodata->addItems(['0'=>'Emissão','1'=>'Vencimento','2'=>'Pagamento']);
  31. $tipodata->setValue('0');
  32. $situacao->addItems(['0'=>'Aberto','1'=>'Liquidado','2'=>'Ambos']);
  33. $situacao->setValue('0');
  34. // add fields
  35. $this->form->addFields( [ new TLabel('Cliente') ], [ $cliente_id ] );
  36. $this->form->addFields( [ new TLabel('Tipo Data')],[$tipodata]);
  37. $this->form->addFields( [ new TLabel('Data Inicial ') ], [ $inicio ]);
  38. $this->form->addFields( [ new TLabel('Data Final') ], [$final] );
  39. $this->form->addFields( [ new TLabel('Situacao')],[$situacao]);
  40. // keep the form filled during navigation with session data
  41. $this->form->setData( TSession::getValue(__CLASS__.'_filter_data') );
  42. $this->form->addAction('Imprimir', new TAction([$this, 'onImprime'],['register_state' => 'false', 'static'=>'1']), 'fa:print red');
  43. $vbox = new TVBox;
  44. $vbox->style = 'width: 100%';
  45. //$vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  46. $vbox->add($this->form);
  47. parent::add($vbox);
  48. }
  49. public function onImprime($param = NULL)
  50. {
  51. $data = $this->form->getData();
  52. $data_filter = TSession::getValue(__CLASS__ . '_data_filter');
  53. TSession::setValue(__CLASS__ . '_data_filter', $data);
  54. TTransaction::open('advday');
  55. $emissao = 'Emitido em: '.date('d/m/Y H:i:s');
  56. $tipodata = $param['tipodata'];
  57. $cliente = (int) $param['cliente_id'];
  58. $inicio = TDate::convertToMask($param['inicio'], 'dd/mm/yyyy','yyyy/mm/dd' );
  59. $final = TDate::convertToMask($param['final'], 'dd/mm/yyyy','yyyy/mm/dd' );
  60. $situa = $param['situacao'];
  61. $parametros = array(
  62. "DATE_REPORT" => $emissao,
  63. "CONTAFIN" => $cliente,
  64. "TIPODATA" => $tipodata ,
  65. "INICIO" => $inicio,
  66. "FINAL" => $final,
  67. "SITUACAO" => $situa
  68. );
  69. $report_name = getcwd().'/app/reports/report_contasreceber.jrxml';
  70. TTransaction::setLogger(new TLoggerHTML('log.html'));
  71. $jasper = new TJasper($report_name, $parametros);
  72. $jasper->outpage();
  73. }
  74. public function show()
  75. {
  76. parent::show();
  77. }
  78. }
  79. ?>

Onde você está colocando a mensagem?
JP

Damião,
Obrigado pelo retorno!
Estou usando a última versão disponível no repositório do GitHub (não sei dizer exatamente se é com ou sem o Java).
TJasper é uma classe sua? É possível compartilhar a forma como vc está chamando o relatório, apenas para comparar com a minha?
DA

Jefferson,

A classe TJasper é do PHPJasper, da QuilhaSoft,que uso, essa abaixo:

 
  1. <?php
  2. use JasperPHP\Report;
  3. //use JasperPHP\ado\TTransaction; Utiliza do Adianti
  4. //use JasperPHP\ado\TLogger; Utiliza do Adianti
  5. //use JasperPHP\ado\TLoggerHTML; Utiliza do Adianti
  6. //use \NumberFormatter;
  7. //use PHPexcel as PHPexcel; // experimental
  8. /**
  9. * classe TJasper
  10. *
  11. * @author Rogerio Muniz de Castro <rogerio@quilhasoft.com.br>
  12. * @version 2018.10.15
  13. * @access restrict
  14. *
  15. * 2015.03.11 -- create
  16. * 2018.10.15 -- revision and internationalize, add TLogger classes
  17. * */
  18. class TJasper {
  19. private $report;
  20. private $type;
  21. private $param;
  22. /**
  23. * method __construct()
  24. *
  25. * @param $jrxml = a jrxml file name
  26. * @param $param = a array with params to use into jrxml report
  27. */
  28. public function __construct($jrxml, array $param) {
  29. $GLOBALS['reports'] = array();
  30. $xmlFile = $jrxml;
  31. $this->type = (array_key_exists('type', $param)) ? $param['type'] : 'pdf';
  32. //error_reporting(0);
  33. $this->param = $param;
  34. $this->report = new JasperPHP\Report($xmlFile, $param); // $GLOBALS['reports'][$xmlFile];
  35. switch ($this->type) {
  36. case 'pdf':
  37. JasperPHP\Instructions::prepare($this->report);
  38. break;
  39. case 'xls':
  40. JasperPHP\Instructions::setProcessor('\JasperPHP\XlsProcessor');
  41. JasperPHP\Instructions::prepare($this->report);
  42. break;
  43. case 'email':
  44. JasperPHP\Instructions::prepare($this->report);
  45. break;
  46. }
  47. }
  48. public function outpage($type = 'pdf') {
  49. $this->report->generate();
  50. $this->report->out();
  51. switch ($this->type) {
  52. case 'pdf':
  53. $pdf = JasperPHP\Instructions::get();
  54. $repname = "report".uniqid().".pdf";
  55. $pdf->Output(getcwd()."/app/output/{$repname}", "F");
  56. $window = TWindow::create('',0.8,0.8);
  57. $object = new TElement('iframe');
  58. $object->src = "app/output/{$repname}";
  59. $object->type = 'application/pdf';
  60. $object->style = "width: 100%; height:600px";
  61. $window->add($object);
  62. $window->show();
  63. break;
  64. case 'xls':
  65. header('Content-Type: application/vnd.ms-excel');
  66. header('Content-Disposition: attachment;filename="01simple.xls"');
  67. header('Cache-Control: max-age=0');
  68. // If you're serving to IE 9, then the following may be needed
  69. header('Cache-Control: max-age=1');
  70. // If you're serving to IE over SSL, then the following may be needed
  71. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  72. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  73. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  74. header('Pragma: public'); // HTTP/1.0
  75. $objWriter = PHPExcel_IOFactory::createWriter(JasperPHP\Instructions::$objOutPut, 'Excel5');
  76. $objWriter->save('php://output');
  77. break;
  78. case 'email':
  79. $pdf = JasperPHP\Instructions::get();
  80. $repname = "informe".uniqid().".pdf";
  81. $pdf->Output(getcwd()."/app/output/{$repname}", "F");
  82. TSession::setValue('name_pdf', "/app/output/{$repname}");
  83. break;
  84. }
  85. }
  86. public function setVariable($name, $value) {
  87. $this->report->arrayVariable[$name]['initialValue'] = $value;
  88. }
  89. }
  90. require('autoloader.php');
  91. require('tcpdf_include.php');
  92. require('tecnickcom/tcpdf/tcpdf.php'); // point to tcpdf class previosly instaled , (probaly in composer instalations)
  93. require('phpoffice/phpexcel/Classes/PHPExcel.php'); // point to tcpdf class previosly instaled , (probaly in composer instalations)
  94. //require('../TCPDF/tcpdf.php'); // point to tcpdf class previosly instaled , (probaly in stand alone instalations)
  95. // on production using composer instalation is not necessaty
  96. /*$report_name = isset($_GET['report']) ? $_GET['report'] : 'testReport.jrxml'; // sql into testReport.txt report do not select any table.
  97. TTransaction::open('dev');
  98. TTransaction::setLogger(new TLoggerHTML('log.html'));
  99. $jasper = new TJasper($report_name, $_GET);
  100. $jasper->outpage();*/
  101. /*public function post()
  102. {
  103. $database = \Config::get('database.connections.mysql');
  104. $output = public_path() . '/report/' . time() . '_codelution';
  105. $ext = "pdf";
  106. \JasperPHP::process(public_path() . '/report/codelution.jasper', $output, array($ext), array(), $database, false, false)->execute();
  107. header('Content-Description: File Transfer');
  108. header('Content-Type: application/octet-stream');
  109. header('Content-Disposition: attachment; filename=' . time() . '_codelution.' . $ext);
  110. header('Content-Transfer-Encoding: binary');
  111. header('Expires: 0');
  112. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  113. header('Pragma: public');
  114. header('Content-Length: ' . filesize($output . '.' . $ext));
  115. flush();
  116. readfile($output . '.' . $ext);
  117. unlink($output . '.' . $ext);
  118. // deletes the temporary file
  119. return Redirect::to('/reporting');
  120. }*/
  121. ?>


A chamada do relatório é essa parte:
 
  1. <?php
  2. $parametros = array(
  3. "DATE_REPORT" => $emissao,
  4. "CONTAFIN" => $cliente,
  5. "TIPODATA" => $tipodata ,
  6. "INICIO" => $inicio,
  7. "FINAL" => $final,
  8. "SITUACAO" => $situa
  9. );
  10. $report_name = getcwd().'/app/reports/report_contasreceber.jrxml';
  11. TTransaction::setLogger(new TLoggerHTML('log.html'));
  12. $jasper = new TJasper($report_name, $parametros);
  13. $jasper->outpage();
  14. ?>


Se quiser verificar como está funcionando o PHPJasper na aplicação, acessa www.retalhotecnologico.com.br/advday usuario e senha = visitante.