Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Dificuldade com acentos e TTableWriterHTML Prezados, boa tarde! Estou tendo dificuldades em gerar um relatório tabular na questão dos acentos com o TTableWriterHTML. O mesmo código funciona perfeitamente com TTableWriterPDF. Verificando o TTableWriterHTML, ele gera um simples sem a questão do charset, etc.. Será que alguém poderia me dar uma forcinha? Grato desde já! Abaixo o código que estou gerando o relatório. ...
EC
Dificuldade com acentos e TTableWriterHTML  
Prezados, boa tarde!
Estou tendo dificuldades em gerar um relatório tabular na questão dos acentos com o TTableWriterHTML. O mesmo código funciona perfeitamente com TTableWriterPDF. Verificando o TTableWriterHTML, ele gera um simples <html> sem a questão do charset, etc..

Será que alguém poderia me dar uma forcinha?
Grato desde já!

Abaixo o código que estou gerando o relatório.
public static function printPedido($param) { $colour = false; $widths = array(350, 70, 30); $formato = ''; if(TPage::isMobile()) { $table = new TTableWriterHTML($widths); $formato = 'HTML'; // requisição veio de um celular } else { $table = new TTableWriterPDF($widths); $formato = 'PDF'; } $table->id = $param['id']; UtilService::paramRel($table,16,14,10,7); //($table,$fontTitle,$fontSubtitle,$font,$fontSmall) $table->setHeaderCallback( function($table) { $unidade = TSession::getValue('userunitid'); $empresa = Empresa::find( $unidade ); $razao = strtoupper($empresa->razao); $table->addRow(); $table->addCell(utf8_decode($razao), 'left', 'header', 3); $table->addRow(); $table->addCell('Solicitação de Orçamento Num: '. $table->id, 'left', 'subtitulo', 3); $table->addRow(); $table->addCell(utf8_decode("Data da Solicitação: " . date('d/m/Y h:i:s')), 'left', 'date', 3); $table->addRow(); $table->addCell('Solicita Orçamento dos Itens Abaixo: ', 'left', 'date', 3); $table->addRow(); $table->addRow(); $table->addCell('Produto','left','title'); $table->addCell('Quantidade','left','title'); $table->addCell('Um','left','title'); UtilService::footerRel($table,3); //table and merge }); $pedidos = Pedido::find($param['id']); $itensPedido = ItensPedido::where('pedido_id','=',$param['id']) ->load(); foreach($itensPedido as $item) { $infs['id'] = $item->produto_id; $detail = AlmoxarifeService::getComposicaoProd($infs); $style = $colour ? 'datap' : 'datai'; $table->addRow(); $table->addCell(utf8_decode($detail->produto_nome), 'left', $style); $table->addCell(number_format($item->qtd,2,',','.'), 'right', $style); $table->addCell(utf8_decode($detail->um_sigla), 'center', $style); $colour = !$colour; } //fim foreach $produtos UtilService::windowOpen($table,'SolicitacaodeOrcamentoNum-',$formato,'Solicitação de Orçamento'); //($table,$fileName,$formato,$title) }


Uso estes services no código:

  1. <?php
  2. class UtilService 
  3. {
  4.      
  5.       
  6.     public static function paramRel($table,$fontTitle,$fontSubtitle,$font,$fontSmall)
  7.     {
  8.         $table->addStyle('header''Helvetica'"{$fontTitle}"'B''#000000''#ffffff','');
  9.         $table->addStyle('subtitulo''Helvetica'"{$fontSubtitle}"'''#000000''#ffffff','');
  10.         $table->addStyle('date''Helvetica'"{$font}'''#000000''#ffffff','');
  11.         $table->addStyle('cabecalho',  'Helvetica'"{$font}"'B''#ffffff''#617FC3');
  12.         $table->addStyle('title',  'Helvetica'"{$font}"'B''#ffffff''#2F4F4F');
  13.         $table->addStyle('datap',  'Helvetica'"{$font}"'',  '#000000''#E3E3E3''LR');
  14.         $table->addStyle('datai',  'Helvetica'"{$font}"'',  '#000000''#ffffff''LR');
  15.         $table->addStyle('totap',  'Helvetica'"{$font}"'B',  '#000000''#E3E3E3''LR');
  16.         $table->addStyle('totai',  'Helvetica'"{$font}"'B',  '#000000''#ffffff''LR');
  17.         $table->addStyle('footer''Helvetica'"{$fontSmall}"'',  '#ffffff''#2F4F4F');
  18.         $table->addStyle('error''Helvetica'"{$font}"'B',  '#ffffff''#ff0000');
  19.     }
  20.     
  21.     public static function footerRel($table,$merge)
  22.     {
  23.         $table->mergeFooter = (int) intval($merge);
  24.         $table->setFooterCallback( function($table) {
  25.         $table->addRow();
  26.         $table->addCell(utf8_decode('SGA SOLUTIONS |  www.sgagricola.com.br | Software de Gestão Agrícola'), 'center''footer'$table->mergeFooter);
  27.         });
  28.     }
  29.     
  30.     public static function windowOpen($table,$fileName,$formato,$title)
  31.     {
  32.         $file "app/output/{$fileName}".md5(uniqid(""));
  33.         $output $file.$formato;
  34.         // stores the file
  35.         if (!file_exists($output) OR is_writable($output))
  36.             {
  37.                 $table->save($output);
  38.                 //parent::openFile($output);
  39.                 //TPage::openFile($output);
  40.                 // open window to show pdf
  41.                 $window TWindow::create(("$title"), 0.90.9);
  42.                 $object = new TElement('object');
  43.                 $object->data  $output;
  44.                 $object->type  'application/pdf';
  45.                 $object->style "width: 100%; height:calc(100% - 10px)";
  46.                 $window->add($object);
  47.                 $window->show();
  48.             }
  49.             else
  50.             {
  51.                 throw new Exception(_t('Permission denied') . ': ' $output);
  52.             }
  53.     }
  54.     
  55.     
  56. }
  57. </code>



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 (2)


LE

Boa tarde Eriuton Charle

Verifique a codificação dos arquivos que está usando para gerar o relatório.
Abra com o Notepad++ e verifique no rodapé se está definido como UTF-8

Outra configuração que deve verificar está relacionado a configuração do seu servidor PHP.
Verifique se a TAG "default_charset" está definida como UTF-8 no php.ini.

Qualquer dúvida sigo a disposição.
EC

Bom dia Leandro Bermond Ebani, desde já Obrigado por responder!
Olha estou usando a ferramenta Adianti Builder, ainda com o teste online, não estou ainda em ambiente de produção, então não sei como olhar isso aqui!