/**
     * Display the images
     */
    private function displayTable()
    {
        if ($this->sportid > 0) {
            $sports_not_short = $this->sportid . ',';
        } else {
            $sports_not_short = '';
            $sports = DB::getInstance()->query('SELECT `id` FROM `' . PREFIX . 'sport` WHERE `short`=0 AND `accountid` = ' . SessionAccountHandler::getId())->fetchAll();
            foreach ($sports as $sport) {
                $sports_not_short .= $sport['id'] . ',';
            }
        }
        $nights = DB::getInstance()->query('SELECT * FROM (
			SELECT
				id,
				time,
				s,
				sportid,
				distance,
				is_track,
				HOUR(FROM_UNIXTIME(`time`)) as `H`,
				MINUTE(FROM_UNIXTIME(`time`)) as `MIN`
			FROM `' . PREFIX . 'training`
			WHERE
				`sportid` IN(' . substr($sports_not_short, 0, -1) . ') AND
                                `accountid` = ' . SessionAccountHandler::getId() . ' AND
				(HOUR(FROM_UNIXTIME(`time`))!=0 OR MINUTE(FROM_UNIXTIME(`time`))!=0) 
				' . $this->getYearDependenceForQuery() . '
			ORDER BY
				ABS(12-(`H`+10)%24-`MIN`/60) ASC,
				`MIN` DESC LIMIT 20
			) t
		ORDER BY
			(`H`+12)%24 ASC,
			`MIN` ASC')->fetchAll();
        if (empty($nights)) {
            $this->dataIsMissing = true;
            return;
        }
        echo '<table class="fullwidth zebra-style">';
        echo '<thead><tr class="b c"><th colspan="8">' . __('Nightly activities') . '</th></tr></thead>';
        echo '<tbody>';
        foreach ($nights as $i => $data) {
            $Activity = new Activity\Entity($data);
            $Linker = new Linker($Activity);
            $View = new Dataview($Activity);
            if ($i % 2 == 0) {
                echo '<tr">';
            }
            echo '<td class="b">' . $View->daytime() . '</td>
				<td>' . $Linker->linkWithSportIcon() . '</td>
				<td>' . $View->distanceOrDuration() . ' ' . SportFactory::name($Activity->sportid()) . '</td>
				<td>' . $Linker->weekLink() . '</td>';
            if ($i % 2 == 1) {
                echo '</tr>';
            }
        }
        echo '</tbody></table>';
        // TODO: Find a better description.
        echo '<p class="text">';
        echo __('2 a.m. is considered as <em>most extreme</em> time for a training. ');
        echo __('The 20 trainings being nearest to that time are listed.');
        echo '</p>';
    }
Esempio n. 2
0
 /**
  * Get sport as string
  * @return string
  */
 protected function getSportString()
 {
     return $this->sportid == -1 ? __('All') : SportFactory::name($this->sportid);
 }