-
Notifications
You must be signed in to change notification settings - Fork 0
/
cetak_detail_penjualan.php
134 lines (108 loc) · 3 KB
/
cetak_detail_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
<?php
session_start();
if (!isset($_SESSION["login"])) {
header("Location: index.php");
exit;
}
require_once __DIR__ . '/vendor/autoload.php';
require 'functions.php';
$kode = $_SESSION["bisnis"];
$dari = $_POST["dari"];
$sampai = $_POST["sampai"];
$penjualans = query("SELECT kode_pembayaran, no_faktur, tgl_pembayaran, nama_pembeli, nama_karyawan, status, total_pembayaran
FROM faktur
JOIN pembeli USING (id_pembeli)
JOIN karyawan USING (id_karyawan)
JOIN pembayaran USING (no_faktur)
WHERE (tgl_pembayaran BETWEEN '$dari' AND '$sampai') AND faktur.kode_bisnis = '$kode'
ORDER BY (no_faktur) ");
$pembayaran = query("SELECT SUM(total_pembayaran) AS total FROM pembayaran JOIN faktur USING (no_faktur) WHERE tgl_pemesanan BETWEEN '$dari' AND '$sampai'")[0];
$mpdf = new \Mpdf\Mpdf();
$html = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laporan Penjualan</title>
<style>
body {
font-family : arial;
font-size : 12px;
}
.biru {
background-color: #BEE5EB;
}
.merah {
background-color: pink;
}
.hitam {
color : white;
background-color: black;
}
.h {
font-size : 18px;
}
.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 : ' . $dari . ' - ' . $sampai . '</b></p></td>
</tr>
</table>
<br>
<table cellpadding="7" cellspacing="0" width="100%">
<tr>
<td class="h">Laporan Penjualan</td>
</tr>
</table>
<br>
<table cellpadding="7" cellspacing="0" width="100%">
<thead>
<tr>
<th class="hitam">Status</th>
<th style="text-align: left">Kode Pembayaran</th>
<th style="text-align: left">No Faktur</th>
<th style="text-align: left">Tanggal Pembayaran</th>
<th style="text-align: left">Nama Pembeli</th>
<th style="text-align: left">Nama Karyawan</th>
<th style="text-align: left">Total Pembayaran</th>
</tr>
</thead>
<tbody>';
foreach ($penjualans as $penjualan) {
$html .= '
<tr>';
if ($penjualan["status"] == 'Lunas') {
$html .= '<td class="biru">' . $penjualan["status"] . '</td>';
} elseif ($penjualan["status"] == 'Belum Lunas') {
$html .= ' <td class="merah">' . $penjualan["status"] . '</td>';
}
$html .= '
<td>' . $penjualan["kode_pembayaran"] . '</td>
<td>' . $penjualan["no_faktur"] . '</td>
<td>' . $penjualan["tgl_pembayaran"] . '</td>
<td>' . $penjualan["nama_pembeli"] . '</td>
<td>' . $penjualan["nama_karyawan"] . '</td>
<td>Rp ' . $penjualan["total_pembayaran"] . '</td>
</tr>';
};
$html .= '
<tr class="hijau left">
<th colspan="6">TOTAL</th>
';
$html .= '
<th style="text-align: left">Rp ' . $pembayaran["total"] . '</th>
</tr>
</tbody>
</table>
</body>
</html>
';
$mpdf->WriteHTML($html);
$mpdf->Output('Laporan_penjualan' . $dari . ' - ' . $sampai . '.pdf', 'I');