} $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; $caption .= $AppUI->_('(no start date)'); } if (!$end) { $end = $start; $caption .= ' ' . $AppUI->_('(no end date)'); } else { $cap = ''; } if ($showLabels) {
// cycle for tasks for each project for ($i = 0, $i_cmp = count($gantt_arr[$p['project_id']]); $i < $i_cmp; $i++) { $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.
$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') { // if hide milestones is ticked this bit is not processed////////////////////////////////////////// if ($showNoMilestones != '1') { $start = new w2p_Utilities_Date($start_date); $start->addDays(0); $start_mile = $start->getDate(); $s = $start_date->format($df); $today_date = date('m/d/Y'); $today_date_stamp = strtotime($today_date); $mile_date = $start_date->format($df); $mile_date_stamp = strtotime($mile_date); // honour the choice to show task names only/////////////////////////////////////////////////// if ($showTaskNameOnly == '1') { $fieldArray = array($name); } else { if ($caller == 'todo') { $fieldArray = array($name, $pname, '', $s, $s); } else { $fieldArray = array($name, '', $s, $s); } }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; if (!$this->event_recurs) { $this->event_times_recuring = 0; } else { //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date //so that the event starts recurring from the start day onwards n times after the start date for the period given //Meaning: The event end date day is useless as far as recurring events are concerned. $start_date = new w2p_Utilities_Date($this->event_start_date); $end_date = new w2p_Utilities_Date($this->event_end_date); $hour = $end_date->getHour(); $minute = $end_date->getMinute(); $end_date->setDate($start_date->getDate()); $end_date->setHour($hour); $end_date->setMinute($minute); $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL); } // ensure changes to check boxes and select lists are honoured $this->event_private = (int) $this->event_private; $this->event_type = (int) $this->event_type; $this->event_cwd = (int) $this->event_cwd; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $this->event_start_date = $AppUI->convertToSystemTZ($this->event_start_date); $this->event_end_date = $AppUI->convertToSystemTZ($this->event_end_date); /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->event_id && $perms->checkModuleItem('events', 'edit', $this->event_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->event_id && $perms->checkModuleItem('events', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if ($stored) { // TODO: I *really* don't like using the POST inside here.. $this->updateAssigned(explode(',', $_POST['event_assigned'])); $custom_fields = new w2p_Core_CustomFields('calendar', 'addedit', $this->event_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->event_id); // Store Custom Fields } return $stored; }
} } } $gantt = new w2p_Output_GanttRenderer($AppUI, $width); $gantt->localize(); $tableTitle = $statusFilter == '-1' ? $AppUI->_('All Projects') : $projectStatus[$statusFilter]; $gantt->setTitle($tableTitle); $columnNames = array('Project name', 'Start Date', 'Finish', 'Actual End'); $columnSizes = array(160, 75, 75, 75); $gantt->setColumnHeaders($columnNames, $columnSizes); $gantt->setProperties(array('showhgrid' => true)); $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_date = (int) $p['project_start_date'] ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($p['project_start_date'], '%Y-%m-%d %T')) : new w2p_Utilities_Date(); $start = $start_date->getDate(); $end_date = (int) $p['project_end_date'] ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($p['project_end_date'], '%Y-%m-%d %T')) : new w2p_Utilities_Date(); $end = $end_date->getDate(); $actual_end = (int) $p['project_actual_end_date'] ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($p['project_actual_end_date'], '%Y-%m-%d %T')) : $end_date; $actual_end = $actual_end->getDate(); $progress = (int) $p['project_percent_complete']; $caption = ''; if (!$start || $start == '0000-00-00') {
protected function hook_preStore() { parent::hook_preStore(); if (!$this->event_recurs) { $this->event_times_recuring = 0; } else { //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date //so that the event starts recurring from the start day onwards n times after the start date for the period given //Meaning: The event end date day is useless as far as recurring events are concerned. $start_date = new w2p_Utilities_Date($this->event_start_date); $end_date = new w2p_Utilities_Date($this->event_end_date); $hour = $end_date->getHour(); $minute = $end_date->getMinute(); $end_date->setDate($start_date->getDate()); $end_date->setHour($hour); $end_date->setMinute($minute); $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL); } // ensure changes to check boxes and select lists are honoured $this->event_private = (int) $this->event_private; $this->event_type = (int) $this->event_type; $this->event_cwd = (int) $this->event_cwd; $this->event_creator = (int) $this->event_creator ? $this->event_creator : $this->_AppUI->user_id; $this->event_owner = (int) $this->event_owner ? $this->event_owner : $this->_AppUI->user_id; $q = $this->_getQuery(); $this->event_updated = $q->dbfnNowWithTZ(); }
/** * Tests subtractSeconds when crossing over a year */ public function testSubtractSecondsAcrossYear() { $date = new w2p_Utilities_Date('2011-01-01 00:00:10'); $date->subtractSeconds(11); $this->assertEquals('2010-12-31 23:59:59', $date->getDate(DATE_FORMAT_ISO)); }
} } $caption = mb_substr($caption, 0, mb_strlen($caption) - 1); } if ($flags == 'm') { // if hide milestones is ticked this bit is not processed////////////////////////////////////////// if ($showNoMilestones != '1') { $start = new w2p_Utilities_Date($start); $start->addDays(0); $start_mile = $start->getDate(); $s = $start->format($df); $mile_date = $start->format($df . ' ' . $AppUI->getPref('TIMEFORMAT')); $mile_date_stamp = strtotime($start_mile); $today = new w2p_Utilities_Date(); $today->convertTZ($AppUI->getPref('TIMEZONE')); $today_mile = $today->getDate(); $today_date = $today->format($df . ' ' . $AppUI->getPref('TIMEFORMAT')); $today_date_stamp = strtotime($today_mile); // honour the choice to show task names only/////////////////////////////////////////////////// if ($showTaskNameOnly == '1') { $fieldArray = array($name); } else { if ($caller == 'todo') { $fieldArray = array($name, $pname, '', $s, $s); } else { $fieldArray = array($name, '', $s, $s); } } /////////////////////////////////////////////////////////////////////////////////////// //set color for milestone according to progress //red for 'not started' #990000
public function store() { $stored = false; $q = $this->_getQuery(); if (!$this->event_recurs) { $this->event_times_recuring = 0; } else { //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date //so that the event starts recurring from the start day onwards n times after the start date for the period given //Meaning: The event end date day is useless as far as recurring events are concerned. $start_date = new w2p_Utilities_Date($this->event_start_date); $end_date = new w2p_Utilities_Date($this->event_end_date); $hour = $end_date->getHour(); $minute = $end_date->getMinute(); $end_date->setDate($start_date->getDate()); $end_date->setHour($hour); $end_date->setMinute($minute); $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL); } // ensure changes to check boxes and select lists are honoured $this->event_private = (int) $this->event_private; $this->event_type = (int) $this->event_type; $this->event_cwd = (int) $this->event_cwd; $this->event_start_date = $this->_AppUI->convertToSystemTZ($this->event_start_date); $this->event_end_date = $this->_AppUI->convertToSystemTZ($this->event_end_date); /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->{$this->_tbl_key} && $this->canEdit()) { $this->event_updated = $q->dbfnNowWithTZ(); $stored = parent::store(); } if (0 == $this->{$this->_tbl_key} && $this->canCreate()) { $this->event_created = $q->dbfnNowWithTZ(); $this->event_updated = $this->event_created; $stored = parent::store(); } return $stored; }