$q->addWhere('project_original_parent = ' . (int) $original_project_id); $pjobj->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); $q->addGroup('pr.project_id'); $q->addOrder('project_start_date, project_end_date, project_name'); $projects = $q->loadHashList('project_id'); $q->clear(); $width = w2PgetParam($_GET, 'width', 600); $start_date = w2PgetParam($_GET, 'start_date', 0); $end_date = w2PgetParam($_GET, 'end_date', 0); $showAllGantt = w2PgetParam($_REQUEST, 'showAllGantt', '1'); $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $original_project = new CProject(); $original_project->load($original_project_id); $tableTitle = $original_project->project_name . ': ' . $AppUI->_('Multi-Project Gantt'); $gantt->setTitle($tableTitle, '#eeeeee'); $columnNames = array('Project name', 'Start Date', 'Finish', 'Actual End'); $columnSizes = array(200, 75, 75, 75); $gantt->setColumnHeaders($columnNames, $columnSizes); /* * TODO: Technically, doing the date math below using the strtotime is bad * form because it is suseptible to the 2038 date bug. Hopefully, we'll * either have this bug fixed and resolved by then and/or no one is * scheduling projects 28 years into the future. Regardless, it's much * easier than actual date math. * ~ caseydk 22 Aug 2010 */ if (!$start_date || !$end_date) { $i = 0; foreach ($projects as $project) { $start = substr($project["project_start_date"], 0, 10);
$end_date = w2PgetParam($_GET, 'end_date', $end_max); //consider critical (concerning end date) tasks as well $start_min = substr($criticalTasksInverted[0]['task_start_date'], 0, 10); if ($start_min == '0000-00-00' || !$start_min) { $start_min = $projects[$project_id]['project_start_date']; } // $end_max = ($projects[$project_id]['project_end_date'] > $criticalTasks[0]['task_end_date']) ? $projects[$project_id]['project_end_date'] : $criticalTasks[0]['task_end_date']; $end_max = substr($criticalTasks[0]['task_end_date'], 0, 10); if ($end_max == '0000-00-00' || !$end_max) { $end_max = $projects[$project_id]['project_end_date']; } $count = 0; $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $pname = $projects[$project_id]['project_name']; $gantt->setTitle($pname, '#' . $projects[$project_id]['project_color_identifier']); // get the prefered date format $field = $showWork == '1' ? 'Work' : 'Dur'; $columnNames = array('Task name', $field, 'Start', 'Finish'); $columnSizes = array(200, 50, 75, 75); $gantt->setColumnHeaders($columnNames, $columnSizes); if (!$start_date || !$end_date) { // find out DateRange from gant_arr $d_start = new w2p_Utilities_Date(); $d_end = new w2p_Utilities_Date(); for ($i = 0, $i_cmp = count($gantt_arr); $i < $i_cmp; $i++) { $a = $gantt_arr[$i][0]; $start = substr($a['task_start_date'], 0, 10); $end = substr($a['task_end_date'], 0, 10); $d_start->Date($start); $d_end->Date($end);
$q->addWhere('pr.project_status <> ' . $template_status); } } $pjobj->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); $q->addGroup('pr.project_id'); $q->addOrder('pr.project_name, task_end_date DESC'); $projects = $q->loadList(); // Don't push the width higher than about 1200 pixels, otherwise it may not display. $width = min(w2PgetParam($_GET, 'width', 600), 1400); $start_date = w2PgetParam($_GET, 'start_date', 0); $end_date = w2PgetParam($_GET, 'end_date', 0); $showAllGantt = w2PgetParam($_REQUEST, 'showAllGantt', '0'); $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $tableTitle = $proFilter == '-1' ? $AppUI->_('All Projects') : $projectStatus[$proFilter]; $gantt->setTitle($tableTitle); $columnNames = array('Project name', 'Start Date', 'Finish', 'Actual End'); $columnSizes = array(160, 75, 75, 75); $gantt->setColumnHeaders($columnNames, $columnSizes); if (!$start_date || !$end_date) { // find out DateRange from $projects array $projectCount = count($projects); for ($i = 0, $i_cmp = $projectCount; $i < $i_cmp; $i++) { $start = substr($projects[$i]['project_start_date'], 0, 10); $end = substr($projects[$i]['project_end_date'], 0, 10); if (0 == strlen($end)) { $lastTask = $pjobj->getCriticalTasks($projects[$i]['project_id']); $projects[$i]['project_actual_end_date'] = $lastTask[0]['task_end_date']; $projects[$i]['project_end_date'] = $lastTask[0]['task_end_date']; $end = substr($lastTask[0]['task_end_date'], 0, 10); }
$max_d_end = $d_end; $end_date = $end; } } } } if ('0000-00-00' == substr($start_date, 0, 10)) { $start_date = date('Y-m-d', time() - 60 * 60 * 24 * 7); } if ('0000-00-00' == substr($end_date, 0, 10)) { $end_date = date('Y-m-d', time() + 60 * 60 * 24 * 7); } $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $pname = $projects[$project_id]['project_name']; $gantt->setTitle($pname); $field = $showWork == '1' ? 'Work' : 'Dur'; if ($showTaskNameOnly == '1') { $columnNames = array('Task name'); $columnSizes = array(300); } else { if ($caller == 'todo') { $columnNames = array('Task name', 'Project name', $field, 'Start', 'Finish'); $columnSizes = array(200, 160, 40, 75, 75); } else { $columnNames = array('Task name', $field, 'Start', 'Finish'); $columnSizes = array(200, 50, 80, 80); } } $gantt->setColumnHeaders($columnNames, $columnSizes); $gantt->setProperties(array('showhgrid' => true));