/** * Construct new input field for: weather * @param string $name * @param string $label * @param string $value optional, default: loading from $_POST */ public function __construct($name, $label, $value = '') { parent::__construct($name, $label, $value); $Condition = new Condition(0); foreach (Condition::completeList() as $id) { $Condition->set($id); $this->addOption($id, $Condition->string()); } }
/** * Display month-table for weather */ private function displayMonthTableWeather() { $Condition = new Weather\Condition(0); $Statement = DB::getInstance()->prepare('SELECT SUM(1) as `num`, ' . $this->getTimerIndexForQuery() . ' as `m` FROM `' . PREFIX . 'training` WHERE `sportid`=? AND `weatherid`=? ' . $this->getYearDependenceForQuery() . ' GROUP BY ' . $this->getTimerIndexForQuery() . ' ORDER BY ' . $this->getTimerForOrderingInQuery() . ' ASC LIMIT 12'); foreach (Weather\Condition::completeList() as $id) { $Condition->set($id); $Statement->execute(array(Configuration::General()->mainSport(), $id)); $data = $Statement->fetchAll(); $i = 1; echo '<tr><td>' . $Condition->icon()->code() . '</td>'; if (!empty($data)) { foreach ($data as $dat) { for (; $i < $dat['m']; $i++) { echo HTML::emptyTD(); } $i++; echo $dat['num'] != 0 ? '<td>' . $dat['num'] . 'x</td>' : HTML::emptyTD(); } for (; $i <= 12; $i++) { echo HTML::emptyTD(); } } else { echo HTML::emptyTD(12); } } echo '</tr>'; }
/** * @return array */ protected function generateDataForWeatherConditions() { $Rows = array(); $Condition = new Weather\Condition(0); $Statement = $this->createStatementToFetchWeatherConditions(); foreach (Weather\Condition::completeList() as $id) { if ($id == Weather\Condition::UNKNOWN) { continue; } $Statement->execute(array($id)); $Condition->set($id); $rowData = array(); foreach ($Statement->fetchAll() as $data) { $rowData[$data['m']] = $data['num'] . 'x'; } $Rows[$Condition->icon()->code()] = $rowData; } return $Rows; }