$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); $lastTask = $pjobj->getCriticalTasks($project['project_id']); $end = substr($lastTask[0]['task_end_date'], 0, 10); $d_start = strtotime($start); $d_end = strtotime($end); if ($i == 0) { $min_d_start = $d_start; $start_date = $start; $max_d_end = $d_end; $end_date = $end; } else { if ($d_start < $min_d_start) { $min_d_start = $d_start; $start_date = $start; } if ($d_end > $max_d_end) { $max_d_end = $d_end;
/* $Id$ $URL$ */ if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } global $caller, $locale_char_set, $showWork, $sortByName, $showLabels; global $gantt_arr, $showPinned, $showArcProjs, $showHoldProjs, $showDynTasks; global $showLowTasks, $user_id, $w2Pconfig; w2PsetExecutionConditions($w2Pconfig); $showLabels = w2PgetParam($_REQUEST, 'showLabels', false); $sortByName = w2PgetParam($_REQUEST, 'sortByName', false); $project_id = w2PgetParam($_REQUEST, 'project_id', 0); $f = w2PgetParam($_REQUEST, 'f', 0); // get the prefered date format $df = $AppUI->getPref('SHDATEFORMAT'); $project = new CProject(); $criticalTasks = $project_id > 0 ? $project->getCriticalTasks($project_id) : null; // pull valid projects and their percent complete information $projects = $project->getAllowedProjects($AppUI->user_id, false); ############################################## /* gantt is called now by the todo page, too. ** there is a different filter approach in todo ** so we have to tweak a little bit, ** also we do not have a special project available */ $caller = w2PgetParam($_REQUEST, 'caller', null); if ($caller == 'todo') { $user_id = w2PgetParam($_REQUEST, 'user_id', $AppUI->user_id); $projects[$project_id]['project_name'] = $AppUI->_('Todo for') . ' ' . CContact::getContactByUserid($user_id); $projects[$project_id]['project_color_identifier'] = 'ff6000'; $showLabels = w2PgetParam($_REQUEST, 'showLabels', false); $showPinned = w2PgetParam($_REQUEST, 'showPinned', false);
// retrieve any state parameters if (isset($_GET['tab'])) { $AppUI->setState('ProjVwTab', $_GET['tab']); } $tab = $AppUI->getState('ProjVwTab') !== NULL ? $AppUI->getState('ProjVwTab') : 0; // check if this record has dependencies to prevent deletion $msg = ''; $obj = new CProject(); // Now check if the proect is editable/viewable. $denied = $obj->getDeniedRecords($AppUI->user_id); if (in_array($project_id, $denied)) { $AppUI->redirect("m=public&a=access_denied"); } $canDelete = $obj->canDelete($msg, $project_id); // get critical tasks (criteria: task_end_date) $criticalTasks = $project_id > 0 ? $obj->getCriticalTasks($project_id) : NULL; // get ProjectPriority from sysvals $projectPriority = dPgetSysVal('ProjectPriority'); $projectPriorityColor = dPgetSysVal('ProjectPriorityColor'); $working_hours = $dPconfig['daily_working_hours'] ? $dPconfig['daily_working_hours'] : 8; $q = new DBQuery(); //check that project has tasks; otherwise run seperate query $q->addTable('tasks'); $q->addQuery("COUNT(distinct tasks.task_id) AS total_tasks"); $q->addWhere('task_project = ' . $project_id); $hasTasks = $q->loadResult(); $q->clear(); // load the record data // GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours if ($hasTasks) { $q->addTable('projects');
} if ($project_id == 0 && $company_id > 0) { $row->project_company = $company_id; } // add in the existing company if for some reason it is dis-allowed if ($project_id && !array_key_exists($row->project_company, $companies)) { $q = new DBQuery(); $q->addTable('companies'); $q->addQuery('company_name'); $q->addWhere('companies.company_id = ' . $row->project_company); $sql = $q->prepare(); $q->clear(); $companies[$row->project_company] = db_loadResult($sql); } // get critical tasks (criteria: task_end_date) $criticalTasks = $project_id > 0 ? $row->getCriticalTasks() : NULL; // get ProjectPriority from sysvals $projectPriority = dPgetSysVal('ProjectPriority'); // format dates $df = $AppUI->getPref('SHDATEFORMAT'); $start_date = new CDate($row->project_start_date); $end_date = intval($row->project_end_date) ? new CDate($row->project_end_date) : null; $actual_end_date = intval($criticalTasks[0]['task_end_date']) ? new CDate($criticalTasks[0]['task_end_date']) : null; $style = $actual_end_date > $end_date && !empty($end_date) ? 'style="color:red; font-weight:bold"' : ''; // setup the title block $ttl = $project_id > 0 ? "Edit Project" : "New Project"; $titleBlock = new CTitleBlock($ttl, 'applet3-48.png', $m, "{$m}.{$a}"); $titleBlock->addCrumb("?m=projects", "projects list"); if ($project_id != 0) { $titleBlock->addCrumb("?m=projects&a=view&project_id={$project_id}", "view this project"); //GT
$addLinksToGantt = dPgetParam($_REQUEST, 'addLinksToGantt', 0); $printpdf = dPgetParam($_REQUEST, 'printpdf', 0); $monospacefont = dPgetParam($_REQUEST, 'monospacefont'); // Get the state of formatting variables here ///////////////////////////////////////////////////// ini_set('memory_limit', $dPconfig['reset_memory_limit']); include $AppUI->getLibraryClass('jpgraph/src/jpgraph'); include $AppUI->getLibraryClass('jpgraph/src/jpgraph_gantt'); require_once 'tasks.class.php'; $project_id = dPgetParam($_REQUEST, 'project_id', 0); $f = dPgetParam($_REQUEST, 'f', 0); // get the prefered date format $df = $AppUI->getPref('SHDATEFORMAT'); require_once $AppUI->getModuleClass('projects'); $project = new CProject(); if ($project_id > 0) { $criticalTasks = $project->getCriticalTasks($project_id); $project->load($project_id); } // pull valid projects and their percent complete information $q = new DBQuery(); $q->addTable('projects'); $q->addQuery('project_id, project_color_identifier, project_name' . ', project_start_date, project_end_date'); $q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project'); $q->addWhere('project_status != 7'); $q->addGroup('project_id'); $q->addOrder('project_name'); $project->setAllowedSQL($AppUI->user_id, $q); $projects = $q->loadHashList('project_id'); $q->clear(); $caller = defVal(@$_REQUEST['caller'], null); /**
</th> <th width="10px" align="center"><?php echo $AppUI->_('Difference'); ?> </th> </tr> <?php //TODO: rotate the headers by 90 degrees? $activeOnly = $active_projects ? true : false; $projectList = CCompany::getProjects($AppUI, $company_id, $activeOnly); $bcode = new CSystem_Bcode(); $project = new CProject(); if (count($projectList)) { foreach ($projectList as $projectItem) { $project->loadFull(null, $projectItem['project_id']); $criticalTasks = $project->getCriticalTasks($projectItem['project_id']); $costs = $bcode->calculateProjectCost($projectItem['project_id'], $start_date->format(FMT_DATETIME_MYSQL), $end_date->format(FMT_DATETIME_MYSQL)); $pstart = new w2p_Utilities_Date($project->project_start_date); $pend = intval($criticalTasks[0]['task_end_date']) ? new w2p_Utilities_Date($criticalTasks[0]['task_end_date']) : new w2p_Utilities_Date(); $filterStart = $start_date; $filterEnd = $end_date; $workingDaysInSpans = $filterStart->findDaysInRangeOverlap($pstart, $pend, $filterStart, $filterEnd); $workingDaysForProj = $pstart->workingDaysInSpan($pend); $factor = $workingDaysInSpans / $workingDaysForProj; $factor = $factor > 1 ? 1 : $factor; ?> <tr> <td width="10" align="right" style="border: outset #eeeeee 1px;background-color:#<?php echo $project->project_color_identifier; ?> ">