-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard-list-matakuliah.php
234 lines (219 loc) · 9.92 KB
/
dashboard-list-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
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
<?php
session_start();
if (!isset($_SESSION["login"])) {
header("Location: login.php");
exit;
}
require "matakuliah-fungsi.php";
// ambil data dari tabel matakuliah
$matakuliah = mysqli_query($conn, "SELECT * FROM matakuliah INNER JOIN Dosen ON MataKuliah.id_dosen = Dosen.id_dosen");
$dosen = mysqli_query($conn, "SELECT * FROM dosen");
// tambah data
if (isset($_POST["submit"])) {
// cek keberhasilan input data
if (tambah($_POST) > 0) {
echo "
<script>
alert('DATA BERHASIL DITAMBAHKAN!');
document.location.href = 'dashboard-list-matakuliah.php';
</script>
";
} else {
echo "
<script>
alert('DATA GAGAL DITAMBAHKAN!');
document.location.href = 'dashboard-list-matakuliah.php';
</script>";
}
}
// cek apakah tombol submit sudah ditekan atau belum
if (isset($_POST["ubah"])) {
// cek keberhasilan ubah data
if (ubah($_POST) > 0) {
echo "
<script>
alert('DATA BERHASIL DIUBAH!');
document.location.href = 'dashboard-list-dosen.php';
</script>
";
} else {
echo "
<script>
alert('DATA GAGAL DIUBAH!');
document.location.href = 'dashboard-list-dosen.php';
</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="assets/css/style.css" />
<link rel="shortcut icon" href="assets/img/page-logo/if-logo.png" type="image/x-icon" />
<title>Admin Dashboard</title>
</head>
<body>
<!-- navbar -->
<nav class="navbar main-color-bg fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="assets/img/dashboard-logo/if-logo-and-text-edit-text.png" alt="Bootstrap" width="300" /></a>
</div>
</nav>
<!-- navbar end -->
<!-- main container -->
<div class="main-container">
<!-- sidebar -->
<aside class="sidebar" id="sidebar">
<ul>
<li><a href="index.php">Beranda</a></li>
<li><a href="dashboard-list-dosen.php">Daftar Dosen</a></li>
<li>
<a href="dashboard-list-matakuliah.php">Daftar Mata Kuliah</a>
</li>
<li><a href="dashboard-list-kategori.php">Daftar Kategori</a></li>
<li>
<a href="dashboard-list-inventaris.php">Daftar Inventaris</a>
</li>
<li><a href="dashboard-qr.php">QR Code</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</aside>
<!-- sidebar end -->
<!-- content -->
<main class="content vh-100 bg-body-tertiary p-5 mt-5">
<h1 class="fs-6">Halaman Daftar matakuliah</h1>
<!-- card table -->
<div class="card">
<div class="card-body">
<!-- Button Add modal -->
<button type="button" class="btn btn-info text-white" data-bs-toggle="modal" data-bs-target="#addData">
Tambah Data
</button>
<!-- Add Modal -->
<div class="modal fade" id="addData" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="" method="post">
<div class="mb-3">
<label for="kode_matakuliah" class="form-label">Kode matakuliah</label>
<input type="text" class="form-control" id="kode_matakuliah" name="kode_matakuliah" autocomplete="off">
</div>
<div class="mb-3">
<label for="nama_matakuliah" class="form-label">Nama matakuliah</label>
<input type="text" class="form-control" id="nama_matakuliah" name="nama_matakuliah" autocomplete="off">
</div>
<div class="mb-3">
<label for="sks_matakuliah" class="form-label">sks matakuliah</label>
<input type="number" class="form-control" id="sks_matakuliah" name="sks_matakuliah" autocomplete="off">
</div>
<div class="mb-3">
<label for="id_dosen" class="form-label">Dosen Pengampu</label>
<select name="id_dosen" class=" form-select" aria-label="Default select example">
<?php foreach ($dosen as $d) : ?>
<option value=" <?= $d['id_dosen'] ?>"><?= $d['nama_dosen'] ?></option>
<?php endforeach ?>
</select>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="col-12 btn btn-info text-white" name="submit">Tambah Data</button>
</div>
</form>
</div>
</div>
</div>
<!-- Add Modal End -->
<hr>
<table class="table table-bordered table-hover align-middle table-sm table-responsive">
<thead class="table-secondary">
<tr class="text-center">
<th scope="col">No</th>
<th scope="col">Kode Matakuliah</th>
<th scope="col">Nama Matakuliah</th>
<th scope="col">SKS</th>
<th scope="col">Dosen Pengampu</th>
<th scope="col">Aksi</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php foreach ($matakuliah as $row) : ?>
<tr class="text-center">
<td><?= $i ?></td>
<td><?= $row["kode_matakuliah"] ?></td>
<td><?= $row["nama_matakuliah"] ?></td>
<td><?= $row["sks_matakuliah"] ?></td>
<td><?= $row["nama_dosen"] ?></td>
<td class="py-3">
<!-- Button Edit modal -->
<button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#edit<?= $row["id_matakuliah"] ?>">
Ubah
</button>
<!-- Edit Modal -->
<div class="modal fade" id="edit<?= $row["id_matakuliah"] ?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Ubah Data</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body text-start">
<form method="post">
<input type="hidden" class="form-control" id="id_matakuliah" name="id_matakuliah" value="<?= $row["id_matakuliah"] ?>" autocomplete="off">
<div class="mb-3">
<label for="kode_matakuliah" class="form-label">Kode Matakuliah</label>
<input type="text" class="form-control" id="kode_matakuliah" name="kode_matakuliah" value="<?= $row["kode_matakuliah"] ?>" autocomplete="off">
</div>
<div class="mb-3">
<label for="nama_matakuliah" class="form-label">Nama matakuliah</label>
<input type="text" class="form-control" id="nama_matakuliah" name="nama_matakuliah" value="<?= $row["nama_matakuliah"] ?>" autocomplete="off">
</div>
<div class="mb-3">
<label for="sks_matakuliah" class="form-label">SKS</label>
<input type="number" class="form-control" id="sks_matakuliah" name="sks_matakuliah" value="<?= $row["sks_matakuliah"] ?>" autocomplete="off">
</div>
<div class="mb-3">
<label for="id_dosen" class="form-label">Dosen Pengampu</label>
<select name="id_dosen" class=" form-select" aria-label="Default select example">
<?php foreach ($dosen as $d) : ?>
<option value=" <?= $d['id_dosen'] ?>"><?= $d['nama_dosen'] ?></option>
<?php endforeach ?>
</select>
</div>
<div class="modal-footer">
<button type="submit" class="col-12 btn btn-warning text-white" name="ubah">Ubah Data</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Edit Modal End -->
<button class="btn btn-danger"><a class="text-decoration-none text-white" href="matakuliah-fungsi-hapus.php?id=<?= $row["id_matakuliah"] ?>" onclick="
return confirm('Apakah anda yakin ingin menghapus data ini?')">Hapus</a></button>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!-- card table end -->
</main>
<!-- content end -->
</div>
<!-- main container end -->
<script src="assets/js/sidebar.js"></script>
<script src="assets/js/bootstrap.bundle.min.js"></script>
</body>
</html>