-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.php
59 lines (51 loc) · 2 KB
/
task.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
<?php
/**
* tasks management
*/
require('./inc/config.php');
// Allowed ?
$user->checkAuthent();
$task = new Task;
$project = new Project;
// No $_POST or $_GET data -> display the list of tasks
if (!count($_POST) && !count($_GET)) {
$smarty->assign('arrTask', $task->get());
$smarty->display('task.tpl');
}
// else $_GET data -> edit or add a task
elseif (count($_GET)) {
// if no "add" in URL -> prefill the form
if (empty($_GET['add'])) {
$arrTask = $task->get($_GET['intTaskId'], true);
if (count($arrTask) == 0) {
displayMessage(STR_TASK_NOT_FOUND_SILLAJ);
}
$smarty->assign( 'booEdit', true); // to fill the fields
$smarty->assign_by_ref( 'intTaskId', $_GET['intTaskId']);
$smarty->assign_by_ref( 'strTask', $arrTask[$_GET['intTaskId']]['strTask']);
$smarty->assign_by_ref( 'strRem', $arrTask[$_GET['intTaskId']]['strRem']);
$smarty->assign_by_ref( 'booShare', $arrTask[$_GET['intTaskId']]['booShare']);
$smarty->assign_by_ref( 'booUseInReport', $arrTask[$_GET['intTaskId']]['booUseInReport']);
$smarty->assign('arrProjectSelected', $task->getProject($_GET['intTaskId']));
$smarty->assign( 'strPageTitle', $smarty->get_template_vars('strPageTitle') . STR_SEP_SILLAJ . $arrTask[$_GET['intTaskId']]['strTask']);
}
$smarty->assign('arrProject', $project->get());
$smarty->display('edit_task.tpl');
}
// else $_POST data -> validate the form
elseif (count($_POST)) {
if (!empty($_POST['booDelete'])) {
$smarty->assign('strMessage', $task->del());
}
else {
if (empty($_POST['booEdit'])) {
$smarty->assign('strMessage', $task->add());
}
else {
$smarty->assign('strMessage', $task->set());
}
}
$smarty->assign('arrTask', $task->get());
$smarty->display('task.tpl');
}
?>