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.
Uso estes services no código:
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:
- <?php
- class UtilService
- {
- public static function paramRel($table,$fontTitle,$fontSubtitle,$font,$fontSmall)
- {
- $table->addStyle('header', 'Helvetica', "{$fontTitle}", 'B', '#000000', '#ffffff','');
- $table->addStyle('subtitulo', 'Helvetica', "{$fontSubtitle}", '', '#000000', '#ffffff','');
- $table->addStyle('date', 'Helvetica', "{$font}" , '', '#000000', '#ffffff','');
- $table->addStyle('cabecalho', 'Helvetica', "{$font}", 'B', '#ffffff', '#617FC3');
- $table->addStyle('title', 'Helvetica', "{$font}", 'B', '#ffffff', '#2F4F4F');
- $table->addStyle('datap', 'Helvetica', "{$font}", '', '#000000', '#E3E3E3', 'LR');
- $table->addStyle('datai', 'Helvetica', "{$font}", '', '#000000', '#ffffff', 'LR');
- $table->addStyle('totap', 'Helvetica', "{$font}", 'B', '#000000', '#E3E3E3', 'LR');
- $table->addStyle('totai', 'Helvetica', "{$font}", 'B', '#000000', '#ffffff', 'LR');
- $table->addStyle('footer', 'Helvetica', "{$fontSmall}", '', '#ffffff', '#2F4F4F');
- $table->addStyle('error', 'Helvetica', "{$font}", 'B', '#ffffff', '#ff0000');
- }
- public static function footerRel($table,$merge)
- {
- $table->mergeFooter = (int) intval($merge);
- $table->setFooterCallback( function($table) {
- $table->addRow();
- $table->addCell(utf8_decode('SGA SOLUTIONS | www.sgagricola.com.br | Software de Gestão Agrícola'), 'center', 'footer', $table->mergeFooter);
- });
- }
- public static function windowOpen($table,$fileName,$formato,$title)
- {
- $file = "app/output/{$fileName}".md5(uniqid(""));
- $output = $file.$formato;
- // stores the file
- if (!file_exists($output) OR is_writable($output))
- {
- $table->save($output);
- //parent::openFile($output);
- //TPage::openFile($output);
- // open window to show pdf
- $window = TWindow::create(("$title"), 0.9, 0.9);
- $object = new TElement('object');
- $object->data = $output;
- $object->type = 'application/pdf';
- $object->style = "width: 100%; height:calc(100% - 10px)";
- $window->add($object);
- $window->show();
- }
- else
- {
- throw new Exception(_t('Permission denied') . ': ' . $output);
- }
- }
- }
- </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
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4
Quero me inscrever agora!
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.
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!