-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_timeline.php
56 lines (49 loc) · 1.87 KB
/
get_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
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
session_start();
require('koneksi.php');
$selected_month = isset($_GET['month']) ? $_GET['month'] : date('m');
$selected_year = isset($_GET['year']) ? $_GET['year'] : date('Y');
$start_date = "$selected_year-$selected_month-01";
$end_date = date('Y-m-t', strtotime($start_date));
// Query untuk data submitted
$sql = "SELECT DATE(waktu) as tanggal FROM laporan WHERE nama = ? AND waktu BETWEEN ? AND ? ORDER BY waktu DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sss", $_SESSION['nama'], $start_date, $end_date);
$stmt->execute();
$result = $stmt->get_result();
$submitted_dates = [];
while ($row = $result->fetch_assoc()) {
$submitted_dates[] = $row['tanggal'];
}
// Generate dates
$date_range = [];
$current = strtotime($start_date);
$last_day = strtotime($end_date);
while ($current <= $last_day) {
$date = date('Y-m-d', $current);
?>
<div class="timeline-item">
<div class="timeline-dot <?php echo in_array($date, $submitted_dates) ? 'submitted' : 'missing'; ?>"></div>
<div class="timeline-content">
<div class="timeline-date"><?php echo date('d M Y', strtotime($date)); ?></div>
<div class="timeline-status">
<?php if (in_array($date, $submitted_dates)): ?>
<span class="badge submitted">Sudah Dikumpulkan ✓</span>
<?php else: ?>
<span class="badge missing">Belum Dikumpulkan</span>
<?php if (strtotime($date) <= strtotime('today')): ?>
<button class="submit-btn" data-date="<?php echo $date; ?>">Submit</button>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php
$current = strtotime('+1 day', $current);
}
// Tutup koneksi
$stmt->close();
$conn->close();
?>