-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletetask.php
131 lines (114 loc) · 5.17 KB
/
deletetask.php
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
<?php
require "./config.php";
require "./common.php";
/*
if (isset($_POST['submit'])) {
try {
$connection = new PDO($dsn, $username, $password, $options);
$id = $_POST['id'];
$sql = "DELETE FROM tasks WHERE id = :id";
echo $sql . "<p>";
$statement = $connection->prepare($sql);
$statement->bindValue(':id', $id);
$statement->execute();
} catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
}
*/
if (isset($_GET['id'])) {
try {
$connection = new PDO($dsn, $username, $password, $options);
$id = $_GET['id'];
$sql = "SELECT * FROM tasks WHERE id = :id";
$statement = $connection->prepare($sql);
$statement->bindValue(':id', $id);
$statement->execute();
$task = $statement->fetch(PDO::FETCH_ASSOC);
} catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
}
?>
<?php require("./templates/header.php"); ?>
<div class="container">
<?php require("./templates/nav.php"); ?>
<?php
if ($statement->rowCount() != 0) { ?>
<div class="card border-primary" style="width: 50%">
<div class="card-header">
<div class="row">
<div class="col-sm">
Due By:
<?php if ($task["dueDate"] != '') {
echo date('n/j/Y',strtotime($task["dueDate"]));
} else {
echo "Not specified";
} ?> <!-- else -->
</div>
<div class="col-sm">
<?php
switch($task["priority"]) {
case 'Normal': ?>
<span class="badge float-right badge-warning">Priority: Normal</span> <?php
break;
case 'High': ?>
<span class="badge float-right badge-danger">Priority: High</span> <?php
break;
case 'Low': ?>
<span class="badge float-right badge-success">Priority: Low</span> <?php
break;
} ?>
</div>
</div> <!-- Row #1 -->
</div> <!-- Header -->
<div class="card-body">
<h5 class ="card-title"><?php echo $task["summary"]; ?></h5>
<p class="card-text"><?php echo $task["details"]; ?></p>
</div> <!-- Body -->
<div class="card card-footer">
<div class = "row">
<div class = "col-sm">
<?php if ($task["isComplete"] == 'false') { ?>
<h4><span class="badge badge-secondary">Incomplete</span></h4>
<?php } else { ?>
<h4><span class="badge badge-secondary">Complete</span></h4>
<?php } ?>
</div>
<div class = "col-sm">
<ul class="nav justify-content-end nav-pills card-header-pills">
<?php if ($task["isComplete"] == 'false') { ?>
<li class="nav-item">
<a class="nav-link"> <i class="fas fa-edit"></i></a>
</li>
<?php } ?>
<li class="nav-item">
<a class="nav-link"> <i class="fas fa-trash-alt"></i></a>
</li>
<li class="nav-item">
<?php if ($task["isComplete"] == 'false') { ?>
<a class="nav-link"> <i class="fas fa-check"></i></a>
<?php } else { ?>
<a class="nav-link"> <i class="fas fa-redo-alt"></i></a>
<?php } ?>
</li>
</ul>
</div>
</div>
</div>
</div> <!-- Card -->
<p>
<div class ="row" style="width: 53%">
<div class="col-sm">
<form method="post" action="/performdelete.php?id=<?php echo $id ?>">
<input type="submit" name="submit" class="btn btn-danger" value="Delete Task">
</form>
</div>
<div class="col-sm">
<a class="btn btn-primary float-right" href="/" role="button">Cancel</a>
</div>
</div>
<?php } else {
echo "<h4>Error: No records returned</h4>";
} ?>
</div> <!-- container -->