$extcss='';
require ("appheader.php");
$race = '91,92,93,94';
$eventstarttime = '2018-07-22 09:00';
$pointlist = array(
"a" => array('name_en'=>'HONG KONG TRAIL', 'name_zh_hant'=>'港島徑','eventdate'=>'2018-07-22'),
"c" => array('name_en'=>'RMAC WILSON TRAIL', 'name_zh_hant'=>'RMAC 衛奕信徑','eventdate'=>'2018-09-02'),
"d" => array('name_en'=>' instinct LANTAU TRAIL', 'name_zh_hant'=>' instinct 鳯凰徑','eventdate'=>'2018-11-04')
);
if ($_SESSION['lang'] == "zh_hant")
{
$title = "迷你四徑 2018 | 全埸總名次";
//$Route = "鳯凰山頂 -> 石門甲";
} else {
$title = "FOUR TRAILS MINI 2018 | Series overall";
//$Route = "Top of Lantau Peak
-> Shek Mun Kap";
}
$headertitle = "Live Track system | " . $title ;
$headerdescription = "";
$headerimg = "http://livetrack.sportsystem.hk/fourtrailsmini2018a/images/logo.png";
//$Temperature = "27.4°C-33.4°C";
//$Humidity = "56%-83%";
//$EventDate = "2018-06-10";
/*---------------*/
$select_gender = "";
$select_group = "";
$select_course = "fourtrailsmini2018all";
$sql = "select * from ". $table_prefix ."membergroups order by sorting";
$stmt = $db->prepare($sql);
$stmt->execute();
$runner_groupstemp = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($runner_groupstemp as $temp)
{
$runner_groups[$temp['id']] = $temp;
}
//d($runner_groups);
$bib = intval(getpostval("bib"));
if (!$bib)
{
//echo "FAILED";
//die();
}
$catwhere = "and calcresult=1 ";
$sql = "select * from ". $table_prefix ."runners where 1=1 and bibno = :bib " . $catwhere . " order by bibno";
$stmt = $db->prepare($sql);
$stmt->bindParam(':bib', str_pad($bib , 4, "0", STR_PAD_LEFT)) ;
$stmt->execute();
$runner = $stmt->fetch(PDO::FETCH_ASSOC);
//d($runner);
if (!$runner && getpostval("bib"))
{
$error = i18n_text("Runner not found");
unset($runner);
}
if ($runner && $runner['races'] != $race && getpostval("bib"))
{
$error = i18n_text("Runner not found for Series");
unset($runner);
}
$runner_group = $runner_groups[$runner['group_id']];
$sql = "select * from ". $table_prefix ."trackrecord_summary where 1=1 and bibno = :bib and cp_code='FINISH' ";
$stmt = $db->prepare($sql);
$stmt->bindParam(':bib', $bib) ;
$stmt->execute();
$finishresult = $stmt->fetch(PDO::FETCH_ASSOC);
if ($finishresult)
$finishresult['formatedduration'] = Duration($finishresult['duration'], false, true);
$finishresult['duration'] = $finishresult['duration'];
$sql = "select recorddatetime,place_group,duration from ". $table_prefix ."trackrecord_summary where 1=1 and bibno = :bib and cp_code='MIDPOINT' ";
$stmt = $db->prepare($sql);
$stmt->bindParam(':bib', $bib) ;
$stmt->execute();
$midpointresult = $stmt->fetch(PDO::FETCH_ASSOC);
if ($midpointresult)
$midpointresult['formatedduration'] = Duration($midpointresult['duration'], false, true);
$midpointresult['duration'] = $midpointresult['duration'];
//d($midpointresult);
//d($finishresult);
//d($runner ) ;
//d($runner_group ) ;
$r['nameonbadge'] = $runner['nameonbadge'];
$r['name'] = displayFirstLastname($runner['firstname'],$runner['lastname']);
$r['bib'] = str_pad($bib , 4, "0", STR_PAD_LEFT);
$r['groups'] = i18n_field($runner_group,'name');
$r['place_group'] = $finishresult['place_group'];
if ($midpointresult)
$r['checkpoint1'] = $midpointresult;
if ($finishresult)
$r['finishpoint'] = $finishresult;
if ($r['name'] && $finishresult['formatedduration'])
{
if ($_SESSION['lang'] == "zh_hant")
{
$headertitle = $r['name'] . ' finished Four Trails MINI - at ' . $finishresult['formatedduration'];
} else {
$headertitle = $r['name'] . ' 在 ' . $finishresult['formatedduration'] . ' 完成了迷你四徑' ;
}
}
if (($r['checkpoint1']['formatedduration'] || $r['checkin']['formatedduration']) && !$r['finishpoint']['formatedduration'] || $r['finishpoint']['duration'] == 9999999 )
{
$status = "DNF";
}
if (!$r['checkpoint1']['formatedduration'] && !$r['checkin']['formatedduration'] && !$r['finishpoint']['formatedduration'])
{
$status = "DNS";
}
if ($r['finishpoint']['formatedduration'] && $r['finishpoint']['duration'] != 9999999 )
{
$status = "FINISHED";
}
if (!$r['finishpoint']['formatedduration'])
{
$r['finishpoint']['formatedduration'] = "N/A";
$r['finishpoint']['place_group'] = "N/A";
$r['place_group'] = "N/A";
}
if (!$r['checkpoint1']['formatedduration'])
{
$r['checkpoint1']['formatedduration'] = "N/A";
$r['checkpoint1']['place_group'] = "N/A";
}
if (getpostval("dataonly") == 1){
$returnhtml = '
'. i18n_text("Time") . '
'; $returnhtml .= '
';
$returnhtml .= '