-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_see_list_event.php
119 lines (105 loc) · 4.89 KB
/
admin_see_list_event.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
<?php
include 'connect.php';
header('Content-type: application/json');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// dapetin data dari POST Ajax
$id_group = $_POST['id'];
$group_name = $_POST['group_name'];
// Buat button 'Add Event'
$outputHeader = '<div class="row">
<div class="col-2">
<input
type="submit"
class="btn btn-primary btn-block"
data-sp= "' . $id_group . '"
id="add-event"
data-bs-toggle="modal"
data-bs-target="#add-event-modal"
value="Add Event">
</div>
<div class="col-2">
<input
type="submit"
class="btn btn-info btn-block"
id="update-event-btn"
value="Update Event">
</div>
<div class="col-2">
<input
type="submit"
class="btn btn-danger btn-block"
id="delete-event-btn"
value="Delete Event">
</div>
<div class="col-2">
<input
type="submit"
class="btn btn-warning btn-block"
id="restore-event-btn"
value="Restore Event">
</div>
<div class="col-2"></div>
<div class="col-2"></div>
</div>';
// Buat button 'See Detail Event'
$detail_button = '<div class="container">
<div class="row">
<input
type="submit"
role="button"
class="btn btn-info see-detail-event"
href="#dtablesModalDetailEvent"
data-sp= "' . $id_group . '"
data-group = "' . $group_name . '"
data-bs-toggle="modal"
value="See Detail Event">
</div>
</div>';
// Ambil semua nama, createdAt, dan id_event dari table event yang namanya bukan 'Empty'
$sql = "SELECT e.nama AS nama,
e.createdAt AS created,
de.id_event AS id_event,
e.isActive AS isActive
FROM detail_event AS de
JOIN event AS e
JOIN group_alkitab AS ga
ON e.id = de.id_event
WHERE de.id_group = ? AND ga.nama = ?
GROUP BY created
HAVING nama != 'Empty'
ORDER BY created DESC";
$stmt = $pdo->prepare($sql);
$stmt->execute([$id_group, $group_name]);
// HTML untuk DataTable
$output = '<table class="table table-bordered">
<thead>
<tr>
<th style="width:5px;"><input type="button" id="clearRadio" class="btn btn-secondary btn-block" value="Clear"></th>
<th>No</th>
<th>Nama Event</th>
<th>Tanggal Dibuat</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>';
$radioButton = '<input class="form-check-input" type="radio">';
$count = 0;
while ($row = $stmt->fetch()) {
$isActiveStatus = '<div class="text-center"><i class="fa fa-check" style="color:green;"></i></div>';
if (!$row['isActive']) {
$isActiveStatus = '<div class="text-center"><i class="fa fa-remove" style="color:red;"></i></div>';
}
$output .= '<tr data-event="' . $row['id_event'] . '">
<td style="width:10px;">' . $radioButton . '</td>
<td>' . ++$count . '</td>
<td>' . $row['nama'] . '</td>
<td data-order="' . $row['created'] . '">' . date("d F Y G:i", strtotime($row['created'])) . '</td>
<td>' . $isActiveStatus . '</td>
<td>' . $detail_button . '</td>
</tr>';
}
$output .= '</tbody></table>';
$notif = '';
echo json_encode(array('output' => $output, 'outputHeader' => $outputHeader, 'notif' => $notif));
}