/** * Get search link * @return string */ public function getSearchLink() { if (Request::isOnSharedPage()) { return $this->getName(); } return ShoeFactory::getSearchLink($this->id()); }
/** * Construct new input field for: shoeid * @param string $name * @param string $label * @param string $value optional, default: loading from $_POST */ public function __construct($name, $label, $value = '') { parent::__construct($name, $label, $value); $this->addLayoutClass(TrainingFormular::$ONLY_RUNNING_CLASS); $this->addOption(0, '---- ' . __('select shoe')); foreach (ShoeFactory::NamesAsArray(!$this->showAll()) as $id => $name) { $this->addOption($id, $name); } }
protected function setUp() { \Cache::clean(); $this->PDO = \DB::getInstance(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'sport` (`name`,`kcal`,`outside`,`accountid`,`power`) VALUES("",600,1,0,1)'); $this->OutdoorID = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'sport` (`name`,`kcal`,`outside`,`accountid`,`power`) VALUES("",400,0,0,0)'); $this->IndoorID = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'shoe` (`name`,`km`,`time`,`accountid`) VALUES("",10,3000,0)'); $this->ShoeID1 = $this->PDO->lastInsertId(); $this->PDO->exec('INSERT INTO `' . PREFIX . 'shoe` (`name`,`km`,`time`,`accountid`) VALUES("",0,0,0)'); $this->ShoeID2 = $this->PDO->lastInsertId(); \SportFactory::reInitAllSports(); \ShoeFactory::reInitAllShoes(); }
header('Location: window.schuhe.table.php?reload=true'); exit; } if (Request::sendId() === false) { $Header = __('Add new shoe'); $Mode = StandardFormular::$SUBMIT_MODE_CREATE; $Shoe = new Shoe(DataObject::$DEFAULT_ID); } else { $Header = __('Edit shoe'); $Mode = StandardFormular::$SUBMIT_MODE_EDIT; $Shoe = new Shoe(Request::sendId()); } $Formular = new StandardFormular($Shoe, $Mode); if ($Formular->submitSucceeded()) { header('Location: window.schuhe.table.php'); ShoeFactory::clearCache(); exit; } if (Request::sendId() > 0) { $DeleteText = '<strong>' . __('Delete shoe') . ' »</strong>'; $DeleteUrl = $_SERVER['SCRIPT_NAME'] . '?delete=true&id=' . $Shoe->id(); $DeleteLink = Ajax::link($DeleteText, 'ajax', $DeleteUrl); if ($Shoe->getKm() != $Shoe->getAdditionalKm()) { $DeleteLink = __('The shoe cannot be deleted as long it is used for some activity.'); } $DeleteFieldset = new FormularFieldset(__('Delete shoe')); $DeleteFieldset->addWarning($DeleteLink); $Formular->addFieldset($DeleteFieldset); } $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Schuhe');
/** * Display table */ public function displayTable() { if (is_null($this->schuhe)) { $this->initTableData(); } echo '<table id="list-of-all-shoes" class="fullwidth zebra-style"> <thead> <tr> <th class="{sorter: \'x\'} small">' . __('x-times') . '</th> <th class="{sorter: false}"></th> <th>' . __('Name') . '</th> <th class="{sorter: \'germandate\'} small">' . __('since') . '</th> <th class="{sorter: \'distance\'}">Ø km</th> <th>Ø ' . __('Pace') . '</th> <th class="{sorter: \'distance\'} small"><small>' . __('max.') . '</small> km</th> <th class="small"><small>' . __('min.') . '</small> ' . __('Pace') . '</th> <th class="{sorter: \'resulttime\'}">' . __('Time') . '</th> <th class="{sorter: \'distance\'}">' . __('Distance') . '</th> <th>' . __('Weight') . '</th> </tr> </thead> <tbody>'; if (!empty($this->schuhe)) { foreach ($this->schuhe as $schuh) { $Shoe = new Shoe($schuh); $in_use = $Shoe->isInUse() ? '' : ' unimportant'; $Pace = new Pace($Shoe->getTime(), $Shoe->getKmInDatabase()); $MaxPace = new Pace($schuh['pace_in_s'], 1); echo '<tr class="' . $in_use . ' r" style="position: relative"> <td class="small">' . $schuh['num'] . 'x</td> <td>' . $this->editLinkFor($schuh['id']) . '</td> <td class="b l">' . ShoeFactory::getSearchLink($schuh['id']) . '</td> <td class="small">' . $Shoe->getSince() . '</td> <td>' . ($schuh['num'] != 0 ? Distance::format($Shoe->getKmInDatabase() / $schuh['num']) : '-') . '</td> <td>' . ($schuh['num'] != 0 ? $Pace->asMinPerKm() . '/km' : '-') . '</td> <td class="small">' . Distance::format($schuh['dist']) . '</td> <td class="small">' . $MaxPace->asMinPerKm() . '/km' . '</td> <td>' . $Shoe->getTimeString() . '</td> <td>' . $Shoe->getKmString() . '</td> <td class="small">' . $Shoe->getWeightString() . '</td> </tr>'; } } else { echo '<tr><td colspan="9">' . __('You don\'t have any shoes') . '</td></tr>'; } echo '</tbody>'; echo '</table>'; Ajax::createTablesorterFor("#list-of-all-shoes", true); }
$_POST = array(Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::ENDURANCE => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::MAX_TRIMP => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::VDOT => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::VDOT_CORRECTOR => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::ELEVATION => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::JD_POINTS => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::TRIMP => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::VDOT => true); /** * Run single cleanups */ $Accounts = $PDO->query(' SELECT id FROM `' . PREFIX . 'account` WHERE `cleanup`=0'); $AccountUpdate = $PDO->prepare('UPDATE `' . PREFIX . 'account` SET `cleanup`=1 WHERE `id`=?'); while ($Account = $Accounts->fetch()) { GlobalCleanupAccount::$ID = $Account['id']; DB::getInstance()->setAccountID($Account['id']); Runalyze\Context::reset(); Runalyze\Configuration::loadAll($Account['id']); ShoeFactory::reInitAllShoes(); $JobLoop = new Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop(); $JobLoop->run(); $JobGeneral = new Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral(); $JobGeneral->run(); if (OUTPUT) { echo $Account['id'] . ':' . EOL; echo implode(EOL, $JobLoop->messages()); echo implode(EOL, $JobGeneral->messages()); echo EOL . EOL; } $AccountUpdate->execute(array($Account['id'])); echo '.' . (CLI ? '' : ' '); } /** * Finish
/** * Recalculate shoe statistics */ protected function recalculateShoeStatistics() { $num = \ShoeFactory::numberOfShoes(); \ShoeFactory::recalculateAllShoes(); $this->addMessage(sprintf(__('Statistics have been recalculated for all <strong>%s</strong> shoes.'), $num)); }
/** * 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 ''; }
/** * Clear internal array */ private static function clearAllShoes() { self::$AllShoes = null; }