Beispiel #1
0
 /**
  * @return string
  */
 public function distance()
 {
     if ($this->Activity->distance() > 0) {
         return $this->Dataview->distance();
     }
     return '';
 }
/**
 * Display formular for editing a training
 * Call:   call/call.Training.edit.php?id=
 */
require '../inc/class.Frontend.php';
use Runalyze\Model\Activity;
use Runalyze\View\Activity\Linker;
use Runalyze\View\Activity\Dataview;
$Frontend = new Frontend();
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
    $Deleter = new Activity\Deleter(DB::getInstance(), Runalyze\Context::Factory()->activity($_GET['delete']));
    $Deleter->setAccountID(SessionAccountHandler::getId());
    $Deleter->delete();
    echo '<div class="panel-content"><p id="submit-info" class="error">' . __('The activity has been removed') . '</p></div>';
    echo '<script>$("#multi-edit-' . (int) $_GET['delete'] . '").remove();Runalyze.Statistics.resetUrl();Runalyze.reloadContent();</script>';
    exit;
}
$Training = new TrainingObject(Request::sendId());
$Activity = new Activity\Object($Training->getArray());
$Linker = new Linker($Activity);
$Dataview = new Dataview($Activity);
echo $Linker->editNavigation();
echo '<div class="panel-heading">';
echo '<h1>' . $Dataview->titleWithComment() . ', ' . $Dataview->dateAndDaytime() . '</h1>';
echo '</div>';
echo '<div class="panel-content">';
$Formular = new TrainingFormular($Training, StandardFormular::$SUBMIT_MODE_EDIT);
$Formular->setId('training');
$Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W50);
$Formular->display();
echo '</div>';
Beispiel #3
0
 /**
  * @param \Runalyze\Data\Laps\Lap $Lap
  * @return string
  */
 protected function additionalTableCellsFor(\Runalyze\Data\Laps\Lap $Lap)
 {
     $Code = '';
     $View = new Dataview(new Activity\Entity($Lap->additionalValues()));
     foreach ($this->AdditionalKeys as $key) {
         switch ($key) {
             case Activity\Entity::CADENCE:
                 $Code .= '<td>' . $View->cadence()->asString() . '</td>';
                 break;
             case Activity\Entity::GROUNDCONTACT:
                 $Code .= '<td>' . $View->groundcontact() . '</td>';
                 break;
             case Activity\Entity::GROUNDCONTACT_BALANCE:
                 $Code .= '<td>' . $View->groundcontactBalance() . '</td>';
                 break;
             case Activity\Entity::VERTICAL_OSCILLATION:
                 $Code .= '<td>' . $View->verticalOscillation() . '</td>';
                 break;
             case Activity\Entity::VERTICAL_RATIO:
                 $Code .= '<td>' . $View->verticalRatio() . '</td>';
                 break;
             case Activity\Entity::STRIDE_LENGTH:
                 $Code .= '<td>' . $View->strideLength()->string() . '</td>';
                 break;
             case Activity\Entity::VDOT:
                 $Code .= '<td>' . $View->vdot()->value() . '</td>';
                 break;
             case Activity\Entity::POWER:
                 $Code .= '<td>' . $View->power() . '</td>';
                 break;
             default:
                 $Code .= '<td></td>';
         }
     }
     return $Code;
 }
    /**
     * Display table-row for a competition
     * @param array $data
     */
    private function displayWKTr(array $data)
    {
        $Activity = new Activity\Entity($data);
        $Linker = new Linker($Activity);
        $Dataview = new Dataview($Activity);
        echo '<tr class="r">
				<td>' . $this->getIconForCompetition($data['id']) . '</td>
				<td class="c small">' . $Linker->weekLink() . '</a></td>
				<td class="l"><strong>' . $Linker->linkWithComment() . '</strong></td>
				<td>' . $Dataview->distance(1) . '</td>
				<td>' . $Dataview->duration()->string(Duration::FORMAT_COMPETITION) . '</td>
				<td class="small">' . $Dataview->pace()->value() . '</td>
				<td class="small">' . Helper::Unknown($Activity->hrAvg()) . ' / ' . Helper::Unknown($Activity->hrMax()) . ' bpm</td>
				<td class="small">' . ($Activity->weather()->isEmpty() ? '' : $Activity->weather()->fullString($Activity->isNight())) . '</td>
			</tr>';
    }
