prepare($sql); $stmt->execute(); $coursestemp = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($coursestemp as $temp) { $courses[$temp['code']] = $temp; } $current_course = $courses[$select_course]; //d($courses); //d($select_course); $sql = "select * from ". $table_prefix ."membergroups where group_set = 2 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; } /* $sql = "select cp_code,count(bibno) as c from ". $table_prefix ."result_public where cp_code is not null group by cp_code"; //d($sql); $stmt = $db->prepare($sql); $stmt->execute(); $overall = $stmt->fetchAll(PDO::FETCH_ASSOC); */ if ($field == "place_group") { $sql = "select * from ". $table_prefix ."runners where group2_id = " . $select_group . $cat_where . " order by bibno"; } else if ($field == "place_gender") { $sql = "select * from ". $table_prefix ."runners where gender = '" . $select_gender . "'" . $cat_where . " order by bibno"; } else { $field = "place_course"; $sql = "select * from ". $table_prefix ."runners where 1=1 " . $cat_where ." order by bibno"; } //d($sql); $stmt = $db->prepare($sql); $stmt->execute(); $runnerstemp = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($runnerstemp as $temp) { if ($showall) { $runner[intval($temp['bibno'])] = $temp; } else if (array_intersect($currentcat, explode(',',$temp['cat']) )) { $runner[intval($temp['bibno'])] = $temp; } } //d($runnerstemp); /* $sql = "SELECT `bibno`, max(`updatetime`) AS latestupdatetime , `response` FROM " . $table_prefix . "trackrecord_summary GROUP BY bib"; $stmt = $db->prepare($sql); $stmt->execute(); $responsetemp = $stmt->fetchAll(PDO::FETCH_ASSOC); d(sizeof($responsetemp)) ; foreach ($responsetemp as $temp) { if ($temp['response'] == "yes") { $showresult[] = $temp['bib']; } } */ //d(sizeof($showresult)); /*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/ $starttime = $current_course['startdatetime']; //$starttime = "2017-01-20 08:30"; if ($field == "place_group") { $sql = "select * from ". $table_prefix ."result_rmac_public su left join ". $table_prefix . "runners ru on CONVERT(su.bibno,UNSIGNED INTEGER) = CONVERT(ru.bibno,UNSIGNED INTEGER) where su.place_group is not null and su.group = " . $select_group . " order by place_group "; } if ($field == "place_gender") { $sql = "select * from ". $table_prefix ."result_rmac_public su left join ". $table_prefix . "runners ru on CONVERT(su.bibno,UNSIGNED INTEGER) = CONVERT(ru.bibno,UNSIGNED INTEGER) where su.place_gender is not null and ru.gender = '" . $select_gender . "' order by place_group "; } if ($field == "place_course") { $sql = "select su.* from ". $table_prefix ."result_rmac_public su left join ". $table_prefix . "runners ru on CONVERT(su.bibno,UNSIGNED INTEGER) = CONVERT(ru.bibno,UNSIGNED INTEGER) where su.place_course is not null order by place_course "; } //d($sql); $stmt = $db->prepare($sql); $stmt->execute(); $resulttemp = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($resulttemp as $r) { $bib = intval($r['bibno']); //$bib = $r['bibno']; $result[$bib] = $r; //$result[$r['bibno']]['result'][$r['cp_code']] = $r[''] if (!$runner[$bib]) { //d($r['bibno']); $incorrectrunner[] = $bib; } else { $runner[$bib][$r['cp_code']] = $r; } } //d($runner); /*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/ /*--------------------------------------- summary ----------------------*/ $totalrunner = sizeof($runner); //SELECT count(*) FROM `fourtrailsmini2017a_runners` WHERE FIND_IN_SET('9',cat) or FIND_IN_SET('13',cat) //$totalrunner = 1060; //$checkpoints = array('CP1','CP2','CP3','CP4'); $checkpoints = array('CP1'); /* $totalcheckin = 0; foreach ($runner as $r) { if ($r['CHECKIN'] || ($r['CP1']) || ($r['CP2']) || ($r['CP3']) || ($r['CP4']) || ($r['FINISH']) ) $totalcheckin++; } */ //$totalmidpoint = 0; foreach ($runner as $r) { foreach ($checkpoints as $checkpoint ) { if ($r[$checkpoint]) { $totalcheckpoint[$checkpoint]++; } } } foreach ($checkpoints as $checkpoint ) { $checkpointprecent[$checkpoint] = ceil(($totalcheckpoint[$checkpoint]/$totalrunner) * 100); } foreach ($checkpoints as $checkpoint ) { if ($checkpointprecent[$checkpoint] > 100 ) $checkpointprecent[$checkpoint] = 100; } //d($runner); //d($totalrunner); //d($totalcheckin); //d($totalfinish); //d($totalmidpoint); //$checkinprecent = ceil(($totalcheckin/$totalrunner) * 100); //$midpointprecent = ceil(($totalmidpoint/$totalcheckin) * 100); //$finishprecent = ceil(($totalfinish/$totalcheckin) * 100); /* d($checkinprecent); d($midpointprecent); d($finishprecent); */ //if ($midpointprecent > 100) $midpointprecent = 100; //if ($finishprecent > 100) $finishprecent = 100; //if ($checkinprecent > 100) $checkinprecent = 100; /*-------------------------------------------------------------*/ if ($field == "place_group") { $arrivechartwhere = " and su.place_group is not null and su.group = " . $select_group ; } if ($field == "place_gender") { $arrivechartwhere = " and su.place_gender is not null and ru.gender = '" . $select_gender . "'" ; } if ($field == "place_course") { $arrivechartwhere = " and su.place_course is not null "; } function cmp($a, $b) { global $field; if ( !$a['FINISH'][$field] && !$b['FINISH'][$field] && !$a['CP1'][$field] && !$b['CP1'][$field] && !$a['CP2'][$field] && !$b['CP2'][$field] && !$a['CP3'][$field] && !$b['CP3'][$field] && !$a['CP4'][$field] && !$b['CP4'][$field] ) { return intcmp($a['bibno'], $b['bibno']); } if ($a['FINISH'][$field] && $b['FINISH'][$field]) return intcmp($a['FINISH'][$field], $b['FINISH'][$field]); if ($a['FINISH'][$field] && !$b['FINISH'][$field]) return -1; if (!$a['FINISH'][$field] && $b['FINISH'][$field]) return 1; if ($a['CP4'][$field] && $b['CP4'][$field]) return intcmp($a['CP4'][$field], $b['CP4'][$field]); if ($a['CP4'][$field] && !$b['CP4'][$field]) return -1; if (!$a['CP4'][$field] && $b['CP4'][$field]) return 1; if ($a['CP3'][$field] && $b['CP3'][$field]) return intcmp($a['CP3'][$field], $b['CP3'][$field]); if ($a['CP3'][$field] && !$b['CP3'][$field]) return -1; if (!$a['CP3'][$field] && $b['CP3'][$field]) return 1; if ($a['CP2'][$field] && $b['CP2'][$field]) return intcmp($a['CP2'][$field], $b['CP2'][$field]); if ($a['CP2'][$field] && !$b['CP2'][$field]) return -1; if (!$a['CP2'][$field] && $b['CP2'][$field]) return 1; if ($a['CP1'][$field] && $b['CP1'][$field]) return intcmp($a['CP1'][$field], $b['CP1'][$field]); if ($a['CP1'][$field] && !$b['CP1'][$field]) return -1; if (!$a['CP1'][$field] && $b['CP1'][$field]) return 1; if (!$b['CHECKIN'][$field]) return -1; if (!$a['CHECKIN'][$field]) return 1; if ($a['CHECKIN'][$field] || $b['CHECKIN'][$field]) return intcmp($a['CHECKIN'][$field], $b['CHECKIN'][$field]); /* if (!$b['CHECKIN'][$field]) return -1; if (!$a['CHECKIN'][$field]) return 1; if ($a['CHECKIN'][$field] || $b['CHECKIN'][$field]) return strcmp($a['CHECKIN'][$field], $b['CHECKIN'][$field]); */ return intcmp($a['bibno'], $b['bibno']); } //d($runner); //d($runner); uasort($runner, "cmp"); //array_orderby($runner, ['FINISH'][$field], SORT_NATURAL , SORT_STRING ); //d($runner); ?>

總成績 Overall result | 大帽山 TAI MO SHAN | 扯旗山 VICTORIA PEAK */ ?>

'; echo i18n_field( $course, "name"); echo ''; } */ //echo ' '; echo ''; echo i18n_text("Overall Ranking"); echo ''; echo '
'; //echo ' '; echo ''; echo i18n_text("Male Group"); echo ''; echo ''; //echo ' '; echo ''; echo i18n_text("Female Group"); echo ''; echo ''; foreach ($runner_groups as $group) { //echo ' '; echo ''; echo i18n_field( $group, "name"); echo ''; echo ''; } ?>

即時追蹤

">
'; echo ''; echo ''; echo ''; //echo ''; //echo ''; //echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($runner as $r) { //d($r); if (array_intersect($currentcat, explode(',',$r['cat']) )) { $warning = true; } else { $warning = false; } if ($warning) { echo ''; } else { echo ''; } echo ''; echo ''; echo ''; /* echo ''; */ /* foreach ($checkpoints as $checkpoint) { echo ''; } */ echo ''; echo ''; echo ''; echo ''; //d($r); } ?>
'; echo i18n_text("Place"); echo ''; echo 'BIB'; echo ''; echo i18n_text("Name"); echo ''; //echo '起步(芯片時間)'; //echo ''; //echo i18n_text("Check Point") . " 1"; //echo ''; //echo '返回點'; //echo ''; echo '終點 大會時間'; echo ''; echo '芯片時間'; echo ''; echo ''; echo '
'; if (!$r['FINISH'][$field] && !$r['CP1'][$field] && !$r['CP2'][$field] && !$r['CP3'][$field] && !$r['CP4'][$field] && !$r['CHECKIN'][$field] && !$r['START'][$field]) //if (!$r['FINISH'][$field] && !$r['START'][$field]) { echo "DNS"; } if (!$r['FINISH'][$field] && ($r['CP1'][$field] || $r['CP2'][$field] || $r['CP3'][$field] || $r['CP4'][$field] || $r['CHECKIN'][$field])) { //echo "DNF"; } // $cc++; // echo $cc; echo $r['FINISH'][$field]; echo ''; //echo str_pad($r['bibno'], 3, "0", STR_PAD_LEFT); echo $r['bibno_display']; echo ''; echo displayFirstLastname($r['firstname'], $r['lastname']); if ($r['nameonbadge']) echo ' (' . trim($r['nameonbadge']) . ')'; /* if ( $r['CHECKIN']['recorddatetime']) { echo '
'; echo i18n_text("Check In") . ":" ; echo $r['CHECKIN']['recorddatetime']; echo '
'; } */ //$cats = explode(",", $r['cat']); //if (!in_array(2,$cats)) //echo 'xxxxxxxxxxx'; echo '
'; if($r['START']['duration']) { echo Duration($r['START']['duration'], false, true); echo '
'; echo $r['START']['recorddatetime']; } if ($r['START'][$field]) { echo ' (' . $r['START'][$field] . ')'; echo '
'; } if (strtotime($r['START']['recorddatetime'])) { echo date("H:i:s", strtotime($r['START']['recorddatetime'])); }; echo '
'; if($r[$checkpoint]['duration']) { echo Duration($r[$checkpoint]['duration'], false, true); echo '
'; echo date("H:i:s", strtotime($r[$checkpoint]['recorddatetime'])); echo '
'; } if ($r[$checkpoint][$field]) { // echo '(' . $r[$checkpoint][$field] . ')'; } echo '
'; if($r['FINISH']['duration']) { echo Duration($r['FINISH']['duration'], false, true); echo '
'; echo $r['FINISH']['recorddatetime']; echo '
'; } if ($r['FINISH'][$field]) { //echo ' (' . $r['FINISH'][$field] . ')'; //echo ''; } echo '
'; if($r['FINISH']['chiptime']) { echo Duration($r['FINISH']['chiptime'], false, true); } echo ''; if ($r['FINISH']['place_course']) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo i18n_text("Overall Ranking") . ":"; echo ''; echo $r['FINISH']['place_course']; echo '
'; //echo i18n_text("Cat. Ranking") . ":"; echo i18n_field($runner_groups[$r['group2_id']],'name'); echo ' '; echo i18n_text("Ranking") . ":"; echo ''; echo $r['FINISH']['place_group']; echo '
'; //d($r); if ($r['gender'] == "M") { echo i18n_text("Male Group"); } else { echo i18n_text("Female Group"); } echo ' '; echo i18n_text("Ranking") . ":"; echo ''; echo $r['FINISH']['place_gender']; echo '
'; } echo '
(int)$b)return 1; if((int)$a < (int)$b)return -1; } ?>