-
Notifications
You must be signed in to change notification settings - Fork 0
/
cetak_penjualan.php
137 lines (113 loc) · 3.32 KB
/
cetak_penjualan.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
session_start();
if (!isset($_SESSION["login"])) {
header("Location: index.php");
exit;
}
require_once __DIR__ . '/vendor/autoload.php';
require 'functions.php';
$no = $_GET["no"];
$bisnis = query("SELECT * FROM faktur JOIN bisnis USING(kode_bisnis) WHERE no_faktur = '$no'")[0];
$penjualan = query("SELECT * FROM faktur JOIN karyawan USING(id_karyawan) JOIN pembeli USING(id_pembeli) WHERE no_faktur = '$no' ")[0];
$transaksis = query("SELECT * FROM transaksi JOIN barang USING(kode_barang) JOIN kategori USING(kode_kategori) WHERE no_faktur = '$no' ");
$mpdf = new \Mpdf\Mpdf();
$html = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Faktur Penjualan</title>
<style>
body {
font-family : arial;
font-size : 12px;
}
.hijau th {
background-color: #009486;
color: white;
}
</style>
</head>
<body>
<table cellpadding="7" cellspacing="0" width="100%">
<tr>
<td><h1>' . $_SESSION["nama_bisnis"] . '</h1></td>
<td align="right"><p><b>Tanggal : ' . $penjualan["tgl_pemesanan"] . '</b></p></td>
</tr>
</table>
<br>
<table cellpadding="7" cellspacing="0" width="100%">
<tr>
<td>
<p>Dari
<br><strong>' . $penjualan["nama_karyawan"] . '</strong><br>' . $bisnis["alamat_bisnis"] . ' <br>Telp : ' . $bisnis["telp_bisnis"] . '<br>Email : ' . $bisnis["email_bisnis"] . '
</p>
</td>
<td>
<p>Kepada
<br><strong>' . $penjualan["nama_pembeli"] . '</strong><br>' . $penjualan["alamat_pembeli"] . '<br>Telp : ' . $penjualan["telp_pembeli"] . '<br>Email : ' . $penjualan["email_pembeli"] . '</br>
</p>
</td>
<td>
<p>
<b>No Faktur : ' . $penjualan["no_faktur"] . '</b><br><b>Tanggal Jatoh Tempo : </b><br>' . $penjualan["tgl_jatohtempo"] . '
</p>
</td>
</tr>
</table>
<br>
<table cellpadding="7" cellspacing="0" width="100%">
<thead>
<tr>
<th style="text-align: left">Nama Barang</th>
<th style="text-align: left">Kategori</th>
<th style="text-align: left">Kuantitas</th>
<th style="text-align: left">Harga Satuan</th>
<th style="text-align: left">Jumlah</th>
</tr>
</thead>
<tbody>
';
foreach ($transaksis as $transaksi) {
$html .= '
<tr>
<td>' . $transaksi["nama_barang"] . '</td>
<td>' . $transaksi["nama_kategori"] . '</td>
<td>' . $transaksi["kuantitas"] . '</td>
<td>Rp ' . $transaksi["harga_jual"] . '</td>
<td>Rp ' . $transaksi["kuantitas"] * $transaksi["harga_jual"] . '</td>
</tr>';
};
$html .= '
<tr class="hijau left">
<th colspan="4" >TOTAL</th>
';
$total[] = 0;
foreach ($transaksis as $transaksi) {
$total[] = $transaksi["kuantitas"] * $transaksi["harga_jual"];
};
$html .= '
<th style="text-align: left">Rp ' . array_sum($total) . '</th>
</tr>
</tbody>
</table>
<br><br>
<table cellpadding="7" cellspacing="0" width="100%">
<tr>
<td>
<p>
<strong>Pembeli</strong><br><br><br><br><br>' . $penjualan["nama_pembeli"] . '
</p>
</td>
<td>
<p>
<strong>Karyawan</strong><br><br><br><br><br>' . $penjualan["nama_karyawan"] . '
</p>
</td>
</tr>
</table>
</body>
</html>
';
$mpdf->WriteHTML($html);
$mpdf->Output('faktur_penjualan_' . $penjualan["no_faktur"] . '.pdf', 'I');