function constructTaskTree_pd($task_data, $parents, $all_tasks, $depth = 0) { global $projTasks, $all_tasks, $task_parent_options, $task_parent, $task_id; $projTasks[$task_data['task_id']] = $task_data['task_name']; $task_data['task_name'] = mb_strlen($task_data[1]) > 45 ? mb_substr($task_data['task_name'], 0, 45) . "..." : $task_data['task_name']; $task_parent_options .= '<option value="' . $task_data['task_id'] . '" >' . getSpaces($depth * 3) . w2PFormSafe($task_data['task_name']) . '</option>'; if (isset($parents[$task_data['task_id']])) { foreach ($parents[$task_data['task_id']] as $child_task) { if ($child_task != $task_id) { constructTaskTree_pd($all_tasks[$child_task], $parents, $all_tasks, $depth + 1); } } } }
$all_tasks = array(); $sub_tasks = $q->exec(); if ($sub_tasks) { while ($sub_task = $q->fetchRow()) { // Build parent/child task list $parents[$sub_task['task_parent']][] = $sub_task['task_id']; $all_tasks[$sub_task['task_id']] = $sub_task; build_date_list($projTasksWithEndDates, $sub_task); } } $q->clear(); // let's iterate root tasks foreach ($root_tasks as $root_task) { build_date_list($projTasksWithEndDates, $root_task); if ($root_task['task_id'] != $task_id) { constructTaskTree_pd($root_task, $parents, $all_tasks); } } $project = new CProject(); $sprojects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects'); $q = new w2p_Database_Query(); $q->addTable('projects'); $q->addQuery('projects.project_id, company_name'); $q->addJoin('companies', 'co', 'co.company_id = project_company'); $idx_companies = $q->loadHashList(); $q->clear(); foreach ($sprojects as $prj_id => $prj_name) { $sprojects[$prj_id] = $idx_companies[$prj_id] . ': ' . $prj_name; } asort($sprojects); $sprojects = arrayMerge(array('' => '(' . $AppUI->_('Move to Project', UI_OUTPUT_RAW) . ')'), $sprojects);