/** * Format pace * @param int $secondsPerKm * @return string */ public function format($secondsPerKm) { if ($secondsPerKm == 0) { return '-:--'; } return Duration::format(round($secondsPerKm * $this->factorForUnit())); }
/** * Display data */ protected function setDataToCode() { $this->Code .= '<table class="fullwidth zebra-style">'; $this->Code .= '<thead><tr>'; $this->Code .= '<th></th>'; $this->Code .= '<th>' . __('Distance') . '</th>'; $this->Code .= '<th>' . __('Time') . '</th>'; $this->Code .= '<th>' . __('Swolf') . '</th>'; $this->Code .= '<th>' . __('Strokes') . '</th>'; $this->Code .= '<th>' . __('Type') . '</th>'; $this->Code .= '</tr></thead>'; $this->Code .= '<tbody>'; $Loop = new Swimdata\Loop($this->Context->swimdata()); $TrackLoop = new Trackdata\Loop($this->Context->trackdata()); $Stroketype = new Stroketype(Stroketype::FREESTYLE); $Distance = new Distance(0); $max = $Loop->num(); for ($i = 1; $i <= $max; ++$i) { $Stroketype->set($Loop->stroketype()); $Distance->set($TrackLoop->distance()); $this->Code .= '<tr class="r">'; $this->Code .= '<td>' . $i . '.</td>'; $this->Code .= '<td>' . $Distance->stringMeter() . '</td>'; $this->Code .= '<td>' . Duration::format($TrackLoop->difference(Trackdata\Object::TIME)) . '</td>'; $this->Code .= '<td>' . $Loop->swolf() . '</td>'; $this->Code .= '<td>' . $Loop->stroke() . '</td>'; $this->Code .= '<td>' . $Stroketype->shortstring() . '</td>'; $this->Code .= '</tr>'; $TrackLoop->nextStep(); $Loop->nextStep(); } $this->Code .= '</tbody>'; $this->Code .= '</table>'; }
/** * @param \Runalyze\Model\Activity\Splits\Entity $Splits * @return string * @codeCoverageIgnore */ protected function stringForActiveLaps(Entity $Splits) { $laps = []; $onlyActiveSplits = $Splits->hasActiveAndInactiveLaps(); foreach ($Splits->asArray() as $Split) { if (!$onlyActiveSplits || $Split->isActive()) { $laps[] = Activity\Duration::format($Split->time()); } } return str_replace(' ', ' ', implode(' / ', $laps)); }
/** * Convert data */ private function convertData() { $totalTime = 0; $totalDist = 0; foreach ($this->Data as $Info) { $totalTime += $Info['time']; $totalDist += $Info['distance']; } foreach ($this->Data as $i => $Info) { if ($totalTime > 0) { $percentage = round(100 * $Info['time'] / $totalTime, 1); } elseif ($totalDist > 0) { $percentage = round(100 * $Info['distance'] / $totalDist, 1); } else { $percentage = '-'; } $this->Data[$i]['percentage'] = $percentage; $this->Data[$i]['time'] = $totalTime > 0 ? Duration::format($Info['time']) : '-'; $this->Data[$i]['distance'] = $totalDist > 0 ? Distance::format($Info['distance']) : '-'; } }
/** * @return string */ protected function getEquipmentTypeCode() { $Code = ' <table class="fullwidth zebra-style c"> <thead> <tr> <th>' . __('Name') . '</th> <th>' . __('Type') . '</th> <th>' . __('max.') . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th> <th>' . __('max. Time') . '</th> <th>' . __('Sports') . '</th> <th>' . __('delete') . ' ' . $this->getDeleteIcon() . '</th> </tr> </thead> <tbody>'; $Sports = $this->Model->allSports(); $Types = $this->Model->allEquipmentTypes(); $Types[] = new EquipmentType\Entity(); foreach ($Types as $Type) { $isNew = !$Type->hasID(); $id = $isNew ? -1 : $Type->id(); $delete = $isNew ? '' : '<input type="checkbox" class="delete-checkbox" name="equipmenttype[delete][' . $id . ']">'; $sportIDs = $isNew ? array() : $this->Model->sportForEquipmentType($id, true); $MaxDistance = new Distance($Type->maxDistance()); $Code .= ' <tr class="' . ($isNew ? ' unimportant' : '') . '"> <td><input type="text" class="middle-size" name="equipmenttype[name][' . $id . ']" value="' . $Type->name() . '"></td> <td><select name="equipmenttype[input][' . $id . ']""> <option value="' . EquipmentType\Entity::CHOICE_SINGLE . '" ' . HTML::Selected(!$Type->allowsMultipleValues()) . '>' . __('Single choice') . '</option> <option value="' . EquipmentType\Entity::CHOICE_MULTIPLE . '" ' . HTML::Selected($Type->allowsMultipleValues()) . '>' . __('Multiple choice') . '</option> </select></td> <td><span class="input-with-unit"><input type="text" class="small-size" name="equipmenttype[max_km][' . $id . ']" value="' . round($MaxDistance->valueInPreferredUnit()) . '"><label class="input-unit">' . $MaxDistance->unit() . '</label></span></td> <td><input type="text" class="small-size" name="equipmenttype[max_time][' . $id . ']" value="' . ($Type->maxDuration() > 0 ? Duration::format($Type->maxDuration()) : '') . '" placeholder="d hh:mm:ss"></td> <td><input name="equipmenttype[sportid_old][' . $id . ']" type="hidden" value="' . implode(',', $sportIDs) . '"> <select name="equipmenttype[sportid][' . $id . '][]" class="middle-size" multiple>'; foreach ($Sports as $Sport) { $Code .= '<option value="' . $Sport->id() . '"' . HTML::Selected(in_array($Sport->id(), $sportIDs)) . '>' . $Sport->name() . '</option>'; } $Code .= '</select></td> <td>' . $delete . '</td> </tr>'; } $Code .= ' </tbody> </table>'; return $Code; }
/** * Display comparison for all years for personal bests */ private function displayPersonalBestYears() { $year = array(); $dists = array(); $kms = is_array($this->Configuration()->value('pb_distances')) ? $this->Configuration()->value('pb_distances') : array(3, 5, 10, 21.1, 42.2); foreach ($kms as $km) { $dists[$km] = array('sum' => 0, 'pb' => INFINITY); } if ($this->RaceContainer->num() == 0) { return; } foreach ($this->RaceContainer->allRaces() as $wk) { $wk['y'] = date('Y', $wk['time']); if (!isset($year[$wk['y']])) { $year[$wk['y']] = $dists; $year[$wk['y']]['sum'] = 0; $year['sum'] = 0; } $year[$wk['y']]['sum']++; foreach ($kms as $km) { if ($km == $wk['distance']) { $year[$wk['y']][$km]['sum']++; if ($wk['s'] < $year[$wk['y']][$km]['pb']) { $year[$wk['y']][$km]['pb'] = $wk['s']; } } } } echo '<table class="fullwidth zebra-style">'; echo '<thead>'; echo '<tr>'; echo '<th></th>'; $Years = array_keys($year); sort($Years); foreach ($Years as $y) { if ($y != 'sum') { echo '<th>' . $y . '</th>'; } } echo '</tr>'; echo '</thead>'; echo '<tbody>'; PersonalBest::activateStaticCache(); PersonalBest::lookupDistances($kms); foreach ($kms as $km) { echo '<tr class="r"><td class="b">' . (new Distance($km))->stringAuto(true, 1) . '</td>'; foreach ($Years as $key) { $y = $year[$key]; if ($key != 'sum') { if ($y[$km]['sum'] != 0) { $PB = new PersonalBest($km); $distance = Duration::format($y[$km]['pb']); if ($PB->seconds() == $y[$km]['pb']) { $distance = '<strong>' . $distance . '</strong>'; } echo '<td>' . $distance . ' <small>' . $y[$km]['sum'] . 'x</small></td>'; } else { echo '<td><em><small>---</small></em></td>'; } } } echo '</tr>'; } echo '<tr class="top-spacer no-zebra r">'; echo '<td class="b">' . __('In total') . '</td>'; foreach ($Years as $key) { if ($key != 'sum') { echo '<td>' . $year[$key]['sum'] . 'x</td>'; } } echo '</tr>'; echo '</tbody>'; echo '</table>'; }
/** * 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 td * @param int $num * @param int $time * @param float $dist * @param float $percent */ private function displayTDfor($num, $time, $dist, $percent) { $tooltip = $num . 'x'; $number = number_format($percent, 1) . ' %'; if ($this->dat == 'km') { $number = Distance::format($dist, false, 0); $tooltip .= ', ' . Duration::format($time); } elseif ($this->dat == 's') { $number = Duration::format($time); } else { $number = number_format($percent, 1) . ' %'; $tooltip .= ', ' . Duration::format($time); } echo '<td>' . Ajax::tooltip($number, $tooltip) . $this->getBarFor($percent) . '</td>'; }
/** * Get elapsed time * @return string */ public function elapsedTime() { if ($this->Activity->elapsedTime() < $this->Activity->duration()) { return '-:--:--'; } return Duration::format($this->Activity->elapsedTime()); }
/** * Show prognosis for a given distance * @param double $distance */ protected function showPrognosis($distance) { $PB = new PersonalBest($distance); $PBTime = $PB->exists() ? Duration::format($PB->seconds()) : '-'; $Prognosis = new Duration($this->Prognosis->inSeconds($distance)); $Distance = new Distance($distance); $Pace = new Pace($Prognosis->seconds(), $distance, Pace::MIN_PER_KM); echo '<p> <span class="right"> ' . sprintf(__('<small>from</small> %s <small>to</small> <strong>%s</strong>'), $PBTime, $Prognosis->string(Duration::FORMAT_AUTO, 0)) . ' <small>(' . $Pace->valueWithAppendix() . ')</small> </span> <strong>' . $Distance->string(Distance::FORMAT_AUTO, 1) . '</strong> </p>'; }
/** * Parse all trackpoints for one lap * @param SimpleXMLElement $Lap */ protected function parseTrackpoints(&$Lap) { $this->lastPoint = 0; foreach ($Lap->Track as $Track) { if ($this->lastPoint > 0) { $this->lastPointWasEmpty = true; } if (count($Track->xpath('./Trackpoint')) > 0) { $this->distancesAreEmpty = count($Track->xpath('./Trackpoint/DistanceMeters')) == 0; if (strtotime((string) $Lap['StartTime']) + 8 < strtotime((string) $Track->Trackpoint[0]->Time)) { $this->lastPointWasEmpty = true; } foreach ($Track->Trackpoint as $Trackpoint) { $this->parseTrackpoint($Trackpoint); } } } if (self::$DEBUG_SPLITS) { Error::getInstance()->addDebug('computed: ' . Duration::format(end($this->gps['time_in_s'])) . ', ' . Distance::format(end($this->gps['km']))); } }
/** * Show data in table view * @param array $data * @param array $timeset */ private function showDataInTableView($data, $timeset) { $Factory = new Factory(SessionAccountHandler::getId()); if (empty($data)) { echo '<p><em>' . __('No data available.') . '</em></p>'; } else { foreach ($data as $dat) { $Sport = $Factory->sport($dat['sportid']); $result = $dat['count_distance'] >= $dat['count'] / 2 ? Distance::format($dat['distance']) : Duration::format($dat['time_in_s']); echo '<p><span class="right"><small><small>(' . sprintf(__('%u-times'), Helper::Unknown($dat['count'], '0')) . ')</small></small> ' . $result . '</span> '; echo $Sport->icon()->code() . ' <strong>' . $Sport->name() . '</strong></p>'; } } echo '<small class="right">' . __('since') . ' ' . date("d.m.Y", $timeset['start']) . '</small>'; echo HTML::clearBreak(); }
/** * Init calculations */ protected function runCalculations() { foreach ($this->Distances as $km) { $Prognosis = $this->PrognosisObject->inSeconds($km); $PB = new PersonalBest($km, DB::getInstance(), false); $PB->lookupWithDetails(); $VDOTprognosis = new VDOT(); $VDOTprognosis->fromPace($km, $Prognosis); $VDOTpb = new VDOT(); $VDOTpb->fromPace($km, $PB->seconds()); $PacePrognosis = new Pace($Prognosis, $km, Pace::MIN_PER_KM); $PacePB = new Pace($PB->seconds(), $km, Pace::MIN_PER_KM); $DateWithLink = Ajax::trainingLink($PB->activityId(), date('d.m.Y', $PB->timestamp()), true); $this->Prognoses[] = array('distance' => Distance::format($km, $km <= 3), 'prognosis' => Duration::format($Prognosis), 'prognosis-pace' => $PacePrognosis->valueWithAppendix(), 'prognosis-vdot' => $VDOTprognosis->uncorrectedValue(), 'diff' => !$PB->exists() ? '-' : ($PB->seconds() > $Prognosis ? '+ ' : '- ') . Duration::format(abs(round($PB->seconds() - $Prognosis))), 'diff-class' => $PB->seconds() > $Prognosis ? 'plus' : 'minus', 'pb' => $PB->seconds() > 0 ? Duration::format($PB->seconds()) : '-', 'pb-pace' => $PB->seconds() > 0 ? $PacePB->valueWithAppendix() : '-', 'pb-vdot' => $PB->seconds() > 0 ? $VDOTpb->uncorrectedValue() : '-', 'pb-date' => $PB->seconds() > 0 ? $DateWithLink : '-'); } }
<?php $Strategy->setVDOT($vdot); ?> <tr> <td class="b"><?php echo $vdot; ?> </td> <?php foreach ($this->Configuration()->value('pace_distances') as $km) { ?> <?php if ($km >= 1) { ?> <td><?php echo Duration::format(round($Prognosis->inSeconds($km))); ?> </td> <?php } ?> <?php } ?> </tr> <?php } ?> </tbody> </table>
/** * Get fieldset for paces * @return \FormularFieldset */ public function getFieldsetPaces() { $Table = '<table class="fullwidth zebra-style"> <thead> <tr> <th>' . __('Name') . '</th> <th class="small">' . __('Pace') . '</th> <th class="small">' . __('Description') . '</th> </tr> </thead> <tbody>'; $VDOT = new VDOT(Configuration::Data()->vdot()); foreach ($this->getArrayForPaces() as $Pace) { $Table .= '<tr> <td class="b">' . $Pace['short'] . '</td> <td class=""><em>' . Duration::format($VDOT->paceAt($Pace['limit-low'] / 100)) . '</em> - <em>' . Duration::format($VDOT->paceAt($Pace['limit-high'] / 100)) . '</em>/km</td> <td class="">' . $Pace['description'] . '</td> </tr>'; } $Table .= ' </tbody> </table>'; $Fieldset = new FormularFieldset(__('Training paces')); $Fieldset->addBlock($Table); $Fieldset->addInfo(__('These paces are based on Jack Daniels\' recommendation.')); return $Fieldset; }
/** * @param float $seconds * @return string */ private function formatTime($seconds) { return Duration::format(round($seconds)); }
/** * Init calculations */ protected function runCalculations() { if (!$this->PrognosisObject->isValid()) { return; } foreach ($this->Distances as $km) { $Prognosis = $this->PrognosisObject->inSeconds($km); $PB = new PersonalBest($km, DB::getInstance(), false); $PB->lookupWithDetails(); $VDOTprognosis = new VDOT(); $VDOTprognosis->fromPace($km, $Prognosis); $VDOTpb = new VDOT(); $VDOTpb->fromPace($km, $PB->seconds()); $PacePrognosis = new Pace($Prognosis, $km, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport())); $PacePB = new Pace($PB->seconds(), $km, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport())); $DateWithLink = Ajax::trainingLink($PB->activityId(), date('d.m.Y', $PB->timestamp()), true); $this->Prognoses[] = array('distance' => (new Distance($km))->stringAuto(), 'prognosis' => Duration::format($Prognosis), 'prognosis-pace' => $PacePrognosis->valueWithAppendix(), 'prognosis-vdot' => $VDOTprognosis->uncorrectedValue(), 'diff' => !$PB->exists() ? '-' : ($PB->seconds() > $Prognosis ? '+ ' : '- ') . Duration::format(abs(round($PB->seconds() - $Prognosis))), 'diff-class' => $PB->seconds() > $Prognosis ? 'plus' : 'minus', 'pb' => $PB->seconds() > 0 ? Duration::format($PB->seconds()) : '-', 'pb-pace' => $PB->seconds() > 0 ? $PacePB->valueWithAppendix() : '-', 'pb-vdot' => $PB->seconds() > 0 ? $VDOTpb->uncorrectedValue() : '-', 'pb-date' => $PB->seconds() > 0 ? $DateWithLink : '-'); } }
/** * Add icon for current pause */ protected function addCurrentPauseIcon() { $Pause = $this->Trackdata->pauses()->at($this->PauseIndex); $Index = $this->RouteLoop->index(); $Tooltip = sprintf(__('<strong>Pause</strong> of %s'), Duration::format($Pause->duration())); $Tooltip .= '<br>' . sprintf(__('<strong>Distance:</strong> %s'), Distance::format($this->Trackdata->at($Index, Trackdata\Entity::DISTANCE))); $Tooltip .= '<br>' . sprintf(__('<strong>Time:</strong> %s'), Duration::format($this->Trackdata->at($Index, Trackdata\Entity::TIME))); if ($Pause->hasHeartRateInfo()) { $Tooltip .= '<br>' . sprintf(__('<strong>Heart rate:</strong>') . ' ' . __('%s to %s'), $Pause->hrStart(), $Pause->hrEnd() . ' bpm'); } $this->addMarkerGeohash($this->Route->at($Index, Route\Entity::GEOHASHES), $this->pauseIcon(), $Tooltip); }
/** * Show prognosis for a given distance * @param double $distance */ protected function showPrognosis($distance) { $PB = new PersonalBest($distance); $PB->lookupWithDetails(); $PBTime = $PB->exists() ? Duration::format($PB->seconds()) : '-'; $PBString = $PB->exists() ? Ajax::trainingLink($PB->activityId(), $PBTime, true) : $PBTime; $Prognosis = new Duration($this->Prognosis->inSeconds($distance)); $Distance = new Distance($distance); $Pace = new Pace($Prognosis->seconds(), $distance, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport())); echo '<p> <span class="right"> ' . sprintf(__('<small>from</small> %s <small>to</small> <strong>%s</strong>'), $PBString, $Prognosis->string(Duration::FORMAT_AUTO, 0)) . ' <small>(' . $Pace->valueWithAppendix() . ')</small> </span> <strong>' . $Distance->stringAuto(true, 1) . '</strong> </p>'; }
/** * Set halfs of competition */ private function setHalfsOfCompetitionToCode() { if (empty($this->Halfs)) { return; } $this->Code .= '<tr class="no-zebra"><td colspan="5"> </td></tr>'; $this->Code .= '<tr class="b bottom-spacer no-zebra"><td colspan="5">' . __('1st/2nd Half') . '</td></tr>'; $totalTime = 0; $totalDist = 0; foreach ($this->Halfs as $Half) { $totalTime += $Half['s']; $totalDist += $Half['km']; } $TotalPace = new Pace($totalTime, $totalDist, $this->PaceUnit); for ($i = 0, $num = count($this->Halfs); $i < $num; $i++) { $Pace = new Pace($this->Halfs[$i]['s'], $this->Halfs[$i]['km'], $this->PaceUnit); $this->Code .= '<tr class="r"> <td></td> <td>' . Distance::format($this->Halfs[$i]['km'], true, 2) . '</td> <td>' . Duration::format($this->Halfs[$i]['s']) . '</td> <td>' . $Pace->valueWithAppendix() . '</td> <td>' . $Pace->compareTo($TotalPace) . '</td> </tr>'; } }
/** * Parse: time in seconds => time-string * @param mixed $value * @param array $options */ private static function parseTime(&$value, $options) { if ($value == 0) { if (isset($options['hide-empty'])) { $value = ''; } else { $value = '0:00:00'; } } else { $value = Duration::format($value); } }
/** * Get fieldset for basic endurance * @return \FormularFieldset */ public function getFieldsetBasicEndurance() { $BasicEndurance = new BasicEndurance(); $BasicEndurance->readSettingsFromConfiguration(); $BEresults = $BasicEndurance->asArray(); $Strategy = new Prognosis\Daniels(); $Strategy->setupFromDatabase(); $Strategy->adjustVDOT(false); $Prognosis = new Prognosis\Prognosis(); $Prognosis->setStrategy($Strategy); $GeneralTable = ' <table class="fullwidth zebra-style"> <tbody class="top-and-bottom-border"> <tr> <td>' . __('<strong>Current VDOT</strong> <small>(based on heart rate)</small>') . '</td> <td class="r">' . round(Configuration::Data()->vdot(), 2) . '</td> <td> </td> <td>' . sprintf(__('<strong>Target kilometer per week</strong> <small>(%s weeks)</small>'), round($BasicEndurance->getDaysForWeekKm() / 7)) . '</td> <td class="r">' . Distance::format($BasicEndurance->getTargetWeekKm(), false, 0) . '</td> <td class="small">' . sprintf(__('done by %s%'), round(100 * $BEresults['weekkm-percentage'])) . '</td> <td class="small">(ø ' . Distance::format($BEresults['weekkm-result'] / $BasicEndurance->getDaysForWeekKm() * 7, false, 0) . ')</td> <td class="small">x' . $BasicEndurance->getPercentageForWeekKilometer() . '</td> <td rowspan="2" class="bottom-spacer b" style="vertical-align:middle;">= ' . round($BEresults['percentage']) . '%</td> </tr> <tr> <td>' . __('<strong>Marathon time</strong> <small>(optimal)</small>') . '</td> <td class="r">' . Duration::format($Prognosis->inSeconds(42.195)) . '</td> <td> </td> <td>' . sprintf(__('<strong>Target long run</strong> <small>(%s weeks)</small>'), round($BasicEndurance->getDaysToRecognizeForLongjogs() / 7)) . '</td> <td class="r">' . Distance::format($BasicEndurance->getRealTargetLongjogKmPerWeek(), false, 0) . '</td> <td class="small">' . sprintf(__('done by %s%'), round(100 * $BEresults['longjog-percentage'])) . '</td> <td class="small">(' . round($BEresults['longjog-result'], 1) . ' points)</td> <td class="small">x' . $BasicEndurance->getPercentageForLongjogs() . '</td> </tr> </tbody> </table>'; $LongjogTable = '<table class="fullwidth zebra-style c"> <thead> <tr> <th>' . __('Date') . '*</th> <th>' . __('Distance') . '</th> <th>' . __('Points') . '</th> </tr> </thead> <tbody>'; $IgnoredLongjogs = 0; $Longjogs = DB::getInstance()->query($BasicEndurance->getQuery(0, true))->fetchAll(); foreach ($Longjogs as $Longjog) { if ($Longjog['points'] >= 0.2) { $LongjogTable .= '<tr> <td>' . Ajax::trainingLink($Longjog['id'], date('d.m.Y', $Longjog['time'])) . '</td> <td>' . Distance::format($Longjog['distance']) . '</td> <td>' . round($Longjog['points'], 1) . ' points</td> </tr>'; } else { $IgnoredLongjogs++; } } $LongjogTable .= '<tr class="top-spacer no-zebra"> <td></td> <td></td> <td class="b">= ' . round($BEresults['longjog-result'], 1) . ' points</td> </tr> </tbody> </table>'; $LongjogTable .= '<p class="small">' . sprintf(__('* %s "long" jogs do not show up, ' . 'because they have less than 0.2 points.'), $IgnoredLongjogs) . '</p>'; $LongjogTable .= '<p class="small">' . sprintf(__('* In general, all runs with more than %s are being considered.'), Distance::format($BasicEndurance->getMinimalDistanceForLongjogs())) . '</p>'; $Fieldset = new FormularFieldset(__('Basic endurance')); $Fieldset->addBlock(__('Your basic endurance is based on your weekly kilometers and your long jogs.<br>' . 'The target is derived from the possible marathon time based on your current shape.') . '<br> '); $Fieldset->addBlock($GeneralTable); $Fieldset->addBlock(__('The points for your long runs are weighted by time and quadratic in distance. ' . 'That means, a long jog yesterday gives more points than a long jog two weeks ago ' . 'and a 30k-jog gives more points than two 20k-jogs.') . '<br> '); $Fieldset->addBlock($LongjogTable); $Fieldset->addBlock(__('The basic endurance is <strong>not</strong> from Jack Daniels.<br>' . 'It\'s our own attempt to adjust the prognosis for long distances based on your current endurance.')); return $Fieldset; }
/** * Get string for time * @return string */ public function getTimeString() { return Duration::format($this->getTime()); }
/** * Display table */ public function displayTable() { if (is_null($this->Equipment)) { $this->initTableData(); } echo '<table id="list-of-all-equipment" class="fullwidth zebra-style"> <thead> <tr> <th class="{sorter: \'x\'} small">' . __('x-times') . '</th> <th>' . __('Name') . '</th> <th class="{sorter: \'germandate\'} small">' . __('since') . '</th> <th class="{sorter: \'distance\'}">Ø ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th> <th>Ø ' . __('Pace') . '</th> <th class="{sorter: \'distance\'} small"><small>' . __('max.') . '</small> ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th> <th class="small"><small>' . __('min.') . '</small> ' . __('Pace') . '</th> <th class="{sorter: \'resulttime\'}">' . __('Time') . '</th> <th class="{sorter: \'distance\'}">' . __('Distance') . '</th> <th>' . __('Notes') . '</th> </tr> </thead> <tbody>'; if (!empty($this->Equipment)) { foreach ($this->Equipment as $data) { $Object = new Model\Equipment\Object($data); $in_use = $Object->isInUse() ? '' : ' unimportant'; $Pace = new Pace($Object->duration(), $Object->distance()); $MaxPace = new Pace($data['pace_in_s'], 1); echo '<tr class="' . $in_use . ' r" style="position: relative"> <td class="small">' . $data['num'] . 'x</td> <td class="b l">' . SearchLink::to('equipmentid', $Object->id(), $Object->name()) . '</td> <td class="small">' . $this->formatData($Object->startDate()) . '</td> <td>' . ($data['num'] != 0 ? Distance::format($Object->distance() / $data['num']) : '-') . '</td> <td>' . ($Object->duration() > 0 ? $Pace->asMinPerKm() . '/km' : '-') . '</td> <td class="small">' . Distance::format($data['dist']) . '</td> <td class="small">' . $MaxPace->asMinPerKm() . '/km' . '</td> <td>' . Duration::format($Object->duration()) . '</td> <td>' . Distance::format($Object->totalDistance()) . '</td> <td class="small">' . $Object->notes() . '</td> </tr>'; } } else { echo '<tr><td colspan="9">' . __('You don\'t have any shoes') . '</td></tr>'; } echo '</tbody>'; echo '</table>'; Ajax::createTablesorterFor("#list-of-all-equipment", true); }
/** * Add tab for general statistics */ protected function addTabForGeneralStatistics() { $User = $this->FrontendSharedList->getUser(); $Stats = DB::getInstance()->query(' SELECT SUM(1) as num, SUM(distance) as dist_sum, SUM(s) as time_sum FROM `' . PREFIX . 'training` WHERE `accountid`="' . $User['id'] . '" GROUP BY `accountid` LIMIT 1 ')->fetch(); $Content = ' <table class="fullwidth"> <tbody> <tr> <td class="b">' . __('Total distance:') . '</td> <td>' . Distance::format($Stats['dist_sum']) . '</td> <td class="b">' . __('Number of activities:') . '</td> <td>' . $Stats['num'] . 'x</td> <td class="b">' . __('Registered since:') . '</td> <td>' . date('d.m.Y', $User['registerdate']) . '</td> </tr> <tr> <td class="b">' . __('Total duration:') . '</td> <td>' . Duration::format($Stats['time_sum']) . '</td> <td class="b">' . __('First activity:') . '</td> <td>' . date('d.m.Y', START_TIME) . '</td> <td class="b">' . __('Last login:'******'</td> <td>' . date('d.m.Y', $User['lastaction']) . '</td> </tr> </tbody> </table>'; $this->StatisticTabs->addTab(__('General statistics'), 'statistics-general', $Content); }
/** * Display the table with general records */ private function displayRekorde() { foreach ($this->rekorde as $rekord) { echo '<table class="fullwidth zebra-style">'; echo '<thead><tr><th colspan="11" class="l">' . $rekord['name'] . '</th></tr></thead>'; echo '<tbody>'; $output = false; $sports = DB::getInstance()->query($rekord['sportquery'])->fetchAll(); $Request = DB::getInstance()->prepare($rekord['datquery']); foreach ($sports as $sport) { $Request->bindValue('sportid', $sport['id']); $Request->execute(); $data = $Request->fetchAll(); if (!empty($data)) { $output = true; echo '<tr class="r">'; echo '<td class="b l">' . Icon::getSportIconForGif($sport['img'], $sport['name']) . ' ' . $sport['name'] . '</td>'; $j = 0; foreach ($data as $j => $dat) { if ($rekord['speed']) { $Pace = new Pace($dat['s'], $dat['distance'], SportFactory::getSpeedUnitFor($sport['id'])); $code = $Pace->valueWithAppendix(); } else { $code = $dat['distance'] != 0 ? Distance::format($dat['distance']) : Duration::format($dat['s']); } echo '<td class="small"><span title="' . date("d.m.Y", $dat['time']) . '"> ' . Ajax::trainingLink($dat['id'], $code) . ' </span></td>'; } for (; $j < 9; $j++) { echo HTML::emptyTD(); } echo '</tr>'; } } if (!$output) { echo '<tr><td colspan="11"><em>' . __('No data available') . '</em></td></tr>'; } echo '</tbody>'; echo '</table>'; } }
/** * Add annotations */ protected function addAnnotations() { if ($this->demandedPace > 0) { $this->Plot->addThreshold("y", $this->demandedPace * 1000, 'rgb(180,0,0)'); //$this->Plot->addAnnotation(count($Data)-1, $this->demandedPace*1000, 'Soll: '.Duration::format(round($this->demandedPace)), -10, -7); } if ($this->achievedPace > 0) { $this->Plot->addThreshold("y", $this->achievedPace * 1000, 'rgb(0,180,0)'); $this->Plot->addAnnotation(0, $this->achievedPace * 1000, 'ø ' . Duration::format(round($this->achievedPace)), -20, -7); } }
/** * Format time * @return string */ private function timeAsString() { return Duration::format($this->Time); }
/** * Parse: time in seconds => time-string * @param mixed $value */ protected static function parseTime(&$value) { if ($value == 0) { $value = '0:00:00'; } else { $value = Duration::format($value); } }
<?php foreach ($this->Range as $value) { ?> <?php $VDOT->setValue($value); ?> <tr> <td class="b"><?php echo $value; ?> </td> <?php foreach ($this->Paces as $data) { ?> <td><?php echo Duration::format($VDOT->paceAt($data['percent'] / 100)); ?> </td> <?php } ?> </tr> <?php } ?> </tbody> </table> <?php echo Ajax::wrapJS('$("#jd-tables-prognosis td.b").each(function(){ if ($(this).text() == \'' . round(Configuration::Data()->vdot()) . '\') $(this).parent().addClass("highlight"); });'); ?>