-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
169 lines (149 loc) · 5.79 KB
/
home.php
File metadata and controls
169 lines (149 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
session_start();
include("connection.php");
include("functions.php");
$user_data = check_login($pdo);
// Check if the form is submitted to add a new task
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['taskName'], $_POST['taskCategory'], $_POST['description'], $_POST['taskTime'], $_POST['taskDate'])) {
$userQuery = "SELECT userid FROM Users WHERE username = '{$user_data['username']}'";
// Proceed with the insert
$sql = "INSERT INTO Tasks (UserID, Title, GroupID, Description, Timing, Date) VALUES (:value1, :value2, :value3, :value4, :value5, :value6)";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':value1', $user_data['userid']);
$stmt->bindValue(':value2', $_POST['taskName']);
$stmt->bindValue(':value3', $_POST['taskCategory']);
$stmt->bindValue(':value4', $_POST['description']);
$stmt->bindValue(':value5', $_POST['taskTime']);
$stmt->bindValue(':value6', $_POST['taskDate']);
$stmt->execute();
// Display a success message using JavaScript alert
echo "<script>alert('Task Added Successfully!');</script>";
}
// Check if the "Mark as Complete" button is clicked
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['taskID'])) {
include("updateTask.php");
updateTaskCompletion($pdo, $_POST['taskID']);
}
// Fetch tasks for the current day with completion status 'f'
$sql = "SELECT * FROM Tasks WHERE Date = CURRENT_DATE AND CompletionStatus = 'f' AND UserID = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$user_data['userid']]);
$tasks = $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>To-Do List Manager</title>
<link rel="stylesheet" href="homecss.css">
<link rel="icon" href="images/favicon.jpg" type="image/jpg">
<style>
body {
background: url('images/background6.jpg');
background-position: center;
background-size: cover;
color: white;
height:170px;
}
h2 {
color: white;
}
p {
font-size: 16px;
}
.add-task-form{
color:white;
}
label,
span {
color:black;
}
.task-box-center {
border:1px solid white;
width:20%;
margin:auto;
margin-top:10px;
display:flex;
justify-content:center;
align-items:center;
flex-direction:column;
}
.task-box-center h2,
.task-box-center p,
.task-box-center button {
margin-top:10px;
}
</style>
</head>
<body>
<div>
<button type="button" onclick="redirectToSignUp()" class="logout">LogOut</button>
</div>
<div class="profileimg">
<img src="<?php echo $user_data['image'];?>" alt="Profile" class="profile-photo">
<h2>Welcome <?php echo $user_data['username']; ?> !</h2>
</div>
<div class="todays-task">
<div class="runmsg">
<p><b>Today's Task</b></p>
</div>
</div>
<br>
<br>
<div class="buttons">
<button type="button" onclick="openAddEventsPopup()">Add Events</button>
</div>
<br>
<br>
<!-- Popup -->
<div id="popup">
<span class="close-btn" onclick="closePopup()">X</span>
<form method='post'>
<div class="add-task-form">
<label for="taskName">Task Name:</label>
<input type="text" id="taskName" name="taskName" required>
<label for="taskCategory">Task Category:</label>
<select id="taskCategory" name="taskCategory" required>
<option value="1">Study</option>
<option value="2">Work</option>
<option value="3">Personal</option>
<!-- Add more options as needed -->
</select>
<label for="description">Description</label>
<textarea type="text" name='description'></textarea>
<label for="taskDate">Date of the Task:</label>
<input type="date" id="taskDate" name="taskDate" required>
<label for="taskTime">Time of the Task:</label>
<input type="time" id="taskTime" name="taskTime" required>
<label for="priorityLevel">Priority Level:</label>
<select id="priorityLevel" name="priorityLevel" required>
<option value="high">High</option>
<option value="medium">Medium</option>
<option value="low">Low</option>
</select>
<button type="submit">+ ADD TASK</button>
</div>
</form>
</div>
<!-- Display tasks for today with completion status 'f' -->
<?php foreach ($tasks as $task): ?>
<div class="task-box-center">
<h2><?= $task['title'] ?></h2>
<p><?= $task['description'] ?></p>
<form method="post" action="">
<input type="hidden" name="taskID" value="<?= $task['taskid'] ?>">
<button type="submit">Mark as Complete</button>
</form>
</div>
<?php endforeach; ?>
<!-- Monthly Calendar -->
</div>
<div class="buttons">
<button type="button" onclick="redirectToAllEvents()">View Calendar</button>
<button type="button" onclick="redirectToDays()">View Tasks of this week</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="homejs.js"></script>
</body>
</html>