Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97848efaca |
110
chat.php
Normal file
110
chat.php
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
require_once __DIR__ . '/ai/LocalAIApi.php';
|
||||||
|
|
||||||
|
$aiReply = '';
|
||||||
|
$userMessage = '';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['chat_history'])) {
|
||||||
|
$_SESSION['chat_history'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
|
||||||
|
$userMessage = trim($_POST['message']);
|
||||||
|
|
||||||
|
if (!empty($userMessage)) {
|
||||||
|
$_SESSION['chat_history'][] = ['user' => $userMessage];
|
||||||
|
|
||||||
|
$conversation = [];
|
||||||
|
foreach ($_SESSION['chat_history'] as $entry) {
|
||||||
|
if (isset($entry['user'])) {
|
||||||
|
$conversation[] = ['role' => 'user', 'content' => $entry['user']];
|
||||||
|
}
|
||||||
|
if (isset($entry['ai'])) {
|
||||||
|
$conversation[] = ['role' => 'assistant', 'content' => $entry['ai']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$resp = LocalAIApi::createResponse(
|
||||||
|
[
|
||||||
|
'input' => $conversation,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!empty($resp['success'])) {
|
||||||
|
$text = LocalAIApi::extractText($resp);
|
||||||
|
if ($text === '') {
|
||||||
|
$decoded = LocalAIApi::decodeJsonFromResponse($resp);
|
||||||
|
$aiReply = $decoded ? json_encode($decoded, JSON_UNESCAPED_UNICODE) : (string)($resp['data'] ?? '');
|
||||||
|
} else {
|
||||||
|
$aiReply = $text;
|
||||||
|
}
|
||||||
|
$_SESSION['chat_history'][] = ['ai' => $aiReply];
|
||||||
|
} else {
|
||||||
|
$aiReply = 'Error: Could not get a response from the AI.';
|
||||||
|
error_log('AI error: ' . ($resp['error'] ?? 'unknown'));
|
||||||
|
$_SESSION['chat_history'][] = ['ai' => $aiReply];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>AI Chat</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Nunito:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Nunito', sans-serif;
|
||||||
|
background-color: #FFFBEB;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: 'Lora', serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="flex flex-col items-center justify-center min-h-screen">
|
||||||
|
|
||||||
|
<div class="w-full max-w-2xl mx-auto bg-white rounded-xl shadow-lg p-6">
|
||||||
|
<div class="mb-4">
|
||||||
|
<h1 class="text-3xl font-bold text-center text-gray-800">AI Chat</h1>
|
||||||
|
<p class="text-center text-gray-500">Have a conversation with our AI assistant.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="chat-box" class="h-96 overflow-y-auto mb-4 p-4 bg-gray-50 rounded-lg">
|
||||||
|
<?php foreach ($_SESSION['chat_history'] as $entry): ?>
|
||||||
|
<?php if (isset($entry['user'])): ?>
|
||||||
|
<div class="text-right mb-3">
|
||||||
|
<span class="inline-block bg-yellow-500 text-white rounded-lg px-4 py-2"><?php echo htmlspecialchars($entry['user']); ?></span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($entry['ai'])): ?>
|
||||||
|
<div class="text-left mb-3">
|
||||||
|
<span class="inline-block bg-gray-200 text-gray-800 rounded-lg px-4 py-2"><?php echo htmlspecialchars($entry['ai']); ?></span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="POST" action="chat.php" class="flex">
|
||||||
|
<input type="text" name="message" class="flex-grow rounded-l-lg p-3 border-t mr-0 border-b border-l text-gray-800 border-gray-200 bg-white focus:outline-none" placeholder="Type your message here..."/>
|
||||||
|
<button type="submit" class="px-6 rounded-r-lg bg-yellow-500 text-white font-bold p-3 uppercase border-yellow-500 border-t border-b border-r hover:bg-yellow-600">Send</button>
|
||||||
|
</form>
|
||||||
|
<div class="text-center mt-6">
|
||||||
|
<a href="index.php" class="text-yellow-500 hover:underline">Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const chatBox = document.getElementById('chat-box');
|
||||||
|
chatBox.scrollTop = chatBox.scrollHeight;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
db/migrations/001_create_activities_table.sql
Normal file
7
db/migrations/001_create_activities_table.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS activities (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
activity_date DATE,
|
||||||
|
notes TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
8
db/migrations/002_create_travel_plans_table.sql
Normal file
8
db/migrations/002_create_travel_plans_table.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS travel_plans (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
destination VARCHAR(255) NOT NULL,
|
||||||
|
start_date DATE,
|
||||||
|
end_date DATE,
|
||||||
|
notes TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
7
db/migrations/003_create_shopping_items_table.sql
Normal file
7
db/migrations/003_create_shopping_items_table.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS shopping_items (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
item_name VARCHAR(255) NOT NULL,
|
||||||
|
quantity VARCHAR(255),
|
||||||
|
is_purchased BOOLEAN DEFAULT FALSE,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
234
index.php
234
index.php
@ -1,150 +1,134 @@
|
|||||||
<?php
|
<!DOCTYPE html>
|
||||||
declare(strict_types=1);
|
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<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>Winter Planner</title>
|
||||||
<?php
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
// Read project preview data from environment
|
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
|
||||||
?>
|
|
||||||
<?php if ($projectDescription): ?>
|
|
||||||
<!-- Meta description -->
|
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
|
||||||
<!-- Open Graph meta tags -->
|
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
|
||||||
<!-- Twitter meta tags -->
|
|
||||||
<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.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<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">
|
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Nunito:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<script src="https://unpkg.com/feather-icons"></script>
|
||||||
<style>
|
<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 {
|
body {
|
||||||
margin: 0;
|
background-color: #FFFBEB;
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Nunito', sans-serif;
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
color: #374151;
|
||||||
color: var(--text-color);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
text-align: center;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
}
|
}
|
||||||
body::before {
|
h1, h2, h3, h4, h5, h6 {
|
||||||
content: '';
|
font-family: 'Lora', serif;
|
||||||
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 {
|
.hero {
|
||||||
0% { background-position: 0% 0%; }
|
background: linear-gradient(135deg, #F59E0B, #FBBF24);
|
||||||
100% { background-position: 100% 100%; }
|
color: white;
|
||||||
|
padding: 4rem 0;
|
||||||
|
border-bottom-left-radius: 1.5rem;
|
||||||
|
border-bottom-right-radius: 1.5rem;
|
||||||
}
|
}
|
||||||
main {
|
.dashboard .card {
|
||||||
padding: 2rem;
|
border: none;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
||||||
|
transition: transform 0.2s;
|
||||||
}
|
}
|
||||||
.card {
|
.dashboard .card:hover {
|
||||||
background: var(--card-bg-color);
|
transform: translateY(-5px);
|
||||||
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 {
|
.dashboard .card-title {
|
||||||
margin: 1.25rem auto 1.25rem;
|
font-size: 1.25rem;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
.dashboard .card-icon {
|
||||||
width: 48px;
|
width: 48px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
color: #F59E0B;
|
||||||
border-top-color: #fff;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
}
|
||||||
@keyframes spin {
|
.footer {
|
||||||
from { transform: rotate(0deg); }
|
padding: 2rem 0;
|
||||||
to { transform: rotate(360deg); }
|
background-color: #FFFFFF;
|
||||||
}
|
margin-top: 4rem;
|
||||||
.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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<header class="p-3 bg-white shadow-sm">
|
||||||
|
<div class="container d-flex justify-content-between align-items-center">
|
||||||
|
<h4 class="m-0">Winter Planner</h4>
|
||||||
|
<nav>
|
||||||
|
<a href="#" class="text-decoration-none me-3">Home</a>
|
||||||
|
<a href="#" class="text-decoration-none me-3">About</a>
|
||||||
|
<a href="#" class="text-decoration-none">Contact</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="card">
|
<section class="hero text-center">
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<div class="container">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<h1 class="display-4">Your Cozy Corner for Winter</h1>
|
||||||
<span class="sr-only">Loading…</span>
|
<p class="lead">Plan activities, chat with AI, and organize your life, all in one place.</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
</section>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
<section class="dashboard container mt-5">
|
||||||
|
<h2 class="text-center mb-4">Dashboard</h2>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<a href="chat.php" class="text-decoration-none">
|
||||||
|
<div class="card text-center p-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<i data-feather="message-circle" class="card-icon mb-3"></i>
|
||||||
|
<h5 class="card-title">AI Chat</h5>
|
||||||
|
<p class="card-text">Chat with our friendly AI assistant.</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<a href="planner.php" class="text-decoration-none">
|
||||||
|
<div class="card text-center p-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<i data-feather="calendar" class="card-icon mb-3"></i>
|
||||||
|
<h5 class="card-title">Activity Planner</h5>
|
||||||
|
<p class="card-text">Plan your winter adventures.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<a href="travel.php" class="text-decoration-none">
|
||||||
|
<div class="card text-center p-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<i data-feather="map" class="card-icon mb-3"></i>
|
||||||
|
<h5 class="card-title">Travel Plans</h5>
|
||||||
|
<p class="card-text">Organize your upcoming trips.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<a href="shopping.php" class="text-decoration-none">
|
||||||
|
<div class="card text-center p-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<i data-feather="shopping-cart" class="card-icon mb-3"></i>
|
||||||
|
<h5 class="card-title">Shopping</h5>
|
||||||
|
<p class="card-text">Manage your shopping lists.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<footer class="footer">
|
||||||
|
<div class="container text-center">
|
||||||
|
<p>© 2025 Winter Planner. All rights reserved.</p>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
feather.replace()
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
122
planner.php
Normal file
122
planner.php
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
// Handle activity deletion
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['activity_id_to_delete'])) {
|
||||||
|
$activityIdToDelete = $_POST['activity_id_to_delete'];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM activities WHERE id = ?");
|
||||||
|
$stmt->execute([$activityIdToDelete]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle new activity creation
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['activity_name'])) {
|
||||||
|
$activityName = trim($_POST['activity_name']);
|
||||||
|
$activityDate = trim($_POST['activity_date']);
|
||||||
|
$activityNotes = trim($_POST['activity_notes']);
|
||||||
|
|
||||||
|
if (!empty($activityName)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO activities (name, activity_date, notes) VALUES (?, ?, ?)");
|
||||||
|
$stmt->execute([$activityName, $activityDate, $activityNotes]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all activities
|
||||||
|
$activities = [];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->query("SELECT id, name, activity_date, notes FROM activities ORDER BY activity_date DESC, created_at DESC");
|
||||||
|
$activities = $stmt->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Activity Planner</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Nunito:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Nunito', sans-serif;
|
||||||
|
background-color: #FFFBEB;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: 'Lora', serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="flex flex-col items-center justify-center min-h-screen">
|
||||||
|
|
||||||
|
<div class="w-full max-w-4xl mx-auto bg-white rounded-xl shadow-lg p-6">
|
||||||
|
<div class="mb-6">
|
||||||
|
<h1 class="text-4xl font-bold text-center text-gray-800">Activity Planner</h1>
|
||||||
|
<p class="text-center text-gray-500">Plan your winter adventures.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Add New Activity</h2>
|
||||||
|
<form method="POST" action="planner.php" class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label for="activity_name" class="block text-sm font-medium text-gray-700">Activity Name</label>
|
||||||
|
<input type="text" id="activity_name" name="activity_name" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="activity_date" class="block text-sm font-medium text-gray-700">Date</label>
|
||||||
|
<input type="date" id="activity_date" name="activity_date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="activity_notes" class="block text-sm font-medium text-gray-700">Notes</label>
|
||||||
|
<textarea id="activity_notes" name="activity_notes" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2"></textarea>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="submit" class="w-full px-4 py-2 bg-yellow-500 text-white font-bold rounded-md hover:bg-yellow-600">Add Activity</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Planned Activities</h2>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<?php if (empty($activities)): ?>
|
||||||
|
<p class="text-gray-500">No activities planned yet.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($activities as $activity): ?>
|
||||||
|
<div class="p-4 bg-gray-50 rounded-lg shadow flex justify-between items-start">
|
||||||
|
<div>
|
||||||
|
<h3 class="font-bold text-lg"><?php echo htmlspecialchars($activity['name']); ?></h3>
|
||||||
|
<p class="text-sm text-gray-600"><?php echo htmlspecialchars($activity['activity_date']); ?></p>
|
||||||
|
<p class="text-sm mt-1"><?php echo htmlspecialchars($activity['notes']); ?></p>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="planner.php">
|
||||||
|
<input type="hidden" name="activity_id_to_delete" value="<?php echo $activity['id']; ?>">
|
||||||
|
<button type="submit" class="text-red-500 hover:text-red-700 font-semibold">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center mt-8">
|
||||||
|
<a href="index.php" class="text-yellow-500 hover:underline">Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
131
shopping.php
Normal file
131
shopping.php
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
// Handle item deletion
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['item_id_to_delete'])) {
|
||||||
|
$itemIdToDelete = $_POST['item_id_to_delete'];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM shopping_items WHERE id = ?");
|
||||||
|
$stmt->execute([$itemIdToDelete]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle item purchase status update
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['item_id_to_toggle'])) {
|
||||||
|
$itemIdToToggle = $_POST['item_id_to_toggle'];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("UPDATE shopping_items SET is_purchased = !is_purchased WHERE id = ?");
|
||||||
|
$stmt->execute([$itemIdToToggle]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle new item creation
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['item_name'])) {
|
||||||
|
$itemName = trim($_POST['item_name']);
|
||||||
|
$quantity = trim($_POST['quantity']);
|
||||||
|
|
||||||
|
if (!empty($itemName)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO shopping_items (item_name, quantity) VALUES (?, ?)");
|
||||||
|
$stmt->execute([$itemName, $quantity]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all shopping items
|
||||||
|
$items = [];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->query("SELECT id, item_name, quantity, is_purchased FROM shopping_items ORDER BY is_purchased ASC, created_at DESC");
|
||||||
|
$items = $stmt->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Shopping List</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Nunito:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Nunito', sans-serif;
|
||||||
|
background-color: #FFFBEB;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: 'Lora', serif;
|
||||||
|
}
|
||||||
|
.purchased {
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: #9CA3AF;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="flex flex-col items-center justify-center min-h-screen">
|
||||||
|
|
||||||
|
<div class="w-full max-w-2xl mx-auto bg-white rounded-xl shadow-lg p-6">
|
||||||
|
<div class="mb-6">
|
||||||
|
<h1 class="text-4xl font-bold text-center text-gray-800">Shopping List</h1>
|
||||||
|
<p class="text-center text-gray-500">Manage your shopping lists.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-6">
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Add New Item</h2>
|
||||||
|
<form method="POST" action="shopping.php" class="flex gap-4">
|
||||||
|
<input type="text" name="item_name" required class="flex-grow rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2" placeholder="Item Name">
|
||||||
|
<input type="text" name="quantity" class="rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2" placeholder="Quantity">
|
||||||
|
<button type="submit" class="px-4 py-2 bg-yellow-500 text-white font-bold rounded-md hover:bg-yellow-600">Add</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Your Shopping List</h2>
|
||||||
|
<div class="space-y-3">
|
||||||
|
<?php if (empty($items)): ?>
|
||||||
|
<p class="text-gray-500">No items in your shopping list yet.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($items as $item): ?>
|
||||||
|
<div class="p-3 bg-gray-50 rounded-lg shadow flex justify-between items-center">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<form method="POST" action="shopping.php" class="mr-3">
|
||||||
|
<input type="hidden" name="item_id_to_toggle" value="<?php echo $item['id']; ?>">
|
||||||
|
<input type="checkbox" <?php echo $item['is_purchased'] ? 'checked' : ''; ?> onchange="this.form.submit()" class="h-5 w-5 rounded border-gray-300 text-yellow-500 focus:ring-yellow-500">
|
||||||
|
</form>
|
||||||
|
<div class="<?php echo $item['is_purchased'] ? 'purchased' : ''; ?>">
|
||||||
|
<span class="font-bold"><?php echo htmlspecialchars($item['item_name']); ?></span>
|
||||||
|
<?php if (!empty($item['quantity'])): ?>
|
||||||
|
<span class="text-sm">(<?php echo htmlspecialchars($item['quantity']); ?>)</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="shopping.php">
|
||||||
|
<input type="hidden" name="item_id_to_delete" value="<?php echo $item['id']; ?>">
|
||||||
|
<button type="submit" class="text-red-500 hover:text-red-700 font-semibold">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center mt-8">
|
||||||
|
<a href="index.php" class="text-yellow-500 hover:underline">Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
129
travel.php
Normal file
129
travel.php
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
// Handle travel plan deletion
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['plan_id_to_delete'])) {
|
||||||
|
$planIdToDelete = $_POST['plan_id_to_delete'];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM travel_plans WHERE id = ?");
|
||||||
|
$stmt->execute([$planIdToDelete]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle new travel plan creation
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['destination'])) {
|
||||||
|
$destination = trim($_POST['destination']);
|
||||||
|
$startDate = trim($_POST['start_date']);
|
||||||
|
$endDate = trim($_POST['end_date']);
|
||||||
|
$notes = trim($_POST['notes']);
|
||||||
|
|
||||||
|
if (!empty($destination)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO travel_plans (destination, start_date, end_date, notes) VALUES (?, ?, ?, ?)");
|
||||||
|
$stmt->execute([$destination, $startDate, $endDate, $notes]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all travel plans
|
||||||
|
$plans = [];
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->query("SELECT id, destination, start_date, end_date, notes FROM travel_plans ORDER BY start_date DESC, created_at DESC");
|
||||||
|
$plans = $stmt->fetchAll();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log("Database error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Travel Planner</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Nunito:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Nunito', sans-serif;
|
||||||
|
background-color: #FFFBEB;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: 'Lora', serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="flex flex-col items-center justify-center min-h-screen">
|
||||||
|
|
||||||
|
<div class="w-full max-w-4xl mx-auto bg-white rounded-xl shadow-lg p-6">
|
||||||
|
<div class="mb-6">
|
||||||
|
<h1 class="text-4xl font-bold text-center text-gray-800">Travel Planner</h1>
|
||||||
|
<p class="text-center text-gray-500">Organize your upcoming trips.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Add New Travel Plan</h2>
|
||||||
|
<form method="POST" action="travel.php" class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label for="destination" class="block text-sm font-medium text-gray-700">Destination</label>
|
||||||
|
<input type="text" id="destination" name="destination" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2">
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label for="start_date" class="block text-sm font-medium text-gray-700">Start Date</label>
|
||||||
|
<input type="date" id="start_date" name="start_date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="end_date" class="block text-sm font-medium text-gray-700">End Date</label>
|
||||||
|
<input type="date" id="end_date" name="end_date" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="notes" class="block text-sm font-medium text-gray-700">Notes</label>
|
||||||
|
<textarea id="notes" name="notes" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-yellow-500 focus:ring-yellow-500 sm:text-sm p-2"></textarea>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="submit" class="w-full px-4 py-2 bg-yellow-500 text-white font-bold rounded-md hover:bg-yellow-600">Add Travel Plan</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold mb-4">Your Travel Plans</h2>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<?php if (empty($plans)): ?>
|
||||||
|
<p class="text-gray-500">No travel plans yet.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($plans as $plan): ?>
|
||||||
|
<div class="p-4 bg-gray-50 rounded-lg shadow flex justify-between items-start">
|
||||||
|
<div>
|
||||||
|
<h3 class="font-bold text-lg"><?php echo htmlspecialchars($plan['destination']); ?></h3>
|
||||||
|
<p class="text-sm text-gray-600"><?php echo htmlspecialchars($plan['start_date']); ?> to <?php echo htmlspecialchars($plan['end_date']); ?></p>
|
||||||
|
<p class="text-sm mt-1"><?php echo htmlspecialchars($plan['notes']); ?></p>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="travel.php">
|
||||||
|
<input type="hidden" name="plan_id_to_delete" value="<?php echo $plan['id']; ?>">
|
||||||
|
<button type="submit" class="text-red-500 hover:text-red-700 font-semibold">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center mt-8">
|
||||||
|
<a href="index.php" class="text-yellow-500 hover:underline">Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user