예제 #1
0
 /**
  * Head for row
  * @param int $index
  * @return string
  */
 protected function rowHead($index)
 {
     $year = $this->Mode == self::MODE_YEAR ? $this->Year : date('Y');
     $month = date('m', $this->TimeEnd - ($index + 0.5) * 31 * DAY_IN_S);
     $start = mktime(0, 0, 1, $month, 1, $year);
     $end = mktime(23, 59, 59, $month + 1, 0, $year);
     return DataBrowserLinker::link(Time::month($month), $start, $end, '');
 }
예제 #2
0
 /**
  * Get X labels
  * @return array
  */
 protected function getXLabels()
 {
     $months = array();
     $add = $this->Year == parent::LAST_6_MONTHS || $this->Year == parent::LAST_12_MONTHS ? date('m') : 0;
     $i = 0;
     for ($m = $this->timerStart; $m <= $this->timerEnd; $m++) {
         $months[] = array($i, Time::month($m + $add, true));
         $i++;
     }
     return $months;
 }
예제 #3
0
 /**
  * Get X labels
  * @return array
  */
 protected function getXLabels()
 {
     $weeks = array();
     $add = $this->Year == parent::LAST_6_MONTHS || $this->Year == parent::LAST_12_MONTHS ? 0 : $this->WeekStart->phpWeek() - $this->timerEnd;
     for ($w = $this->timerStart; $w <= $this->timerEnd; $w++) {
         $time = strtotime($this->WeekStart->lastDayOfWeekForStrtotime() . " -" . ($this->timerEnd - $w + $add) . " weeks");
         $string = date("d", $time) <= 7 ? Time::month(date("m", $time), true) : '';
         if ($string != '' && date("m", $time) == 1) {
             $string .= ' \'' . date("y", $time);
         }
         $weeks[] = array($w - $this->timerStart, $string);
     }
     return $weeks;
 }
예제 #4
0
파일: class.HTML.php 프로젝트: 9x/Runalyze
 /**
  * Get a tr-tag for a bold header-line containing all month-names
  * @param int $fixedWidth Fixed width for every month-td in percent [set '0' for no fixed width]
  * @param int $emptyTDs Number of empty td before the month-td
  * @return string
  */
 public static function monthTR($fixedWidth = 0, $emptyTDs = 1, $tag = 'td')
 {
     $width = $fixedWidth > 0 ? ' width="' . $fixedWidth . '%"' : '';
     $html = '<tr class="b">';
     for ($i = 1; $i <= $emptyTDs; $i++) {
         $html .= '<' . $tag . '></' . $tag . '>';
     }
     for ($m = 1; $m <= 12; $m++) {
         $html .= '<' . $tag . $width . '>' . Time::month($m, true) . '</' . $tag . '>';
     }
     $html .= '</tr>';
     return $html;
 }
예제 #5
0
 /**
  * Display title
  */
 protected function displayTitle()
 {
     $timeForLinks = $this->timestamp_start < time() && time() < $this->timestamp_end ? time() : $this->timestamp_start;
     echo DataBrowserLinker::monthLink(Time::month(date("m", $timeForLinks)), $timeForLinks) . ', ';
     echo DataBrowserLinker::yearLink(date("Y", $timeForLinks), $timeForLinks) . ', ';
     echo DataBrowserLinker::weekLink(date("W", $timeForLinks) . '. ' . __('week'), $timeForLinks);
 }
예제 #6
0
 /**
  * Display title
  */
 protected function displayTitle()
 {
     $timeForLinks = $this->TimestampStart < time() && time() < $this->TimestampEnd ? time() : $this->TimestampStart;
     echo DataBrowserLinker::monthLink(Time::month(date("m", $timeForLinks)), $timeForLinks) . ', ';
     echo DataBrowserLinker::yearLink(date("Y", $timeForLinks), $timeForLinks) . ', ';
     echo DataBrowserLinker::weekLink(Configuration::General()->weekStart()->phpWeek($timeForLinks) . '. ' . __('week'), $timeForLinks);
 }
예제 #7
0
<?php

/**
 * Draw weather-plot
 * Call:   include 'Plot.Average.php'
 * @package Runalyze\Plugins\Stats
 */
use Runalyze\Util\Time;
use Runalyze\Activity\Temperature;
$Temperature = new Temperature();
$Months = array();
$Temperatures = array();
for ($m = 1; $m <= 12; $m++) {
    $Months[] = array($m - 1, Time::month($m, true));
    for ($y = START_YEAR, $n = date('Y'); $y <= $n; $y++) {
        $Temperatures[$y] = array(null, null, null, null, null, null, null, null, null, null, null, null);
    }
}
$Query = '
	SELECT
		YEAR(FROM_UNIXTIME(`time`)) as `y`,
		MONTH(FROM_UNIXTIME(`time`)) as `m`,
		AVG(`temperature`) as `temp`
	FROM `' . PREFIX . 'training`
	WHERE
		!ISNULL(`temperature`)
	GROUP BY `y`, `m`
	ORDER BY `y` ASC, `m` ASC';
