Ejemplo n.º 1
0
 public function testStaticMethod()
 {
     Configuration::General()->weightUnit()->set(WeightUnit::KG);
     $unit = ' ' . Configuration::General()->weightUnit()->unit();
     $this->assertEquals('10.0' . $unit, Weight::format(10, true, 1));
     $this->assertEquals('12.346' . $unit, Weight::format(12.3456, true, 3));
     $this->assertEquals('12.3', Weight::format(12.3456, false, 1));
 }
Ejemplo n.º 2
0
        ?>
			<tr>
				<td><?php 
        echo RunalyzePluginPanel_Sportler::getDeleteLinkFor($Info['id']);
        ?>
</td>
				<td><?php 
        echo RunalyzePluginPanel_Sportler::getEditLinkFor($Info['id']);
        ?>
</td>
			<?php 
        foreach ($Fields as $Key => $Unit) {
            ?>
				<?php 
            if ($Key == 'weight') {
                $Weight = new Weight($Info[$Key]);
                $Info[$Key] = $Weight->string(false) . ' <small>' . $Weight->unit() . '</small>';
            }
            ?>
				<?php 
            $Value = $Unit == 'date' ? date('d.m.Y', $Info[$Key]) : $Info[$Key];
            ?>
				<?php 
            if ($Unit == 'date') {
                $Unit = '';
            }
            ?>
				<?php 
            if ($Key == 'sleep_duration' && $Value > 0) {
                $Value = (new Duration($Value * 60))->string('G:i');
            }
Ejemplo n.º 3
0
<?php

/**
 * Draw weight and rest-heartrate for the user
 * Call:   include 'Plot.gewicht.php'
 * @package Runalyze\Plugins\Panels
 */
use Runalyze\Activity\Weight;
$Weight = new Weight();
$Factory = new PluginFactory();
$Plugin = $Factory->newInstance('RunalyzePluginPanel_Sportler');
$Wunschgewicht = $Plugin->Configuration()->value('wunschgewicht');
if ($Plugin->Configuration()->value('plot_timerange') > 0) {
    $QueryEnd = 'WHERE `time` > ' . (time() - DAY_IN_S * (int) $Plugin->Configuration()->value('plot_timerange')) . ' AND `accountid` = ' . SessionAccountHandler::getId() . ' ORDER BY `time` DESC';
} else {
    $QueryEnd = 'WHERE `accountid` = ' . SessionAccountHandler::getId() . ' ORDER BY `time` DESC LIMIT ' . (int) $Plugin->Configuration()->value('plot_points');
}
$Data = array_reverse(DB::getInstance()->query('SELECT weight,pulse_rest,time FROM `' . PREFIX . 'user`' . ' ' . $QueryEnd)->fetchAll());
$Weights = array();
$HRrests = array();
if (count($Data) == 1) {
    $Data[1] = $Data[0];
}
if (!empty($Data)) {
    foreach ($Data as $D) {
        $Weights[$D['time'] . '000'] = $Weight->set($D['weight'])->valueInPreferredUnit();
        $HRrests[$D['time'] . '000'] = (int) $D['pulse_rest'];
    }
}
$Labels = array_keys($Weights);
foreach ($Labels as $i => &$value) {
    /**
     * Display the content (old design)
     */
    protected function displayContentInOldDesign()
    {
        $Weight = '';
        $Analyse = '';
        $UserData = new UserData(DataObject::$LAST_OBJECT);
        if ($this->Configuration()->value('use_weight')) {
            $UserWeight = new Weight($UserData->getWeight());
            $Weight = __('Weight') . ': <strong>' . Helper::Unknown($UserWeight->string(false), '-') . ' ' . $UserWeight->unit() . '</strong><br>';
        }
        if ($this->Configuration()->value('use_pulse')) {
            $Pulse = Helper::Unknown($UserData->getPulseRest(), '-') . ' bpm / ' . Helper::Unknown($UserData->getPulseMax()) . ' bpm';
        } else {
            $Pulse = Helper::Unknown($UserData->getPulseMax(), '-') . ' bpm';
        }
        if ($this->Configuration()->value('use_body_fat')) {
            $Analyse = __('Fat') . ': ' . Helper::Unknown($UserData->getBodyFat(), '-') . ' &#37;, ' . __('Water') . ': ' . Helper::Unknown($UserData->getWater(), '-') . ' &#37;, ' . __('Muscles') . ': ' . Helper::Unknown($UserData->getMuscles(), '-') . ' &#37;';
        }
        $AnalyseIsHidden = $this->Configuration()->value('use_weight') || $this->Configuration()->value('use_pulse');
        if (!$AnalyseIsHidden && !$this->Configuration()->value('use_body_fat')) {
            return;
        }
        echo '
			<div id="sportler-content">
				<span class="right">' . $Pulse . '</span>
				' . Ajax::flotChange($Weight, 'sportler_flots', 'sportler_weights') . '
				' . Ajax::flotChange($Analyse, 'sportler_flots', 'sportler_analyse', !$AnalyseIsHidden) . '

				<div id="sportler_flots" class="flot-changeable" style="position:relative;width:320px;height:150px;margin:0 auto;">
					<div class="flot ' . Ajax::$IMG_WAIT . '" id="sportler_weights" style="width:320px;height:150px;position:absolute;"></div>
					<div class="flot ' . Ajax::$IMG_WAIT . ($AnalyseIsHidden ? ' flot-hide' : '') . '" id="sportler_analyse" style="width:320px;height:150px;position:absolute;"></div>
				</div>
			</div>';
        include FRONTEND_PATH . '../plugin/' . $this->key() . '/Plot.gewicht.php';
        include FRONTEND_PATH . '../plugin/' . $this->key() . '/Plot.analyse.php';
    }