38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
// ob_start();
|
|
|
|
$pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
|
|
$pdf->AddPage('P');
|
|
$i = 0;
|
|
$html = '</h4> <h2 align="center">LAPORAN RIWAYAT KONSUMSI PENGGUNA</h2>
|
|
<p>DARI TGL: ' . $mulai . ' S/D TGL: ' . $sampai . '</p>
|
|
<table cellspacing="1" border="1" bgcolor="#666666" cellpadding="2">
|
|
<tr bgcolor="#ffffff">
|
|
<th width="50%" align="center">Waktu</th>
|
|
<th width="25%" align="center">Nama</th>
|
|
<th width="25%" align="center">Total Kalori</th>
|
|
</tr>';
|
|
|
|
$total = 0;
|
|
$jm = 0;
|
|
foreach ($data as $value) {
|
|
$i++;
|
|
$html .= '<tr bgcolor="#ffffff">
|
|
<td align="left">' . date("d-m-Y", strtotime($value->waktu)) . '</td>
|
|
<td align="center">' . $value->nama . '</td>
|
|
<td align="center">' . round($value->total_kalori, 0) . '</td>
|
|
</tr>';
|
|
if ($value->total_kalori != 0) {
|
|
$total += round($value->total_kalori);
|
|
$jm += 1;
|
|
}
|
|
}
|
|
|
|
|
|
$total = $total / $jm;
|
|
$html .= '</table>';
|
|
$pdf->writeHTML($html, true, false, true, false, '');
|
|
ob_end_clean();
|
|
$pdf->Output('LAPORAN_KALORI_' . $sampai . '.pdf', 'I');
|
|
?>
|