$Data = DB::getInstance()->query($Query)->fetchAll();
foreach ($Data as $dat) {
    $Temperatures[$dat['y']][$dat['m'] - 1] = $Temperature->format((int) $dat['temp'], false);
예제 #8
0
 /**
  * Display table head
  */
 protected function displayHead()
 {
     echo '<table class="fullwidth zebra-style r">';
     echo '<thead>';
     echo '<th></th>';
     for ($i = 1; $i <= 12; $i++) {
         echo '<th width="7.5%">' . Time::month(($i + $this->MonthOffsetForHeader) % 12 + 1, true) . '</th>';
     }
     echo '</thead>';
     echo '<tbody>';
 }
 /**
  * Display an empty th and ths for chosen years/months
  * @param bool $prependEmptyTag
  * @param string $width
  */
 protected function displayTableHeadForTimeRange($prependEmptyTag = true, $width = '8%')
 {
     echo '<th></th>';
     $width = ' width="' . $width . '"';
     $num = $this->showsLast6Months() ? 6 : 12;
     $add = $this->showsTimeRange() ? date('m') - $num - 1 + 12 : -1;
     for ($i = 1; $i <= 12; $i++) {
         echo '<th' . $width . '>' . Time::month(($i + $add) % 12 + 1, true) . '</th>';
     }
 }
 /**
  * Display the table with most kilometer for each year/month/week
  */
 private function displayMostKilometer()
 {
     echo '<table class="fullwidth zebra-style">';
     echo '<thead><tr><th colspan="11" class="l">' . __('Most kilometers') . '</th></tr></thead>';
     echo '<tbody>';
     if (empty($this->weeks)) {
         echo '<tr><td colspan="11"><em>' . __('No data available') . '</em></td></tr>';
         echo HTML::spaceTR(11);
         echo '</tbody>';
         echo '</table>';
         return;
     }
     // Years
     if ($this->year == -1) {
         echo '<tr class="r"><td class="c b">' . __('per year') . '</td>';
         foreach ($this->years as $i => $year) {
             $link = DataBrowserLinker::link(Distance::format($year['km']), mktime(0, 0, 0, 1, 1, $year['year']), mktime(23, 59, 50, 12, 31, $year['year']));
             echo '<td class="small"><span title="' . $year['year'] . '">' . $link . '</span></td>';
         }
         for (; $i < 9; $i++) {
             echo HTML::emptyTD();
         }
         echo '</tr>';
     }
     // Months
     echo '<tr class="r"><td class="c b">' . __('per month') . '</td>';
     foreach ($this->months as $i => $month) {
         $link = DataBrowserLinker::link(Distance::format($month['km']), mktime(0, 0, 0, $month['month'], 1, $month['year']), mktime(23, 59, 50, $month['month'] + 1, 0, $month['year']));
         echo '<td class="small"><span title="' . Time::month($month['month']) . ' ' . $month['year'] . '">' . $link . '</span></td>';
     }
     for (; $i < 9; $i++) {
         echo HTML::emptyTD();
     }
     echo '</tr>';
     // Weeks
     echo '<tr class="r"><td class="c b">' . __('per week') . '</td>';
     foreach ($this->weeks as $i => $week) {
         $link = DataBrowserLinker::link(Distance::format($week['km']), Time::weekstart($week['time']), Time::weekend($week['time']));
         echo '<td class="small"><span title="' . __('Week') . ' ' . $week['week'] . ' ' . $week['year'] . '">' . $link . '</span></td>';
     }
     for (; $i < 9; $i++) {
         echo HTML::emptyTD();
     }
     echo '</tr>';
     echo '</tbody>';
     echo '</table>';
 }
예제 #11
0
 /**
  * Display an empty th and ths for chosen years/months
  * @param bool $prependEmptyTag
  * @param string $width
  */
 protected function displayTableHeadForTimeRange($prependEmptyTag = true, $width = '8%')
 {
     if ($prependEmptyTag) {
         echo '<th></th>';
     }
     if (!empty($width)) {
         $width = ' width="' . $width . '"';
     }
     if ($this->showsAllYears()) {
         $year = date('Y');
         for ($i = START_YEAR; $i <= $year; $i++) {
             echo '<th' . $width . '>' . $i . '</th>';
         }
         echo '<th>' . __('In total') . '</th>';
     } else {
         $num = $this->showsLast6Months() ? 6 : 12;
         $add = $this->showsTimeRange() ? date('m') - $num - 1 + 12 : -1;
         for ($i = 1; $i <= 12; $i++) {
             echo '<th' . $width . '>' . Time::month(($i + $add) % 12 + 1, true) . '</th>';
         }
     }
 }