/** * Display the table with summed data for every month */ private function displayData() { echo '<table class="fullwidth zebra-style r">'; echo '<thead>' . HTML::monthTr(8, 1) . '</thead>'; echo '<tbody>'; if (empty($this->ABCData)) { echo '<tr><td colspan="13" class="c"><em>' . __('No activities with running drills found.') . '</em></td></tr>'; } foreach ($this->ABCData as $y => $Data) { echo '<tr><td class="b l">' . $y . '</td>'; for ($m = 1; $m <= 12; $m++) { if (isset($Data[$m]) && $Data[$m]['num'] > 0) { echo '<td title="' . $Data[$m]['num'] . 'x">' . round(100 * $Data[$m]['abc'] / $Data[$m]['num']) . ' %</td>'; } else { echo HTML::emptyTD(); } } echo '</tr>'; } echo '</tbody></table>'; }
/** * Display table for clothes */ private function displayClothesTable() { if (!$this->Configuration()->value('for_clothes')) { return; } echo '<table class="fullwidth zebra-style"> <thead><tr> <th></th> <th>' . __('Temperatures') . '</th> <th>Ø</th> <th colspan="2"></th> <th>' . __('Temperatures') . '</th> <th>Ø</th> <th colspan="2"></th> <th>' . __('Temperatures') . '</th> <th>Ø</th> </tr></thead>'; echo '<tr class="r">'; $ClothesQuery = DB::getInstance()->prepare('SELECT AVG(`temperature`) as `avg`, MAX(`temperature`) as `max`, MIN(`temperature`) as `min` FROM `' . PREFIX . 'training` WHERE `temperature` IS NOT NULL AND FIND_IN_SET(:id,`clothes`) != 0 ' . $this->getSportAndYearDependenceForQuery()); $i = 0; if (!empty($this->Clothes)) { foreach ($this->Clothes as $kleidung) { echo $i % 3 == 0 ? '</tr><tr class="r">' : '<td> </td>'; $ClothesQuery->execute(array(':id' => $kleidung['id'])); $dat = $ClothesQuery->fetch(); echo '<td class="l">' . $kleidung['name'] . '</td>'; if (isset($dat['min'])) { echo '<td>' . $dat['min'] . '°C ' . __('to') . ' ' . $dat['max'] . '°C</td>'; echo '<td>' . round($dat['avg']) . '°C</td>'; } else { echo '<td colspan="2" class="c"><em>-</em></td>'; } $i++; } } for (; $i % 3 != 2; $i++) { echo HTML::emptyTD(3); } echo '</tr>'; echo '</table>'; }
/** * Get fieldset for VDOT * @return \FormularFieldset */ public function getFieldsetVDOT() { $Table = '<table class="fullwidth zebra-style"> <thead> <tr> <th colspan="10">' . sprintf(__('VDOT values of the last %s days'), Configuration::Vdot()->days()) . '</th> </tr> </thead> <tbody class="top-and-bottom-border">'; $Tooltip = new Tooltip(''); $VDOT = new VDOT(0, new VDOTCorrector(Configuration::Data()->vdotFactor())); $VDOTs = DB::getInstance()->query('SELECT `id`,`time`,`distance`,IF(`vdot_with_elevation`>0,`vdot_with_elevation`,`vdot`) as `vdot` FROM `' . PREFIX . 'training` WHERE time>=' . (time() - Configuration::Vdot()->days() * DAY_IN_S) . ' AND vdot>0 AND use_vdot=1 AND accountid = ' . SessionAccountHandler::getId() . ' ORDER BY time ASC')->fetchAll(); foreach ($VDOTs as $i => $Data) { if ($i % 10 == 0) { $Table .= '<tr>'; } $Tooltip->setText(date('d.m.Y', $Data['time']) . ': ' . Distance::format($Data['distance'])); $VDOT->setValue($Data['vdot']); $Table .= '<td ' . $Tooltip->attributes() . '>' . Ajax::trainingLink($Data['id'], $VDOT->value()) . '</td>'; if ($i % 10 == 9) { $Table .= '</tr>'; } } if (count($VDOTs) % 10 != 0) { $Table .= HTML::emptyTD(10 - count($VDOTs) % 10); } $Table .= '</tbody></table>'; $Fieldset = new FormularFieldset(__('VDOT')); $Fieldset->addBlock(sprintf(__('The VDOT value is the average, weighted by the time, of the VDOT of your activities in the last %s days.'), Configuration::Vdot()->days())); $Fieldset->addBlock(sprintf(__('Your current VDOT shape: <strong>%s</strong><br> '), Configuration::Data()->vdot())); $Fieldset->addBlock($Table); $Fieldset->addInfo(__('Jack Daniels uses VDOT as a fixed value and not based on the training progress.<br>' . 'We do instead predict the VDOT from all activities based on the heart rate. ' . 'These formulas are derived from Jack Daniels\' tables as well.')); return $Fieldset; }
/** * Display the table with summed data for every month */ private function displayData() { echo '<table class="analysis-table fullwidth zebra-style r">'; echo '<thead>' . HTML::monthTr(8, 1) . '</thead>'; echo '<tbody>'; if (empty($this->KmData)) { echo '<tr><td colspan="13" class="c"><em>' . __('No activities found.') . '</em></td></tr>'; } foreach ($this->KmData as $y => $Data) { echo '<tr><td class="b l">' . $y . '</td>'; for ($m = 1; $m <= 12; $m++) { if (isset($Data[$m])) { if ($this->dat == 'km') { echo '<td title="' . Distance::format($Data[$m]['distance']) . '">' . Distance::format($Data[$m]['distance']) . $this->getCircleFor(100 * $Data[$m]['distance'] / $this->maxKm) . '</td>'; //echo '<td style="vertical-align: bottom;">' . $tooltip . $circle . '</td>'; } else { if ($this->dat == 's') { echo '<td title="' . $Data[$m]['s'] . '">' . Duration::format($Data[$m]['s']) . $this->getCircleFor(100 * $Data[$m]['s'] / $this->maxs) . '</td>'; } else { if ($this->dat == 'em') { echo '<td title="' . Elevation::format($Data[$m]['elevation']) . '">' . Elevation::format($Data[$m]['elevation']) . $this->getCircleFor(100 * $Data[$m]['elevation'] / $this->maxEm) . '</td>'; } else { if ($this->dat == 'kcal') { echo '<td title="' . $Data[$m]['kcal'] . ' kcal">' . $Data[$m]['kcal'] . ' kcal' . $this->getCircleFor(100 * $Data[$m]['kcal'] / $this->maxKcal) . '</td>'; } else { if ($this->dat == 'trimp') { echo '<td title="' . $Data[$m]['trimp'] . '">' . $Data[$m]['trimp'] . $this->getCircleFor(100 * $Data[$m]['trimp'] / $this->maxTrimp) . '</td>'; } else { if ($this->dat == 'n') { echo '<td title="' . $Data[$m]['n'] . '">' . $Data[$m]['n'] . $this->getCircleFor(100 * $Data[$m]['n'] / $this->maxN) . '</td>'; } } } } } } } else { echo HTML::emptyTD(); } } echo '</tr>'; } echo '</tbody></table>'; }
/** * Display the table with most kilometer for each year/month/week */ private function displayMostKilometer() { echo '<table class="fullwidth zebra-style">'; echo '<thead><tr><th colspan="11" class="l">' . __('Most kilometers') . '</th></tr></thead>'; echo '<tbody>'; if (empty($this->weeks)) { echo '<tr><td colspan="11"><em>' . __('No data available') . '</em></td></tr>'; echo HTML::spaceTR(11); echo '</tbody>'; echo '</table>'; return; } // Years if ($this->year == -1) { echo '<tr class="r"><td class="c b">' . __('per year') . '</td>'; foreach ($this->years as $i => $year) { $link = DataBrowserLinker::link(Distance::format($year['km']), mktime(0, 0, 0, 1, 1, $year['year']), mktime(23, 59, 50, 12, 31, $year['year'])); echo '<td class="small"><span title="' . $year['year'] . '">' . $link . '</span></td>'; } for (; $i < 9; $i++) { echo HTML::emptyTD(); } echo '</tr>'; } // Months echo '<tr class="r"><td class="c b">' . __('per month') . '</td>'; foreach ($this->months as $i => $month) { $link = DataBrowserLinker::link(Distance::format($month['km']), mktime(0, 0, 0, $month['month'], 1, $month['year']), mktime(23, 59, 50, $month['month'] + 1, 0, $month['year'])); echo '<td class="small"><span title="' . Time::Month($month['month']) . ' ' . $month['year'] . '">' . $link . '</span></td>'; } for (; $i < 9; $i++) { echo HTML::emptyTD(); } echo '</tr>'; // Weeks echo '<tr class="r"><td class="c b">' . __('per week') . '</td>'; foreach ($this->weeks as $i => $week) { $link = DataBrowserLinker::link(Distance::format($week['km']), Time::Weekstart($week['time']), Time::Weekend($week['time'])); echo '<td class="small"><span title="' . __('Week') . ' ' . $week['week'] . ' ' . $week['year'] . '">' . $link . '</span></td>'; } for (; $i < 9; $i++) { echo HTML::emptyTD(); } echo '</tr>'; echo '</tbody>'; echo '</table>'; }
/** * Display public icon */ public function displayPublicIcon() { if (!is_object($this->Activity) || !$this->Activity->isPublic()) { echo HTML::emptyTD(); } else { echo HTML::td(\Icon::$ADD_SMALL_GREEN, 'link'); } }
/** * Display most visited cities */ private function displayCities() { echo '<table style="width:25%;" class="right zebra-style">'; echo '<thead><tr><th colspan="2">' . __('Most frequent places') . '</th></tr></thead>'; echo '<tbody>'; $i = 1; if (empty($this->Cities)) { echo HTML::emptyTD(2, HTML::em(__('There are no routes.'))); } foreach ($this->Cities as $city => $num) { $i++; echo '<tr class="a' . ($i % 2 + 1) . '"> <td>' . $num . 'x</td> <td>' . SearchLink::to('route', $city, $city, 'like') . '</td> </tr>'; if ($i == 11) { break; } } echo '</tbody>'; echo '</table>'; }
/** * Display table for clothes */ private function displayClothesTable() { /*if (!$this->Configuration()->value('for_clothes')) return;*/ echo '<table class="fullwidth zebra-style"> <thead><tr> <th></th> <th>' . __('Temperatures') . '</th> <th>Ø</th> <th colspan="2"></th> <th>' . __('Temperatures') . '</th> <th>Ø</th> <th colspan="2"></th> <th>' . __('Temperatures') . '</th> <th>Ø</th> </tr></thead>'; echo '<tr class="r">'; $EquipmentQuery = DB::getInstance()->query('SELECT AVG(`temperature`) as `avg`, MAX(`temperature`) as `max`, MIN(`temperature`) as `min`, eq.equipmentid FROM `' . PREFIX . 'training` LEFT JOIN runalyze_activity_equipment eq ON id=eq.activityid WHERE eq.activityid IS NOT NULL GROUP BY eq.equipmentid ' . $this->getSportAndYearDependenceForQuery())->fetchAll(); $EquipmentsTemperatures = array(); foreach ($EquipmentQuery as $Equipment) { $EquipmentsTemperatures[$Equipment['equipmentid']] = $Equipment; } $i = 0; if (!empty($this->Equipment)) { foreach ($this->Equipment as $equipment) { echo $i % 3 == 0 ? '</tr><tr class="r">' : '<td> </td>'; echo '<td class="l">' . $equipment->name() . '</td>'; if (isset($EquipmentsTemperatures[$equipment->id()])) { $Temperatures = $EquipmentsTemperatures[$equipment->id()]; echo '<td>' . Temperature::format($Temperatures['min'], true) . ' ' . __('to') . ' ' . Temperature::format($Temperatures['max'], true) . '</td>'; echo '<td>' . Temperature::format(round($Temperatures['avg']), true) . '</td>'; } else { echo '<td colspan="2" class="c"><em>-</em></td>'; } $i++; } } for (; $i % 3 != 2; $i++) { echo HTML::emptyTD(3); } echo '</tr>'; echo '</table>'; }
/** * 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>'; } }
/** * Display table with last week-statistics * @param bool $showAllWeeks */ private function displayWeekTable($showAllWeeks = false) { if (($this->showsAllYears() || $this->showsSpecificYear() && $this->year != date('Y')) && !$showAllWeeks) { return; } $Dataset = new Dataset(); if ($this->Configuration()->value('compare_weeks')) { $Dataset->activateKilometerComparison(); } $title = $showAllWeeks ? __('All training weeks') : __('Last 10 training weeks'); echo '<table class="r fullwidth zebra-style">'; echo '<thead><tr><th colspan="' . ($Dataset->cols() + 1) . '">' . $title . '</th></tr></thead>'; echo '<tbody>'; if (!$showAllWeeks) { $starttime = time(); $maxW = 9; } else { $starttime = $this->year == date("Y") ? time() : mktime(1, 0, 0, 12, 31, $this->year); $maxW = ($starttime - mktime(1, 0, 0, 12, 31, $this->year - 1)) / (7 * DAY_IN_S); } $CompleteData = array(); $CurrentWeekEnd = Time::Weekend($starttime); $CompleteResult = $Dataset->getGroupOfTrainingsForTimerange($this->sportid, 7 * DAY_IN_S, $CurrentWeekEnd - ($maxW + 2) * 7 * DAY_IN_S, $CurrentWeekEnd); foreach ($CompleteResult as $Data) { $CompleteData[$Data['timerange']] = $Data; } for ($w = 0; $w <= $maxW; $w++) { $time = $starttime - $w * 7 * DAY_IN_S; $start = Time::Weekstart($time); $end = Time::Weekend($time); $week = Icon::$CALENDAR . ' ' . __('Week') . ' ' . date('W', $time); //echo '<tr><td class="b l"">'.DataBrowserLinker::link($week, $start, $end).'</td>'; echo '<tr><td class="l"><span class="b">' . DataBrowserLinker::link($week, $start, $end, '') . '</span> <span class="small">' . date('d.m', $start) . " - " . date('d.m', $end) . '</span></td>'; if (isset($CompleteData[$w]) && !empty($CompleteData[$w])) { $Dataset->setGroupOfTrainings($CompleteData[$w]); if (isset($CompleteData[$w + 1])) { $Dataset->setKilometerToCompareTo($CompleteData[$w + 1]['distance']); } $Dataset->displayTableColumns(); } else { echo HTML::emptyTD($Dataset->cols(), '<em>' . __('No activities') . '</em>', 'c small'); } echo '</tr>'; } echo '</tbody>'; echo '</table>'; }
/** * Display the table with summed data for every month */ private function displayData() { echo '<p><strong>' . __('Tag') . ': ' . $this->AllTags[$this->TagId] . '</p>'; echo '<table class="fullwidth zebra-style r">'; echo '<thead>' . HTML::monthTr(8, 1) . '</thead>'; echo '<tbody>'; if (empty($this->TagData)) { echo '<tr><td colspan="13" class="c"><em>' . __('No activities found.') . '</em></td></tr>'; } foreach ($this->TagData as $y => $Data) { echo '<tr><td class="b l">' . $y . '</td>'; for ($m = 1; $m <= 12; $m++) { if (isset($Data[$m]) && $Data[$m] > 0) { echo '<td>' . $Data[$m] . 'x</td>'; } else { echo HTML::emptyTD(); } } echo '</tr>'; } echo '</tbody></table>'; }
/** * Display the table with summed data for every month */ private function displayElevationData() { echo '<table class="fullwidth zebra-style r">'; echo '<thead>' . HTML::monthTr(8, 1) . '</thead>'; echo '<tbody>'; if (empty($this->ElevationData)) { echo '<tr><td colspan="13" class="l"><em>' . __('No routes found.') . '</em></td></tr>'; } foreach ($this->ElevationData as $y => $Data) { echo ' <tr> <td class="b l">' . $y . '</td>' . NL; for ($m = 1; $m <= 12; $m++) { if (isset($Data[$m]) && $Data[$m]['elevation'] > 0) { $Link = new SearchLink(); $Link->fromTo(mktime(0, 0, 0, $m, 1, $y), mktime(0, 0, 0, $m + 1, 0, $y)); $Link->sortBy('elevation'); echo '<td>' . $Link->link($Data[$m]['elevation'] . ' m') . '</td>'; } else { echo HTML::emptyTD(); } } echo '</tr>' . NL; } echo '</tbody></table>'; }
/** * 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 the analysis */ private function displayAnalysis() { if (empty($this->AnalysisData)) { echo HTML::info(__('There is no data for this sport.')); } foreach ($this->AnalysisData as $i => $Data) { if (!is_array($Data)) { continue; } $this->printTableStart($Data['name']); if (empty($Data['foreach'])) { echo '<tr class="c">' . HTML::emptyTD($this->colspan, '<em>' . __('No data available.') . '</em>') . '</tr>'; } else { foreach ($Data['foreach'] as $i => $Each) { echo '<tr><td class="c b">' . $Each['name'] . '</td>'; for ($t = $this->timer_start; $t <= $this->timer_end; $t++) { if (isset($Data['array'][$Each['id']][$t])) { $num = $Data['array'][$Each['id']][$t]['num']; $dist = $Data['array'][$Each['id']][$t]['distance']; $time = $Data['array'][$Each['id']][$t]['s']; if ($this->dat == 'km') { $percent = $Data['array']['timer_sum_km'][$t] > 0 ? round(100 * $dist / $Data['array']['timer_sum_km'][$t], 1) : 0; } else { $percent = $Data['array']['timer_sum_s'][$t] > 0 ? round(100 * $time / $Data['array']['timer_sum_s'][$t], 1) : 0; } $this->displayTDfor($num, $time, $dist, $percent); } else { echo HTML::emptyTD(); } } if (isset($Data['array']['id_sum_s'][$Each['id']])) { $num = $Data['array']['id_sum_num'][$Each['id']]; $time = $Data['array']['id_sum_s'][$Each['id']]; $dist = $Data['array']['id_sum_km'][$Each['id']]; if ($this->dat == 'km') { $percent = $Data['array']['all_sum_km'] > 0 ? round(100 * $dist / $Data['array']['all_sum_km'], 1) : 0; } else { $percent = $Data['array']['all_sum_s'] > 0 ? round(100 * $time / $Data['array']['all_sum_s'], 1) : 0; } $this->displayTDfor($num, $time, $dist, $percent); } else { echo HTML::emptyTD(); } echo '</tr>'; } if ($i == count($Data['foreach']) - 1) { echo '<tr class="top-spacer no-zebra"><td class="c b">' . __('Total') . '</td>'; for ($t = $this->timer_start; $t <= $this->timer_end; $t++) { if (isset($Data['array']['timer_sum_km'][$t])) { if ($this->Sport->usesDistance() && $this->dat != 's') { echo '<td>' . Distance::format($Data['array']['timer_sum_km'][$t], false, 0) . '</td>'; } else { echo '<td>' . Duration::format($Data['array']['timer_sum_s'][$t]) . '</td>'; } } else { echo HTML::emptyTD(); } } if ($this->Sport->usesDistance() && $this->dat != 's') { echo '<td>' . Distance::format($Data['array']['all_sum_km'], false, 0) . '</td></tr>'; } else { echo '<td>' . Duration::format($Data['array']['all_sum_s']) . '</td></tr>'; } } } $this->printTableEnd(); } }
/** * Display table body */ protected function displayTableBody() { $maxIndex = ceil(($this->TimeEnd - $this->TimeStart) / $this->Timerange) - 1; $CompleteData = array(); $CompleteResult = $this->Dataset->getGroupOfTrainingsForTimerange($this->Sportid, $this->Timerange, $this->TimeStart, $this->TimeEnd); 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]); $this->Dataset->setGroupOfTrainings($CompleteData[$index]); if (isset($CompleteData[$index + 1])) { $this->Dataset->setKilometerToCompareTo($CompleteData[$index + 1]['distance']); } $this->Dataset->displayTableColumns(); } else { echo HTML::emptyTD($this->Dataset->cols() + 1 + $this->AdditionalColumns, '<em>' . __('No activities') . '</em>', 'c small'); } echo '</tr>'; } }