This repository has been archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search-tasks.php
286 lines (234 loc) · 12.4 KB
/
search-tasks.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php
require("lib/bootstrap.php");
if ($auth->isLogedIn() && $users->isUser($session->get("userid"))) {
$term = $utilities->filter($_GET["s"]);
$allSearchedTasks = $searches->searchAllTasks($term, $session->get("account"));
$allActiveUserTasks = $tasks->listUserTasks($session->get("userid"), 1);
} else {
// user not loged
$utilities->redirect("error.php?code=12");
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?php echo APPLICATION_TITLE ?> - Search Results</title>
<!-- styles -->
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/fonts.css" />
<link rel="stylesheet" href="css/jquery.ui.custom.css" />
<link rel="stylesheet" href="css/jquery.ui.achtung.css" />
<link rel="stylesheet" href="css/jquery.tiptip.css" />
<link rel="stylesheet" href="css/style.css" />
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie8.css" />
<![endif]-->
<!--[if lte IE 7]>
<link rel="stylesheet" href="css/ie7.css" />
<![endif]-->
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<!-- scripts -->
<script src="js/jquery.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/jquery.ui.custom.js"></script>
<script src="js/jquery.stickypanel.js"></script>
<script src="js/jquery.ui.achtung.js"></script>
<script src="js/jquery.tiptip.js"></script>
<script src="js/jquery.tinysort.js"></script>
<script src="js/jquery.highlight.js"></script>
<script src="js/script.js"></script>
<!-- remove for production -->
<script src="js/cssrefresh.js"></script>
<!-- javascript -->
<script>
$(document).ready(function() {
<?php
$utilities->notify($notice, 7);
?>
$("#by-title").click(function() {
$("ul.listing > li").tsort('',{attr:'data-title'});
$(".tip").removeClass("sorted");
$(this).addClass("sorted");
return false;
});
$("#by-date").click(function() {
$("ul.listing > li").tsort('',{attr:'data-expire'});
$(".tip").removeClass("sorted");
$(this).addClass("sorted");
return false;
});
$("#by-project").click(function() {
$("ul.listing > li").tsort('',{attr:'data-project'});
$(".tip").removeClass("sorted");
$(this).addClass("sorted");
return false;
});
$("ul.listing > li").click(function() {
window.location.href="task.php?pid="+$(this).attr("data-projectid")+"&tid="+$(this).attr("data-id");
});
$('.listing').highlight('<?php echo $term;?>');
$("#search-field").autocomplete({
source: "lib/api/get-my-tasks.php",
minLength: 3,
select: function(event, ui) {
window.location.href = ui.item.id;
}
});
});
</script>
</head>
<body>
<!-- wrap -->
<div id="wrap">
<!-- header -->
<header>
<!-- search -->
<div id="search-bar">
<form id="search-form" action="search-tasks.php" method="get">
<fieldset>
<input name="s" type="text" id="search-field" class="text-input rounded" placeholder="Search tasks" required></input>
<a class="blue-button default-button tip" id="search-button" role="button" href="#" title="Search open tasks"></a>
<a class="blue-button default-button tip" id="close-button" role="button" href="#" title="Close search panel"></a>
</fieldset>
</form>
</div>
<!-- /search -->
<?php if (defined("SHORTCUTS") && SHORTCUTS) { ?>
<!-- breadcrumbs -->
<div class="breadcrumbs">
<a class="tip" href="home.php" title="Home: Select project"><img src="images/home.png"></a>
<?php
if ($users->isOwner($session->get("userid"))) {
?>
<a class="separator"><img src="images/separator.png"></a>
<a class="tip" href="all-projects.php" title="All Projects"><img src="images/all-projects.png"></a>
<a class="tip" href="#" title="All Tasks"><img src="images/all-tasks.png"></a>
<a class="tip" href="all-users.php" title="All Users"><img src="images/all-users.png"></a>
<?php } ?>
<a class="separator"><img src="images/separator.png"></a>
<a class="tip" href="#" id="search-trigger" title="Search"><img src="images/search.png"></a>
</div>
<!-- /breadcrumbs -->
<?php } ?>
<!-- welcome message -->
<div id="welcome-message">
<p>Welcome to <?php echo APPLICATION_TITLE ?> <span class="orange"><?php echo $session->get("firstname"); ?></span></p>
</div>
<!-- /welcome message -->
<!-- top panel -->
<div id="top-panel">
<!-- settings -->
<div id="settings">
<ul id="settings-menu">
<li><a class="tip" href="my-tasks.php" role="link" title="List my tasks"><img src="images/all-tasks-gray.png">My Tasks</a></li>
<li><a class="tip" href="my-projects.php" role="link" title="List my projects"><img src="images/all-projects-gray.png">My Projects</a></li>
<?php
if ($users->isAdmin($session->get("userid"))) {
?>
<li><a class="tip" href="all-users.php" role="link" title="List all users"><img src="images/all-users-gray.png">Users</a></li>
<?php } ?>
<li><a class="tip" href="my-account.php" role="link" title="My account details"><img src="images/user-gray.png">My Account</a></li>
<li><a class="tip" href="index.php?action=logout" role="link" title="Logout"><img src="images/logout-gray.png">Logout</a></li>
</ul>
<a id="settings-button" class="tip" href="#" role="link" title="Your settings"><img src="images/settings.png"></a>
</div>
<!-- /settings -->
</div>
<!-- /top panel -->
<div id="header-title">
<h1>SEARCH RESULTS</h1>
</div>
<!-- loader -->
<div id="loader">
<img src="images/loading.gif" alt="Loading page" />
</div>
<!-- /loader -->
</header>
<!-- /header -->
<!-- main wrapper -->
<section id="main-wrapper">
<!-- main content -->
<div id="main-content" class="project-tasks clearer">
<!-- project description -->
<article id="project-description">
<p>Search results for: <strong><?php echo $term;?></strong></p>
</article>
<!-- /project description -->
<!-- project tasks -->
<article id="project-tasks">
<div class="sortable">
<!-- task header -->
<div class="task-header">
<div class="task-title">
<p><a class="tip" id="by-title" href="#" title="Sort by task name">Tasks</a></p>
</div>
<div class="task-date">
<p><a class="tip sorted" id="by-date" href="#" title="Sort by task expiration date">Due</a></p>
</div>
<div class="task-user">
<p><a class="tip" id="by-project" href="#" title="Sort by project name">Project</a></p>
</div>
</div>
<!-- /task header -->
<ul class="listing">
<?php
$index = 0;
for ($i=0; $i < count($allSearchedTasks); $i++) {
?>
<?php
$activeTasksProject = $projects->getProject($allSearchedTasks[$i]["project"]);
if ($projects->isProjectOpen($activeTasksProject[0]["id"]) && $roles->canViewProject($activeTasksProject[0]["id"], $session->get("userid"))) {
?>
<?php
if (!$tasks->isTaskPrivate($allSearchedTasks[$i]["project"], $allSearchedTasks[$i]["id"]) || ($tasks->isTaskPrivate($allSearchedTasks[$i]["project"], $allSearchedTasks[$i]["id"]) && !$roles->isProjectClient($allSearchedTasks[$i]["project"], $session->get("userid"))) || $tasks->isTaskMine($allSearchedTasks[$i]["project"], $allSearchedTasks[$i]["id"], $session->get("userid"))) {
?>
<li data-id="<?php echo $allSearchedTasks[$i]["id"]; ?>" data-expire="<?php echo $allSearchedTasks[$i]["expire"]; ?>" data-created="<?php echo $allSearchedTasks[$i]["created"]; ?>" data-assigned="<?php echo $users->getShortUserName($tasks->getAssignedTaskUser($activeTasksProject[0]["id"], $allSearchedTasks[$i]["id"])); ?>" data-title="<?php echo $allSearchedTasks[$i]["title"]; ?>" data-project="<?php echo $projects->getProjectTitle($activeTasksProject[0]["id"]);?>" data-projectid="<?php echo $projects->getProjectId($activeTasksProject[0]["id"]);?>">
<!-- task -->
<div class="task task-bg <?php if ($tasks->isTaskHasPriority($allSearchedTasks[$i]["project"], $allSearchedTasks[$i]["id"])) { echo 'high'; } ?> <?php echo $utilities->setColorClass($allSearchedTasks[$i]["expire"]); ?> <?php if ($tasks->isTaskPrivate($allSearchedTasks[$i]["project"], $allSearchedTasks[$i]["id"])) { echo 'private'; } ?>">
<div class="task-title <?php if($tasks->isTaskExpired($allSearchedTasks[$i]["project"], $allSearchedTasks[$i]["id"])){ echo'striked';} ?>">
<p><a class="tip" href="task.php?tid=<?php echo $allSearchedTasks[$i]["id"]; ?>&pid=<?php echo $allSearchedTasks[$i]["project"]; ?>" role="link" title="<?php echo strip_tags($allSearchedTasks[$i]["description"]); ?>"><?php echo $allSearchedTasks[$i]["title"]; ?></a></p>
</div>
<div class="task-date">
<p><a class="tip" href="#" role="link" title="Due: <?php echo $utilities->formatRemainingDate($allSearchedTasks[$i]["expire"], SHORT_DATE_FORMAT); ?>"><?php echo $utilities->formatDate($allSearchedTasks[$i]["expire"], SHORT_DATE_FORMAT); ?></a></p>
</div>
<div class="task-user task-project">
<p><a class="tip" href="project.php?pid=<?php echo $allSearchedTasks[$i]["project"]; ?>" role="link" title="<?php echo strip_tags($activeTasksProject[0]["description"]); ?>"><?php echo $activeTasksProject[0]["title"]; ?></a></p>
</div>
</div>
<!-- /task -->
</li>
<?php $index++; ?>
<?php } ?>
<?php } ?>
<?php } ?>
</ul>
<?php if($index == 0) {?>
<!-- results has no tasks -->
<div id="add-first-task" style="margin-bottom: 20px;">
<a class="blue-button default-button shadow tip" role="button" href="#" title="" onClick="return false;">No results for <?php echo $term;?></a>
</div>
<!-- /results has no tasks -->
<?php } ?>
</div>
</article>
<!-- project tasks -->
</div>
<!-- /main content -->
</section>
<!-- /main wrapper -->
<!-- footer -->
<footer>
<!-- logo -->
<div id="logo">
<img class="ng-logo" src="images/logo.png" alt="<?php echo APPLICATION_TITLE ?> logo" />
</div>
<!-- /logo -->
</footer>
<!-- /footer -->
</div>
<!-- /wrap -->
</body>
</html>