Beispiel #1
0
 public function testFromKilograms()
 {
     $Weight = new Weight();
     $Weight->set(10);
     $this->assertEquals(10.0, $Weight->kg());
     $this->assertEquals(22.04, $Weight->pounds(), '', 0.01);
     $this->assertEquals(1.57, $Weight->stones(), '', 0.01);
 }
Beispiel #2
0
$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) {
    if ($i != 0 && $i != count($Labels) - 1) {
        $value = '';
    }
}
$Plot = new Plot("sportler_weights", 320, 150);
if ($Plugin->Configuration()->value('use_weight')) {
    $Plot->Data[] = array('label' => __('Weight'), 'color' => '#008', 'data' => $Weights);
}
if ($Plugin->Configuration()->value('use_pulse')) {
    $Plot->Data[] = array('label' => __('Resting HR'), 'color' => '#800', 'data' => $HRrests, 'yaxis' => 2);