-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcetakFullRekap.php
208 lines (201 loc) · 7.76 KB
/
cetakFullRekap.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
// ! mencetak full rekas
include 'database.php';
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$tanggalCetak = $_POST['tanggalCetak'];
$catatan = $_POST['catatan'];
if(empty($catatan)){
$catatan = "-";
}
$tanggalDB = $_POST['tanggalDB'];
$filename = "FullRekap(".$tanggalCetak.").pdf";
$queryPenjualanProduk = "SELECT DISTINCT nama_produk_terjual, harga_satuan, SUM(jumlah_produk_terjual) AS jumlah_produk_terjual
FROM produk_terjual WHERE tanggal_terjual = '$tanggalDB' GROUP BY nama_produk_terjual,id_bahan_baku";
$queryBahanBaku = "SELECT p.id_bahan_baku,b.nama_bahan, SUM(p.jumlah_produk_terjual) as total_jumlah
FROM produk_terjual p INNER JOIN bahan_baku b ON p.id_bahan_baku = b.id_bahan_baku
WHERE p.tanggal_terjual = '$tanggalDB' GROUP BY p.id_bahan_baku";
$queryReject = "SELECT bahan_baku.nama_bahan, SUM(reject.jumlah_reject) AS jumlah_reject,
reject.keterangan FROM bahan_baku INNER JOIN reject
ON bahan_baku.id_bahan_baku = reject.id_bahan_baku
WHERE reject.tanggal_reject = '$tanggalDB' GROUP BY reject.id_bahan_baku, reject.keterangan";
$queryKeuangan = "SELECT * FROM saldo WHERE tanggal_update = '$tanggalDB'";
$html = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pareanom Full Rekap</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="assets/styles/cetakFullRekap.css">
</head>
<body>
<div class="isi-rekap">
<h1>REKAP '. $tanggalCetak .'</h1>
<h2>PENJUALAN PRODUK :</h2>
<table class="table table-striped" border="1">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Nama Produk / Add Ons</th>
<th scope="col">Jumlah</th>
<th scope="col">Total</th>
</tr>
</thead>';
$query = mysqli_query($connect, $queryPenjualanProduk);
if(mysqli_num_rows($query) == 0){
$html.='<tbody>
<tr>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>';
}
$id = 1;
$TOTAL = 0;
while ($data = mysqli_fetch_array($query)) {
$harga_satuan = $data["harga_satuan"];
$jumlah_produk_terjual = $data["jumlah_produk_terjual"];
$total = $harga_satuan * $jumlah_produk_terjual;
$html.='<tbody>
<tr>
<td>'.$id.'</td>
<td>'.$data["nama_produk_terjual"].'</td>
<td>'.$data["jumlah_produk_terjual"].'</td>
<td>'.$total.'</td>
</tr>
</tbody>';
$id++;
$TOTAL += $total;
}
$html.='</table>
<div class="total">
<h3>TOTAL : Rp. '.$TOTAL.'</h3>
</div>
<h2>BAHAN TERPAKAI :</h2>
<table class="table table-striped" border="1">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Bahan</th>
<th scope="col">Jumlah</th>
</tr>
</thead>';
$query = mysqli_query($connect, $queryBahanBaku);
$id = 1;
if(mysqli_num_rows($query) == 0){
$html.='<tbody>
<tr>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>';
}
while ($data = mysqli_fetch_array($query)) {
$html.='<tbody>
<tr>
<td>'.$id.'</td>
<td>'.$data["nama_bahan"].'</td>
<td>'.$data["total_jumlah"].'</td>
</tr>
</tbody>';
$id++;
}
$html.='</table>
<h2>REJECT :</h2>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Nama Bahan / Add Ons</th>
<th scope="col">Jumlah</th>
<th scope="col">keterangan</th>
</tr>
</thead>';
$query = mysqli_query($connect, $queryReject);
if(mysqli_num_rows($query) == 0){
$html.='<tbody>
<tr>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>';
}
$id = 1;
while ($data = mysqli_fetch_array($query)) {
$html.='<tbody>
<tr style="background-color: #ff4434; color: white;">
<td>'.$id.'</td>
<td>'.$data["nama_bahan"].'</td>
<td>'.$data["jumlah_reject"].'</td>
<td>'.$data["keterangan"].'</td>
</tr>
</tbody>';
$id++;
}
$html.='</table>
<h2>KEUANGAN :</h2>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Jumlah</th>
<th scope="col">Tanggal</th>
<th scope="col">Catatan</th>
<th scope="col">Jenis</th>
</tr>
</thead>';
$query = mysqli_query($connect, $queryKeuangan);
if(mysqli_num_rows($query) == 0){
$html.='<tbody>
<tr>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>';
}
$id = 1;
while ($data = mysqli_fetch_array($query)) {
$tanggal_update = date("d - F - Y", strtotime($data["tanggal_update"]));
if ($data['jenis'] == "Pemasukan") {
$html.='<tbody>
<tr style="background-color: cornflowerblue; color: white;">
<td>'.$id.'</td>
<td>'.$data["nominal_saldo"].'</td>
<td>'.$tanggal_update.'</td>
<td>'.$data["keterangan"].'</td>
<td>'.$data["jenis"].'</td>
</tr>
</tbody>';
} else {
$html.='<tbody>
<tr style="background-color: #ff4434; color: white;">
<td >'.$id.'</td>
<td>'.$data["nominal_saldo"].'</td>
<td>'.$tanggal_update.'</td>
<td>'.$data["keterangan"].'</td>
<td>'.$data["jenis"].'</td>
</tr>
</tbody>';
}
$id++;
}
$html.='</table>
<h2> CATATAN </h2>
<div class="form-catatan">
<textarea class="form-control" name="catatan" id="floatingTextarea" readonly>'.$catatan.'</textarea>
</div>';
$html.='</div>';
$mpdf->WriteHTML($html);
$mpdf->Output($filename,"I");
?>