This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-kenshin.php
151 lines (132 loc) · 4.6 KB
/
list-kenshin.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
<?php require_once('includes/init.php'); ?>
<?php cek_login($role = array(1, 2)); ?>
<?php
$judul_page = 'List Kenshin';
require_once('template-parts/header.php');
?>
<div class="main-content-row">
<div class="container clearfix">
<?php include_once('template-parts/sidebar-kenshin.php'); ?>
<div class="main-content the-content">
<?php
$status = isset($_GET['status']) ? $_GET['status'] : '';
$msg = '';
switch($status):
case 'sukses-baru':
$msg = 'Data Kenshin baru berhasil ditambahkan';
break;
case 'sukses-hapus':
$msg = 'Kenshin berhasil dihapus';
break;
case 'sukses-edit':
$msg = 'Kenshin berhasil diedit';
break;
endswitch;
if($msg):
echo '<div class="msg-box msg-box-full">';
echo '<p><span class="fa fa-bullhorn"></span> '.$msg.'</p>';
echo '</div>';
endif;
?>
<h1>Daftar Peserta UKT</h1>
<?php
$query = $pdo->prepare('SELECT * FROM kenshin WHERE kyu_id = ' . $_GET['kyu']);
$query->execute();
// menampilkan berupa nama field
$query->setFetchMode(PDO::FETCH_ASSOC);
if($query->rowCount() > 0):
?>
<table class="pure-table pure-table-striped">
<thead>
<tr>
<th>Nama Kenshin</th>
<th>NIM</th>
<th>NIK Kempo</th>
<th>Detail</th>
<th>Edit</th>
<th>Hapus</th>
</tr>
</thead>
<tbody>
<?php while($hasil = $query->fetch()): ?>
<tr>
<td><?php echo $hasil['nama_kenshin']; ?></td>
<td><?php echo $hasil['nim']; ?></td>
<td><?php echo $hasil['nik']; ?></td>
<td><a href="single-kenshin.php?id=<?php echo $hasil['id_kenshin']; ?>&kyu=<?=$_GET['kyu']?>"><span class="fa fa-eye"></span> Detail</a></td>
<td><a href="edit-kenshin.php?id=<?php echo $hasil['id_kenshin']; ?>&kyu=<?=$_GET['kyu']?>"><span class="fa fa-pencil"></span> Edit</a></td>
<td><a href="hapus-kenshin.php?id=<?php echo $hasil['id_kenshin']; ?>&kyu=<?=$_GET['kyu']?>" class="red yaqin-hapus"><span class="fa fa-times"></span> Hapus</a></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<!-- Langsung Lihat Nilai ==================== -->
<?php
// Fetch semua kriteria
$query = $pdo->prepare('SELECT id_kriteria, nama, type, bobot FROM kriteria
WHERE kyu_id = '.$_GET['kyu'].'
ORDER BY urutan_order ASC');
$query->execute();
$kriterias = $query->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_UNIQUE);
// Fetch semua kenshin
$query2 = $pdo->prepare('SELECT id_kenshin, nama_kenshin FROM kenshin WHERE kyu_id = ' . $_GET['kyu']);
$query2->execute();
$query2->setFetchMode(PDO::FETCH_ASSOC);
$kenshins = $query2->fetchAll();
?>
<h3>Nilai per-Kriteria</h3>
<table class="pure-table pure-table-striped">
<thead>
<tr class="super-top">
<th rowspan="2" class="super-top-left">Nama Kenshin</th>
<th colspan="<?php echo count($kriterias); ?>">Kriteria</th>
</tr>
<tr>
<?php foreach($kriterias as $kriteria ): ?>
<th><?php echo $kriteria['nama']; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach($kenshins as $kenshin): ?>
<tr>
<td><?php echo $kenshin['nama_kenshin']; ?></td>
<?php
// Ambil Nilai
$query3 = $pdo->prepare('SELECT id_kriteria, nilai FROM nilai_kenshin
WHERE id_kenshin = :id_kenshin');
$query3->execute(array(
'id_kenshin' => $kenshin['id_kenshin']
));
$query3->setFetchMode(PDO::FETCH_ASSOC);
$nilais = $query3->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_UNIQUE);
foreach($kriterias as $id_kriteria => $values):
echo '<td>';
if(isset($nilais[$id_kriteria])) {
echo $nilais[$id_kriteria]['nilai'];
$kriterias[$id_kriteria]['nilai'][$kenshin['id_kenshin']] = $nilais[$id_kriteria]['nilai'];
} else {
echo 0;
$kriterias[$id_kriteria]['nilai'][$kenshin['id_kenshin']] = 0;
}
if(isset($kriterias[$id_kriteria]['tn_kuadrat'])){
$kriterias[$id_kriteria]['tn_kuadrat'] += pow($kriterias[$id_kriteria]['nilai'][$kenshin['id_kenshin']], 2);
} else {
$kriterias[$id_kriteria]['tn_kuadrat'] = pow($kriterias[$id_kriteria]['nilai'][$kenshin['id_kenshin']], 2);
}
echo '</td>';
endforeach;
?>
</pre>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p>Maaf, belum ada data untuk kenshin.</p>
<?php endif; ?>
</div>
</div><!-- .container -->
</div><!-- .main-content-row -->
<?php
require_once('template-parts/footer.php');