/**
  * 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());
     }
 }
예제 #2
0
 /**
  * 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>';
     }
 }
예제 #5
0
파일: Weather.php 프로젝트: rob-st/Runalyze
 /**
  * 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();
 }
예제 #6
0
 /**
  * @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;
 }
예제 #7
0
 /**
  * Is the weather-data empty?
  * @return bool
  */
 public function isEmpty()
 {
     return $this->Temperature->isUnknown() && $this->Condition->isUnknown();
 }