1177 lines
36 KiB
PHP
1177 lines
36 KiB
PHP
<?php
|
|
// config.php - Database configuration
|
|
class Database {
|
|
private $host = "202.46.28.160";
|
|
private $port = "45432";
|
|
private $db_name = "tgs01_5803024013";
|
|
private $username = "5803024013";
|
|
private $password = "pw5803024013";
|
|
public $conn;
|
|
|
|
public function getConnection() {
|
|
$this->conn = null;
|
|
try {
|
|
$this->conn = new PDO(
|
|
"pgsql:host=" . $this->host . ";port=" . $this->port . ";dbname=" . $this->db_name,
|
|
$this->username,
|
|
$this->password
|
|
);
|
|
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
} catch(PDOException $exception) {
|
|
echo "Connection error: " . $exception->getMessage();
|
|
}
|
|
return $this->conn;
|
|
}
|
|
}
|
|
|
|
// Initialize database and create tables if they don't exist
|
|
function initializeDatabase() {
|
|
$database = new Database();
|
|
$conn = $database->getConnection();
|
|
|
|
try {
|
|
// Create groups table
|
|
$query = "CREATE TABLE IF NOT EXISTS groups (
|
|
group_id SERIAL PRIMARY KEY,
|
|
group_name VARCHAR(255) NOT NULL UNIQUE,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
)";
|
|
$conn->exec($query);
|
|
|
|
// Create tasks table
|
|
$query = "CREATE TABLE IF NOT EXISTS tasks (
|
|
task_id SERIAL PRIMARY KEY,
|
|
task_name VARCHAR(255) NOT NULL,
|
|
task_description TEXT,
|
|
group_id INTEGER REFERENCES groups(group_id) ON DELETE CASCADE,
|
|
is_done BOOLEAN DEFAULT FALSE,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
)";
|
|
$conn->exec($query);
|
|
|
|
// Insert default groups if none exist
|
|
$stmt = $conn->prepare("SELECT COUNT(*) FROM groups");
|
|
$stmt->execute();
|
|
$count = $stmt->fetchColumn();
|
|
|
|
if ($count == 0) {
|
|
$defaultGroups = ['Personal', 'Work', 'Urgent'];
|
|
foreach ($defaultGroups as $group) {
|
|
$stmt = $conn->prepare("INSERT INTO groups (group_name) VALUES (?)");
|
|
$stmt->execute([$group]);
|
|
}
|
|
}
|
|
|
|
} catch(PDOException $exception) {
|
|
echo "Error creating tables: " . $exception->getMessage();
|
|
}
|
|
}
|
|
|
|
// Handle AJAX requests and form submissions
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$database = new Database();
|
|
$conn = $database->getConnection();
|
|
|
|
$action = $_POST['action'] ?? '';
|
|
|
|
try {
|
|
switch ($action) {
|
|
case 'add_group':
|
|
$groupName = trim($_POST['group_name']);
|
|
if (!empty($groupName)) {
|
|
$stmt = $conn->prepare("INSERT INTO groups (group_name) VALUES (?)");
|
|
$stmt->execute([$groupName]);
|
|
echo json_encode(['success' => true, 'message' => 'Group added successfully']);
|
|
} else {
|
|
echo json_encode(['success' => false, 'message' => 'Group name cannot be empty']);
|
|
}
|
|
exit;
|
|
|
|
case 'add_task':
|
|
$taskName = trim($_POST['task_name']);
|
|
$taskDesc = trim($_POST['task_description']);
|
|
$groupId = $_POST['group_id'];
|
|
|
|
if (!empty($taskName) && !empty($groupId)) {
|
|
$stmt = $conn->prepare("INSERT INTO tasks (task_name, task_description, group_id) VALUES (?, ?, ?)");
|
|
$stmt->execute([$taskName, $taskDesc, $groupId]);
|
|
echo json_encode(['success' => true, 'message' => 'Task added successfully']);
|
|
} else {
|
|
echo json_encode(['success' => false, 'message' => 'Task name and group are required']);
|
|
}
|
|
exit;
|
|
|
|
case 'toggle_task':
|
|
$taskId = $_POST['task_id'];
|
|
$isDone = $_POST['is_done'] === 'true' ? 'TRUE' : 'FALSE';
|
|
|
|
$stmt = $conn->prepare("UPDATE tasks SET is_done = $isDone WHERE task_id = ?");
|
|
$stmt->execute([$taskId]);
|
|
echo json_encode(['success' => true]);
|
|
exit;
|
|
|
|
case 'delete_task':
|
|
$taskId = $_POST['task_id'];
|
|
$stmt = $conn->prepare("DELETE FROM tasks WHERE task_id = ?");
|
|
$stmt->execute([$taskId]);
|
|
echo json_encode(['success' => true, 'message' => 'Task deleted successfully']);
|
|
exit;
|
|
|
|
case 'delete_group':
|
|
$groupId = $_POST['group_id'];
|
|
$stmt = $conn->prepare("DELETE FROM groups WHERE group_id = ?");
|
|
$stmt->execute([$groupId]);
|
|
echo json_encode(['success' => true, 'message' => 'Group and all associated tasks deleted successfully']);
|
|
exit;
|
|
|
|
case 'update_task':
|
|
$taskId = $_POST['task_id'];
|
|
$taskName = trim($_POST['task_name']);
|
|
$taskDesc = trim($_POST['task_description']);
|
|
$groupId = $_POST['group_id'];
|
|
|
|
if (!empty($taskName) && !empty($groupId)) {
|
|
$stmt = $conn->prepare("UPDATE tasks SET task_name = ?, task_description = ?, group_id = ? WHERE task_id = ?");
|
|
$stmt->execute([$taskName, $taskDesc, $groupId, $taskId]);
|
|
echo json_encode(['success' => true, 'message' => 'Task updated successfully']);
|
|
} else {
|
|
echo json_encode(['success' => false, 'message' => 'Task name and group are required']);
|
|
}
|
|
exit;
|
|
}
|
|
} catch(PDOException $exception) {
|
|
echo json_encode(['success' => false, 'message' => 'Database error: ' . $exception->getMessage()]);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Initialize database
|
|
initializeDatabase();
|
|
|
|
// Fetch data for display
|
|
$database = new Database();
|
|
$conn = $database->getConnection();
|
|
|
|
// Get all groups with their tasks
|
|
$query = "SELECT g.group_id, g.group_name,
|
|
t.task_id, t.task_name, t.task_description, t.is_done, t.created_at as task_created
|
|
FROM groups g
|
|
LEFT JOIN tasks t ON g.group_id = t.group_id
|
|
ORDER BY g.group_name, t.created_at DESC";
|
|
$stmt = $conn->prepare($query);
|
|
$stmt->execute();
|
|
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Organize data by groups
|
|
$groupsData = [];
|
|
foreach ($results as $row) {
|
|
$groupId = $row['group_id'];
|
|
if (!isset($groupsData[$groupId])) {
|
|
$groupsData[$groupId] = [
|
|
'group_id' => $row['group_id'],
|
|
'group_name' => $row['group_name'],
|
|
'tasks' => []
|
|
];
|
|
}
|
|
|
|
if ($row['task_id']) {
|
|
$groupsData[$groupId]['tasks'][] = [
|
|
'task_id' => $row['task_id'],
|
|
'task_name' => $row['task_name'],
|
|
'task_description' => $row['task_description'],
|
|
'is_done' => $row['is_done'],
|
|
'task_created' => $row['task_created']
|
|
];
|
|
}
|
|
}
|
|
|
|
// Get all groups for the dropdown
|
|
$stmt = $conn->prepare("SELECT group_id, group_name FROM groups ORDER BY group_name");
|
|
$stmt->execute();
|
|
$allGroups = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Advanced To-Do List Manager</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
|
|
background-size: 400% 400%;
|
|
animation: gradientShift 15s ease infinite;
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
@keyframes gradientShift {
|
|
0% { background-position: 0% 50%; }
|
|
50% { background-position: 100% 50%; }
|
|
100% { background-position: 0% 50%; }
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
background: rgba(255, 255, 255, 0.95);
|
|
backdrop-filter: blur(20px);
|
|
border-radius: 25px;
|
|
padding: 40px;
|
|
box-shadow:
|
|
0 25px 50px rgba(0, 0, 0, 0.15),
|
|
0 0 0 1px rgba(255, 255, 255, 0.1);
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
h1 {
|
|
text-align: center;
|
|
color: #1a202c;
|
|
margin-bottom: 40px;
|
|
font-size: 3rem;
|
|
font-weight: 800;
|
|
background: linear-gradient(135deg, #667eea, #764ba2, #f093fb, #f5576c);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
letter-spacing: -0.02em;
|
|
text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.forms-section {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 30px;
|
|
margin-bottom: 50px;
|
|
}
|
|
|
|
.form-card {
|
|
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
|
|
padding: 30px;
|
|
border-radius: 20px;
|
|
box-shadow:
|
|
0 10px 30px rgba(0, 0, 0, 0.1),
|
|
inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.form-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 4px;
|
|
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
|
|
background-size: 400% 100%;
|
|
animation: colorFlow 3s ease infinite;
|
|
}
|
|
|
|
@keyframes colorFlow {
|
|
0%, 100% { background-position: 0% 50%; }
|
|
50% { background-position: 100% 50%; }
|
|
}
|
|
|
|
.form-card h3 {
|
|
color: #2d3748;
|
|
margin-bottom: 25px;
|
|
font-size: 1.4rem;
|
|
font-weight: 700;
|
|
padding-bottom: 15px;
|
|
position: relative;
|
|
}
|
|
|
|
.form-card h3::after {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
width: 60px;
|
|
height: 3px;
|
|
background: linear-gradient(90deg, #667eea, #764ba2);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
font-weight: 600;
|
|
color: #4a5568;
|
|
font-size: 14px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
input[type="text"], textarea, select {
|
|
width: 100%;
|
|
padding: 16px 20px;
|
|
border: 2px solid #e2e8f0;
|
|
border-radius: 12px;
|
|
font-size: 16px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
background: #ffffff;
|
|
font-family: inherit;
|
|
}
|
|
|
|
input[type="text"]:focus, textarea:focus, select:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
box-shadow:
|
|
0 0 0 4px rgba(102, 126, 234, 0.1),
|
|
0 4px 12px rgba(102, 126, 234, 0.15);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
textarea {
|
|
resize: vertical;
|
|
min-height: 100px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.btn {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
padding: 16px 32px;
|
|
border-radius: 12px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.btn::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: -100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
|
transition: left 0.6s;
|
|
}
|
|
|
|
.btn:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 12px 25px rgba(102, 126, 234, 0.3);
|
|
}
|
|
|
|
.btn:hover::before {
|
|
left: 100%;
|
|
}
|
|
|
|
.btn-danger {
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
box-shadow: 0 12px 25px rgba(255, 107, 107, 0.3);
|
|
}
|
|
|
|
.btn-success {
|
|
background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
|
|
}
|
|
|
|
.btn-success:hover {
|
|
box-shadow: 0 12px 25px rgba(0, 184, 148, 0.3);
|
|
}
|
|
|
|
.groups-container {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
|
|
gap: 30px;
|
|
}
|
|
|
|
.group-card {
|
|
background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
|
|
border-radius: 20px;
|
|
box-shadow:
|
|
0 15px 35px rgba(0, 0, 0, 0.1),
|
|
0 5px 15px rgba(0, 0, 0, 0.08);
|
|
overflow: hidden;
|
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
position: relative;
|
|
}
|
|
|
|
.group-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 6px;
|
|
background: linear-gradient(90deg,
|
|
#ff6b6b 0%,
|
|
#4ecdc4 20%,
|
|
#45b7d1 40%,
|
|
#96ceb4 60%,
|
|
#feca57 80%,
|
|
#ff9ff3 100%);
|
|
}
|
|
|
|
.group-card:hover {
|
|
transform: translateY(-8px) scale(1.02);
|
|
box-shadow:
|
|
0 25px 50px rgba(0, 0, 0, 0.15),
|
|
0 10px 30px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.group-header {
|
|
background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
|
|
color: white;
|
|
padding: 25px 30px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
position: relative;
|
|
}
|
|
|
|
.group-header::before {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 1px;
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
|
}
|
|
|
|
.group-header h3 {
|
|
font-size: 1.4rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.delete-group-btn {
|
|
background: rgba(255, 107, 107, 0.2);
|
|
border: 2px solid rgba(255, 107, 107, 0.3);
|
|
color: #ff6b6b;
|
|
padding: 10px 16px;
|
|
border-radius: 10px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
backdrop-filter: blur(10px);
|
|
}
|
|
|
|
.delete-group-btn:hover {
|
|
background: rgba(255, 107, 107, 0.9);
|
|
color: white;
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.tasks-list {
|
|
padding: 25px;
|
|
max-height: 450px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.tasks-list::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
.tasks-list::-webkit-scrollbar-track {
|
|
background: #f1f5f9;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.tasks-list::-webkit-scrollbar-thumb {
|
|
background: linear-gradient(135deg, #667eea, #764ba2);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.task-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 20px;
|
|
margin-bottom: 16px;
|
|
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
|
|
border-radius: 15px;
|
|
border-left: 5px solid;
|
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.task-item:nth-child(1) { border-left-color: #ff6b6b; }
|
|
.task-item:nth-child(2) { border-left-color: #4ecdc4; }
|
|
.task-item:nth-child(3) { border-left-color: #45b7d1; }
|
|
.task-item:nth-child(4) { border-left-color: #96ceb4; }
|
|
.task-item:nth-child(5) { border-left-color: #feca57; }
|
|
.task-item:nth-child(6) { border-left-color: #ff9ff3; }
|
|
.task-item:nth-child(7) { border-left-color: #54a0ff; }
|
|
.task-item:nth-child(8) { border-left-color: #5f27cd; }
|
|
.task-item:nth-child(n+9) { border-left-color: #00d2d3; }
|
|
|
|
.task-item::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 100%);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.task-item:hover {
|
|
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
|
|
transform: translateX(8px) translateY(-2px);
|
|
box-shadow:
|
|
0 8px 25px rgba(0, 0, 0, 0.1),
|
|
0 4px 12px rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
.task-item.completed {
|
|
opacity: 0.6;
|
|
background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
|
|
}
|
|
|
|
.task-item.completed .task-content {
|
|
text-decoration: line-through;
|
|
}
|
|
|
|
.task-checkbox {
|
|
margin-right: 20px;
|
|
transform: scale(1.3);
|
|
cursor: pointer;
|
|
accent-color: #667eea;
|
|
}
|
|
|
|
.task-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.task-name {
|
|
font-weight: 700;
|
|
color: #2d3748;
|
|
margin-bottom: 8px;
|
|
font-size: 16px;
|
|
letter-spacing: 0.3px;
|
|
}
|
|
|
|
.task-description {
|
|
color: #718096;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.task-actions {
|
|
display: flex;
|
|
gap: 12px;
|
|
margin-left: 20px;
|
|
}
|
|
|
|
.task-actions button {
|
|
padding: 10px 16px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
border-radius: 10px;
|
|
border: none;
|
|
cursor: pointer;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.edit-btn {
|
|
background: linear-gradient(135deg, #feca57 0%, #ff9ff3 100%);
|
|
color: #2d3748;
|
|
}
|
|
|
|
.edit-btn:hover {
|
|
transform: scale(1.1);
|
|
box-shadow: 0 8px 20px rgba(254, 202, 87, 0.4);
|
|
}
|
|
|
|
.delete-btn {
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
|
|
color: white;
|
|
}
|
|
|
|
.delete-btn:hover {
|
|
transform: scale(1.1);
|
|
box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
|
|
}
|
|
|
|
.no-tasks {
|
|
text-align: center;
|
|
color: #a0aec0;
|
|
font-style: italic;
|
|
padding: 40px;
|
|
font-size: 16px;
|
|
background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
|
|
border-radius: 15px;
|
|
border: 2px dashed #cbd5e0;
|
|
}
|
|
|
|
.notification {
|
|
position: fixed;
|
|
top: 30px;
|
|
right: 30px;
|
|
padding: 20px 30px;
|
|
background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
|
|
color: white;
|
|
border-radius: 15px;
|
|
box-shadow:
|
|
0 10px 30px rgba(0, 184, 148, 0.3),
|
|
0 5px 15px rgba(0, 0, 0, 0.1);
|
|
transform: translateX(400px);
|
|
opacity: 0;
|
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
z-index: 1000;
|
|
font-weight: 600;
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
backdrop-filter: blur(10px);
|
|
}
|
|
|
|
.notification.show {
|
|
transform: translateX(0);
|
|
opacity: 1;
|
|
}
|
|
|
|
.notification.error {
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
|
|
box-shadow:
|
|
0 10px 30px rgba(255, 107, 107, 0.3),
|
|
0 5px 15px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.modal {
|
|
display: none;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: rgba(0, 0, 0, 0.6);
|
|
backdrop-filter: blur(5px);
|
|
z-index: 2000;
|
|
justify-content: center;
|
|
align-items: center;
|
|
animation: fadeIn 0.3s ease;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; }
|
|
to { opacity: 1; }
|
|
}
|
|
|
|
.modal-content {
|
|
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
|
|
padding: 40px;
|
|
border-radius: 20px;
|
|
width: 90%;
|
|
max-width: 500px;
|
|
box-shadow:
|
|
0 25px 50px rgba(0, 0, 0, 0.25),
|
|
0 10px 30px rgba(0, 0, 0, 0.15);
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.modal-content::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 4px;
|
|
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
|
|
}
|
|
|
|
.modal-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.modal-header h2 {
|
|
color: #2d3748;
|
|
font-weight: 700;
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
.close-btn {
|
|
background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
|
|
border: none;
|
|
font-size: 24px;
|
|
cursor: pointer;
|
|
color: #4a5568;
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.close-btn:hover {
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
|
|
color: white;
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
/* Colorful priority indicators */
|
|
.task-item[data-priority="high"]::before {
|
|
background: linear-gradient(135deg, rgba(255, 107, 107, 0.1) 0%, rgba(238, 90, 36, 0.1) 100%);
|
|
}
|
|
|
|
.task-item[data-priority="medium"]::before {
|
|
background: linear-gradient(135deg, rgba(254, 202, 87, 0.1) 0%, rgba(255, 159, 243, 0.1) 100%);
|
|
}
|
|
|
|
.task-item[data-priority="low"]::before {
|
|
background: linear-gradient(135deg, rgba(150, 206, 180, 0.1) 0%, rgba(78, 205, 196, 0.1) 100%);
|
|
}
|
|
|
|
/* Modern animations */
|
|
@keyframes pulse {
|
|
0%, 100% { opacity: 1; }
|
|
50% { opacity: 0.7; }
|
|
}
|
|
|
|
.loading {
|
|
animation: pulse 2s infinite;
|
|
}
|
|
|
|
/* Enhanced mobile responsiveness */
|
|
@media (max-width: 768px) {
|
|
.forms-section {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.groups-container {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.container {
|
|
padding: 25px;
|
|
margin: 10px;
|
|
border-radius: 20px;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 2.2rem;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.form-card, .modal-content {
|
|
padding: 25px;
|
|
}
|
|
|
|
.task-actions {
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.task-actions button {
|
|
padding: 8px 14px;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
|
|
/* Dark mode support */
|
|
@media (prefers-color-scheme: dark) {
|
|
.container {
|
|
background: rgba(26, 32, 44, 0.95);
|
|
color: #e2e8f0;
|
|
}
|
|
|
|
.form-card, .group-card, .modal-content {
|
|
background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
|
|
color: #e2e8f0;
|
|
}
|
|
|
|
.task-item {
|
|
background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
|
|
color: #e2e8f0;
|
|
}
|
|
|
|
.task-name {
|
|
color: #f7fafc;
|
|
}
|
|
|
|
.task-description {
|
|
color: #a0aec0;
|
|
}
|
|
|
|
input[type="text"], textarea, select {
|
|
background: #4a5568;
|
|
color: #e2e8f0;
|
|
border-color: #718096;
|
|
}
|
|
|
|
input[type="text"]:focus, textarea:focus, select:focus {
|
|
background: #2d3748;
|
|
}
|
|
}
|
|
|
|
/* Smooth transitions for everything */
|
|
* {
|
|
transition: color 0.3s ease, background-color 0.3s ease;
|
|
}
|
|
|
|
/* Fun hover effects for interactive elements */
|
|
.form-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow:
|
|
0 15px 40px rgba(0, 0, 0, 0.12),
|
|
inset 0 1px 0 rgba(255, 255, 255, 0.9);
|
|
}
|
|
|
|
/* Glassmorphism effect for modern look */
|
|
.container, .form-card, .group-card, .modal-content {
|
|
backdrop-filter: blur(20px);
|
|
-webkit-backdrop-filter: blur(20px);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🚀 Advanced To-Do List Manager</h1>
|
|
|
|
<div class="forms-section">
|
|
<!-- Add Group Form -->
|
|
<div class="form-card">
|
|
<h3>📁 Create New Group</h3>
|
|
<form id="addGroupForm">
|
|
<div class="form-group">
|
|
<label for="group_name">Group Name:</label>
|
|
<input type="text" id="group_name" name="group_name" required placeholder="Enter group name">
|
|
</div>
|
|
<button type="submit" class="btn">Add Group</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Add Task Form -->
|
|
<div class="form-card">
|
|
<h3>✅ Create New Task</h3>
|
|
<form id="addTaskForm">
|
|
<div class="form-group">
|
|
<label for="task_name">Task Name:</label>
|
|
<input type="text" id="task_name" name="task_name" required placeholder="Enter task name">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="task_description">Description (Optional):</label>
|
|
<textarea id="task_description" name="task_description" placeholder="Enter task description"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="group_id">Select Group:</label>
|
|
<select id="group_id" name="group_id" required>
|
|
<option value="">Choose a group</option>
|
|
<?php foreach ($allGroups as $group): ?>
|
|
<option value="<?= $group['group_id'] ?>"><?= htmlspecialchars($group['group_name']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn">Add Task</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Groups and Tasks Display -->
|
|
<div class="groups-container">
|
|
<?php if (empty($groupsData)): ?>
|
|
<div class="no-tasks">
|
|
<h3>No groups found</h3>
|
|
<p>Start by creating your first group!</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($groupsData as $group): ?>
|
|
<div class="group-card">
|
|
<div class="group-header">
|
|
<h3><?= htmlspecialchars($group['group_name']) ?></h3>
|
|
<button class="delete-group-btn" onclick="deleteGroup(<?= $group['group_id'] ?>)">
|
|
🗑️ Delete Group
|
|
</button>
|
|
</div>
|
|
<div class="tasks-list">
|
|
<?php if (empty($group['tasks'])): ?>
|
|
<div class="no-tasks">No tasks in this group yet</div>
|
|
<?php else: ?>
|
|
<?php foreach ($group['tasks'] as $task): ?>
|
|
<div class="task-item <?= $task['is_done'] === 't' ? 'completed' : '' ?>">
|
|
<input type="checkbox" class="task-checkbox"
|
|
<?= $task['is_done'] === 't' ? 'checked' : '' ?>
|
|
onchange="toggleTask(<?= $task['task_id'] ?>, this.checked)">
|
|
<div class="task-content">
|
|
<div class="task-name"><?= htmlspecialchars($task['task_name']) ?></div>
|
|
<?php if ($task['task_description']): ?>
|
|
<div class="task-description"><?= htmlspecialchars($task['task_description']) ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="task-actions">
|
|
<button class="edit-btn" onclick="editTask(<?= $task['task_id'] ?>, '<?= htmlspecialchars($task['task_name'], ENT_QUOTES) ?>', '<?= htmlspecialchars($task['task_description'], ENT_QUOTES) ?>', <?= $group['group_id'] ?>)">
|
|
Edit
|
|
</button>
|
|
<button class="delete-btn" onclick="deleteTask(<?= $task['task_id'] ?>)">
|
|
Delete
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Edit Task Modal -->
|
|
<div id="editModal" class="modal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h3>Edit Task</h3>
|
|
<button class="close-btn" onclick="closeEditModal()">×</button>
|
|
</div>
|
|
<form id="editTaskForm">
|
|
<input type="hidden" id="edit_task_id" name="task_id">
|
|
<div class="form-group">
|
|
<label for="edit_task_name">Task Name:</label>
|
|
<input type="text" id="edit_task_name" name="task_name" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="edit_task_description">Description:</label>
|
|
<textarea id="edit_task_description" name="task_description"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="edit_group_id">Group:</label>
|
|
<select id="edit_group_id" name="group_id" required>
|
|
<?php foreach ($allGroups as $group): ?>
|
|
<option value="<?= $group['group_id'] ?>"><?= htmlspecialchars($group['group_name']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<div style="display: flex; gap: 10px; justify-content: flex-end;">
|
|
<button type="button" class="btn btn-danger" onclick="closeEditModal()">Cancel</button>
|
|
<button type="submit" class="btn btn-success">Update Task</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Notification -->
|
|
<div id="notification" class="notification"></div>
|
|
|
|
<script>
|
|
// Show notification
|
|
function showNotification(message, isError = false) {
|
|
const notification = document.getElementById('notification');
|
|
notification.textContent = message;
|
|
notification.className = 'notification' + (isError ? ' error' : '');
|
|
notification.classList.add('show');
|
|
|
|
setTimeout(() => {
|
|
notification.classList.remove('show');
|
|
}, 3000);
|
|
}
|
|
|
|
// Add Group Form Handler
|
|
document.getElementById('addGroupForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData();
|
|
formData.append('action', 'add_group');
|
|
formData.append('group_name', document.getElementById('group_name').value);
|
|
|
|
try {
|
|
const response = await fetch('', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
showNotification(result.message);
|
|
document.getElementById('group_name').value = '';
|
|
setTimeout(() => location.reload(), 1000);
|
|
} else {
|
|
showNotification(result.message, true);
|
|
}
|
|
} catch (error) {
|
|
showNotification('Error adding group', true);
|
|
}
|
|
});
|
|
|
|
// Add Task Form Handler
|
|
document.getElementById('addTaskForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData();
|
|
formData.append('action', 'add_task');
|
|
formData.append('task_name', document.getElementById('task_name').value);
|
|
formData.append('task_description', document.getElementById('task_description').value);
|
|
formData.append('group_id', document.getElementById('group_id').value);
|
|
|
|
try {
|
|
const response = await fetch('', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
showNotification(result.message);
|
|
document.getElementById('addTaskForm').reset();
|
|
setTimeout(() => location.reload(), 1000);
|
|
} else {
|
|
showNotification(result.message, true);
|
|
}
|
|
} catch (error) {
|
|
showNotification('Error adding task', true);
|
|
}
|
|
});
|
|
|
|
// Toggle Task Status
|
|
async function toggleTask(taskId, isDone) {
|
|
const formData = new FormData();
|
|
formData.append('action', 'toggle_task');
|
|
formData.append('task_id', taskId);
|
|
formData.append('is_done', isDone);
|
|
|
|
try {
|
|
const response = await fetch('', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
location.reload();
|
|
}
|
|
} catch (error) {
|
|
showNotification('Error updating task status', true);
|
|
}
|
|
}
|
|
|
|
// Delete Task
|
|
async function deleteTask(taskId) {
|
|
if (!confirm('Are you sure you want to delete this task?')) return;
|
|
|
|
const formData = new FormData();
|
|
formData.append('action', 'delete_task');
|
|
formData.append('task_id', taskId);
|
|
|
|
try {
|
|
const response = await fetch('', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
showNotification(result.message);
|
|
setTimeout(() => location.reload(), 1000);
|
|
} else {
|
|
showNotification(result.message, true);
|
|
}
|
|
} catch (error) {
|
|
showNotification('Error deleting task', true);
|
|
}
|
|
}
|
|
|
|
// Delete Group
|
|
async function deleteGroup(groupId) {
|
|
if (!confirm('Are you sure you want to delete this group and all its tasks?')) return;
|
|
|
|
const formData = new FormData();
|
|
formData.append('action', 'delete_group');
|
|
formData.append('group_id', groupId);
|
|
|
|
try {
|
|
const response = await fetch('', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
showNotification(result.message);
|
|
setTimeout(() => location.reload(), 1000);
|
|
} else {
|
|
showNotification(result.message, true);
|
|
}
|
|
} catch (error) {
|
|
showNotification('Error deleting group', true);
|
|
}
|
|
}
|
|
|
|
// Edit Task Modal Functions
|
|
function editTask(taskId, taskName, taskDescription, groupId) {
|
|
document.getElementById('edit_task_id').value = taskId;
|
|
document.getElementById('edit_task_name').value = taskName;
|
|
document.getElementById('edit_task_description').value = taskDescription;
|
|
document.getElementById('edit_group_id').value = groupId;
|
|
document.getElementById('editModal').style.display = 'flex';
|
|
}
|
|
|
|
function closeEditModal() {
|
|
document.getElementById('editModal').style.display = 'none';
|
|
}
|
|
|
|
// Edit Task Form Handler
|
|
document.getElementById('editTaskForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData();
|
|
formData.append('action', 'update_task');
|
|
formData.append('task_id', document.getElementById('edit_task_id').value);
|
|
formData.append('task_name', document.getElementById('edit_task_name').value);
|
|
formData.append('task_description', document.getElementById('edit_task_description').value);
|
|
formData.append('group_id', document.getElementById('edit_group_id').value);
|
|
|
|
try {
|
|
const response = await fetch('', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
showNotification(result.message);
|
|
closeEditModal();
|
|
setTimeout(() => location.reload(), 1000);
|
|
} else {
|
|
showNotification(result.message, true);
|
|
}
|
|
} catch (error) {
|
|
showNotification('Error updating task', true);
|
|
}
|
|
});
|
|
|
|
// Close modal when clicking outside
|
|
window.addEventListener('click', function(e) {
|
|
const modal = document.getElementById('editModal');
|
|
if (e.target === modal) {
|
|
closeEditModal();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|