diff --git a/chat.php b/chat.php new file mode 100644 index 0000000..daece4b --- /dev/null +++ b/chat.php @@ -0,0 +1,110 @@ + $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]; + } + } +} + +?> + + + + + + AI Chat + + + + + + +
+
+

AI Chat

+

Have a conversation with our AI assistant.

+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ Back to Home +
+
+ + + + + diff --git a/db/migrations/001_create_activities_table.sql b/db/migrations/001_create_activities_table.sql new file mode 100644 index 0000000..661a628 --- /dev/null +++ b/db/migrations/001_create_activities_table.sql @@ -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 +); diff --git a/db/migrations/002_create_travel_plans_table.sql b/db/migrations/002_create_travel_plans_table.sql new file mode 100644 index 0000000..dac935c --- /dev/null +++ b/db/migrations/002_create_travel_plans_table.sql @@ -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 +); diff --git a/db/migrations/003_create_shopping_items_table.sql b/db/migrations/003_create_shopping_items_table.sql new file mode 100644 index 0000000..c825f3b --- /dev/null +++ b/db/migrations/003_create_shopping_items_table.sql @@ -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 +); diff --git a/index.php b/index.php index 7205f3d..fc3fe8a 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,134 @@ - - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Winter Planner + + + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- +
+
+

Winter Planner

+ +
+
+ +
+
+
+

Your Cozy Corner for Winter

+

Plan activities, chat with AI, and organize your life, all in one place.

+
+
+ +
+

Dashboard

+ +
+
+ + + + - + \ No newline at end of file diff --git a/planner.php b/planner.php new file mode 100644 index 0000000..9f879b2 --- /dev/null +++ b/planner.php @@ -0,0 +1,122 @@ +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()); +} + +?> + + + + + + Activity Planner + + + + + + +
+
+

Activity Planner

+

Plan your winter adventures.

+
+ +
+
+

Add New Activity

+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+

Planned Activities

+
+ +

No activities planned yet.

+ + +
+
+

+

+

+
+
+ + +
+
+ + +
+
+
+ +
+ Back to Home +
+
+ + + diff --git a/shopping.php b/shopping.php new file mode 100644 index 0000000..671428f --- /dev/null +++ b/shopping.php @@ -0,0 +1,131 @@ +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()); +} + +?> + + + + + + Shopping List + + + + + + +
+
+

Shopping List

+

Manage your shopping lists.

+
+ +
+

Add New Item

+
+ + + +
+
+ +
+

Your Shopping List

+
+ +

No items in your shopping list yet.

+ + +
+
+
+ + onchange="this.form.submit()" class="h-5 w-5 rounded border-gray-300 text-yellow-500 focus:ring-yellow-500"> +
+
+ + + () + +
+
+
+ + +
+
+ + +
+
+ +
+ Back to Home +
+
+ + + diff --git a/travel.php b/travel.php new file mode 100644 index 0000000..7fd3a3e --- /dev/null +++ b/travel.php @@ -0,0 +1,129 @@ +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()); +} + +?> + + + + + + Travel Planner + + + + + + +
+
+

Travel Planner

+

Organize your upcoming trips.

+
+ +
+
+

Add New Travel Plan

+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ +
+
+
+
+

Your Travel Plans

+
+ +

No travel plans yet.

+ + +
+
+

+

to

+

+
+
+ + +
+
+ + +
+
+
+ +
+ Back to Home +
+
+ + +