/**
  * Set default values
  */
 protected function setDefaultValues()
 {
     $Strategy = new Prognosis\Bock();
     $TopResults = $Strategy->getTopResults(2);
     $CurrentShape = Configuration::Data()->vdotShape();
     if (empty($_POST)) {
         $Factory = new PluginFactory();
         $Plugin = $Factory->newInstance('RunalyzePluginPanel_Prognose');
         $_POST['model'] = 'jack-daniels';
         $_POST['distances'] = implode(', ', $Plugin->getDistances());
         $_POST['vdot'] = $CurrentShape;
         $_POST['endurance'] = true;
         $_POST['endurance-value'] = BasicEndurance::getConst();
         $_POST['best-result-km'] = !empty($TopResults) ? $TopResults[0]['distance'] : '5.0';
         $_POST['best-result-time'] = !empty($TopResults) ? Duration::format($TopResults[0]['s']) : '0:26:00';
         $_POST['second-best-result-km'] = !empty($TopResults) ? $TopResults[1]['distance'] : '10.0';
         $_POST['second-best-result-time'] = !empty($TopResults) ? Duration::format($TopResults[1]['s']) : '1:00:00';
     }
     $this->InfoLines['jack-daniels'] = __('Your current VDOT:') . ' ' . $CurrentShape . '. ';
     $this->InfoLines['jack-daniels'] .= __('Your current basic endurance:') . ' ' . BasicEndurance::getConst() . '.';
     $ResultLine = empty($TopResults) ? __('none') : sprintf(__('%s in %s <small>(%s)</small> and %s in %s <small>(%s)</small>'), Distance::format($TopResults[0]['distance']), Duration::format($TopResults[0]['s']), date('d.m.Y', $TopResults[0]['time']), Distance::format($TopResults[1]['distance']), Duration::format($TopResults[1]['s']), date('d.m.Y', $TopResults[1]['time']));
     $this->InfoLines['robert-bock'] = __('Your two best results:') . ' ' . $ResultLine;
     $this->setupJackDanielsStrategy();
     $this->setupBockStrategy();
     $this->setupSteffnyStrategy();
     $this->setupCameronStrategy();
 }
Example #2
0
 /**
  * Display additional info
  */
 protected function displayInfos()
 {
     if ($this->showsAverage()) {
         $BasicEndurance = new BasicEndurance();
         $BasicEndurance->readSettingsFromConfiguration();
         echo HTML::info(__('Goal and average are based on current basic endurance calculations.'));
     }
 }
 /**
  * Recalculate value
  */
 public static function recalculateValue()
 {
     $Object = new self();
     $Object->readSettingsFromConfiguration();
     $BASIC_ENDURANCE = $Object->value();
     Configuration::Data()->updateBasicEndurance($BASIC_ENDURANCE);
     self::$CONST_VALUE = $BASIC_ENDURANCE;
 }
    /**
     * 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;
    }
Example #5
0
 /**
  * Recalculate basic endurance
  */
 protected function recalculateBasicEndurance()
 {
     $oldValue = Configuration::Data()->basicEndurance();
     \BasicEndurance::recalculateValue();
     $newValue = Configuration::Data()->basicEndurance();
     $this->addSuccessMessage(__('Basic endurance'), $oldValue, $newValue);
 }