Compare commits

...

2 Commits

Author SHA1 Message Date
Flatlogic Bot
06e33a4bd4 Auto commit: 2025-10-08T00:33:34.379Z 2025-10-08 00:33:34 +00:00
Flatlogic Bot
a6d0ca0eea agenda 2025-10-08 00:23:05 +00:00
5 changed files with 340 additions and 155 deletions

52
assets/css/custom.css Normal file
View File

@ -0,0 +1,52 @@
body {
background-color: #F4F7F6;
font-family: '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Helvetica Neue', 'Arial', 'sans-serif';
color: #333333;
}
.header-gradient {
background: linear-gradient(135deg, #4A90E2 0%, #50E3C2 100%);
color: white;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Georgia', serif;
}
.card {
border-radius: 8px;
border: none;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.btn-primary {
background-color: #4A90E2;
border-color: #4A90E2;
border-radius: 8px;
padding: 10px 20px;
font-weight: bold;
}
.btn-primary:hover {
background-color: #357ABD;
border-color: #357ABD;
}
.nav-tabs .nav-link {
border-radius: 8px 8px 0 0;
border-color: #dee2e6 #dee2e6 #fff;
}
.nav-tabs .nav-link.active {
background-color: #fff;
border-color: #dee2e6 #dee2e6 #fff;
color: #4A90E2;
font-weight: bold;
}
.toast-container {
position: fixed;
top: 20px;
right: 20px;
z-index: 1055;
}

20
assets/js/main.js Normal file
View File

@ -0,0 +1,20 @@
(() => {
'use strict'
const form = document.querySelector('#agendaForm');
if (form) {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
}
const toastEl = document.querySelector('.toast');
if (toastEl) {
const toast = new bootstrap.Toast(toastEl);
toast.show();
}
})();

View File

@ -1,17 +1,99 @@
<?php <?php
// Generated by setup_mariadb_project.sh — edit as needed. // db/config.php
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_30944');
define('DB_USER', 'app_30944');
define('DB_PASS', 'a7e8bc69-cff3-4925-afbf-b433d626326b');
// --- Database Credentials ---
// We are using environment variables for configuration.
$db_host = getenv('DB_HOST') ?: '127.0.0.1';
$db_port = getenv('DB_PORT') ?: '3306';
$db_name = getenv('DB_DATABASE') ?: 'app';
$db_user = getenv('DB_USERNAME') ?: 'app';
$db_pass = getenv('DB_PASSWORD') ?: 'app';
/**
* Establishes a PDO database connection.
*
* @return PDO|null A PDO connection object on success, or null on failure.
*/
function db() { function db() {
static $pdo; global $db_host, $db_port, $db_name, $db_user, $db_pass;
if (!$pdo) { static $pdo = null;
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, if ($pdo !== null) {
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, return $pdo;
]); }
}
return $pdo; $dsn = "mysql:host={$db_host};port={$db_port};dbname={$db_name};charset=utf8mb4";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $db_user, $db_pass, $options);
return $pdo;
} catch (PDOException $e) {
// In a real application, you would log this error and show a generic error page.
// For this development environment, we'll just show the error.
error_log('Database Connection Error: ' . $e->getMessage());
// Returning null or you could throw an exception.
return null;
}
}
/**
* Runs database migrations.
* It finds all .php files in the migrations directory and runs them in order.
* Each migration file should contain a function with the same name as the file (without .php).
*/
function run_migrations() {
$pdo = db();
if (!$pdo) {
// Cannot run migrations without a database connection.
return;
}
$migration_dir = __DIR__ . '/migrations';
if (!is_dir($migration_dir)) {
return; // No migrations directory.
}
$files = glob($migration_dir . '/*.php');
sort($files);
// Check if migrations table exists, create if not
$pdo->exec("CREATE TABLE IF NOT EXISTS migrations (migration VARCHAR(255) PRIMARY KEY)");
// Get all executed migrations
$executed_migrations = $pdo->query("SELECT migration FROM migrations")->fetchAll(PDO::FETCH_COLUMN);
foreach ($files as $file) {
$migration_name = basename($file, '.php');
if (in_array($migration_name, $executed_migrations)) {
continue; // Skip already executed migration
}
require_once $file;
// The function name inside the migration file must match the filename.
// e.g., 001_create_agenda_table.php must contain a function named 'migration_001_create_agenda_table'
$migration_function_name = 'migration_' . str_replace(['-'], '_', $migration_name);
if (function_exists($migration_function_name)) {
try {
$pdo->beginTransaction();
$migration_function_name($pdo);
// Record the migration
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)");
$stmt->execute([$migration_name]);
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
error_log("Migration failed: {$migration_name}. Error: " . $e->getMessage());
// Stop on first failed migration
return;
}
}
}
} }

View File

@ -0,0 +1,15 @@
<?php
function migration_001_create_agenda_table($pdo) {
$sql = "
CREATE TABLE IF NOT EXISTS agenda (
id INT AUTO_INCREMENT PRIMARY KEY,
tanggal DATE NOT NULL,
waktu TIME NOT NULL,
judul VARCHAR(255) NOT NULL,
deskripsi TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
";
$pdo->exec($sql);
}

300
index.php
View File

@ -1,150 +1,166 @@
<?php <?php
declare(strict_types=1); require_once 'db/config.php';
@ini_set('display_errors', '1');
@error_reporting(E_ALL); // Run migrations to ensure the database schema is up to date.
@date_default_timezone_set('UTC'); 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'];
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?> ?>
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="id">
<head> <head>
<meta charset="utf-8" /> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Style</title> <title>Aplikasi Agenda Kegiatan Pimpinan</title>
<?php <meta name="description" content="Manage Leadership Schedules with Ease: Daily Agenda App for Executives and Secretaries">
// Read project preview data from environment <meta name="keywords" content="agenda pimpinan, jadwal kegiatan, manajemen jadwal, aplikasi agenda, sekretaris, eksekutif, jadwal harian, pengingat rapat">
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; <meta property="og:title" content="Aplikasi Agenda Kegiatan Pimpinan">
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; <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'] ?? ''); ?>">
<?php if ($projectDescription): ?> <meta name="twitter:card" content="summary_large_image">
<!-- Meta description --> <meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<!-- Twitter meta tags --> <script src="https://unpkg.com/feather-icons"></script>
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head> </head>
<body> <body>
<main>
<div class="card"> <header class="header-gradient text-white p-4 text-center">
<h1>Analyzing your requirements and generating your website…</h1> <h1 class="mb-0">Agenda Kegiatan Pimpinan</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> </header>
<span class="sr-only">Loading…</span>
</div> <?php if ($toast_message): ?>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> <div class="toast-container">
<p class="hint">This page will update automatically as the plan is implemented.</p> <div class="toast align-items-center text-white bg-<?php echo $toast_message['type']; ?> border-0" role="alert" aria-live="assertive" aria-atomic="true">
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p> <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> </div>
</main> <?php endif; ?>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC) <main class="container my-5">
</footer> <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>&copy; <?php echo date('Y'); ?> Aplikasi Agenda Pimpinan. Dibuat dengan &hearts; 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> </body>
</html> </html>