Beispiel #5
0
 /**
  * Get content for a given dataset
  * @param string $name
  * @return string
  */
 public function getDataset($name)
 {
     switch ($name) {
         case 'sportid':
             if (!is_null($this->Sport)) {
                 return $this->Sport->icon()->code();
             }
             return '';
         case 'typeid':
             if (!is_null($this->Type)) {
                 if ($this->Type->isQualitySession()) {
                     return '<strong>' . $this->Type->abbreviation() . '</strong>';
                 }
                 return $this->Type->abbreviation();
             }
             return '';
         case 'time':
             return $this->Dataview->daytime();
         case 'distance':
             return $this->Dataview->distance() . $this->distanceComparison();
         case 's':
             return $this->Dataview->duration()->string();
         case 'pace':
             if ($this->Activity->distance() > 0) {
                 if (isset($this->ActivityData['s_sum_with_distance'])) {
                     if ($this->ActivityData['s_sum_with_distance'] > 0) {
                         $Pace = new Pace($this->ActivityData['s_sum_with_distance'], $this->Activity->distance(), SportFactory::getSpeedUnitFor($this->Activity->sportid()));
                         return $Pace->valueWithAppendix();
                     }
                     return '';
                 }
                 return $this->Dataview->pace()->valueWithAppendix();
             }
             return '';
         case 'elevation':
             if ($this->Activity->elevation() > 0) {
                 return $this->Dataview->elevation()->string();
             }
             return '';
         case 'kcal':
             return $this->Dataview->calories();
         case 'pulse_avg':
             if ($this->Activity->hrAvg() > 0) {
                 return $this->Dataview->hrAvg()->string();
             }
             return '';
         case 'pulse_max':
             if ($this->Activity->hrMax() > 0) {
                 return $this->Dataview->hrMax()->string();
             }
             return '';
         case 'trimp':
             return $this->Dataview->trimp();
         case 'cadence':
             if ($this->Dataview->cadence()->value() > 0) {
                 return $this->Dataview->cadence()->asString();
             }
             return '';
         case 'stride_length':
             if ($this->Dataview->strideLength()->value() > 0) {
                 return $this->Dataview->strideLength()->string();
             }
             return '';
         case 'groundcontact':
             return $this->Dataview->groundcontact();
         case 'vertical_oscillation':
             return $this->Dataview->verticalOscillation();
         case 'power':
             return $this->Dataview->power();
         case 'temperature':
             if (!$this->Activity->weather()->temperature()->isUnknown() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return Temperature::format($this->Activity->weather()->temperature()->value(), true, false);
             }
             return '';
         case 'weatherid':
             if (!$this->Activity->weather()->isEmpty() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return $this->Activity->weather()->condition()->icon()->code();
             }
             return '';
         case 'routeid':
             if ($this->Activity->get(Activity\Object::ROUTEID) > 0) {
                 return $this->cut($this->Factory->route($this->Activity->get(Activity\Object::ROUTEID))->name());
             }
             return '';
         case 'splits':
             if (!$this->Activity->splits()->isEmpty()) {
                 if ($this->Activity->splits()->hasActiveAndInactiveLaps() || round($this->Activity->splits()->totalDistance()) != round($this->Activity->distance()) || !is_null($this->Type) && $this->Type->id() == Configuration::General()->competitionType()) {
                     // TODO: Icon with tooltip?
                     $Icon = new Icon(Icon::CLOCK);
                     return $Icon->code();
                 }
             }
             return '';
         case 'comment':
             return $this->cut($this->Activity->comment());
         case 'partner':
             return $this->cut($this->Activity->partner()->asString());
         case 'abc':
             return $this->Dataview->abcIcon();
         case 'vdoticon':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->vdotIcon();
             }
             return '';
         case 'vdot':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport() && $this->Activity->vdotByHeartRate() > 0) {
                 if (!$this->Activity->usesVDOT()) {
                     return '<span class="unimportant">' . $this->Dataview->vdot()->value() . '</span>';
                 }
                 return $this->Dataview->vdot()->value();
             }
             return '';
         case 'jd_intensity':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->jdIntensityWithStresscolor();
             }
             return '';
         case 'fit_vdot_estimate':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->fitVdotEstimate();
             }
             return '';
         case 'fit_recovery_time':
             return $this->Dataview->fitRecoveryTime();
         case 'fit_hrv_analysis':
             return $this->Dataview->fitHRVscore();
     }
     return '';
 }
    /**
     * Display the images
     */
    private function displayTable()
    {
        if ($this->sportid > 0) {
            $sports_not_short = $this->sportid . ',';
        } else {
            $sports_not_short = '';
            $sports = DB::getInstance()->query('SELECT `id` FROM `' . PREFIX . 'sport` WHERE `short`=0 AND `accountid` = ' . SessionAccountHandler::getId())->fetchAll();
            foreach ($sports as $sport) {
                $sports_not_short .= $sport['id'] . ',';
            }
        }
        $nights = DB::getInstance()->query('SELECT * FROM (
			SELECT
				id,
				time,
				s,
				sportid,
				distance,
				is_track,
				HOUR(FROM_UNIXTIME(`time`)) as `H`,
				MINUTE(FROM_UNIXTIME(`time`)) as `MIN`
			FROM `' . PREFIX . 'training`
			WHERE
				`sportid` IN(' . substr($sports_not_short, 0, -1) . ') AND
                                `accountid` = ' . SessionAccountHandler::getId() . ' AND
				(HOUR(FROM_UNIXTIME(`time`))!=0 OR MINUTE(FROM_UNIXTIME(`time`))!=0) 
				' . $this->getYearDependenceForQuery() . '
			ORDER BY
				ABS(12-(`H`+10)%24-`MIN`/60) ASC,
				`MIN` DESC LIMIT 20
			) t
		ORDER BY
			(`H`+12)%24 ASC,
			`MIN` ASC')->fetchAll();
        if (empty($nights)) {
            $this->dataIsMissing = true;
            return;
        }
        echo '<table class="fullwidth zebra-style">';
        echo '<thead><tr class="b c"><th colspan="8">' . __('Nightly activities') . '</th></tr></thead>';
        echo '<tbody>';
        foreach ($nights as $i => $data) {
            $Activity = new Activity\Entity($data);
            $Linker = new Linker($Activity);
            $View = new Dataview($Activity);
            if ($i % 2 == 0) {
                echo '<tr">';
            }
            echo '<td class="b">' . $View->daytime() . '</td>
				<td>' . $Linker->linkWithSportIcon() . '</td>
				<td>' . $View->distanceOrDuration() . ' ' . SportFactory::name($Activity->sportid()) . '</td>
				<td>' . $Linker->weekLink() . '</td>';
            if ($i % 2 == 1) {
                echo '</tr>';
            }
        }
        echo '</tbody></table>';
        // TODO: Find a better description.
        echo '<p class="text">';
        echo __('2 a.m. is considered as <em>most extreme</em> time for a training. ');
        echo __('The 20 trainings being nearest to that time are listed.');
        echo '</p>';
    }
