Ejemplo n.º 1
0
 /**
  * Add line for average and goal
  */
 protected function addAverage()
 {
     if ($this->showsAverage()) {
         $BasicEndurance = new BasicEndurance();
         $BasicEndurance->readSettingsFromConfiguration();
         $Result = $BasicEndurance->asArray();
         $Avg = $this->factorForWeekKm() * $Result['weekkm-percentage'] * $BasicEndurance->getTargetWeekKm();
         $Goal = $this->factorForWeekKm() * $BasicEndurance->getTargetWeekKm();
         $LabelKeys = array_keys($this->getXLabels());
         $this->addThreshold('y', $Avg, '#999');
         $this->addThreshold('y', $Goal, '#999');
         $this->addAnnotation(-1, $Avg, sprintf(__('avg:') . ' %d km', $Avg), 0, -10);
         $this->addAnnotation(end($LabelKeys), $Goal, sprintf(__('goal:') . ' %d km', $Goal), 0, -10);
     }
 }
    /**
     * 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>&nbsp;</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&#37;'), round(100 * $BEresults['weekkm-percentage'])) . '</td>
						<td class="small">(&oslash; ' . 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']) . '&#37;</td>
					</tr>
					<tr>
						<td>' . __('<strong>Marathon time</strong> <small>(optimal)</small>') . '</td>
						<td class="r">' . Duration::format($Prognosis->inSeconds(42.195)) . '</td>
						<td>&nbsp;</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&#37;'), 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 &quot;long&quot; 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>&nbsp;');
        $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>&nbsp;');
        $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;
    }