-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.php
More file actions
59 lines (50 loc) · 1.87 KB
/
task.php
File metadata and controls
59 lines (50 loc) · 1.87 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
/* Файл: task.php (Управление задачей) */
<?php
session_start();
require 'config/db.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
if (!isset($_GET['id'])) {
die("Ошибка: задача не найдена.");
}
$task_id = $_GET['id'];
// Получение информации о задаче
$stmt = $pdo->prepare("SELECT * FROM tasks WHERE id = ?");
$stmt->execute([$task_id]);
$task = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$task) {
die("Ошибка: задача не найдена.");
}
// Обновление статуса задачи
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$new_status = $_POST['status'];
$stmt = $pdo->prepare("UPDATE tasks SET status = ? WHERE id = ?");
$stmt->execute([$new_status, $task_id]);
header("Location: project.php?id=" . $task['project_id']);
exit();
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title><?php echo htmlspecialchars($task['title']); ?></title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<h1><?php echo htmlspecialchars($task['title']); ?></h1>
<p>Статус: <?php echo htmlspecialchars($task['status']); ?></p>
<h3>Обновить статус</h3>
<form method="post">
<select name="status">
<option value="todo" <?php if ($task['status'] == 'todo') echo 'selected'; ?>>В планах</option>
<option value="in_progress" <?php if ($task['status'] == 'in_progress') echo 'selected'; ?>>В процессе</option>
<option value="done" <?php if ($task['status'] == 'done') echo 'selected'; ?>>Выполнено</option>
</select>
<button type="submit">Обновить</button>
</form>
<a href="project.php?id=<?php echo $task['project_id']; ?>">Назад к проекту</a>
</body>
</html>