Example #1
0
 public function testFilterTasks()
 {
     $tasks = array(array('project' => 'Project 1', 'name' => 'hello world', 'asignee' => 'someone 1', 'startDate' => strtotime('2015-10-01'), 'workload' => 5), array('project' => 'Project 1', 'name' => 'hello world 2', 'asignee' => 'someone 2', 'startDate' => strtotime('2015-10-05'), 'workload' => 10), array('project' => 'Project 2', 'name' => 'hello world 3', 'asignee' => 'someone 3', 'dependency' => 'afterPrevious', 'workload' => 10));
     $nonBusinessdays = array(strtotime('2015-10-02'));
     $filters = array('project' => 'Project 2');
     $gantt = new PhpGantt($tasks, $nonBusinessdays);
     $actual = $gantt->filterTasks($tasks, $filters);
     $expected = array(array('project' => 'Project 2', 'name' => 'hello world 3', 'asignee' => 'someone 3', 'dependency' => 'afterPrevious', 'workload' => 10));
     $this->assertSame($expected, $actual);
 }
Example #2
0
 public function testBuildTableHeader()
 {
     $nonBusinessdays = array(strtotime('2016-07-04'));
     $dateUtil = new DateUtil($nonBusinessdays, array(0, 6));
     $htmlBuilder = new HtmlBuilder($dateUtil);
     $tasks = array(array('project' => 'Project 1', 'name' => 'hello world 2', 'asignee' => 'someone 1', 'startDate' => strtotime('2016-07-01'), 'workload' => 3), array('project' => 'Project 2', 'name' => 'hello world 3', 'asignee' => 'someone 2', 'dependency' => 'afterPrevious', 'workload' => 3));
     $phpgantt = new PhpGantt($tasks, $nonBusinessdays);
     $tasks = $phpgantt->resolveDependency($tasks);
     $html = $htmlBuilder->buildTableHeader($phpgantt->dates, $tasks);
     $actual = substr_count($html, 'project_name');
     $expected = 5;
     $this->assertSame($actual, $expected);
 }
Example #3
0
<?php

require 'vendor/autoload.php';
use DateRange\DateRange;
use PhpGantt\PhpGantt;
$tasks = [['project' => 'Project 1', 'name' => 'hello world', 'startDate' => strtotime('2015-10-01'), 'assignee' => 'someone1', 'workload' => 5], ['project' => 'Project 1', 'name' => 'hello world 2', 'startDate' => strtotime('2015-10-05'), 'assignee' => 'someone2', 'workload' => 10], ['project' => 'Project 2', 'name' => 'hello world 3', 'dependency' => 'afterPrevious', 'assignee' => 'someone3', 'workload' => 15], ['project' => 'Project 2', 'name' => 'hello world 3', 'dependency' => 'afterPrevious', 'assignee' => 'someone2', 'workload' => 15]];
$nonBusinessdays = [strtotime('2015-10-02'), strtotime('2015-10-06'), strtotime('2015-10-20'), strtotime('2015-11-23'), strtotime('2015-11-24')];
$gantt = new PhpGantt($tasks, $nonBusinessdays);
?>

<html>
<head>
  <meta charset="utf-8" />
  <?php 
$gantt->cssRenderer->render();
?>
  <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
  <?php 
$gantt->jsRenderer->render();
?>
</head>
<body>
<?php 
$gantt->render();
?>
</body>
</html>