/** * 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>'; }
/** * Add line for average and goal */ protected function addAverage() { if ($this->showsAverage()) { $BasicEndurance = new BasicEndurance(); $BasicEndurance->readSettingsFromConfiguration(); $Result = $BasicEndurance->asArray(); $Avg = new Distance($this->factorForWeekKm() * $Result['weekkm-percentage'] * $BasicEndurance->getTargetWeekKm()); $Goal = new Distance($this->factorForWeekKm() * $BasicEndurance->getTargetWeekKm()); $LabelKeys = array_keys($this->getXLabels()); $this->addThreshold('y', round($Avg->valueInPreferredUnit()), '#999'); $this->addThreshold('y', round($Goal->valueInPreferredUnit()), '#999'); $this->addAnnotation(-1, round($Avg->valueInPreferredUnit()), __('avg:') . ' ' . $Avg->string(true, 0), 0, -10); $this->addAnnotation(end($LabelKeys), round($Goal->valueInPreferredUnit()), __('goal:') . ' ' . $Goal->string(true, 0), 0, -10); } }
/** * @param \Runalyze\Model\EquipmentType\Object $EquipmentType * @param boolean $inuse */ protected function showListFor(Model\EquipmentType\Object $EquipmentType, &$inuse) { $max = 0; $showDistance = $EquipmentType->hasMaxDistance(); $hasMaxDuration = $showDistance || $EquipmentType->hasMaxDuration(); $allEquipment = DB::getInstance()->query('SELECT * FROM `' . PREFIX . 'equipment` WHERE `typeid`="' . $EquipmentType->id() . '" AND `accountid`="' . SessionAccountHandler::getId() . '" ORDER BY ISNULL(`date_end`) DESC, `distance` DESC')->fetchAll(); foreach ($allEquipment as $data) { $Object = new Model\Equipment\Object($data); $Distance = new Distance($Object->totalDistance()); $Duration = new Duration($Object->duration()); if ($inuse && !$Object->isInUse()) { echo '<div id="hiddenequipment" style="display:none;">'; $inuse = false; } if ($max == 0) { $max = $Object->duration(); } echo '<p style="position:relative;"> <span class="right">' . ($showDistance ? $Distance->string() : $Duration->string()) . '</span> <strong>' . SearchLink::to('equipmentid', $Object->id(), $Object->name()) . '</strong> ' . $this->getUsageImage($showDistance ? $Object->totalDistance() / $EquipmentType->maxDistance() : $Object->duration() / ($hasMaxDuration ? $EquipmentType->maxDuration() : $max)) . ' </p>'; } if (empty($allEquipment)) { echo HTML::em(__('You don\'t have any equipment')); } if (!$inuse) { echo '</div>'; } }
/** * Set boxed values */ protected function setBoxedValues() { $Distance = new Distance($this->Context->activity()->distance()); $this->BoxedValues = array(new BoxedValue(Helper::Unknown($Distance->string(false, false), '-.--'), $Distance->unit(), __('Distance')), new BoxedValue($this->Context->dataview()->duration()->string(), '', __('Time')), new BoxedValue($this->Context->dataview()->elapsedTime(), '', __('Elapsed time')), new BoxedValue($this->Context->dataview()->pace()->value(), $this->Context->dataview()->pace()->appendix(), __('Pace')), new BoxedValue(Helper::Unknown($this->Context->activity()->hrAvg(), '-'), 'bpm', __('ø Heartrate')), new BoxedValue(Helper::Unknown($this->Context->activity()->hrMax(), '-'), 'bpm', __('max. Heartrate')), new BoxedValue($this->Context->activity()->calories(), 'kcal', __('Calories')), new BoxedValue(Helper::Unknown($this->Context->dataview()->vdot()->value(), '-'), '', __('VDOT'), $this->Context->dataview()->vdotIcon()), new BoxedValue($this->Context->activity()->trimp(), '', __('TRIMP')), new Box\Elevation($this->Context)); }
/** * Show boxed values * @param array $data */ private function showDataAsBoxedValues($data) { $Factory = new Factory(SessionAccountHandler::getId()); foreach ($data as $dat) { // TODO: Define the decision (distance or time) somehow in the configuration $Sport = $Factory->sport($dat['sportid']); $Value = new BoxedValue(); $Value->setIcon($Sport->icon()->code()); $Value->setInfo($Sport->name()); $Value->defineAsFloatingBlock('w50'); if ($dat['count_distance'] >= $dat['count'] / 2) { $Distance = new Distance($dat['distance']); $Value->setValue($Distance->string(false, false, false)); $Value->setUnit($Distance->unit()); } else { $Duration = new Duration($dat['time_in_s']); $Value->setValue($Duration->string(Duration::FORMAT_WITH_HOURS)); } $Value->display(); } }
/** * Distance * @return string */ public function distance() { $Distance = new Distance($this->Activity->distance()); if ($this->Activity->isTrack()) { return $Distance->stringMeter(); } return $Distance->string(); }