/** * Display table body */ protected function displayTableBody() { $maxIndex = ceil(($this->TimeEnd - $this->TimeStart) / $this->Timerange) - 1; $CompleteData = array(); $CompleteResult = $this->DatasetQuery->fetchSummaryForTimerange($this->Sportid, $this->Timerange, $this->TimeStart, $this->TimeEnd); $Context = new Dataset\Context(new Runalyze\Model\Activity\Entity(), $this->AccountID); $hiddenKeys = array(Dataset\Keys::SPORT); foreach ($CompleteResult as $Data) { $CompleteData[$Data['timerange']] = $Data; } for ($index = 0; $index <= $maxIndex; ++$index) { echo '<tr><td class="l"><span class="b">' . $this->rowHead($index) . '</span></td>'; if (isset($CompleteData[$index]) && !empty($CompleteData[$index])) { echo '<td class="small">' . $CompleteData[$index]['num'] . 'x</td>'; $this->displayAdditionalColumns($CompleteData[$index]); if ($this->CompareKilometers) { $value = isset($CompleteData[$index + 1]) ? $CompleteData[$index + 1]['distance'] : 0; $CompleteData[$index][Dataset\Keys\Distance::KEY_DISTANCE_COMPARISON] = $value; } $Context->setActivityData($CompleteData[$index]); echo $this->DatasetTable->codeForColumns($Context, $hiddenKeys); } else { echo HTML::emptyTD($this->DatasetTable->numColumns() + 1 + $this->AdditionalColumns, '<em>' . __('No activities') . '</em>', 'c small'); } echo '</tr>'; } }
/** * Init all days for beeing displayed */ protected function initDays() { $this->initShortModes(); $this->initEmptyDays(); $Statement = $this->DatasetQuery->statementToFetchActivities($this->TimestampStart, $this->TimestampEnd); while ($Training = $Statement->fetch()) { $w = Time::diffInDays($Training['time'], $this->TimestampStart); if (in_array($Training['sportid'], $this->SportsShort) || in_array($Training['typeid'], $this->TypesShort)) { $this->Days[$w]['shorts'][] = $Training; } else { $this->Days[$w]['trainings'][] = $Training; } } }
/** * Search trainings */ protected function searchTrainings() { $this->TotalNumberOfTrainings = DB::getInstance()->query('SELECT COUNT(*) FROM `' . PREFIX . 'training` AS `t` ' . $this->getWhere() . $this->getOrder() . ' LIMIT 1')->fetchColumn(); $this->Page = (int) Request::param('page'); if (($this->Page - 1) * $this->ResultsPerPage > $this->TotalNumberOfTrainings) { $this->Page--; } $this->DatasetQuery->resetJoins(); $this->Trainings = DB::getInstance()->query('SELECT DISTINCT `t`.`id`, `t`.`time` ' . ($this->multiEditorRequested() ? '' : ', ' . $this->DatasetQuery->queryToSelectAllKeys() . ' ' . $this->DatasetQuery->queryToSelectJoinedFields()) . ' FROM `' . PREFIX . 'training` AS `t` ' . $this->DatasetQuery->queryToJoinTables() . ' ' . $this->getWhere() . ' ' . $this->DatasetQuery->queryToGroupByActivity() . $this->getOrder() . $this->getLimit())->fetchAll(); }