166 lines
8.5 KiB
PHP
166 lines
8.5 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
// Run migrations to ensure the database schema is up to date.
|
|
run_migrations();
|
|
|
|
$pdo = db();
|
|
$toast_message = null;
|
|
|
|
// Handle form submission
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$tanggal = $_POST['tanggal'] ?? null;
|
|
$waktu = $_POST['waktu'] ?? null;
|
|
$judul = $_POST['judul'] ?? null;
|
|
$deskripsi = $_POST['deskripsi'] ?? '';
|
|
|
|
if ($tanggal && $waktu && $judul) {
|
|
try {
|
|
$stmt = $pdo->prepare("INSERT INTO agenda (tanggal, waktu, judul, deskripsi) VALUES (?, ?, ?, ?)");
|
|
$stmt->execute([$tanggal, $waktu, $judul, $deskripsi]);
|
|
$toast_message = ['type' => 'success', 'message' => 'Agenda berhasil ditambahkan!'];
|
|
} catch (PDOException $e) {
|
|
error_log($e->getMessage());
|
|
$toast_message = ['type' => 'danger', 'message' => 'Gagal menambahkan agenda.'];
|
|
}
|
|
} else {
|
|
$toast_message = ['type' => 'warning', 'message' => 'Semua kolom wajib diisi.'];
|
|
}
|
|
}
|
|
|
|
// Fetch agenda for the current week
|
|
$today = new DateTime();
|
|
$start_of_week = (clone $today)->modify('monday this week');
|
|
$end_of_week = (clone $today)->modify('friday this week');
|
|
|
|
$agendas = [];
|
|
if ($pdo) {
|
|
$stmt = $pdo->prepare("SELECT * FROM agenda WHERE tanggal BETWEEN ? AND ? ORDER BY tanggal, waktu");
|
|
$stmt->execute([$start_of_week->format('Y-m-d'), $end_of_week->format('Y-m-d')]);
|
|
$results = $stmt->fetchAll();
|
|
foreach ($results as $row) {
|
|
$day_name = date('l', strtotime($row['tanggal']));
|
|
$agendas[$day_name][] = $row;
|
|
}
|
|
}
|
|
|
|
$days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Aplikasi Agenda Kegiatan Pimpinan</title>
|
|
<meta name="description" content="Manage Leadership Schedules with Ease: Daily Agenda App for Executives and Secretaries">
|
|
<meta name="keywords" content="agenda pimpinan, jadwal kegiatan, manajemen jadwal, aplikasi agenda, sekretaris, eksekutif, jadwal harian, pengingat rapat">
|
|
<meta property="og:title" content="Aplikasi Agenda Kegiatan Pimpinan">
|
|
<meta property="og:description" content="Manage Leadership Schedules with Ease: Daily Agenda App for Executives and Secretaries">
|
|
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<script src="https://unpkg.com/feather-icons"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<header class="header-gradient text-white p-4 text-center">
|
|
<h1 class="mb-0">Agenda Kegiatan Pimpinan</h1>
|
|
</header>
|
|
|
|
<?php if ($toast_message): ?>
|
|
<div class="toast-container">
|
|
<div class="toast align-items-center text-white bg-<?php echo $toast_message['type']; ?> border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="d-flex">
|
|
<div class="toast-body">
|
|
<?php echo htmlspecialchars($toast_message['message']); ?>
|
|
</div>
|
|
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<main class="container my-5">
|
|
<div class="row">
|
|
<div class="col-lg-4 mb-4">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h2 class="card-title mb-4"><i data-feather="plus-circle" class="me-2"></i>Tambah Agenda Baru</h2>
|
|
<form id="agendaForm" method="POST" action="index.php" class="needs-validation" novalidate>
|
|
<div class="mb-3">
|
|
<label for="tanggal" class="form-label">Tanggal</label>
|
|
<input type="date" class="form-control" id="tanggal" name="tanggal" required>
|
|
<div class="invalid-feedback">Tolong masukkan tanggal.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="waktu" class="form-label">Waktu</label>
|
|
<input type="time" class="form-control" id="waktu" name="waktu" required>
|
|
<div class="invalid-feedback">Tolong masukkan waktu.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="judul" class="form-label">Judul Kegiatan</label>
|
|
<input type="text" class="form-control" id="judul" name="judul" required>
|
|
<div class="invalid-feedback">Tolong masukkan judul kegiatan.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="deskripsi" class="form-label">Deskripsi (Opsional)</label>
|
|
<textarea class="form-control" id="deskripsi" name="deskripsi" rows="3"></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-100">Simpan Agenda</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-8">
|
|
<h2 class="mb-4"><i data-feather="calendar" class="me-2"></i>Agenda Minggu Ini</h2>
|
|
<ul class="nav nav-tabs mb-3" id="agendaTab" role="tablist">
|
|
<?php foreach ($days as $index => $day): ?>
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link <?php echo $index === 0 ? 'active' : ''; ?>" id="<?php echo strtolower($day); ?>-tab" data-bs-toggle="tab" data-bs-target="#<?php echo strtolower($day); ?>" type="button" role="tab" aria-controls="<?php echo strtolower($day); ?>" aria-selected="<?php echo $index === 0 ? 'true' : 'false'; ?>"><?php echo $day; ?></button>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<div class="tab-content" id="agendaTabContent">
|
|
<?php foreach ($days as $index => $day): ?>
|
|
<div class="tab-pane fade <?php echo $index === 0 ? 'show active' : ''; ?>" id="<?php echo strtolower($day); ?>" role="tabpanel" aria-labelledby="<?php echo strtolower($day); ?>-tab">
|
|
<?php if (!empty($agendas[$day])): ?>
|
|
<?php foreach ($agendas[$day] as $item): ?>
|
|
<div class="card mb-3">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($item['judul']); ?></h5>
|
|
<span class="text-muted"><?php echo date('H:i', strtotime($item['waktu'])); ?></span>
|
|
</div>
|
|
<p class="card-text"><?php echo nl2br(htmlspecialchars($item['deskripsi'])); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<div class="text-center text-muted p-5">
|
|
<i data-feather="coffee" class="mb-3" style="width: 48px; height: 48px;"></i>
|
|
<p>Tidak ada agenda untuk hari ini.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="text-center text-muted py-4 mt-5">
|
|
<p>© <?php echo date('Y'); ?> Aplikasi Agenda Pimpinan. Dibuat dengan ♥ oleh Flatlogic.</p>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
<script>
|
|
feather.replace();
|
|
</script>
|
|
</body>
|
|
</html>
|