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 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 group_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[$temp['bibno']] = $temp; } else if (array_intersect($currentcat, explode(',',$temp['cat']) )) { $runner[$temp['bibno']] = $temp; } } /* $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 . $resulttable . " 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 . $resulttable . " 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 . $resulttable . " 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 "; } $stmt = $db->prepare($sql); $stmt->execute(); $resulttemp = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($resulttemp as $r) { //$bib = intval($r['bibno']); $bib = str_pad($r['bibno'], 4, '0', STR_PAD_LEFT); $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; } } /*-------------------------------------------------------------*/ foreach ($runner as $key=>$r) { if ($r['firstname'] == "SPARE") unset($runner[$key]); } /*-------------------------------------------------------------*/ /*--------------------------------------- summary ----------------------*/ $totalrunner = sizeof($runner); //SELECT count(*) FROM `fourtrailsmini2017a_runners` WHERE FIND_IN_SET('9',cat) or FIND_IN_SET('13',cat) //$totalrunner = 1060; $totalcheckin = 0; foreach ($runner as $r) { if ($r['CHECKIN'] || ($r['CP1']) || ($r['CP2']) || ($r['CP3']) || ($r['FINISH']) ) $totalcheckin++; } /* $totalmidpoint = 0; foreach ($runner as $r) { if ($r['MIDPOINT']) $totalmidpoint++; } $totalfinish = 0; foreach ($runner as $r) { if ($r['FINISH']) $totalfinish++; } */ //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 "; } //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['FINISH']); $finalstatus = null; if (array_intersect($currentcat, explode(',',$r['cat']) )) { $warning = true; } else { $warning = false; } if ($warning) { echo ''; } else { echo ''; } echo ''; echo ''; echo ''; // echo ''; echo ''; echo ''; // // echo ''; echo ''; echo ''; echo ''; //d($r); } ?>
'; echo i18n_text("Place"); echo ''; echo 'BIB'; echo ''; echo i18n_text("Name"); echo ''; // echo i18n_text("Start Time"); // // echo '('; // // echo i18n_text("Chip Time"); // // echo ')'; // echo '
'; // echo '
'; echo i18n_text("Check Point") . " 1"; echo '
鶴藪水塘Hok Tau Reservoir
'; echo '
'; // echo i18n_text("Check Point") . " 2"; // echo '
黃嶺Wong Leng
'; // echo '
'; echo i18n_text("Check Point") . " 2"; echo '
仙姑峰Hsien Ku Fung
'; echo '
'; echo i18n_text("Finish"); echo '
新娘潭路Bride’s Pool Rd
'; echo '
'; echo '
'; if ($r['FINISH']['recorddatetime'] > $cutofftime) { echo "DNF"; $finalstatus = "DNF"; } if (!$r['FINISH'][$field] && !$r['CP1'][$field] && !$r['CP2'][$field] && !$r['CP3'][$field] && !$r['CHECKIN'][$field] && !$r['START'][$field]) { echo "DNS"; $finalstatus = "DNS"; } if (!$r['FINISH'][$field] && ($r['CP1'][$field] || $r['CP2'][$field] || $r['CP3'][$field] || $r['CHECKIN'][$field] || $r['START'][$field])) { echo "DNF"; $finalstatus = "DNF"; } if ($finalstatus) { } else { echo $r['FINISH'][$field]; } echo ''; echo $r['bibno']; 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']['recorddatetime']) // { // //echo Duration($r['START']['duration'], false, true); // echo '
'; // echo $r['START']['recorddatetime']; // echo '
'; // } // //if ($r['START'][$field]) { // // echo ' (' . $r['START'][$field] . ')'; // // echo ''; // //} // echo '
'; echo displaytimeblock($r['CP1']); echo ''; echo displaytimeblock($r['CP2']); // echo ''; // echo displaytimeblock($r['CP3']); // // echo ''; echo displaytimeblock($r['FINISH']); //if ($r['FINISH'][$field]) { //echo ' (' . $r['FINISH'][$field] . ')'; //echo ''; //} echo ''; if ($r['FINISH']['place_course'] && $finalstatus != "DNS" && $finalstatus != "DNF" ) { 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['group_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 '
'; $ret .= Duration($r['duration'], false, true); $ret .= ''; // if ($r['chiptime']) { // $ret .= '
'; // $ret .= 'Chip time'; // $ret .= '
'; // $ret .= '
'; // $ret .= Duration($r['chiptime'], false, true); // $ret .= '
'; // } $ret .= '
'; $ret .= $r['recorddatetime']; $ret .= '
'; //if ($r[$field]) { // echo '(' . $r[$field] . ')'; //} } return $ret; } function intcmp($a,$b) { if((int)$a == (int)$b)return 0; if((int)$a > (int)$b)return 1; if((int)$a < (int)$b)return -1; } function cmp($a, $b) { global $field; if ( !$a['FINISH'][$field] && !$b['FINISH'][$field] && !$a['CP2'][$field] && !$b['CP2'][$field] && !$a['CP1'][$field] && !$b['CP1'][$field] ) { return intcmp($a['bibno'], $b['bibno']); } // && !$a['START'][$field] && !$b['START'][$field] // && !$a['CHECKIN'][$field] && !$b['CHECKIN'][$field] // && !$a['CP3'][$field] && !$b['CP3'][$field] /*-------------*/ 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['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 ($a['START'][$field] && $b['START'][$field]) // return intcmp($a['START'][$field], $b['START'][$field]); // // // if ($a['START'][$field] && !$b['START'][$field]) // return -1; // // if (!$a['START'][$field] && $b['START'][$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']); } ?>