Yii Framework Forum: Membuat Report Fpdf Dari Php Ke Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Membuat Report Fpdf Dari Php Ke Yii membuat report fpdf dari php ke yii Rate Topic: -----

#1 User is offline   Yoga07 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 12-February 13

Posted 14 February 2013 - 04:18 AM

master master saya newbie nih udah keliling keliling cari cara tutorial bikin report pake fpdf ga masih ga ngerti aja
nah saya buat aja di php nya cara ke yii innya gimana yah ? makasih para master
<?php
//koneksi ke database
$host = "localhost";
$user = "root";
$pass = "";
$dbnm = "aplikasi";
$conn = mysql_connect($host, $user, $pass);
if ($conn) {
$open = mysql_select_db($dbnm);
if (!$open) {
die ("Database tidak dapat dibuka karena ".mysql_error());
}
} else {
die ("Server MySQL tidak terhubung karena ".mysql_error());
}
$query = mysql_query("select * from penjualan");
$data = array();
while($row = mysql_fetch_assoc($query)){
array_push($data,$row);
}
$judul = "Laporan Penjualan";
$header = array(
array("label"=>"ID","length"=>30,"align"=>"L"),
array("label"=>"Kode Jual","length"=>30,"align"=>"L"),
array("label"=>"Nama Jual","length"=>40,"align"=>"L"),
array("label"=>"Singakatan Nama","length"=>40,"align"=>"L")
);

require_once('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B','16');
$pdf->Cell(0,20, $judul, '0', 1, 'C');
$pdf->SetFont('Arial','','10');
$pdf->SetFillColor(255,0,0);
$pdf->SetTextColor(255);
$pdf->SetDrawColor(128,0,0);
foreach ($header as $kolom) {
$pdf->Cell($kolom['length'], 5, $kolom['label'], 1, '0',
$kolom['align'], true);
}
$pdf->Ln();

$pdf->SetFillColor(224,235,255);
$pdf->SetTextColor(0);
$pdf->SetFont('');
$fill=false;
foreach ($data as $baris) {
$i = 0;
foreach ($baris as $cell) {
$pdf->Cell($header[$i]['length'], 5, $cell, 1, '0',
$kolom['align'], $fill);
$i++;
}
$fill = !$fill;
$pdf->Ln();
}

$pdf->Output();
?>

?>
0

#2 User is offline   Nur Rochim 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 04-February 13
  • Location:Indonesia

Posted 14 February 2013 - 08:19 AM

Quote

::) Coba nyemplung d sini aja gan... dah pada di bhs ne klik disini
ini ane ada tutor fpdf gan klik disono
atau ini gan ekstn klik

0

#3 User is offline   M Hermansyah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 25-August 13

Posted 29 December 2013 - 11:01 PM

saya coba buat penjelasan step-by-step untuk membuat surat dalam pdf di file terlampir. Sudah teruji jalan di localhost.

Ada perubahan sedikit di file terlampir:
1. Di protected/controller/SuratController.php, tambahkan ‘pdf’menjadi..
….
'actions'=>array('index','view','pdf')
….

2. Untuk implementasi di webserver (karena Fatal error: Class 'FPDF' not found in..yg terjadi karena pengaruh huruf kapital/kecil) perlu beberapa perbaikan:
a) Nama file protected/components/PDF.php diganti jadi Pdf.php.
B) Di dalam file Pdf.php text "Class PDF extends FPDF" ganti menjadi "Class PDF extends fpdf".
c) Pada file protected/controller/SuratController.php
//Instanciation of inherited class
$pdf=new PDF('P','mm','A4'); ubah jadi $pdf=new Pdf('P','mm','A4'); //hanya huruf P yg besar

Attached File(s)


0

#4 User is offline   Nasirudin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 01-March 13
  • Location:Cikarang

Posted 22 March 2014 - 09:15 PM

Komplit Mas terimaksih sangat membantu
0

#5 User is offline   zayhard99 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-September 13

Posted 21 April 2014 - 12:27 AM

Trims tutorialnya mas. :)
oh ya, mau tanya lebih baik pakek fpdf ini atau dompdf ya mas ?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users