/**
  * Display formular for one training
  * @param TrainingObject $SingleObject
  */
 protected function displaySingleFormularFor(TrainingObject $SingleObject)
 {
     if ($SingleObject->Weather()->isEmpty()) {
         $SingleObject->setWeatherForecast();
     }
     $Formular = new TrainingFormular($SingleObject, StandardFormular::$SUBMIT_MODE_CREATE);
     $Formular->setId('training');
     $Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W50);
     $Formular->display();
 }
Esempio n. 2
0
 /**
  * Insert training
  * @param int $i
  */
 protected function insertTraining($i)
 {
     if (!isset($_POST['training-data'][$i])) {
         return;
     }
     $Data = unserialize(urldecode($_POST['training-data'][$i]));
     $Training = new TrainingObject(DataObject::$DEFAULT_ID);
     $Training->setFromArray($Data);
     $Training->setWeatherForecast();
     $Training->insert();
     $this->InsertedIDs[] = $Training->id();
 }
 /**
  * Set average temperature from array
  */
 private function setTemperatureFromArray()
 {
     $array = $this->TrainingObject->getArrayTemperature();
     if (!empty($array) && (min($array) != max($array) || min($array) != 0)) {
         $this->TrainingObject->setTemperature(round(array_sum($array) / count($array)));
     }
 }
 protected function checkArraySizes(\TrainingObject $object)
 {
     $arrays = array('elevation' => $object->getArrayAltitudeOriginal(), 'cadence' => $object->getArrayCadence(), 'distance' => $object->getArrayDistance(), 'heartrate' => $object->getArrayHeartrate(), 'latitude' => $object->getArrayLatitude(), 'longitude' => $object->getArrayLongitude(), 'pace' => $object->getArrayPace(), 'time' => $object->getArrayTime());
     $num = 0;
     $fails = false;
     $result = array();
     foreach ($arrays as $key => $array) {
         $count = count($array);
         if ($count > 1) {
             if ($num == 0) {
                 $num = $count;
             } elseif ($num != $count) {
                 $fails = true;
             }
             $result[$key] = $count;
         }
     }
     $this->assertFalse($fails, print_r($result, true));
 }
Esempio n. 5
0
 /**
  * Calculate distance
  */
 private function setDistanceFromGPSdata()
 {
     if (!empty($this->gps['latitude']) && !empty($this->gps['longitude']) && empty($this->gps['km'])) {
         $num = count($this->gps['latitude']);
         $this->gps['km'] = array(0);
         $lastDistance = 0;
         for ($i = 1; $i < $num; ++$i) {
             $step = round(Runalyze\Model\Route\Object::gpsDistance($this->gps['latitude'][$i - 1], $this->gps['longitude'][$i - 1], $this->gps['latitude'][$i], $this->gps['longitude'][$i]), ParserAbstract::DISTANCE_PRECISION);
             $this->gps['km'][] = $lastDistance + $step;
             $lastDistance += $step;
         }
         $this->TrainingObject->setArrayDistance($this->gps['km']);
         $this->TrainingObject->setDistance(end($this->gps['km']));
     }
 }
Esempio n. 6
0
/**
 * 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>';
 /**
  * Fill splits from gpx
  */
 protected function fillSplitsFromGPX()
 {
     if ($this->GPXImporter->object()->hasArrayTime() && $this->GPXImporter->object()->hasArrayDistance()) {
         $this->TrainingObject->Splits()->fillDistancesFromArray($this->GPXImporter->object()->getArrayTime(), $this->GPXImporter->object()->getArrayDistance());
     }
 }
 /**
  * Get table row for training
  * @param TrainingObject $TrainingObject
  * @param int $i
  */
 private function getTableRowFor(TrainingObject &$TrainingObject, $i)
 {
     $TrainingObject->updateAfterParsing();
     $Data = urlencode(serialize($TrainingObject->getArray()));
     $Inputs = HTML::checkBox('training-import[' . $i . ']', true);
     $Inputs .= HTML::hiddenInput('training-data[' . $i . ']', $Data);
     $Preview = new Preview(new Activity\Entity(array(Activity\Entity::TIMESTAMP => $TrainingObject->getTimestamp(), Activity\Entity::SPORTID => $TrainingObject->get('sportid'), Activity\Entity::TIME_IN_SECONDS => $TrainingObject->getTimeInSeconds(), Activity\Entity::DISTANCE => $TrainingObject->getDistance(), Activity\Entity::IS_TRACK => $TrainingObject->isTrack(), Activity\Entity::HR_AVG => $TrainingObject->getPulseAvg(), Activity\Entity::SPLITS => $TrainingObject->get('splits'), Activity\Entity::ROUTEID => $TrainingObject->hasPositionData())));
     $Row = '<td>' . $Inputs . '</td>';
     $Row .= '<td>' . $Preview->dateAndTime() . '</td>';
     $Row .= '<td>' . $Preview->duration() . '</td>';
     $Row .= '<td>' . $Preview->distance() . '</td>';
     $Row .= '<td>' . $Preview->sportIcon() . '</td>';
     $Row .= '<td>' . $Preview->hrIcon() . '</td>';
     $Row .= '<td>' . $Preview->splitsIcon() . '</td>';
     $Row .= '<td>' . $Preview->mapIcon() . '</td>';
     return $Row;
 }
Esempio n. 9
0
 * 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'])) {
    $Factory = Runalyze\Context::Factory();
    $Deleter = new Activity\Deleter(DB::getInstance(), $Factory->activity($_GET['delete']));
    $Deleter->setAccountID(SessionAccountHandler::getId());
    $Deleter->setEquipmentIDs($Factory->equipmentForActivity($_GET['delete'], true));
    $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\Entity($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>';