-
Notifications
You must be signed in to change notification settings - Fork 0
/
tampil_matakuliah.php
113 lines (111 loc) · 5.33 KB
/
tampil_matakuliah.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
<?php
session_start();
if (empty($_SESSION['username']) || empty($_SESSION['password'])) {
echo "<script>
setTimeout(function() {
alert('Anda tidak memiliki akses');
window.location = 'login.php';
}, 1000); // Delay 1 detik
</script>";
} else {
// Ambil level pengguna dari sesi
$level = $_SESSION['level'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data Mata Kuliah</title>
<link href="bootstrap-5.3.2-dist/css/bootstrap.min.css" rel="stylesheet">
<script src="bootstrap-5.3.2-dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-12 mb-4">
<?php include "menu.php"; ?>
</div>
</div>
<div class="card border-danger mb-4">
<div class="card-header bg-danger text-white">
<h4 class="m-0">Data Mata Kuliah</h4>
</div>
<div class="card-body text-success">
<?php
if ($level == 'admin') {
// Jika level admin, tampilkan tombol Tambah Data
?>
<div class="row">
<div class="col-md-6 mb-3 ">
<a href='matakuliah/tambah_matakuliah.php' class='btn btn-primary'>Tambah Data</a>
</div>
<div class="col-md-6 ">
<form action="matakuliah/cari_matakuliah.php" method="GET">
<div class="btn-group float-end" role="group">
<input type="text" name="keyword" class="form-control" placeholder="Masukan keyword" required>
<button type="submit" class="btn btn-primary">Pencarian</button>
</div>
</form>
</div>
</div>
<?php
}
?>
<div class="row">
<div class="col-md-12">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>No</th>
<th>Kode Mata Kuliah</th>
<th>Nama Mata Kuliah</th>
<th>SKS</th>
<th>Jenis</th>
<?php
if ($level == 'admin') {
// Jika level admin, tampilkan kolom Aksi
echo "<th>Aksi</th>";
}
?>
</tr>
</thead>
<tbody>
<?php
include "config/koneksi.php";
$i = 0;
$tampil = mysqli_query($koneksi, "SELECT * FROM tbl_matakuliah");
while ($data = mysqli_fetch_array($tampil)) {
$i++;
?>
<tr>
<td><?= $i ?></td>
<td><?= $data['kode_matakuliah'] ?></td>
<td><?= $data['nama_matakuliah'] ?></td>
<td><?= $data['sks'] ?></td>
<td><?= $data['jenis'] ?></td>
<?php
if ($level == 'admin') {
// Jika level admin, tampilkan tombol Edit dan Hapus
echo "<td>
<a href='matakuliah/edit_matakuliah.php?kode_matakuliah={$data['kode_matakuliah']}' class='btn btn-primary'>Edit</a>
<a href='matakuliah/delete_matakuliah.php?kode_matakuliah={$data['kode_matakuliah']}' class='btn btn-danger' onclick=\"return confirm('Apakah anda yakin ingin menghapus ini ?')\">Hapus</a>
</td>";
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
?>