if ($showLabels) { $caption .= $AppUI->_($projectStatus[$p['project_status']]) . ', '; $caption .= $p['project_active'] != 0 ? $AppUI->_('active') : $AppUI->_('archived'); } $enddate = new w2p_Utilities_Date($end); $startdate = new w2p_Utilities_Date($start); $actual_end = intval($p['project_actual_end_date']) ? $p['project_actual_end_date'] : $end; $columnValues = array('project_name' => $pname, 'start_date' => $start, 'end_date' => $end, 'actual_end' => $actual_end); $gantt->addBar($columnValues, $caption, 0.6, $p['project_color_identifier'], $p['project_active'], $progress, $p['project_id']); // If showAllGant checkbox is checked if ($showAllGantt) { // insert tasks into Gantt Chart // select for tasks for each project $task = new CTask(); $orderBy = $sortTasksByName ? 'task_name' : 'task_end_date ASC'; $tasks = $task->getAllowedTaskList($AppUI, $p['project_id'], $orderBy); $bestColor = bestColor('#ffffff', '#' . $p['project_color_identifier'], '#000000'); foreach ($tasks as $t) { $name = $t['task_name']; $name = mb_strlen($name) > 34 ? mb_substr($name, 0, 30) . '...' : $name; //Check if start date exists, if not try giving it the end date. //If the end date does not exist then set it for today. //This avoids jpgraphs internal errors that render the gantt completely useless if ($t['task_start_date'] == '0000-00-00 00:00:00') { if ($t['task_end_date'] == '0000-00-00 00:00:00') { $todaydate = new w2p_Utilities_Date(); $t['task_start_date'] = $todaydate->format(FMT_TIMESTAMP_DATE); } else { $t['task_start_date'] = $t['task_end_date']; } }
case 'projects': $project_company = w2PgetParam($_GET, 'project_company', 0); if ($user_id > 0) { $projectList = CContact::getProjects($user_id); } else { $projectList = CCompany::getProjects($AppUI, $project_company); } foreach ($projectList as $project) { $resultList[$project['project_id']] = $project['project_name']; } break; case 'tasks': $title = 'Task'; $task_project = (int) w2PgetParam($_GET, 'task_project', 0); $myTask = new CTask(); $task_list = $myTask->getAllowedTaskList($AppUI, $task_project); $level = 0; $query_result = array(); $last_parent = 0; foreach ($task_list as $task) { if ($task['task_parent'] != $task['task_id']) { if ($last_parent != $task['task_parent']) { $last_parent = $task['task_parent']; $level++; } } else { $last_parent = 0; $level = 0; } $query_result[$task['task_id']] = ($level ? str_repeat(' ', $level) : '') . $task['task_name']; }
echo $AppUI->_('Target Budget'); ?> </th> <th width="10px" align="center"><?php echo $AppUI->_('Actual Cost'); ?> </th> <th width="10px" align="center"><?php echo $AppUI->_('Difference'); ?> </th> </tr> <?php //TODO: rotate the headers by 90 degrees? $task = new CTask(); $taskList = $task->getAllowedTaskList(null, $project_id); $bcode = new CSystem_Bcode(); if (count($taskList)) { foreach ($taskList as $taskItem) { $task->loadFull(null, $taskItem['task_id']); $costs = $bcode->calculateTaskCost($taskItem['task_id'], $start_date->format(FMT_DATETIME_MYSQL), $end_date->format(FMT_DATETIME_MYSQL)); $tstart = new w2p_Utilities_Date($task->task_start_date); $tend = new w2p_Utilities_Date($task->task_end_date); $filterStart = $start_date; $filterEnd = $end_date; $workingDaysInSpans = $filterStart->findDaysInRangeOverlap($tstart, $tend, $filterStart, $filterEnd); $workingDaysForTask = $tstart->workingDaysInSpan($tend); $factor = $workingDaysInSpans / $workingDaysForTask; $factor = $factor > 1 ? 1 : $factor; ?> <tr>
$end = $start; $caption .= ' ' . $AppUI->_('(no end date)'); } if ($showLabels == '1') { $caption .= $AppUI->_($projectStatus[$p['project_status']]) . ', '; $caption .= $p['project_active'] ? $AppUI->_('active') : $AppUI->_('archived'); } $columnValues = array('project_name' => $pname, 'start_date' => $start, 'end_date' => $end, 'actual_end' => $actual_end); $gantt->addBar($columnValues, $caption, 0.6, $p['project_color_identifier'], $p['project_active'], $progress, $p['project_id']); // If showAllGant checkbox is checked if ($showAllGantt) { // insert tasks into Gantt Chart // select for tasks for each project $task = new CTask(); $orderBy = $sortTasksByName ? 'task_name' : 'task_end_date ASC'; $tasks = $task->getAllowedTaskList(null, $p['project_id'], $orderBy); $bestColor = bestColor('#ffffff', '#' . $p['project_color_identifier'], '#000000'); foreach ($tasks as $t) { $name = $t['task_name']; $name = mb_strlen($name) > 34 ? mb_substr($name, 0, 30) . '...' : $name; $t['task_start_date'] = __extract_from_projects_gantt3($t); $t['task_end_date'] = __extract_from_projects_gantt4($t); if ($t['task_milestone'] != 1) { $columnValues = array('task_name' => $name, 'start_date' => $t['task_start_date'], 'end_date' => $t['task_end_date'], 'actual_end' => ''); $height = $t['task_dynamic'] == 1 ? 0.1 : 0.6; $gantt->addBar($columnValues, $t['task_percent_complete'] . '% ' . $AppUI->_('Complete'), $height, $p['project_color_identifier'], $p['project_active'], $t['task_percent_complete'], $t['task_id']); } else { $gantt->addMilestone(array('-- ' . $name), $t['task_start_date']); } $task->task_id = $t['task_id']; $workers = $task->assignees($task->task_id);
case 'projects': $project_company = w2PgetParam($_GET, 'project_company', 0); if ($user_id > 0) { $projectList = CContact::getProjects($user_id); } else { $projectList = CCompany::getProjects($AppUI, $project_company); } foreach ($projectList as $project) { $resultList[$project['project_id']] = $project['project_name']; } break; case 'tasks': $title = 'Task'; $task_project = (int) w2PgetParam($_GET, 'task_project', 0); $myTask = new CTask(); $task_list = $myTask->getAllowedTaskList(null, $task_project); $level = 0; $query_result = array(); $last_parent = 0; foreach ($task_list as $task) { if ($task['task_parent'] != $task['task_id']) { if ($last_parent != $task['task_parent']) { $last_parent = $task['task_parent']; $level++; } } else { $last_parent = 0; $level = 0; } $query_result[$task['task_id']] = ($level ? str_repeat(' ', $level) : '') . $task['task_name']; }