Exemple #1
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->setDateRange($start_date, $end_date);
$row = 0;
if (!is_array($projects) || 0 == count($projects)) {
    $d = new w2p_Utilities_Date();
    $columnValues = array('project_name' => $AppUI->_('No projects found'), 'start_date' => $d->getDate(), 'end_date' => $d->getDate(), 'actual_end' => '');
    $gantt->addBar($columnValues, ' ', 0.6, 'red');
} else {
    foreach ($projects as $p) {
        $pname = $p['project_name'];
        $pname = mb_strlen($pname) > 30 ? mb_substr($pname, 0, 25) . '...' : $pname;
        //using new jpGraph determines using Date object instead of string
        $start = $p['project_start_date'] > '1969-12-31 19:00:00' ? $p['project_start_date'] : '';
        $end_date = $p['project_end_date'] > '1969-12-31 19:00:00' ? $p['project_end_date'] : $p['project_actual_end_date'];
        $end_date = new w2p_Utilities_Date($end_date);
        $end = $end_date->getDate();
        $start = new w2p_Utilities_Date($start);
        $start = $start->getDate();
        $progress = (int) $p['project_percent_complete'];
        $caption = '';
        if (!$start || $start == '0000-00-00') {
            $start = !$end ? date('Y-m-d') : $end;
                $start_date = $start;
            }
            if ($d_end > $max_d_end) {
                $max_d_end = $d_end;
                $end_date = $end;
            }
        }
        $i++;
    }
}
$gantt->SetDateRange($start_date, $end_date);
$row = 0;
if (!is_array($projects) || sizeof($projects) == 0) {
    $d = new w2p_Utilities_Date();
    $columnValues = array('project_name' => $AppUI->_('No projects found'), 'start_date' => $d->getDate(), 'end_date' => $d->getDate(), 'actual_end' => '');
    $gantt->addBar($columnValues, ' ', 0.6, 'red');
} else {
    if (is_array($projects)) {
        //pull all tasks into an array keyed by the project id, and get the tasks in hierarchy
        if ($showAllGantt) {
            // insert tasks into Gantt Chart
            // select for tasks for each project
            // pull tasks
            $q = new w2p_Database_Query();
            $q->addTable('tasks', 't');
            $q->addQuery('t.task_id, task_parent, task_name, task_start_date, task_end_date, task_duration, task_duration_type, task_priority, task_percent_complete, task_order, task_project, task_milestone, project_id, project_name, task_dynamic');
            $q->addJoin('projects', 'p', 'project_id = t.task_project');
            $q->addOrder('project_id, task_start_date');
            $q->addWhere('project_original_parent = ' . (int) $original_project_id);
            //$tasks = $q->loadList();
            $task = new CTask();
Exemple #3
0
                $q->addWhere('t.task_duration_type = 24');
                $q->addWhere('t.task_id = ' . (int) $a['task_id']);
                $wh = $q->loadResult();
                $work_hours = $wh * $w2Pconfig['daily_working_hours'];
                $q->clear();
                $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 = 1');
                $q->addWhere('t.task_id = ' . (int) $a['task_id']);
                $wh2 = $q->loadResult();
                $work_hours += $wh2;
                $q->clear();
                //due to the round above, we don't want to print decimals unless they really exist
                $dur = $work_hours;
            }
            $dur .= ' h';
            $enddate = new w2p_Utilities_Date($end);
            $startdate = new w2p_Utilities_Date($start);
            $height = $a['task_dynamic'] == 1 ? 0.1 : 0.6;
            if ($caller == 'todo') {
                $columnValues = array('task_name' => $name, 'project_name' => $pname, 'duration' => $dur, 'start_date' => $start, 'end_date' => $end, 'actual_end' => '');
            } else {
                $columnValues = array('task_name' => $name, 'duration' => $dur, 'start_date' => $start, 'end_date' => $end, 'actual_end' => '');
            }
            $gantt->addBar($columnValues, $caption, $height, '8F8FBD', true, $progress, $a['task_id']);
        }
        $q->clear();
    }
}
$gantt->render();