<?php
require "fpdf.php";
$db = new PDO("mysql:host=localhost;dbname=coba","root");
$id="";
class myPDF extends FPDF{
function header(){
$this->image('adw1.png',15,10);
$this->image('huawei.png',235,13);
$this->SetFont('Times','B',14);
$this->Cell(276,10,'Berita Acara Barang Keluar',0,0,'C');
$this->Ln();
$this->SetFont('Times','B',12);
$this->Cell(276,10,'PT ADYAWINSA WEST JAVA',0,0,'C');
$this->Ln(20);
$this->SetFont('Times','',10);
$this->Cell(276,-15,'JL. RUMAH SAKIT NO 108',0,0,'C');
$this->Ln(5);
$this->Line(10,36,287,36);
$this->SetLineWidth(0);
$this->Line(10,37,287,37);
$this->Ln(5);
$this->SetFont('Times','B',8);
$this->Cell(8,10,'No',1,0,'C');
$this->Cell(20,10,'Tgl Keluar',1,0,'C');
$this->Cell(30,10,'Nama Receiver',1,0,'C');
$this->Cell(60,10,'Nama Barang',1,0,'C');
$this->Cell(15,10,'Bom Code',1,0,'C');
$this->Cell(35,10,'Site Name',1,0,'C');
$this->Cell(20,10,'Site ID',1,0,'C');
$this->Cell(10,10,'Qty',1,0,'C');
$this->Cell(10,10,'Unit',1,0,'C');
$this->Cell(20,10,'Material Type',1,0,'C');
$this->Cell(20,10,'Nama Project',1,0,'C');
$this->Cell(30,10,'Keterangan',1,0,'C');
$this->Ln();
}
function footer(){
$this->SetY(-15);
$this->SetFont('Arial','',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
$this->SetY(140);
$this->SetFont('Arial','',10);
$this->Cell(100,10,'Receiver',0,0,'C');
$this->SetY(140);
$this->SetFont('Arial','',10);
$this->Cell(0,10,'Verified By',0,0,'C');
$this->SetY(140);
$this->SetFont('Arial','',10);
$this->Cell(450,10,'Approved By',0,0,'C');
$this->SetY(160);
$this->SetFont('Arial','',10);
$this->Cell(100,10,'(.........................)',0,0,'C');
$this->SetY(160);
$this->SetFont('Arial','',10);
$this->Cell(0,10,'(.........................)',0,0,'C');
$this->SetY(160);
$this->SetFont('Arial','',10);
$this->Cell(450,10,'(.........................)',0,0,'C');
}
function viewTable($db){
$no=1;
$id = $_GET['bk_id'];
$this->SetFont('Times','',6);
$stmt = $db->query("SELECT tgl_keluar, nama_karyawan, barang_nama, bom_code, site_name, site_id, qty, barang_kategori, material_type, nama_project, keterangan from barang_keluar INNER JOIN bk_detail ON barang_keluar.bk_id = bk_detail.bk_id where barang_keluar.bk_id = '$id'");
while($data = $stmt->fetch(PDO::FETCH_OBJ))
{
$this->Cell(8,10,$no++,1,0,'C');
$this->Cell(20,10,$data->tgl_keluar,1,0,'C');
$this->Cell(30,10,$data->nama_karyawan,1,0,'C');
$this->Cell(60,10,$data->barang_nama,1,0,'C');
$this->Cell(15,10,$data->bom_code,1,0,'C');
$this->Cell(35,10,$data->site_name,1,0,'C');
$this->Cell(20,10,$data->site_id,1,0,'C');
$this->Cell(10,10,$data->qty,1,0,'C');
$this->Cell(10,10,$data->barang_kategori,1,0,'C');
$this->Cell(20,10,$data->material_type,1,0,'C');
$this->Cell(20,10,$data->nama_project,1,0,'C');
$this->Cell(30,10,$data->keterangan,1,0,'C');
$this->Ln();
}
}
}
$pdf = new myPDF();
$pdf->SetAutoPageBreak(true,70);
$pdf->AliasNbPages();
$pdf->AddPage('L','A4',0);
$pdf->viewTable($db);
$pdf->Output();;