//$q->addTable('user_tasks'); $q->addTable('user_tasks'); $q->addWhere('user_tasks.user_id = ' . (int) $user_id); $q->addWhere('user_tasks.task_id = tasks.task_id'); $q->addWhere('task_percent_complete = 100'); //TODO: use date class to construct date. $q->addWhere('task_end_date >= \'' . date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - 7, date('Y'))) . '\''); break; case 'children': $q->addWhere('task_parent = ' . (int) $task_id); $q->addWhere('tasks.task_id <> ' . $task_id); break; case 'deepchildren': $taskobj = new CTask(); $taskobj->load((int) $task_id); $deepchildren = $taskobj->getDeepChildren(); $q->addWhere('tasks.task_id IN (' . implode(',', $deepchildren) . ')'); $q->addWhere('tasks.task_id <> ' . $task_id); break; case 'myproj': $q->addWhere('project_owner = ' . (int) $user_id); break; case 'mycomp': if (!$AppUI->user_company) { $AppUI->user_company = 0; } $q->addWhere('project_company = ' . (int) $AppUI->user_company); break; case 'myunfinished': $q->addTable('user_tasks'); $q->addWhere('user_tasks.user_id = ' . (int) $user_id);
public function getDeepChildren() { $children = $this->getChildren(); if ($children) { $deep_children = array(); $tempTask = new CTask(); foreach ($children as $child) { $tempTask->load($child); $deep_children = array_merge($deep_children, $tempTask->getDeepChildren()); } return array_merge($children, $deep_children); } return array(); }
function getDeepChildren() { $q = new DBQuery(); $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere("task_id <> '" . $this->task_id . "' AND task_parent = '" . $this->task_id . "'"); $sql = $q->prepare(); $q->clear(); $children = db_loadColumn($sql); if ($children) { $deep_children = array(); $tempTask = new CTask(); foreach ($children as $child) { $tempTask->peek($child); $deep_children = array_merge($deep_children, $tempTask->getDeepChildren()); } return array_merge($children, $deep_children); } return array(); }
//$user_id = $AppUI->getState('user_id'); } } // check permissions $canEdit = $perms->checkModule($m, 'edit'); // if task priority set and items selected, do some work $action = dPgetParam($_POST, 'action', 99); $selected = dPgetParam($_POST, 'selected', 0); if ($selected && count($selected)) { $new_task = dPgetParam($_POST, 'new_task', -1); $new_project = dPgetParam($_POST, 'new_project', $project_id); foreach ($selected as $key => $val) { $t = new CTask(); $t->load($val); if (isset($_POST['include_children']) && $_POST['include_children']) { $children = $t->getDeepChildren(); } if ($action == 'f') { //mark task as completed if ($perms->checkModuleItem('tasks', 'edit', $t->task_id)) { $t->task_percent_complete = 100; $t->store(); } if (isset($children)) { foreach ($children as $child_id) { if ($perms->checkModuleItem('tasks', 'edit', $child_t->task_id)) { $child_t = new CTask(); $child_t->load($child_id); $child_t->task_percent_complete = 100; $child_t->store(); }
$q->addGroup('project_id'); $q->addOrder('project_name'); $project->setAllowedSQL($AppUI->user_id, $q); $projects = $q->loadHashList('project_id'); $q->clear(); $caller = defVal(@$_REQUEST['caller'], null); /** * if task filtering has been requested create the list of task_ids * which will be used to filter the query */ if ($ganttTaskFilter > 0) { $task_child_search = new CTask(); $task_child_search->peek($ganttTaskFilter); //$childrenlist[] = $ganttTaskFilter; //print_r($childrenlist); $childrenlist = $task_child_search->getDeepChildren(); //print_r($childrenlist); $where .= ' t.task_id IN (' . $ganttTaskFilter . ', ' . implode(', ', $childrenlist) . ')'; } //else { // $where = ''; //} //echo '<pre> $where = ' . $where . '</pre>'; //die; // gantt is called now by the todo page, too. There is a different filter approach in todo // so we have to tweak a little bit, also we do not have a special project available if ($caller == 'todo') { $user_id = defVal(@$_REQUEST['user_id'], 0); $projects[$project_id]['project_name'] = $AppUI->_('Todo for') . ' ' . dPgetUsernameFromID($user_id); $projects[$project_id]['project_color_identifier'] = 'ff6000'; $q->addTable('tasks', 't');
/** * @param $f * @param $q * @param $user_id * @param $task_id * @param $AppUI * @return string */ function __extract_from_tasks3($f, $q, $user_id, $task_id, $AppUI) { $f = $f ? $f : ''; if ($task_id) { //if we are on a task context make sure we show ALL the children tasks $f = 'deepchildren'; } switch ($f) { case 'myfinished7days': $q->addWhere('ut.user_id = ' . (int) $user_id); case 'allfinished7days': $q->addTable('user_tasks'); $q->addWhere('user_tasks.user_id = ' . (int) $user_id); $q->addWhere('user_tasks.task_id = tasks.task_id'); $q->addWhere('task_percent_complete = 100'); //TODO: use date class to construct date. $q->addWhere('task_end_date >= \'' . date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - 7, date('Y'))) . '\''); break; case 'children': $q->addWhere('task_parent = ' . (int) $task_id); $q->addWhere('tasks.task_id <> ' . $task_id); break; case 'deepchildren': $taskobj = new CTask(); $taskobj->load((int) $task_id); $deepchildren = $taskobj->getDeepChildren(); $q->addWhere('tasks.task_id IN (' . implode(',', $deepchildren) . ')'); $q->addWhere('tasks.task_id <> ' . $task_id); break; case 'myproj': $q->addWhere('project_owner = ' . (int) $user_id); break; case 'mycomp': if (!$AppUI->user_company) { $AppUI->user_company = 0; } $q->addWhere('project_company = ' . (int) $AppUI->user_company); break; case 'myunfinished': $q->addTable('user_tasks'); $q->addWhere('user_tasks.user_id = ' . (int) $user_id); $q->addWhere('user_tasks.task_id = tasks.task_id'); $q->addWhere('(task_percent_complete < 100 OR task_end_date = \'\')'); break; case 'allunfinished': $q->addWhere('(task_percent_complete < 100 OR task_end_date = \'\')'); break; case 'unassigned': $q->leftJoin('user_tasks', 'ut_empty', 'tasks.task_id = ut_empty.task_id'); $q->addWhere('ut_empty.task_id IS NULL'); break; case 'taskcreated': $q->addWhere('task_creator = ' . (int) $user_id); break; case 'taskowned': $q->addWhere('task_owner = ' . (int) $user_id); break; case 'all': //break; //break; default: if ($user_id) { $q->addTable('user_tasks'); $q->addWhere('user_tasks.user_id = ' . (int) $user_id); $q->addWhere('user_tasks.task_id = tasks.task_id'); } break; } return $q; }