Kaskus

Tech

ngapabangetAvatar border
TS
ngapabanget
(ASK) PHP Report dengan FPDF
Sebelumnya ane permisi buat agan - agan Programer & web master lainnya emoticon-Big Grin
ane mau minta tolong & mohon bantuannya nih,
kebetulan ane baru pertama kali bikin Report pake FPDF
nah ane itu masih bingung sama peletakkkan & pemanggilan query dari DB (MySql)

Spoiler for ini bentuk laporannya:


nah ceritanya ane itu kan punya 2 tabel DB (pohouling & pohouling_detail) mau manggil data dari DB MySQL ke kolom yang ane warnai merahitu gan,

Spoiler for ini tabel DB'nya:


kebetulan kalau untuk mengambil setiap field dari tabel yg ade di DB ane itu udah alhamdulillah udah berhasil emoticon-Peace(yg ane kasih buletan Ijo)

langsung aje yaa gan ke coodingan ane :

Code:

<?php

require_once("fpdf/fpdf.php");

class FPDF_AutoWrapTable extends FPDF {
private $data = array();
private $options = array(
'filename' => '',
'destinationfile' => '',
'paper_size'=>'A4',
'orientation'=>'P'
);

function __construct($data = array(), $options = array()) {
parent::__construct();
$this->data = $data;
$this->options = $options;

}

public function rptDetailData () {
//
$border = 0;
$this->AddPage();
$this->SetAutoPageBreak(true,60);
$this->AliasNbPages();
$left = 25;


$this->Image('image/max.jpeg',27,27,75,45);

//header
$this->SetFont("", "B", 11);
$this->Cell(0,18, ' PT. ........................');

$this->Ln(11);
$this->SetFont("", "", 8);
$this->Cell(0,22, ' ........................... ');

$this->Ln(10);
$this->SetFont("","", 8);
$this->Cell(0,26,' ..............................');

$this->Ln(20);
$this->Cell(0, 2, " ", "B");
$this->Ln();
$this->Cell(0, 2, " ", "B");
$this->Ln(15);

$this->SetFont('','B',8);
$this->Cell(0,5,'PO ( Purchase Order )',0,0,'C');
$this->Ln(10);
$this->Cell(0,5,'..............................',0,0,'C');

$this->Ln(10);
$this->SetFont('','',7);
//$this->Cell(0,40,'ID Work Order ',0,'LR', 'L');



$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'P/O No', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h, '' , 0, 0, 'L',true);


$this->Ln(15);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'P/O Date', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': 19/10/2012', 0, 0, 'L',true);


$this->Ln(15);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'Delivery Date', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': 20/10/2012 to 21/10/2012', 0, 0, 'L',true);


$this->Ln(15);
$this->Cell(0, 2, " ", "B");


$this->Ln(3);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'Contract Refference No', 0, 0, 'C',true);
$this->SetX($left += 170); $this->Cell(100, $h,': 12345', 0, 0, 'L',true);


$this->Ln(14);
$this->Cell(250, 1, " ", "B");


$this->Ln(5);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'PO Quantity', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': 12345', 0, 0, 'L',true);


$this->Ln(15);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'PO Delivery Quantity', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': 12345', 0, 0, 'L',true);


$this->Ln(15);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'Remain PO Quantity', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': 12345', 0, 0, 'L',true);


$this->Ln(16);
$this->Cell(250, 2, " ", "B");
$this->Ln(2);
$this->Cell(250, 2, " ", "B");

$this->Ln(5);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'MPC Head Office Contact Person', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': cahyo', 0, 0, 'L',true);


$this->Ln(15);
$h = 15;
$left = 28.5;
$top = 80;
$this->SetFillColor(255,255,255);
$this->SetX($left += 0); $this->Cell(170, $h, 'MPC Port Contact Person', 0, 0, 'L',true);
$this->SetX($left += 170); $this->Cell(100, $h,': ardy', 0, 0, 'L',true);

$this->Ln(15);
$this->Cell(0, 2, " ", "B");






$this->Ln(15);
$h = 20;
$left = 40;
$top = 80;
#tableheader
$this->SetFont("", "B", 7);
$this->SetFillColor(255,255,255);
$left = $this->GetX();
$this->Cell(20,$h,'Seq',1,0,'C',true);
$this->SetX($left += 20); $this->Cell(100, $h, 'Spesification', 1, 0, 'C',true);
$this->SetX($left += 100); $this->Cell(60, $h, 'SPK Seq Plan', 1, 0, 'C',true);
$this->SetX($left += 60); $this->Cell(40, $h, 'Unit', 1, 0, 'C',true);
$this->SetX($left += 40); $this->Cell(45, $h, 'Qty', 1, 0, 'C',true);
$this->SetX($left += 45); $this->Cell(60, $h, 'Price', 1, 0, 'C',true);
$this->SetX($left += 60); $this->Cell(70, $h, 'Amount', 1, 0, 'C',true);
$this->SetX($left += 70); $this->Cell(70, $h, 'Port Destination', 1, 0, 'C',true);
$this->SetX($left += 70); $this->Cell(75, $h, 'Remark', 1, 1, 'C',true);
//$this->Ln(20);

$this->SetFont('','',7);
$this->SetWidths(array(20,100,60,40,45,60,70,70,75));
$this->SetAligns(array('C','L','C','C','C','C','C','C','L'));
$no = 1;

//tipu daya
$amount = 200000000;

$this->SetFillColor(255);
foreach ($this->data as $baris) {
$this->Row(
array($no++,
$baris['spesification'],
$baris['wosequenceplan'],
$baris['unit'],
$baris['qty'],
$baris['price'],
$amount,
$baris['id_port'],
$baris['remark']

));
}
$this->Ln(10);
$this->Cell(0, 2.5, " ", "B");

$this->Ln(12);
$this->Cell(0,20,'Grand Total : Rp. 200.000.000,00',1,0, 'C');

$this->Ln(30);
$h = 50;


Lanjutan coodingnya di bawah yaa gan,
gak muat soalnya emoticon-Big Grin
Diubah oleh ngapabanget 22-10-2012 19:29
0
1.7K
1
GuestAvatar border
Komentar yang asik ya
Urutan
Terbaru
Terlama
GuestAvatar border
Komentar yang asik ya
Komunitas Pilihan