forked from andre1337/punya-joshua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcetakp.php
61 lines (54 loc) · 1.74 KB
/
cetakp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
//koneksi ke database
mysql_connect("localhost","root","");
mysql_select_db("db_ikan");
//mengambil data dari tabel
$sql=mysql_query("SELECT t.id_transaksi, t.nama_pembeli, t.alamat, t.pakan, t.harga, t.jumlah, t.total FROM transaksip t order by id_transaksi asc");
$data = array();
while ($row = mysql_fetch_assoc($sql)) {
array_push($data, $row);
}
//mengisi judul dan header tabel
$judul = "LAPORAN TRANSAKSI PEMESANAN PAKAN IKAN";
$header = array(
array("label"=>"TRANSAKSI", "length"=>20, "align"=>"L"),
array("label"=>"NAMA PEMBELI", "length"=>30, "align"=>"L"),
array("label"=>"ALAMAT", "length"=>30, "align"=>"L"),
array("label"=>"PAKAN IKAN", "length"=>40, "align"=>"L"),
array("label"=>"HARGA", "length"=>20, "align"=>"L"),
array("label"=>"JUMLAH", "length"=>20, "align"=>"L"),
array("label"=>"TOTAL", "length"=>30, "align"=>"L"),
);
//memanggil fpdf
require_once ("fpdf/fpdf.php");
$pdf = new FPDF;
$pdf->AddPage();
//tampilan Judul Laporan
$pdf->SetFont('Arial','B','16'); //Font Arial, Tebal/Bold, ukuran font 1
$pdf->Cell(0,20, $judul, '0', 1, 'C');
//Header Table
$pdf->SetFont('Arial','','9');
$pdf->SetFillColor(46, 139, 87); //warna dalam kolom header
$pdf->SetTextColor(255); //warna tulisan putih
$pdf->SetDrawColor(0, 100, 0); //warna border
foreach ($header as $kolom) {
$pdf->Cell($kolom['length'], 5, $kolom['label'], 1, '0', $kolom['align'], true);
}
$pdf->Ln();
//menampilkan data table
$pdf->SetFillColor(245, 222, 179); //warna dalam kolom data
$pdf->SetTextColor(0); //warna tulisan hitam
$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();
}
//output file pdf
$pdf->Output();
?>