$t = $gantt_arr[$p['project_id']][$i][0]; $level = $gantt_arr[$p['project_id']][$i][1]; if ($t['task_end_date'] == null) { $t['task_end_date'] = $t['task_start_date']; } $tStart = $t['task_start_date'] > '0000-00-00 00:00:00' ? $t['task_start_date'] : date('Y-m-d H:i:s'); $tEnd = $t['task_end_date'] > '0000-00-00 00:00:00' ? $t['task_end_date'] : date('Y-m-d H:i:s'); $tStartObj = new w2p_Utilities_Date($tStart); $tEndObj = new w2p_Utilities_Date($tEnd); if ($t['task_milestone'] != 1) { $advance = str_repeat(' ', $level + 2); $name = mb_strlen($advance . $t['task_name']) > 35 ? mb_substr($advance . $t['task_name'], 0, 33) . '...' : $advance . $t['task_name']; $height = $t['task_dynamic'] == 1 ? 0.1 : 0.6; $columnValues = array('project_name' => $name, 'start_date' => $tStartObj->getDate(), 'end_date' => $tEndObj->getDate(), 'actual_end' => ''); $gantt->addBar($columnValues, '', $height, $p['project_color_identifier'], $p['project_active'], $progress, $p['project_id']); } else { $name = $advance . '* ' . $t['task_name']; $milestone = substr($t['task_start_date'], 0, 10); $milestoneDate = new w2p_Utilities_Date($milestone); $gantt->addMilestone(array($name, '', $milestoneDate->format($df)), $t['task_start_date']); } // End of insert workers for each task into Gantt Chart } // End of insert tasks into Gantt Chart } // End of if showAllGant checkbox is checked } } // End of check for valid projects array. } $gantt->render();
$t['task_end_date'] = db_unix2dateTime(db_dateTime2unix($t['task_start_date']) + SECONDS_PER_DAY * convert2days($t['task_duration'], $t['task_duration_type'])); } else { $todaydate = new w2p_Utilities_Date(); $t['task_end_date'] = $todaydate->format(FMT_TIMESTAMP_DATE); } } $tStart = intval($t['task_start_date']) ? $t['task_start_date'] : $start; $tEnd = intval($t['task_end_date']) ? $t['task_end_date'] : $end; $tStartObj = new w2p_Utilities_Date($t['task_start_date']); $tEndObj = new w2p_Utilities_Date($t['task_end_date']); if ($t['task_milestone'] != 1) { $columnValues = array('task_name' => $name, 'start_date' => $tStart, 'end_date' => $tEnd, '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->getAssigned(); foreach ($workers as $w) { $columnValues = array('user_name' => ' * ' . $w['user_name'], 'start_date' => $tStart, 'end_date' => $tEnd, 'actual_end' => ''); $height = $t['task_dynamic'] == 1 ? 0.1 : 0.6; $gantt->addBar($columnValues, $w['user_name'], 0.6, $p['project_color_identifier'], true, $t['task_percent_complete'], $t['task_id']); } // End of insert workers for each task into Gantt Chart } unset($tasks); // End of insert tasks into Gantt Chart } // End of if showAllGant checkbox is checked }
//green for 'achieved' #006600 // blue for 'planned' #0000FF if ($a['task_percent_complete'] == 100) { $color = '#006600'; } else { if (strtotime($mile_date) < strtotime($today_date)) { $color = '#990000'; } else { if ($a['task_percent_complete'] == 0) { $color = '#0000FF'; } else { $color = '#FF9900'; } } } $gantt->addMilestone($fieldArray, $a['task_start_date'], $color); } //this closes the code that is not processed if hide milestones is checked /////////////// } else { $type = $a['task_duration_type']; $dur = $a['task_duration']; if ($type == 24) { $dur *= $w2Pconfig['daily_working_hours']; } if ($showWork == '1') { $work_hours = 0; $q = new w2p_Database_Query(); $q->addTable('tasks', 't'); $q->addJoin('user_tasks', 'u', 't.task_id = u.task_id', 'inner'); $q->addQuery('ROUND(SUM(t.task_duration*u.perc_assignment/100),2) AS wh'); $q->addWhere('t.task_duration_type = 24');
$caption .= $rw['contact_display_name'] . ';'; break; default: $caption .= $rw['contact_display_name'] . ' [' . $rw['perc_assignment'] . '%];'; break; } } $q->clear(); $caption = mb_substr($caption, 0, mb_strlen($caption) - 1); } if ($flags == 'm') { $start = new w2p_Utilities_Date($start); $start->addDays(0); $s = $start->format($df); if ($caller == 'todo') { $gantt->addMilestone(array($name, $pname, '', $s, $s), $a['task_start_date']); } else { $gantt->addMilestone(array($name, '', $s, $s), $a['task_start_date']); } } else { $type = $a['task_duration_type']; $dur = $a['task_duration']; if ($type == 24) { $dur *= $w2Pconfig['daily_working_hours']; } if ($showWork == '1') { $work_hours = 0; $q = new w2p_Database_Query(); $q->addTable('tasks', 't'); $q->addJoin('user_tasks', 'u', 't.task_id = u.task_id', 'inner'); $q->addQuery('ROUND(SUM(t.task_duration*u.perc_assignment/100),2) AS wh');
// if the milestone is near the end of the date range for which we are showing the chart // make the caption go on the left side of the milestone marker $task_start_date = $AppUI->formatTZAwareTime($a['task_start_date'], '%Y-%m-%d %T'); /* * TODO: This is an ugly hack to correct the placement of the * milestones on the gantt charts. I have no clue why this * adjustment is needed, but it is.. * ~ caseydk 02 August 2012 */ $my_time = strtotime($task_start_date) + 24 * 60 * 60; $task_start_date = date('Y-m-d', $my_time); $captionToTheLeft = false; if ($mile_date_stamp + 72 * 60 * 60 >= strtotime($end_date)) { $captionToTheLeft = true; } $gantt->addMilestone($fieldArray, $a['task_start_date'], $color, 0, $captionToTheLeft); } } else { $type = $a['task_duration_type']; $dur = $a['task_duration']; if ($type == 24) { $dur *= $w2Pconfig['daily_working_hours']; } if ($showWork == '1') { $dur = $a['task_hours_worked']; } $dur = round($dur, 0); $dur .= ' h'; $height = $a['task_dynamic'] == 1 ? 0.1 : 0.6; if ($showTaskNameOnly == '1') { $columnValues = array('task_name' => $name);