Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'config.php';
- include 'laporan.php';
- // query list
- $sql = "SELECT * FROM table WHERE field = '' ";
- $query = $this->db->query($sql);
- $data = $query->result();
- // query sisa
- $sqlsisa = "SELECT * FROM table WHERE field = '' ";
- $querysisa = $this->db->query($sqlsisa);
- $sisa = $querysisa->result();
- $pdf = new Laporan();
- $pdf->AddPage('P', 'a4');
- $pdf->SetFont('Arial','',12);
- $pdf->SetMargins(5,10,0);
- $pdf->SetAutoPageBreak(0);
- $pdf->body($data, $sisa);
- $pdf->Output();
- ?>
- // file laporan.php
- <?php
- require('../assets/pdf/fpdf.php');
- class Laporan extends FPDF
- {
- function Header()
- {
- // code header
- //Pilih font Arial bold 15
- $this->SetFont('Arial','B',12);
- //Judul dalam bingkai
- $this->SetLeftMargin(5);
- $this->SetX(0);
- $this->SetY(0);
- $this->Cell(69,8,'LAPORAN ....','B',1,'L');
- // Insert a logo in the top-left corner at 300 dpi
- // $this->Image('http://path.com/assets/img/logo-cuci-medium.png',175,1,30);
- }
- public function body($data, $sisa)
- {
- // code display body pdf
- $this->SetX(200);
- $this->SetY(12);
- $this->SetX(0);
- $this->SetY(10);
- $this->SetFont('Arial','',10);
- $this->Ln(5);
- $this->Cell(30,5,"SISA",0,0);
- $this->Cell(40,5,": ". $sisa,0,1);
- foreach ($data as $row) {
- $this->Cell(50,5,$row->field,'BR',0,'L');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement