Example #1
0
 public static function createTextBasedBurndownChart($bible, $year, $month)
 {
     // Number of days in the month for on the X-axis.
     $time = mktime(0, 0, 0, $month, 15, $year);
     $days_in_month = date("t", $time);
     // Assemble history of this sprint.
     $database_sprint = Database_Sprint::getInstance();
     $history = $database_sprint->getHistory($bible, $year, $month);
     $data = array();
     for ($day = 1; $day <= $days_in_month; $day++) {
         if (Filter_Datetime::isBusinessDay($year, $month, $day)) {
             $data[$day] = "";
             foreach ($history as $item) {
                 if ($day == $item['day']) {
                     $tasks = $item['tasks'];
                     $complete = $item['complete'];
                     $tasks = $tasks * (100 - $complete) / 100;
                     $tasks = intval($tasks);
                     $data[$day] = $tasks;
                 }
             }
         }
     }
     unset($item);
     $lines = array();
     $lines[] = '<table style="text-align:center;">';
     $lines[] = '<tr style="vertical-align: bottom;">';
     foreach ($data as $day => $tasks) {
         $text = str_repeat("▓<br>", intval($tasks));
         $lines[] = "<td>{$text}</td>";
     }
     $lines[] = "</tr>";
     // Write number of days along the x-axis.
     $lines[] = '<tr>';
     foreach ($data as $day => $tasks) {
         $lines[] = "<td style=\"width:1em\">{$day}</td>";
     }
     $lines[] = "</tr>";
     // Write "days" below the x-axis.
     $lines[] = '<tr>';
     $columncount = count($data);
     $text = Locale_Translate::_("days");
     $lines[] = "<td colspan=\"{$columncount}\">{$text}</td>";
     $lines[] = "</tr>";
     $lines[] = "</table>";
     $chart = implode("\n", $lines);
     return $chart;
 }
Example #2
0
 public function testIsBusinessDay()
 {
     $this->assertFalse(Filter_Datetime::isBusinessDay(2013, 9, 1));
     $this->assertTrue(Filter_Datetime::isBusinessDay(2013, 9, 2));
     $this->assertTrue(Filter_Datetime::isBusinessDay(2013, 9, 3));
     $this->assertTrue(Filter_Datetime::isBusinessDay(2013, 9, 4));
     $this->assertTrue(Filter_Datetime::isBusinessDay(2013, 9, 5));
     $this->assertTrue(Filter_Datetime::isBusinessDay(2013, 9, 6));
     $this->assertFalse(Filter_Datetime::isBusinessDay(2013, 9, 7));
     $this->assertFalse(Filter_Datetime::isBusinessDay(2013, 9, 8));
     $this->assertTrue(Filter_Datetime::isBusinessDay(2013, 9, 30));
 }