![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: todo.php 156 2008-04-11 15:47:40Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/tasks/todo.php $ */ 2 global $showEditCheckbox, $this_day, $other_users, $w2Pconfig, $user_id; 3 4 if (!defined('W2P_BASE_DIR')) { 5 die('You should not access this file directly.'); 6 } 7 8 $showEditCheckbox = w2PgetConfig('direct_edit_assignment'); 9 // Project status from sysval, defined as a constant 10 $project_on_hold_status = 4; 11 $perms = &$AppUI->acl(); 12 13 if (isset($_GET['tab'])) { 14 $AppUI->setState('ToDoTab', w2PgetParam($_GET, 'tab', null)); 15 } 16 $tab = $AppUI->getState('ToDoTab') !== null ? $AppUI->getState('ToDoTab') : 0; 17 18 if (isset($_POST['task_type'])) { 19 $AppUI->setState('ToDoTaskType', w2PgetParam($_POST, 'task_type', '')); 20 } 21 global $task_type; 22 $task_type = $AppUI->getState('ToDoTaskType') !== null ? $AppUI->getState('ToDoTaskType') : ''; 23 24 $project_id = intval(w2PgetParam($_GET, 'project_id', 0)); 25 $date = (!w2PgetParam($_GET, 'date', '') == '') ? $this_day->format(FMT_TIMESTAMP_DATE) : intval(w2PgetParam($_GET, 'date', '')); 26 $user_id = $AppUI->user_id; 27 $no_modify = false; 28 $other_users = false; 29 30 if ($perms->checkModule('admin', 'view')) { // let's see if the user has sysadmin access 31 $other_users = true; 32 if (($show_uid = w2PgetParam($_REQUEST, 'show_user_todo', 0)) != 0) { // lets see if the user wants to see anothers user mytodo 33 $user_id = $show_uid; 34 $no_modify = true; 35 $AppUI->setState('tasks_todo_user_id', $user_id); 36 } elseif ($AppUI->getState('tasks_todo_user_id')) { 37 $user_id = $AppUI->getState('tasks_todo_user_id'); 38 } 39 } 40 41 // check permissions 42 $canEdit = $perms->checkModule($m, 'edit'); 43 44 // retrieve any state parameters 45 if (isset($_POST['show_form'])) { 46 $AppUI->setState('TaskDayShowArc', w2PgetParam($_POST, 'show_arc_proj', 0)); 47 $AppUI->setState('TaskDayShowLow', w2PgetParam($_POST, 'show_low_task', 0)); 48 $AppUI->setState('TaskDayShowHold', w2PgetParam($_POST, 'show_hold_proj', 0)); 49 $AppUI->setState('TaskDayShowDyn', w2PgetParam($_POST, 'show_dyn_task', 0)); 50 $AppUI->setState('TaskDayShowPin', w2PgetParam($_POST, 'show_pinned', 0)); 51 $AppUI->setState('TaskDayShowEmptyDate', w2PgetParam($_POST, 'show_empty_date', 0)); 52 53 } 54 // Required for today view. 55 global $showArcProjs, $showLowTasks, $showHoldProjs, $showDynTasks, $showPinned, $showEmptyDate; 56 57 $showArcProjs = $AppUI->getState('TaskDayShowArc', 0); 58 $showLowTasks = $AppUI->getState('TaskDayShowLow', 1); 59 $showHoldProjs = $AppUI->getState('TaskDayShowHold', 0); 60 $showDynTasks = $AppUI->getState('TaskDayShowDyn', 0); 61 $showPinned = $AppUI->getState('TaskDayShowPin', 0); 62 $showEmptyDate = $AppUI->getState('TaskDayShowEmptyDate', 0); 63 64 global $task_sort_item1, $task_sort_type1, $task_sort_order1; 65 global $task_sort_item2, $task_sort_type2, $task_sort_order2; 66 $task_sort_item1 = w2PgetParam($_GET, 'task_sort_item1', ''); 67 $task_sort_type1 = w2PgetParam($_GET, 'task_sort_type1', ''); 68 $task_sort_item2 = w2PgetParam($_GET, 'task_sort_item2', ''); 69 $task_sort_type2 = w2PgetParam($_GET, 'task_sort_type2', ''); 70 $task_sort_order1 = intval(w2PgetParam($_GET, 'task_sort_order1', 0)); 71 $task_sort_order2 = intval(w2PgetParam($_GET, 'task_sort_order2', 0)); 72 73 // if task priority set and items selected, do some work 74 $task_priority = w2PgetParam($_POST, 'task_priority', 99); 75 $selected = w2PgetParam($_POST, 'selected_task', 0); 76 77 if (is_array($selected) && count($selected)) { 78 foreach ($selected as $key => $val) { 79 if ($task_priority == 'c') { 80 // mark task as completed 81 $q = new DBQuery; 82 $q->addTable('tasks'); 83 $q->addUpdate('task_percent_complete', '100'); 84 $q->addWhere('task_id=' . (int)$val); 85 } else 86 if ($task_priority == 'd') { 87 // delete task 88 $q = new DBQuery; 89 $q->setDelete('tasks'); 90 $q->addWhere('task_id=' . (int)$val); 91 } else 92 if ($task_priority > -2 && $task_priority < 2) { 93 // set priority 94 $q = new DBQuery; 95 $q->addTable('tasks'); 96 $q->addUpdate('task_priority', $task_priority); 97 $q->addWhere('task_id=' . (int)$val); 98 } 99 $q->exec(); 100 echo db_error(); 101 $q->clear(); 102 } 103 } 104 105 $AppUI->savePlace(); 106 107 $proj = &new CProject; 108 $tobj = &new CTask; 109 110 $allowedProjects = $proj->getAllowedSQL($AppUI->user_id,'pr.project_id'); 111 $allowedTasks = $tobj->getAllowedSQL($AppUI->user_id, 'ta.task_id'); 112 113 // query my sub-tasks (ignoring task parents) 114 115 $q = new DBQuery; 116 $q->addQuery('ta.*'); 117 $q->addQuery('project_name, pr.project_id, project_color_identifier'); 118 $q->addQuery('tp.task_pinned'); 119 $q->addTable('projects', 'pr'); 120 $q->addTable('tasks', 'ta'); 121 $q->addTable('user_tasks', 'ut'); 122 $q->leftJoin('user_task_pin', 'tp', 'tp.task_id = ta.task_id and tp.user_id = ' . (int)$user_id); 123 $q->leftJoin('project_departments', 'project_departments', 'pr.project_id = project_departments.project_id OR project_departments.project_id IS NULL'); 124 $q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL'); 125 126 $q->addWhere('ut.task_id = ta.task_id'); 127 $q->addWhere('ut.user_id = ' . (int)$user_id); 128 $q->addWhere('( ta.task_percent_complete < 100 or ta.task_percent_complete is null)'); 129 $q->addWhere('ta.task_status = 0'); 130 $q->addWhere('pr.project_id = ta.task_project'); 131 if (!$showArcProjs) { 132 $q->addWhere('project_active = 1'); 133 if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { 134 $q->addWhere('project_status <> ' . (int)$template_status); 135 } 136 } 137 if (!$showLowTasks) { 138 $q->addWhere('task_priority >= 0'); 139 } 140 if (!$showHoldProjs) { 141 $q->addWhere('project_status <> ' . (int)$project_on_hold_status); 142 } 143 if (!$showDynTasks) { 144 $q->addWhere('task_dynamic <> 1'); 145 } 146 if ($showPinned) { 147 $q->addWhere('task_pinned = 1'); 148 } 149 if (!$showEmptyDate) { 150 $q->addWhere('ta.task_start_date <> \'\' AND ta.task_start_date <> \'0000-00-00 00:00:00\''); 151 } 152 if ($task_type != '') { 153 $q->addWhere('ta.task_type = ' . (int)$task_type); 154 } 155 156 if (count($allowedTasks)) { 157 $q->addWhere($allowedTasks); 158 } 159 160 if (count($allowedProjects)) { 161 $q->addWhere($allowedProjects); 162 } 163 164 $q->addGroup('ta.task_id'); 165 $q->addOrder('ta.task_end_date'); 166 $q->addOrder('task_priority DESC'); 167 168 //echo "<pre>$sql</pre>"; 169 global $tasks; 170 $tasks = $q->loadList(); 171 $q->clear(); 172 173 /* we have to calculate the end_date via start_date+duration for 174 ** end='0000-00-00 00:00:00' 175 */ 176 for ($j = 0, $j_cmp = count($tasks); $j < $j_cmp; $j++) { 177 178 if ($tasks[$j]['task_end_date'] == '0000-00-00 00:00:00' || $tasks[$j]['task_end_date'] == '') { 179 if ($tasks[$j]['task_start_date'] == '0000-00-00 00:00:00' || $tasks[$j]['task_start_date'] == '') { 180 $tasks[$j]['task_start_date'] = '0000-00-00 00:00:00'; //just to be sure start date is "zeroed" 181 $tasks[$j]['task_end_date'] = '0000-00-00 00:00:00'; 182 } else { 183 $tasks[$j]['task_end_date'] = calcEndByStartAndDuration($tasks[$j]); 184 } 185 } 186 } 187 188 global $priorities; 189 $priorities = array('1' => 'high', '0' => 'normal', '-1' => 'low'); 190 191 global $durnTypes; 192 $durnTypes = w2PgetSysVal('TaskDurationType'); 193 194 if (!$min_view) { 195 $titleBlock = new CTitleBlock('My Tasks To Do', 'applet-48.png', $m, $m . '.' . $a); 196 $titleBlock->addCrumb('?m=tasks', 'tasks list'); 197 $titleBlock->show(); 198 } 199 200 // If we are called from anywhere but directly, we would end up with 201 // double rows of tabs that would not work correctly, and since we 202 // are called from the day view of calendar, we need to prevent this 203 if ($m == 'tasks' && $a == 'todo') { 204 ?> 205 206 207 <table cellspacing="0" cellpadding="2" border="0" width="100%" class="std"> 208 <tr> 209 <td width="80%" valign="top"> 210 <?php 211 // Tabbed information boxes 212 $tabBox = new CTabBox('?m=tasks&a=todo', W2P_BASE_DIR . '/modules/', $tab); 213 $tabBox->add('tasks/todo_tasks_sub', 'My Tasks'); 214 $tabBox->add('tasks/todo_gantt_sub', 'My Gantt'); 215 // Wouldn't it be better to user $tabBox->loadExtras('tasks', 'todo'); and then 216 // add tasks_tab.todo.my_open_requests.php in helpdesk? 217 if ($AppUI->isActiveModule('helpdesk')) { 218 $tabBox->add('helpdesk/vw_idx_my', 'My Open Requests'); 219 } 220 $tabBox->show(); 221 ?> 222 </td> 223 </tr> 224 </table> 225 <?php 226 } else { 227 include W2P_BASE_DIR . '/modules/tasks/todo_tasks_sub.php'; 228 } 229 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 03:00:03 2009 | Cross-referenced by PHPXref 0.7 |