-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcetak_rekap.php
61 lines (53 loc) · 1.63 KB
/
cetak_rekap.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
session_start();
include "koneksi.php";
#ambil data di tabel dan masukkan ke array
$query = "SELECT dt.idtransaksi,dt.idbarang,t.tanggal,dt.qty,dt.harga,dt.subtotal FROM transaksi t,detail_pembayaran dt WHERE dt.idtransaksi=t.idtransaksi";
$sql = mysql_query ($query);
$data = array();
while ($row = mysql_fetch_assoc($sql)) {
array_push($data, $row);
}
#setting judul laporan dan header tabel
$judul = "Rekap Pembayaran";
$header = array(
array("label"=>"ID Transaksi", "length"=>30, "align"=>"L"),
array("label"=>"ID Barang", "length"=>30, "align"=>"L"),
array("label"=>"Tanggal", "length"=>30, "align"=>"L"),
array("label"=>"Quantity", "length"=>30, "align"=>"L"),
array("label"=>"Harga", "length"=>30, "align"=>"L"),
array("label"=>"Subtotal", "length"=>30, "align"=>"L"),
);
#sertakan library FPDF dan bentuk objek
require_once ("assets/fpdf/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
#tampilkan judul laporan
$pdf->SetFont('Arial','B','16');
$pdf->Cell(0,20, $judul, '0', 1, 'C');
#buat header tabel
$pdf->SetFont('Arial','','10');
$pdf->SetFillColor(355,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();
#tampilkan data tabelnya
$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();
}
#output file PDF
$pdf->Output();
?>