-
Notifications
You must be signed in to change notification settings - Fork 3
/
i_member_troli.php
executable file
·293 lines (161 loc) · 5.57 KB
/
i_member_troli.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php
/*
******************************************************************
* CMS-TOKO-BIASAWAE v1.0 (code : Daun Muda). 2018
******************************************************************
* Dikembangkan oleh : Agus Muhajir *
* http://github.com/hajirodeon *
* http://hajirodeon.wordpress.com *
* http://facebook.com/hajirodeon *
* sms/wa/telegram : 081-829-88-54 *
* email : [email protected] *
* ****************************************************************
*/
session_start();
require("inc/config.php");
require("inc/fungsi.php");
require("inc/koneksi.php");
//PROSES ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//jika simpan
if ((isset($_GET['aksi']) && $_GET['aksi'] == 'simpan'))
{
//ambil nilai
$sesikd = cegah($_GET['sesikd']);
$itemkd = cegah($_GET['itemkd']);
$detailkd = cegah($_GET['detailkd']);
$jmlku = cegah($_GET['jmlku']);
//detail e
$qtyk = mysqli_query($koneksi, "SELECT * FROM m_item ".
"WHERE kd = '$itemkd'");
$rtyk = mysqli_fetch_assoc($qtyk);
$e_nama = balikin($rtyk['nama']);
$e_isi = balikin($rtyk['isi']);
$e_berat = nosql($rtyk['berat']);
$e_harga = nosql($rtyk['harga']);
$e_jml = nosql($rtyk['jml']);
//ketahui detail sebelumnya...
$qku = mysqli_query($koneksi, "SELECT * FROM member_order_detail ".
"WHERE kd = '$detailkd'");
$rku = mysqli_fetch_assoc($qku);
$ku_jml = nosql($rku['jumlah']);
//netralkan dulu, stock...
mysqli_query($koneksi, "UPDATE m_item SET jml = jml + '$ku_jml' ".
"WHERE kd = '$itemkd'");
//hitung subtotal lagi...
$e_subtotal = $jmlku * $e_harga;
$e_subtotal_berat = $jmlku * $e_berat;
//update jumlah...
mysqli_query($koneksi, "UPDATE member_order_detail SET jumlah = '$jmlku', ".
"subtotal = '$e_subtotal', ".
"subtotal_berat = '$e_subtotal_berat', ".
"postdate = '$today' ".
"WHERE member_kd = '$sesikd' ".
"AND kd = '$detailkd'");
//kurangi stock
mysqli_query($koneksi, "UPDATE m_item SET jml = jml - '$jmlku' ".
"WHERE kd = '$itemkd'");
exit();
}
//jika hapus
if ((isset($_GET['aksi']) && $_GET['aksi'] == 'hapus'))
{
//ambil nilai
$sesikd = cegah($_GET['sesikd']);
$detailkd = cegah($_GET['detailkd']);
//ketahui detail sebelumnya...
$qku = mysqli_query($koneksi, "SELECT * FROM member_order_detail ".
"WHERE kd = '$detailkd'");
$rku = mysqli_fetch_assoc($qku);
$ku_itemkd = nosql($rku['item_kd']);
$ku_jml = nosql($rku['jumlah']);
//detail e
$qtyk = mysqli_query($koneksi, "SELECT * FROM m_item ".
"WHERE kd = '$ku_itemkd'");
$rtyk = mysqli_fetch_assoc($qtyk);
$e_jml = nosql($rtyk['jml']);
//netralkan dulu, stock...
mysqli_query($koneksi, "UPDATE m_item SET jml = jml + '$ku_jml' ".
"WHERE kd = '$itemkd'");
//hapus
mysqli_query($koneksi, "DELETE FROM member_order_detail ".
"WHERE kd = '$detailkd'");
?>
<script language='javascript'>
//membuat document jquery
$(document).ready(function(){
window.location.href = "member_troli.php";
});
</script>
<?php
exit();
}
//jika subtotal
if ((isset($_GET['aksi']) && $_GET['aksi'] == 'subtotal'))
{
//ambil nilai
$sesikd = cegah($_GET['sesikd']);
$detailkd = cegah($_GET['detailkd']);
//ketahui detail sebelumnya...
$qku = mysqli_query($koneksi, "SELECT * FROM member_order_detail ".
"WHERE kd = '$detailkd'");
$rku = mysqli_fetch_assoc($qku);
$ku_subtotal = nosql($rku['subtotal']);
echo xduit2($ku_subtotal);
exit();
}
//jika total
if ((isset($_GET['aksi']) && $_GET['aksi'] == 'total'))
{
//ambil nilai
$notakd = cegah($_GET['notakd']);
$sesikd = cegah($_GET['sesikd']);
//ketahui detail sebelumnya...
$qku = mysqli_query($koneksi, "SELECT SUM(subtotal) AS total ".
"FROM member_order_detail ".
"WHERE member_kd = '$sesikd' ".
"AND nota_kd = '$notakd'");
$rku = mysqli_fetch_assoc($qku);
$ku_subtotal = nosql($rku['total']);
$nilku = xduit2($ku_subtotal);
//update
mysqli_query($koneksi, "UPDATE member_order SET subtotal = '$ku_subtotal' ".
"WHERE member_kd = '$sesikd' ".
"AND kd = '$notakd'");
echo "<b>$nilku</b>";
exit();
}
//jika rincian
if ((isset($_GET['aksi']) && $_GET['aksi'] == 'rincian'))
{
//ambil nilai
$sesikd = cegah($_GET['sesikd']);
$notakd = cegah($_SESSION['notakd']);
//ketahui detail sebelumnya...
$qku = mysqli_query($koneksi, "SELECT * FROM member_order_detail ".
"WHERE member_kd = '$sesikd' ".
"AND nota_kd = '$notakd'");
$rku = mysqli_fetch_assoc($qku);
$tku = mysqli_num_rows($qku);
//ketahui detail sebelumnya...
$qku = mysqli_query($koneksi, "SELECT SUM(subtotal_berat) AS total_berat, ".
"SUM(jumlah) AS total_qty ".
"FROM member_order_detail ".
"WHERE member_kd = '$sesikd' ".
"AND nota_kd = '$notakd'");
$rku = mysqli_fetch_assoc($qku);
$ku_total_berat = nosql($rku['total_berat']);
$ku_total_qty = nosql($rku['total_qty']);
$ku_total_jenis = $tku;
echo "[Jumlah Jenis Item : <b>$ku_total_jenis</b>].
[Jumlah Qty Item : <b>$ku_total_qty</b>].
[Jumlah Berat : <b>$ku_total_berat Gram</b>].";
//update
mysqli_query($koneksi, "UPDATE member_order SET barang_jml_jenis = '$ku_total_jenis', ".
"barang_qty = '$ku_total_qty', ".
"barang_berat = '$ku_total_berat' ".
"WHERE member_kd = '$sesikd' ".
"AND kd = '$notakd'");
exit();
}
exit();
?>