Skip to content

Instantly share code, notes, and snippets.

@FredAzevedo
Last active October 31, 2018 02:27
Show Gist options
  • Save FredAzevedo/6c06b15801562ab35139d8537a3de42c to your computer and use it in GitHub Desktop.
Save FredAzevedo/6c06b15801562ab35139d8537a3de42c to your computer and use it in GitHub Desktop.
<?php
class OsOrcamento extends TWindow
{
public function __construct()
{
parent::__construct();
parent::setTitle('Orçamento de Serviços');
parent::setSize(0.8,0.8);
$object = new TElement('object');
$object->data = "tmp/OsOrcamentoReport.pdf";
$object->style = "width: 100%; height:calc(100% - 10px)";
parent::add($object);
}
function onViewOrcamento($param)
{
$key = $param['key'];
//START TCPDF
include_once( 'vendor/autoload.php' );
try
{
TTransaction::open('sample');
$units = SystemUnit::where('id','=',TSession::getValue('userunitid'))->load();
if ($units)
{
foreach ($units as $unit)
{
$pdf = new ReportWizard();
$pdf->set_logo("LogoWS.png");
$pdf->set_razao_social($unit->razao_social);
$pdf->set_nome_fantasia($unit->nome_fantasia);
$endereco = $unit->logradouro." Nº: ".$unit->numero." Bairro: ".$unit->bairro.". ".$unit->complemento." Cidade: ".$unit->cidade." UF: ".$unit->uf." CEP: ".$unit->cep;
$pdf->set_endereco($endereco);
$pdf->set_cnpj($unit->cnpj);
$pdf->set_documento($key);
$pdf->set_telefones($unit->telefone);
$pdf->set_ie($unit->insc_estadual);
$pdf->set_im($unit->insc_municipal);
$pdf->addPage('L', 'A4');
$arq = "/Users/fred/Documents/Projetos/MacroERP-5.0/tmp/OsOrcamentoReport.pdf";
$pdf->SetFont('Times','',12);
$pdf->Output($arq, "F");
}
}
//END TCPDF
TTransaction::close();
}
catch (Exception $e) // in case of exception
{
// shows the exception error message
new TMessage('error', '<b>Error</b> ' . $e->getMessage());
// undo all pending operations
TTransaction::rollback();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment