Example #1
0
 public function testMerge()
 {
     $dateRange = new DateRange(strtotime('2015-10-01'), strtotime('2015-10-05'));
     $target = new DateRange(strtotime('2015-10-03'), strtotime('2015-10-07'));
     $actual = $dateRange->merge($target);
     $this->assertSame(strtotime('2015-10-01'), $actual->startDate);
     $this->assertSame(strtotime('2015-10-07'), $actual->endDate);
     $target = new DateRange(strtotime('2015-10-08'), strtotime('2015-10-10'));
     $actual = $dateRange->merge($target);
     $this->assertSame(strtotime('2015-10-01'), $actual->startDate);
     $this->assertSame(strtotime('2015-10-10'), $actual->endDate);
 }
Example #2
0
 public function buildTableBody($dates, $tasks)
 {
     $html = '';
     $html .= '<div class="table_body_wrapper">';
     $html .= '<table class="table_body">' . PHP_EOL;
     $html .= '<tbody>' . PHP_EOL;
     $html .= '<tr>' . PHP_EOL;
     foreach ($dates as $date) {
         $html .= '<td class="cell_header' . $this->getBusinessDayClass($date) . '">' . date('m', $date) . '</td>' . PHP_EOL;
     }
     $html .= '</tr>' . PHP_EOL;
     $html .= '<tr>' . PHP_EOL;
     foreach ($dates as $date) {
         $html .= '<td class="cell_header' . $this->getBusinessDayClass($date) . '">' . date('d', $date) . '</td>' . PHP_EOL;
     }
     $html .= '</tr>' . PHP_EOL;
     $html .= '<tr>' . PHP_EOL;
     foreach ($dates as $date) {
         $html .= '<td class="cell_header' . $this->getBusinessDayClass($date) . '">' . $this->dateUtil->days[date('w', $date)] . '</td>' . PHP_EOL;
     }
     $html .= '</tr>' . PHP_EOL;
     // Build row of gantt.
     foreach ($tasks as $task) {
         $taskDateRange = new DateRange($task['startDate'], strtotime('+ ' . ($task['workload'] - 1) . ' day', $task['startDate']));
         $taskDates = $this->dateUtil->removeNonBusinessdays($taskDateRange->extract());
         foreach ($dates as $date) {
             if ($this->dateUtil->isToday($date)) {
                 $class_for_today = ' today';
             } else {
                 $class_for_today = '';
             }
             if (in_array($date, $taskDates)) {
                 $html .= '<td class="cell filled' . $this->getBusinessDayClass($date) . $class_for_today . '">' . $this->marker . '</td>' . PHP_EOL;
             } else {
                 $html .= '<td class="cell' . $this->getBusinessDayClass($date) . $class_for_today . '"></td>' . PHP_EOL;
             }
         }
         $html .= '</tr>' . PHP_EOL;
     }
     $html .= '</tbody>' . PHP_EOL;
     $html .= '</table>' . PHP_EOL;
     $html .= '</div>' . PHP_EOL;
     return $html;
 }
Example #3
0
 public function extractDates($tasks)
 {
     if (!is_array($this->dates)) {
         $this->dates = array();
     }
     foreach ($tasks as $task) {
         $dateRange = new DateRange($task['startDate'], strtotime('+ ' . ($task['workload'] - 1) . ' day', $task['startDate']));
         $businessDays = $this->dateUtil->removeNonBusinessdays($dateRange->extract());
         $results = array_merge($this->dates, $businessDays);
         foreach ($results as $result) {
             $this->dates[] = $result;
         }
     }
 }