-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.php
More file actions
87 lines (73 loc) · 1.41 KB
/
todo.php
File metadata and controls
87 lines (73 loc) · 1.41 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
<?php
/* 'title' => 'Laundry',
'priority' => 2,
'due' => '',
'complete' => true,
];
$list[] = [
'title' => 'Clean out refrigerator',
'priority' => 3,
'due' => '09/16/2016',
'complete' => false,
];
*/
include 'list.php';
$status = 'all';
$field = 'priority';
$action = 'week';
$order = array();
if ($status == 'all') {
$order = array_keys($list);
} else {
foreach ($list as $key => $item) {
if ($item['complete'] == $status) {
$order[] = $key;
}
}
}
switch ($action) {
case 'sort':
if ($field) {
$sort = array();
foreach ($order as $id) {
$sort[$id] = $list[$id][$field];
}
asort($sort);
$order = array_keys($sort);
}
break;
case 'week':
foreach ($order as $key => value) {
if (strtotime($list[$value]['due']) > strtotime("+1 week")) || !$list[$value]['due']) {
unset($order[$key]);
}
}
break;
}
//var_dump($sort);
//var_dump($list);
echo '<table>';
echo '<tr>';
echo '<th>Title</th>';
echo '<th>Priority</th>';
echo '<th>Due Date</th>';
echo '<th>Complete</th>';
echo '</tr>';
foreach ($order as $id) {
echo '<tr>';
echo '<td>' . $list[$id]['title'] . "</td>\n";
echo '<td>' . $list[$id]['priority'] . "</td>\n";
echo '<td>' . $list[$id]['due'] . "</td>\n";
echo '<td>';
if ($list[$id]['complete']) {
echo 'Yes';
} else {
echo 'No';
}
echo "</td>\n";
echo '</tr>';
}
echo '</table';
//var_dump($list);
//echo $list[0]['title'];
?>