-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdisplay.php
89 lines (82 loc) · 3 KB
/
display.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
<?php
include("includes/header.php");
//This is where all the action happens. Most php files in TaskStep link here in some form or another, so best advice is DON'T CHANGE IT!
if (isset($_GET["cmd"]))
{
$id = $_GET["id"];
switch ($_GET["cmd"])
{
case "delete":
$sql = "DELETE FROM items WHERE id=$id";
$result = $mysqli->query($sql);
break;
case "do":
$sql = "UPDATE items SET done=1 WHERE id=$id";
$result = $mysqli->query($sql);
echo "<div id='updated' class='fade'><img src='images/accept.png' alt='' /> ".$l_msg_itemdo."</div>";
break;
case "undo":
$sql = "UPDATE items SET done=0 WHERE id=$id";
$result = $mysqli->query($sql);
echo "<div id='deleted' class='fade'><img src='images/undone.png' alt='' /> ".$l_msg_itemundo."</div>";
break;
default: //Error trap it so that if a dodgy command is given it doesn't drop dead
echo "<div class='error'><img src='images/exclamation.png' alt='' /> ".$l_msg_actionerror."</div>";
break;
}
}
//This is the sorting form, as promised
$display = (isset($_GET["display"])) ? $_GET["display"] : '';
$sortby = (isset($_GET["sort"])) ? $_GET["sort"] : 'date';
$section = (isset($_GET["section"])) ? $_GET["section"] : '';
$tid = (isset($_GET["tid"])) ? $_GET["tid"] : '';
switch ($display)
{
case "section":
//Massively cleaned up section which obtains section titles from the language file
foreach($l_sectionlist as $key=>$value){
if($section==$key){
$currentsection = $key;
$sectiontitle = $value;
}
}
$result = $mysqli->query("SELECT * FROM items WHERE section='$currentsection' ORDER BY $sortby");
echo "<div id='sectiontitle'><h1>$sectiontitle</h1></div>";
$noresultsurl = '?section=' . $section;
break;
case "project":
case "context":
$idresult = $mysqli->query("SELECT title FROM {$display}s WHERE id='$tid'");
$disptitle = $idresult->fetch_row()[0];
$result = $mysqli->query("SELECT * FROM items WHERE $display='$disptitle' ORDER BY $sortby");
echo "<div id='sectiontitle'><h1>$disptitle</h1></div>";
$noresultsurl = '?tid=' . $tid;
break;
case "all":
$result = $mysqli->query("SELECT * FROM items ORDER BY $sortby");
echo "<div id='sectiontitle'><h1>".$l_nav_allitems."</h1></div>";
$noresultsurl = '';
break;
case "today":
$today = date("Y-m-d");
$todayf = date($menu_date_format);
$result = $mysqli->query("SELECT * FROM items WHERE date='$today' ORDER BY $sortby");
echo "<div id='sectiontitle'><h1>".$l_nav_today.": $todayf</h1></div>";
$noresultsurl = '';
break;
}
$numberrows = $result->num_rows;
sort_form($display, $section, $tid, $sortby);
if ($numberrows == 0)
{
$message = ( $display == "today" ) ? $l_msg_notoday : $l_msg_noitems;
echo "<div class='inform'><img src='images/information.png' alt='' /> ".$message." <a href='edit.php$noresultsurl'>".$l_msg_addsome."</a></div>";
}
else display_items($display, $section, $tid, $sortby);
if(isset($_POST['submit'])) //If submit is hit
{
$section=$_POST['section'];
$sortby=$_POST['sort'];
}
include('includes/footer.php');
?>