From caaaf66dafc0847be34ab34fac5b032549d8ccaf Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 9 Nov 2025 16:42:16 +0000 Subject: [PATCH] MyTaskManager V1 --- assets/css/custom.css | 60 ++++++++ assets/js/main.js | 18 +++ index.php | 348 +++++++++++++++++++++++++----------------- 3 files changed, 285 insertions(+), 141 deletions(-) create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..53fd522 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,60 @@ +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap'); + +body { + font-family: 'Inter', sans-serif; + background-color: #F8F9FA; + color: #333; +} + +.navbar-brand { + font-weight: 700; +} + +.task-card { + border-radius: 0.5rem; + border: 1px solid #e9ecef; + box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); + transition: box-shadow 0.2s ease-in-out; +} + +.task-card:hover { + box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15); +} + +.task-card.completed { + background-color: #f8f9fa; + opacity: 0.7; +} + +.task-card.completed .card-title, +.task-card.completed .card-text { + text-decoration: line-through; +} + +.btn-primary { + background-color: #4A90E2; + border-color: #4A90E2; +} + +.btn-primary:hover { + background-color: #357ABD; + border-color: #357ABD; +} + +.btn-success { + background-color: #50E3C2; + border-color: #50E3C2; +} + +.btn-success:hover { + background-color: #38A89D; + border-color: #38A89D; +} + +.form-control, .form-select { + border-radius: 0.5rem; +} + +.toast-container { + z-index: 1090; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..864866e --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,18 @@ +document.addEventListener('DOMContentLoaded', function () { + // Initialize toasts if they are present + var toastElList = [].slice.call(document.querySelectorAll('.toast')); + var toastList = toastElList.map(function (toastEl) { + return new bootstrap.Toast(toastEl, { delay: 3000 }); + }); + toastList.forEach(toast => toast.show()); + + // Add confirmation to delete buttons + const deleteForms = document.querySelectorAll('form.delete-task-form'); + deleteForms.forEach(form => { + form.addEventListener('submit', function (event) { + if (!confirm('Are you sure you want to delete this task?')) { + event.preventDefault(); + } + }); + }); +}); diff --git a/index.php b/index.php index 7205f3d..251a4c2 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,216 @@ exec(" + CREATE TABLE IF NOT EXISTS tasks ( + id INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + description TEXT, + status ENUM('pending', 'completed') DEFAULT 'pending' NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) + "); + + // --- HANDLE POST REQUESTS --- + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (session_status() == PHP_SESSION_NONE) { + session_start(); + } + $action = $_POST['action'] ?? ''; + + if ($action === 'add_task') { + $title = trim($_POST['title'] ?? ''); + $description = trim($_POST['description'] ?? ''); + + if (!empty($title)) { + $stmt = $pdo->prepare("INSERT INTO tasks (title, description) VALUES (?, ?)"); + $stmt->execute([$title, $description]); + $_SESSION['message'] = 'Task added successfully!'; + $_SESSION['message_type'] = 'success'; + } else { + $_SESSION['message'] = 'Task title cannot be empty.'; + $_SESSION['message_type'] = 'danger'; + } + } elseif ($action === 'update_status') { + $task_id = filter_var($_POST['task_id'] ?? 0, FILTER_VALIDATE_INT); + if ($task_id) { + $stmt = $pdo->prepare("UPDATE tasks SET status = 'completed' WHERE id = ?"); + $stmt->execute([$task_id]); + $_SESSION['message'] = 'Task marked as completed!'; + $_SESSION['message_type'] = 'success'; + } + } elseif ($action === 'delete_task') { + $task_id = filter_var($_POST['task_id'] ?? 0, FILTER_VALIDATE_INT); + if ($task_id) { + $stmt = $pdo->prepare("DELETE FROM tasks WHERE id = ?"); + $stmt->execute([$task_id]); + $_SESSION['message'] = 'Task deleted successfully!'; + $_SESSION['message_type'] = 'success'; + } + } + + // Redirect to self to prevent form resubmission + header("Location: " . $_SERVER['PHP_SELF']); + exit; + } + + // Check for session message + if (session_status() == PHP_SESSION_NONE) { + session_start(); + } + if (isset($_SESSION['message'])) { + $message = $_SESSION['message']; + $message_type = $_SESSION['message_type']; + unset($_SESSION['message']); + unset($_SESSION['message_type']); + } + + + // --- FETCH TASKS FOR DISPLAY --- + $stmt = $pdo->query("SELECT * FROM tasks ORDER BY status ASC, created_at DESC"); + $tasks = $stmt->fetchAll(PDO::FETCH_ASSOC); + +} catch (PDOException $e) { + $error_message = "Database error: " . $e->getMessage(); + $tasks = []; + $message = $error_message; + $message_type = 'danger'; +} -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + + + MyTaskManager + + + + + + + + + + + + -
-
-

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

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

Add a New Task

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

Your Tasks

+ +
+ +

You have no tasks yet. Add one above to get started!

+
+ +
+ +
+
+
+
+

+
+
+ +
+ + + +
+ +
+ + + +
+
+
+
+ +
+ +
+ +
+ + + +
+
-
- + + + + + + + + - + \ No newline at end of file