$q->addWhere('project_departments.department_id = ' . (int) $department); } if (!($department > 0) && $company_id != 0) { $q->addWhere('project_company = ' . (int) $company_id); } $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 ($showInactive != '1') { $q->addWhere('pr.project_active = 1'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $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[$row['task_project']]['tasks'][] = $row; } $width = min(w2PgetParam($_GET, 'width', 600), 1400); $start_date = w2PgetParam($_GET, 'start_date', $start_min); $end_date = w2PgetParam($_GET, 'end_date', $end_max); //consider critical (concerning end date) tasks as well if ($caller != 'todo') { $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']; } $count = 0; // If hyperlinks are to be added then the graph is of a set width/////// if ($addLinksToGantt == '1') { $width = 1450; } $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $gantt->setTitle($projects[$project_id]['project_name'], '#' . $projects[$project_id]['project_color_identifier']); $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(250, 60, 80, 80); } }
$q->clear(); $width = min(w2PgetParam($_GET, 'width', 600), 1400); $start_date = w2PgetParam($_GET, 'start_date', $start_min); $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);
$max_d_end = $d_end; $start_date = $start; $end_date = $end; } else { if (Date::compare($min_d_start, $d_start) > 0) { $min_d_start = $d_start; $start_date = $start; } if (Date::compare($max_d_end, $d_end) < 0) { $max_d_end = $d_end; $end_date = $end; } } } } $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $field = $showWork == '1' ? 'Work' : 'Dur'; if ($showTaskNameOnly == '1') { $columnNames = array('Task name'); $columnSizes = array(600); } else { if ($caller == 'todo') { $columnNames = array('Task name', 'Project name', $field, 'Start', 'Finish'); $columnSizes = array(180, 135, 40, 75, 75); } else { $columnNames = array('Task name', $field, 'Start', 'Finish'); $columnSizes = array(250, 60, 90, 90); } } $gantt->setColumnHeaders($columnNames, $columnSizes);