-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_timeline.php
63 lines (56 loc) · 2.41 KB
/
load_timeline.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
<?php
require('koneksi.php');
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$month = $_POST['month'];
$year = $_POST['year'];
$nama = $_SESSION['nama'];
$sql = "SELECT *, DATE_FORMAT(waktu, '%d-%m-%Y') as formatted_date,
UNIX_TIMESTAMP(waktu) as timestamp_waktu
FROM laporan
WHERE nama = ?
AND MONTH(waktu) = ?
AND YEAR(waktu) = ?
ORDER BY waktu DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sii", $nama, $month, $year);
$stmt->execute();
$result = $stmt->get_result();
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$no = 1;
$output = '<table class="timeline-table" style="min-width: 1500px;">
<thead>
<tr>
<th style="width: 50px; min-width: 50px;">NO</th>
<th class="task-header">TUGAS</th>
<th class="task-header" style="width: 150px; min-width: 150px;">KATEGORI</th>';
for ($i = 1; $i <= $days_in_month; $i++) {
$output .= "<th>$i</th>";
}
$output .= '</tr></thead><tbody>';
while ($row = $result->fetch_assoc()) {
$output .= "<tr class='task-row'>";
$output .= "<td style='text-align: center;'>" . $no++ . "</td>";
$output .= "<td>" . $row['laporan'] . "</td>";
$output .= "<td style='text-align: center;'>" . ($row['kategori'] ? $row['kategori'] : 'Periode Juli - November') . "</td>";
for ($i = 1; $i <= $days_in_month; $i++) {
$task_date = date('j', strtotime($row['waktu']));
if ($task_date == $i) {
$approvedClass = ($row['status'] == 1) ? 'approved' : '';
$tooltipData = htmlspecialchars(json_encode([
'laporan' => $row['laporan'],
'tanggal' => $row['formatted_date'],
'kategori' => $row['kategori'] ? $row['kategori'] : 'Periode Juli - November',
'status' => $row['status'],
'img' => base64_encode($row['img_dir'])
]), ENT_QUOTES);
$output .= "<td class='has-task {$approvedClass}' onclick='showTaskDetail(this)' data-task='{$tooltipData}'></td>";
} else {
$output .= "<td></td>";
}
}
$output .= "</tr>";
}
$output .= '</tbody></table>';
echo $output;
}