-
Notifications
You must be signed in to change notification settings - Fork 0
/
masuk.php
331 lines (302 loc) · 18.9 KB
/
masuk.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<?php
require 'function.php';
require 'cek.php';
// Get data
// Mengambil jumlah total data barang masuk yang ada
$get1 = mysqli_query($conn, "SELECT * FROM masuk");
$count1 = mysqli_num_rows($get1);
// Mengambil jumlah semua stock yang ada pada tabel barang masuk
$get2 = mysqli_query($conn, "SELECT SUM(qty) AS total_stock FROM masuk");
$row2 = mysqli_fetch_assoc($get2);
$total_stock = $row2['total_stock'];
?>
<!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>Barang Masuk</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>
<style>
.zoomable{
width: 100px;
}
.tambahkan{
margin-right: 230px;
}
.shaddow {
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
border-radius: 10px;
}
.table th, .table td {
vertical-align: middle;
text-align: center;
}
.table-responsive {
border-radius: 10px;
overflow: hidden;
}
.thead-secondary {
background-color: #f4f4f4;
color: black;
}
</style>
</head>
<body class="sb-nav-fixed">
<nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
<a class="navbar-brand" href="index.php">StockPedia.</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-dark" id="sidenavAccordion">
<div class="sb-sidenav-menu">
<div class="nav">
<div class="sb-sidenav-menu-heading">Fitur</div>
<a class="nav-link" href="index.php">
<div class="sb-nav-link-icon"><i class="fas fa-table mr-1"></i></div>
Stock Barang
</a>
<a class="nav-link" href="masuk.php">
<div class="sb-nav-link-icon"><i class="fas fa-arrow-right mr-1"></i></div>
Barang Masuk
</a>
<a class="nav-link" href="keluar.php">
<div class="sb-nav-link-icon"><i class="fas fa-arrow-left mr-1"></i></div>
Barang Keluar
</a>
<a class="nav-link" href="peminjaman.php">
<div class="sb-nav-link-icon"><i class="fas fa-handshake mr-1"></i></div>
Peminjaman Barang
</a>
<a class="nav-link" href="admin.php">
<div class="sb-nav-link-icon"><i class="fas fa-user mr-1"></i></div>
Kelola Admin
</a>
<br><br>
<a class="nav-link" href="logout.php">
Logout
</a>
</div>
</div>
<div class="sb-sidenav-footer">
<div class="small">Logged in as</div>
Ifkar AQ
</div>
</nav>
</div>
<div id="layoutSidenav_content">
<main>
<div class="container-fluid">
<h1 class="mt-4">Barang Masuk</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item active">Stock barang yang masuk</li>
</ol>
<div class="card mb-4">
<div class="card-header bg-success text-white d-flex justify-content-between align-items-center">
<div>
<i class="fas fa-arrow-right mr-1"></i>
Data Table Barang Masuk
</div>
<!-- Button untuk membuka form insert-->
<button type="button" class="tambahkan btn btn-light text-success btn-sm" data-toggle="modal" data-target="#myModal">
<strong>Tambahkan</strong>
</button>
<div class="row">
<div class="col">
<form method="post" class="form-inline">
<div class="form-group">
<label for="tgl_mulai" class="mr-2">Tanggal Mulai :</label>
<input type="date" id="tgl_mulai" name="tgl_mulai" class="form-control mr-2">
</div>
<div class="form-group">
<label for="tgl_selesai" class="mr-2">Tanggal Selesai :</label>
<input type="date" id="tgl_selesai" name="tgl_selesai" class="form-control mr-2">
</div>
<button type="submit" name="filter_tgl" class="btn btn-light text-success"><strong>Filter</strong></button>
</form>
</div>
</div>
</div>
<div class="shaddow card-body">
<div class="row">
<div class="col-auto">
<div class="card bg-light text-dark p-2">
<h6 class="m-0">Total Data Barang Masuk : <?=$count1;?></h6>
</div>
</div>
<div class="col-auto">
<div class="card bg-light text-dark p-2">
<h6 class="m-0">Total Barang Yang Masuk : <?=$total_stock;?> Barang</h6>
</div>
</div>
</div>
<br>
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th>Gambar</th>
<th>Nama Barang</th>
<th>Tanggal</th>
<th>Jumlah</th>
<th>Penerima Stock</th>
<th>Aksi</th>
</tr>
</thead>
<!-- Menampilkan data yang ada pada tabel database ke dalam tabel stock -->
<tbody>
<?php
if(isset($_POST['filter_tgl'])){
$mulai = $_POST['tgl_mulai'];
$selesai = $_POST['tgl_selesai'];
if($mulai!=null || $selesai!=null){
$result = mysqli_query($conn, "SELECT * FROM masuk m JOIN stock s ON s.idbarang = m.idbarang
WHERE m.tanggal BETWEEN '$mulai' AND DATE_ADD('$selesai', INTERVAL 1 DAY) ORDER BY m.idmasuk DESC");
} else {
$result = mysqli_query($conn, "SELECT * FROM masuk m, stock s WHERE s.idbarang = m.idbarang ORDER BY m.tanggal DESC, m.idmasuk DESC");
}
} else {
$result = mysqli_query($conn, "SELECT * FROM masuk m, stock s WHERE s.idbarang = m.idbarang ORDER BY m.tanggal DESC, m.idmasuk DESC");
}
$i= 1;
while($row = mysqli_fetch_assoc($result)) {
$idm = $row['idmasuk'];
$idbarang = $row['idbarang'];
$namabarang = $row['namabarang'];
$tanggal = $row['tanggal'];
$quantity = $row['qty'];
$penerima = $row['penerima'];
$unik_id = $idbarang . '-' . $idm;
// Cek ada gambar atau tidak
$image = $row['image'];
if($image==null){
// jika tidak ada gambar
$img = 'No Photo';
} else {
// jika ada gambar
$img = '<img src="images/'.$image.'" class="zoomable">';
}
?>
<tr>
<td><?=$i++;?></td>
<td><?=$img;?></td>
<td><?=$namabarang;?></td>
<td><?=$tanggal;?></td>
<td><?=$quantity;?></td>
<td><?=$penerima;?></td>
<td>
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#edit<?=$unik_id;?>">
Edit
</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete<?=$unik_id;?>">
Delete
</button>
</td>
</tr>
<!-- Edit Modal -->
<div class="modal fade" id="edit<?=$unik_id;?>">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit Barang</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form method="post">
<div class="modal-body">
<input type="number" name="qty" value="<?=$quantity;?>" class="form-control" required>
<br>
<input type="text" name="penerima" value="<?=$penerima;?>" class="form-control" required>
<br>
<input type="hidden" name="idbarang" value="<?=$idbarang;?>">
<input type="hidden" name="idm" value="<?=$idm;?>">
<button type="submit" class="btn btn-primary" name="updatebarangmasuk">Submit</button>
</div>
</form>
</div>
</div>
</div>
<!-- Delete Modal -->
<div class="modal fade" id="delete<?=$unik_id;?>">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Delete Barang</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form method="post">
<div class="modal-body">
Apakah Anda yakin ingin menghapus <?=$namabarang;?>?
<input type="hidden" name="idbarang" value="<?=$idbarang;?>">
<input type="hidden" name="kty" value="<?=$quantity;?>">
<input type="hidden" name="idm" value="<?=$idm;?>">
<br>
<br>
<button type="submit" class="btn btn-danger" name="deletebarangmasuk">Delete</button>
</div>
</form>
</div>
</div>
</div>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
</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>
<!-- form untuk menambahkan data barang-->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Tambah Barang</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form action="" method="post">
<div class="modal-body">
<select name="barangnya" class="form-control">
<?php
$ambilsemuadatanya = mysqli_query($conn,"select * from stock");
while($fetcharray = mysqli_fetch_array($ambilsemuadatanya)){
$namabarangnya = $fetcharray['namabarang'];
$idbarangnya = $fetcharray['idbarang'];
?>
<option value="<?=$idbarangnya;?>"><?=$namabarangnya;?></option>
<?php
}
?>
</select> <br>
<input type="number" name="qty" placeholder="Quantity" class="form-control" required><br>
<input type="text" name="penerima" placeholder="Penerima" class="form-control" required><br>
<button type="submit" class="btn btn-primary" name="barangmasuk">Submit</button><br>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</html>