-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
96 lines (75 loc) · 2.33 KB
/
index.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
<?php
session_start();
// //membatasi halaman sebelum login
// if(!isset($_SESSION['login'])){
// echo "<script>
// alert('login dulu');
// document.location.href = 'login.php';
// </script>";
// die;
// }
header("Location: test.php");
// header("Location: terbitkan.php");
//membatasi halaman sesuai user login
if($_SESSION['level'] != 1 and $_SESSION['level'] != 2){
echo "<script>
alert('tidak punya hak akses');
document.location.href = 'crud-modal.php';
</script>";
//membatasi halaman sebelum login
if(!isset($_SESSION['login'])){
echo "<script>
alert('login dulu');
document.location.href = 'login.php';
</script>";
die;
}
exit;
}
$title = 'Daftar Barang';
include 'layout/navbar.php';
//URUTAN TERBESAR DAN TERKECIL DARI JUMLAH BARANG
$data_barang = select("SELECT * FROM barang ORDER BY id_barang DESC");
?>
<!---->
<br>
<br>
<br>
<!---->
<div class="container mt-5">
<h1><i class="fas fa-list"></i> Daftar Barang</h1>
<hr>
<a href="tambah-barang.php" class="btn btn-primary mb-1"> <i class="fas fa-plus-circle"></i>tambah</a>
<table class="table table-bordered table-striped mt-3" id="table">
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>Jumlah</th>
<th>Harga</th>
<th>Tanggal</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
<?php $no = 1; ?>
<?php foreach ($data_barang as $barang) : ?>
<tr>
<td><?= $no++; ?></td>
<td><?= $barang['nama']; ?></td>
<td><?= $barang['jumlah']; ?></td>
<td>Rp. <?= number_format($barang ['harga'],0,',','.'); ?></td>
<td><?= date('d/m/Y H:i:s', strtotime($barang['tanggal'])); ?></td>
<td width="20%" class="text-center">
<a href="ubah-barang.php?id_barang=<?= $barang['id_barang']; ?>"
class="btn btn-success"><i class="fas fa-edit"></i>Ubah</a>
<a href="hapus-barang.php?id_barang=<?= $barang['id_barang']; ?>"
onclick="return confirm('Yakin Data Dihapus');" class="btn btn-danger">
<i class="fas fa-trash-alt"></i>Hapus</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php include 'layout/footer.php'; ?>