Beispiel #7
0
 /**
  * Get content for a given dataset
  * @param string $name
  * @return string
  */
 public function getDataset($name)
 {
     switch ($name) {
         case 'sportid':
             if (!is_null($this->Sport)) {
                 return $this->Sport->icon()->code();
             }
             return '';
         case 'typeid':
             if (!is_null($this->Type)) {
                 if ($this->Type->isQualitySession()) {
                     return '<strong>' . $this->Type->abbreviation() . '</strong>';
                 }
                 return $this->Type->abbreviation();
             }
             return '';
         case 'time':
             return $this->Dataview->daytime();
         case 'distance':
             return $this->Dataview->distance() . $this->distanceComparison();
         case 's':
             return $this->Dataview->duration()->string();
         case 'pace':
             if ($this->Activity->distance() > 0) {
                 // TODO: 's_sum_with_distance'
                 //return $this->TrainingObject->DataView()->getSpeedStringForTime( $this->TrainingObject->getTimeInSecondsSumWithDistance() );
                 return $this->Dataview->pace()->valueWithAppendix();
             }
             return '';
         case 'elevation':
             return $this->Dataview->elevation();
         case 'kcal':
             return $this->Dataview->calories();
         case 'pulse_avg':
             if ($this->Activity->hrAvg() > 0) {
                 return $this->Dataview->hrAvg()->string();
             }
             return '';
         case 'pulse_max':
             if ($this->Activity->hrMax() > 0) {
                 return $this->Dataview->hrMax()->string();
             }
             return '';
         case 'trimp':
             return $this->Dataview->trimp();
         case 'cadence':
             if ($this->Dataview->cadence()->value() > 0) {
                 return $this->Dataview->cadence()->asString();
             }
             return '';
         case 'stride_length':
             if ($this->Dataview->strideLength()->inCM() > 0) {
                 return $this->Dataview->strideLength()->string();
             }
             return '';
         case 'groundcontact':
             return $this->Dataview->groundcontact();
         case 'vertical_oscillation':
             return $this->Dataview->verticalOscillation();
         case 'power':
             return $this->Dataview->power();
         case 'temperature':
             if (!$this->Activity->weather()->temperature()->isUnknown() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return $this->Activity->weather()->temperature()->asString();
             }
             return '';
         case 'weatherid':
             if (!$this->Activity->weather()->isEmpty() && (is_null($this->Sport) || $this->Sport->isOutside())) {
                 return $this->Activity->weather()->condition()->icon()->code();
             }
             return '';
         case 'routeid':
             if ($this->Activity->get(Activity\Object::ROUTEID) > 0) {
                 return $this->cut($this->Factory->route($this->Activity->get(Activity\Object::ROUTEID))->name());
             }
             return '';
         case 'clothes':
             return $this->cut($this->Dataview->clothes());
         case 'splits':
             if (!$this->Activity->splits()->isEmpty()) {
                 if ($this->Activity->splits()->hasActiveAndInactiveLaps() || round($this->Activity->splits()->totalDistance()) != round($this->Activity->distance()) || !is_null($this->Type) && $this->Type->id() == Configuration::General()->competitionType()) {
                     // TODO: Icon with tooltip?
                     $Icon = new Icon(Icon::CLOCK);
                     return $Icon->code();
                 }
             }
             return '';
         case 'comment':
             return $this->cut($this->Activity->comment());
         case 'partner':
             return $this->cut($this->Activity->partner()->asString());
         case 'abc':
             return $this->Dataview->abcIcon();
         case 'shoeid':
             if ($this->Activity->shoeID() > 0) {
                 return ShoeFactory::NameOf($this->Activity->shoeID());
             }
             return '';
         case 'vdoticon':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->vdotIcon();
             }
             return '';
         case 'vdot':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport() && $this->Activity->vdotByHeartRate() > 0) {
                 if (!$this->Activity->usesVDOT()) {
                     return '<span class="unimportant">' . $this->Dataview->vdot()->value() . '</span>';
                 }
                 return $this->Dataview->vdot()->value();
             }
             return '';
         case 'jd_intensity':
             if (!is_null($this->Sport) && $this->Sport->id() == Configuration::General()->runningSport()) {
                 return $this->Dataview->jdIntensityWithStresscolor();
             }
             return '';
     }
     return '';
 }