forked from azumi99/crudwebproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaksi.php
276 lines (261 loc) · 15.4 KB
/
transaksi.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
<?php
require 'function.php';
require 'ceklog.php'
?>
<!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, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Record Transaksi</title>
<link href="css/styles.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js" crossorigin="anonymous"></script>
</head>
<body class="sb-nav-fixed">
<nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
<a class="navbar-brand" href="index.php">Record Transaksi</a>
<button class="btn btn-link btn-sm order-1 order-lg-0" id="sidebarToggle" href="#"><i class="fas fa-bars"></i></button>
</nav>
<div id="layoutSidenav">
<div id="layoutSidenav_nav">
<nav class="sb-sidenav accordion sb-sidenav-light" id="sidenavAccordion">
<div class="sb-sidenav-menu">
<div class="nav">
<?php
$nama = mysqli_query($conn, "select * from login");
while ($list = mysqli_fetch_array($nama)) {
$name = $list['nama'];
?>
<div>
<h3 class="sb-sidenav-menu-heading" style="margin-left: 35px;">Welcome <?= $name; ?></h3>
<img src="assets/img/settings.png" alt="" style="margin-left: 70px;">
</div>
<?php
}
?>
<div class="sb-sidenav-menu-heading">Menu</div>
<a class="nav-link" href="index.php">
<div class="sb-nav-link-icon"><i class="fas fa-layer-group"></i></div>
Stock
</a>
<a class="nav-link" href="pegawai.php">
<div class="sb-nav-link-icon"><i class="fas fa-user-tie"></i></div>
Pegawai
</a>
<a class="nav-link" href="pembeli.php">
<div class="sb-nav-link-icon"><i class="fas fa-shopping-bag"></i></div>
Pembeli
</a>
<a class="nav-link" href="transaksi.php">
<div class="sb-nav-link-icon"><i class="fas fa-credit-card"></i></div>
Transaksi
</a>
<a class="nav-link" href="logout.php">
<div class="sb-nav-link-icon"><i class="fas fa-sign-out-alt"></i></div>
Logout
</a>
</div>
</div>
</nav>
</div>
<div id="layoutSidenav_content">
<main>
<div class="container-fluid">
<h1 class="mt-4">Data Transaksi</h1>
<div class="card mb-4">
<div class="card-header">
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#transaksimodal">
Tambah Transaksi
</button>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Id</th>
<th>Tanggal</th>
<th>Pembeli</th>
<th>Pegawai</th>
<th>Merk</th>
<th>Tipe</th>
<th>Jumlah</th>
<th>Harga</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$viewtransaksi = mysqli_query($conn, "select * from transaksi left join handphone on transaksi.id_hp=handphone.id_hp left join pegawai on transaksi.id_pegawai=pegawai.id_pegawai left join pembeli on transaksi.id_pembeli=pembeli.id_pembeli
");
while ($data = mysqli_fetch_array($viewtransaksi)) {
$idtransaksi = $data['id_transaksi'];
$tanggal = $data['tanggal'];
$nama_pembeli = $data['nama'];
$nama_pegawai = $data['nama_pgw'];
$merk = $data['merk'];
$tipe = $data['tipe'];
$jumlah = $data['jumlah'];
$total_harga = $data['total_harga'];
$idpembeli = $data['id_pembeli'];
$idpegawai = $data['id_pegawai'];
$idhandphone = $data['id_hp'];
$harga = $data['harga_hp'];
?>
<tr>
<td><?= $idtransaksi; ?></td>
<td><?= $tanggal; ?></td>
<td><?= $nama_pembeli; ?></td>
<td><?= $nama_pegawai; ?></td>
<td><?= $merk; ?></td>
<td><?= $tipe; ?></td>
<td><?= $jumlah; ?></td>
<td>Rp <?= $total_harga; ?></td>
<td>
<button style="margin: 2px;" type="button" class="btn btn-danger" data-toggle="modal" data-target="#deletetransaksi<?= $idtransaksi; ?>">delete</button>
</td>
</tr>
<!-- delete modal transaksi -->
<div class="modal fade" id="deletetransaksi<?= $idtransaksi; ?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Hapus Data Pembeli</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form method="POST">
<div class="modal-body">
<fieldset disabled>
<input type="text" value="<?= $nama_pembeli; ?>" class="form-control">
<br />
<input type="text" value="<?= $merk; ?>" class="form-control">
<br />
<input type="text" value="<?= $tipe; ?>" class="form-control">
<br>
<input type="text" value="<?= $total_harga; ?>" class="form-control">
<br />
</fieldset>
<br />
Apakah anda ingin menghapus data transaksi ini?
<br />
<br />
<input type="hidden" name="id_transaksi" value="<?= $idtransaksi; ?>">
<input type="hidden" name="id_hp" value="<?= $idhandphone; ?>">
<input type="hidden" name="jumlah" value="<?= $jumlah; ?>">
<button type="submit" name="deletetransaksi" class="btn btn-danger">Hapus</button>
</div>
</form>
</div>
</div>
</div>
<!-- delete modal transaksi -->
<?php
};
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<footer class="py-4 bg-light mt-auto">
<div class="container-fluid">
<div class="d-flex align-items-center justify-content-between small">
<div class="text-muted">Copyright © <a href="https://acbagusid.anandanesia.com/about.html" style="text-decoration:none;">Kelompok6 2021</a></div>
</div>
</div>
</footer>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="js/scripts.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
<script src="assets/demo/chart-area-demo.js"></script>
<script src="assets/demo/chart-bar-demo.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js" crossorigin="anonymous"></script>
<script src="assets/demo/datatables-demo.js"></script>
</body>
<!-- Modal -->
<div class="modal fade" id="transaksimodal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Tambah Data Pembeli</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form method="POST">
<div class="modal-body">
<select name="pembeli" class="form-control">
<option selected value="<?= $idpembeli; ?>">pilih pembeli</option>
<?php
$tampilanpembeli = mysqli_query($conn, "select * from pembeli");
while ($fetcharray = mysqli_fetch_array($tampilanpembeli)) {
$nama_list = $fetcharray['nama'];
$idpembeli = $fetcharray['id_pembeli'];
?>
<option value="<?= $idpembeli; ?>"><?= $nama_list; ?></option>
<?php
}
?>
</select>
<br />
<select name="pgw" class="form-control">
<option selected value="<?= $idpegawai; ?>">pilih pegawai</option>
<?php
$tampilanpegawai = mysqli_query($conn, "select * from pegawai");
while ($fetcharray = mysqli_fetch_array($tampilanpegawai)) {
$namapegawai = $fetcharray['nama_pgw'];
$idpgw = $fetcharray['id_pegawai'];
?>
<option value="<?= $idpgw; ?>"><?= $namapegawai; ?></option>
<?php
}
?>
</select>
<br>
<select name="handphone" class="form-control " id="handphone" required>
<option selected>pilih handphone</option>
<?php
$tampilanhp = mysqli_query($conn, "select * from handphone");
while ($d = mysqli_fetch_array($tampilanhp)) {
?>
<option value="<?php echo $d['id_hp'] ?>_<?php echo $d['harga_hp'] ?>"><?php echo $d['merk'] ?> <?php echo $d['tipe'] ?> <?php echo $d['harga_hp'] ?>, <?php echo $d['stock_hp'] ?></option>
<?php
}
?>
</select>
<br />
<input type="number" name="jumlah" placeholder="jumlah" id="jumlah" class="form-control">
<br />
<input type="number" name="harga" placeholder="harga" class="form-control harga">
<br />
<button type="submit" name="savetransaksi" class="btn btn-primary">Tambah</button>
</div>
</form>
</div>
</div>
</div>
</html>
<script>
var data = 0;
var jumlah = 0;
var total = 0;
$('#handphone, #jumlah').on('change input', function() {
var data = $('#handphone').val().split('_') || 0;
var jumlah = $('#jumlah').val() || 0;
var total = data[1] * jumlah;
$('.harga').val(total);
});
</script>