<?php
// vim: sw=4:ts=4
/**
* @version 00.04.09
* @package polaring
* @license This component in released under the GNU/GPL License
*
* File: view/day.php
* Role: Returns information about specific day.
*
**/
function showDay($dateTime) {
$phpindex = give::phpindex()."?section=polar";
$w = $_SESSION['workouts'][$dateTime];
visa::backLink($_REQUEST);
$trDatum = ucfirst(strftime("%a %d %b %Y, %R",
$w['dateStartTime']));
echo "<h2>".$trDatum."</h2>\n";
echo " <table class=\"dag\" >\n" .
" <tfoot>\n".
" <tr>\n".
" <td><p><a href=\"".$phpindex.
"&mission=samples&dateTime=".$dateTime."\">".
strings::expression("polar", "viewSamples").
"</a></p></td>\n".
" </tr>\n".
" </tfoot>\n".
" <tbody>\n";
$writeRow = array(
strings::expression("polar", "time").": ".$w['duration']);
if ( $w['distance'] > 0 ) {
$writeRow[] = strings::expression("polar", "distance").
": ".$w['distance']." ".$w['unitDistance'];
}
if ( $w['ascent'] > 0 || $w['ascent'] < 0 ) {
$writeRow[] = strings::expression("polar", "ascent").
": ".round($w['ascent'], 1)." ".$w['unitAltitude'];
}
if ( $w['speedAvg'] > 0 ) {
$writeRow[] = strings::expression("polar", "speedAvgMax").
": ".give::speedUnited($w['speedAvg'])."/".
give::speedUnited($w['speedMax'])." ".
$_SESSION['unitSpeed'];
}
if ( $w['altitudeAvg'] != 0 ) {
$writeRow[] = strings::expression("polar",
"altitudeAvgMax").": ".round($w['altitudeAvg'], 1)."/"
.round($w['altitudeMax'], 1)." ".$w['unitAltitude'];
}
if ( $w['hrAvg'] > 0 ) {
$writeRow[] = strings::expression("polar", "hrAvgMax").
": ".round($w['hrAvg'], 0)."/".$w['hrMax']." ".
$w['unitHr'];
}
if ( $w['energy'] > 0 ) {
$writeRow[] = strings::expression("polar", "energy").
": ".$w['energy']." ".$w['unitEnergy'];
}
if ( $w['temperatureAvg'] != 0 ) {
$writeRow[] = strings::expression("polar",
"temperatureAvgMax").": ".$w['temperatureAvg']."/"
.$w['temperatureMax']." ".$w['unitTemperature'];
}
foreach ($writeRow as $rad) {
list($text, $value) = split(': ', $rad);
echo " <tr>\n" .
" <td class=\"headline\"><p>".$text."</p></td>\n" .
" <td class=\"right\" ><p>".$value."</p></td>\n" .
" </tr>\n";
}
echo " </tbody>\n" .
" </table>\n";
/***********\
* GRAPHS
\***********/
echo "<h2>".strings::expression("polar", "graphs").
"</h2>\n<hr />\n";
echo "<table class=\"center day\" width=\"100%\" border=\"0\">\n".
" <thead>\n";
if ( isset($_REQUEST['selGraph']) ) {
echo " <tr>\n <td colspan=\"2\" class=\"center\">";
visa::graphLinkMedium($_REQUEST['selGraph']);
echo "</td>\n </tr>\n";
}
echo " </thead>\n <tfoot>\n <tr>\n <td colspan=\"2\" ".
"class=\"center\"><p>(".strings::expression("polar",
"ClickToEnlargeGraph").")</p></td>\n </tr>\n </tfoot>\n".
" <tbody>\n";
$_SESSION['nGraphs'] = 0;
// Google Maps
if ( $w['sampleLocationLat']['0'] ) {
visa::graphLinkSmall("dayGmapRoute",
strings::expression("polar", "Map"), "350", "150");
//gmaps::mapDiv();
}
// heartrate and distance
if ( $w['hrAvg'] > 0 ) {
// We've got a heartbeat!
if ( $w['distance'] > 0 ) {
// We've got a heartbeat!
if ( $w['distance'] > 0 ) {
// We've got both heartbeat and speed!
visa::graphLinkSmall("dayHeartrateSpeed",
strings::expression("polar", "hr_and_speed"),
"330", "150");
} else {
// We've got heartbeat but no speed.
visa::graphLinkSmall("dayHeartrate",
strings::expression("polar", "hr"),
"330", "150");
}
}
} elseif ( $w['distance'] > 0 ) {
// We haven't got a heartbeat but we HAVE got speed.
visa::graphLinkSmall("daySpeed",
strings::expression("polar", "speed"),
"330", "150");
}
// altitude
if ( $w['ascent'] != 0 ) {
// Have distance? Let x be distance (y=alt)
// Otherwise: let x be time (y=alt).
if ( $w['distance'] > 0 ) {
visa::graphLinkSmall("dayAltitudeDist",
strings::expression("polar", "altitude"),
"330", "150");
} else {
visa::graphLinkSmall("dayAltitudeTime",
strings::expression("polar", "altitude"),
"330", "150");
}
}
// heartrate-zones
if ( $w['hrAvg'] > 0 ) {
// heartrate in zones
visa::graphLinkSmall("dayHeartrateZones",
strings::expression("polar", "percent_of_maxhr"),
"330", "150");
// heartrate in zones (pie-graph)
visa::graphLinkSmall("dayHeartratePies",
strings::expression("polar", "hr_rounded_to_tenths").
" & ".strings::expression("polar", "hrZones"),
"150", "165");
}
echo " </tbody>\n</table>\n";
visa::backLink($_REQUEST);
return(true);
}
?>