Created
August 24, 2013 13:19
-
-
Save gilsonbp/6328106 to your computer and use it in GitHub Desktop.
Método para impressão de relatório com mPdf.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function relatorioAction() { | |
$this->getHelper('layout')->disableLayout(); | |
$this->getHelper('viewRenderer')->setNoRender(); | |
// default path mpdf and library | |
define('_MPDF_PATH', '../library/mpdf/'); | |
include '../library/mpdf/mpdf.php'; | |
$itens = new Application_Model_DbTable_Pedidoitem(); | |
$pedidos = new Application_Model_DbTable_Pedido(); | |
$usuario = $pedidos->getDadosUserPedido($this->_getParam('id')); | |
$html = "<html><head>"; | |
$html .= "<link href='" . CSS_PATH . "/style.css' rel='stylesheet' type='text/css'>"; | |
$html .= "<link href='" . CSS_PATH . "/grid_rel.css' rel='stylesheet' type='text/css'>"; | |
$html .= "<title>Teste</title>"; | |
$html .= "</head><body>"; | |
$html .= "<ul class='box-rel'><li> | |
<span class='label'>Cód. Cliente: </span> | |
<span class='campo'>{$usuario['codigo']}</span> | |
</li>"; | |
$html .= "<li> | |
<span class='label'>Nome: </span> | |
<span class='campo'>{$usuario['nome']}</span> | |
</li>"; | |
$html .= "<li> | |
<span class='label'>E-mail: </span> | |
<span class='campo'>{$usuario['email']}</span> | |
</li>"; | |
$html .= "<li> | |
<span class='label'>Fone: </span> | |
<span class='campo'>{$usuario['fone']}</span> | |
</li></ul>"; | |
$html .= "<div id='grid'> | |
<table border='0' cellspacing='0'> | |
<thead> | |
<tr> | |
<th>Cod. Aux.</th> | |
<th>Produto</th> | |
<th>Quant</th> | |
<th>Pontos</th> | |
<th>Total</th> | |
<th>Status</th> | |
</tr> | |
</thead> | |
<tbody>"; | |
$i = 0; | |
foreach ($itens->getItensTrocaGeral($this->_getParam('id')) as $item) { | |
if (($i % 2) == 1) { | |
$class_grid = "linha2"; | |
} else { | |
$class_grid = "linha1"; | |
} | |
switch ($item['status']) { | |
case 'P': | |
$status = "Pendente"; | |
break; | |
case 'T': | |
$status = "Trocado"; | |
break; | |
} | |
$html .= "<tr class='$class_grid'>"; | |
$html .= "<td>{$item['cod_aux']}</td>"; | |
$html .= "<td>{$item['titulo']}</td>"; | |
$html .= "<td style='text-align: center;'>" . number_format($item['quant'], 0, ',', '.') . "</td>"; | |
$html .= "<td>" . number_format($item['pontos'], 0, ',', '.') . "</td>"; | |
$html .= "<td>" . number_format($item['quant'] * $item['pontos'], 0, ',', '.') . "</td>"; | |
$html .= "<td>$status</td></tr><br/>"; | |
$i++; | |
} | |
$html .= "</tbody> | |
</table> | |
</div>"; | |
$html .= "<br/><br/><br/><br/> | |
<table style='width: 100%; border: 0;'> | |
<tr> | |
<td style='text-align: center;'>Ass.:-----------------------------------------</td> | |
<td style='text-align: center;'>Ass.:-----------------------------------------</td> | |
</tr> | |
<tr> | |
<td style='text-align: center;'>Separação Produtos</td> | |
<td style='text-align: center;'>Emissão Nota Fiscal</td> | |
</tr> | |
</table>"; | |
$html .= "</body></html>"; | |
$pdf = new mPDF(); | |
$pdf->SetTitle("Relatório de Trocas"); | |
$pdf->SetAuthor("Harpia Systems - Clube Wellida"); | |
$pdf->SetHeader('Supermercado Wellida|Relatório de Trocas|{DATE j/m/Y}'); | |
$pdf->SetFooter('Supermercado Wellida||{PAGENO}'); | |
$pdf->WriteHTML($html); | |
$pdf->Output(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment