/** * 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()); } }
/** * Clear weather */ public function clear() { $this->Temperature->setTemperature(null); $this->Condition->set(Condition::UNKNOWN); $this->WindSpeed->set(null); $this->WindDegree->set(null); $this->Humidity->set(null); $this->Pressure->set(null); }
/** * 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>'; }
/** * Display statistics for weather */ private function displayWeatherStatistics() { $Condition = new Weather\Condition(0); $Strings = array(); $Weather = DB::getInstance()->query('SELECT SUM(1) as num, weatherid FROM `' . PREFIX . 'training` WHERE `typeid`=' . Configuration::General()->competitionType() . ' AND `weatherid`!=' . Weather\Condition::UNKNOWN . ' AND `accountid` = ' . SessionAccountHandler::getId() . ' GROUP BY `weatherid` ORDER BY `weatherid` ASC')->fetchAll(); foreach ($Weather as $W) { $Condition->set($W['weatherid']); $Strings[] = $W['num'] . 'x ' . $Condition->icon()->code(); } if (!empty($Strings)) { echo '<strong>' . __('Weather statistics') . ':</strong> '; echo implode(', ', $Strings); echo '<br><br>'; } }
/** * Is the weather-data empty? * @return bool */ public function isEmpty() { return $this->Temperature->isUnknown() && $this->Condition->isUnknown() && $this->WindSpeed->isUnknown() && $this->WindDegree->isUnknown() && $this->Humidity->isUnknown() && $this->Pressure->isUnknown(); }
/** * @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; }
/** * Is the weather-data empty? * @return bool */ public function isEmpty() { return $this->Temperature->isUnknown() && $this->Condition->isUnknown(); }