function calcRankingPoints($round) { global $glb_connection_server; global $strConvtableRankingPoints, $strConvtableRankingPointsU20, $cfgEventType; global $strEventTypeSVMNL, $strEventTypeSingleCombined, $strEventTypeClubAdvanced, $strEventTypeClubBasic, $strEventTypeClubTeam, $strEventTypeClubMixedTeam; global $cvtTable; try { $valid = false; $minus = true; // // initialize parameters // $pStart = 0; $pStep = 0; $bSVM = false; // set if contest type has a result limitation for only best athletes // e.g.: for svm NL only the 2 best athletes of a team are counting -> distribute points on these athletes $countMaxRes = 0; // set to the maximum of countet results in case of an svm contest $sql = "\r\n SELECT\r\n w.Punktetabelle\r\n , w.Punkteformel\r\n , w.Typ\r\n FROM\r\n runde as r\r\n LEFT JOIN wettkampf as w ON (r.xWettkampf = w.xWettkampf )\r\n WHERE \r\n r.xRunde = {$round}"; $qry = $glb_connection_server->prepare($sql); $qry->execute(); $row = $qry->fetch(PDO::FETCH_NUM); $rpt = ""; if ($row[0] == $cvtTable[$strConvtableRankingPoints]) { $rpt = $cvtTable[$strConvtableRankingPoints]; } elseif ($row[0] == $cvtTable[$strConvtableRankingPointsU20]) { $rpt = $cvtTable[$strConvtableRankingPointsU20]; } if ($row[0] == $rpt) { // if mode is team if ($row[2] > $cfgEventType[$strEventTypeSingleCombined]) { $bSVM = true; switch ($row[2]) { case $cfgEventType[$strEventTypeSVMNL]: $countMaxRes = 1; break; case $cfgEventType[$strEventTypeClubBasic]: $countMaxRes = 1; break; case $cfgEventType[$strEventTypeClubAdvanced]: $countMaxRes = 2; break; case $cfgEventType[$strEventTypeClubTeam]: $countMaxRes = 5; break; case $cfgEventType[$strEventTypeClubMixedTeam]: $countMaxRes = 6; break; default: $countMaxRes = 1; } } //list($pStart, $pStep) = explode(" ", $GLOBALS['cvtFormulas'][$rpt][$row[1]]); list($pStart, $pStep) = explode(" ", $row[1]); if (strpos($row[1], '-')) { $pStep = str_replace('-', '', $pStep); $minus = true; } else { $pStep = str_replace('+', '', $pStep); $minus = false; } $valid = true; } // // calculate points // if ($valid) { // if svm, the ranking points have only to be distributed on the results that count afterwards for team // so: only the best 2 athletes of the same team will get points if (!$bSVM) { $sql = "\r\n SELECT\r\n ss.xSerienstart\r\n , ss.Rang\r\n FROM\r\n serienstart AS ss\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie )\r\n WHERE \r\n s.xRunde = {$round}\r\n AND ss.Rang > 0\r\n ORDER BY ss.Rang ASC\r\n "; $qry = $glb_connection_server->prepare($sql); $qry->execute(); } else { $sql = "\r\n SELECT \r\n ss.xSerienstart\r\n , ss.Rang\r\n , IF(a.xTeam > 0, a.xTeam, staf.xTeam)\r\n FROM\r\n serienstart AS ss\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie )\r\n LEFT JOIN start AS st ON (ss.xStart = st.xStart)\r\n LEFT JOIN staffel AS staf ON (st.xStaffel = staf.xStaffel)\r\n LEFT JOIN anmeldung AS a ON (st.xAnmeldung = a.xAnmeldung)\r\n WHERE \r\n s.xRunde = {$round}\r\n AND ss.Rang > 0\r\n ORDER BY ss.Rang ASC;"; $qry = $glb_connection_server->prepare($sql); $qry->execute(); } $rows = $qry->fetchAll(PDO::FETCH_NUM); $pts = 0; // points to share $rank = 1; // current rank $update = array(); // holding serienstart[key] with points $tmp = array(); // holding temporary serienstarts $point = $pStart; // current points to set $i = 0; // share counter $cClubs = array(); // count athlete teams for svm mode foreach ($rows as $row) { if ($bSVM) { // count athletes per club if (isset($cClubs[$row[2]])) { $cClubs[$row[2]]++; } else { $cClubs[$row[2]] = 1; } // skip result if more than MaxRes athletes of a team are on top if (isset($cClubs[$row[2]]) && $cClubs[$row[2]] > $countMaxRes) { $sql = "UPDATE resultat SET\r\n Punkte = 0\r\n WHERE\r\n xSerienstart = {$row['0']};"; $qry = $glb_connection_server->prepare($sql); $qry->execute(); AA_StatusChanged($row[0]); continue; // skip } } if ($rank != $row[1] && $i > 0) { $p = $pts / $i; // divide points for athletes with the same rank $p = round($p, 1); foreach ($tmp as $x) { $update[$x] = $p; } $i = 1; $pts = $point; $rank = $row[1]; $tmp = array(); } else { $i++; $pts += $point; } $tmp[] = $row[0]; if ($minus) { $point -= $pStep; } else { $point += $pStep; } } // check on last entries if ($i > 0) { $p = $pts / $i; // divide points for athletes with the same rank $p = round($p, 1); foreach ($tmp as $x) { $update[$x] = $p; } } // update points foreach ($update as $key => $p) { $sql = "UPDATE resultat SET\r\n Punkte = {$p}\r\n WHERE\r\n xSerienstart = {$key};"; $qry = $glb_connection_server->prepare($sql); $qry->execute(); AA_StatusChanged($key); } } // endif $valid } catch (PDOException $e) { trigger_error($e->getMessage()); } }
function AA_results_deleteResults($round) { require './lib/common.lib.php'; require './lib/utils.lib.php'; global $cfgMaxAthlete; $prog_mode = AA_results_getProgramMode(); // get each heat start and delete results for it mysql_query("LOCK TABLES serie as s READ, serienstart as sst READ, serienstart AS WRITE ,resultat WRITE"); $sql = "SELECT \r\n sst.xSerienstart, \r\n s.xSerie \r\n FROM\r\n serienstart as sst\r\n LEFT JOIN serie as s ON (sst.xSerie = s.xSerie)\r\n WHERE\r\n s.xRunde = " . $round; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $z = 0; while ($row = mysql_fetch_array($res)) { mysql_query("DELETE FROM resultat WHERE xSerienstart = " . $row[0]); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } AA_StatusChanged(0, 0, $row[0]); if ($prog_mode == 2) { if ($z == 0) { mysql_query("UPDATE serie SET MaxAthlet = " . $cfgMaxAthlete . " WHERE xSerie = " . $row[1]); $sql = "UPDATE serie SET MaxAthlet = " . $cfgMaxAthlete . " WHERE xSerie = " . $row[1]; if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } mysql_query("UPDATE serienstart SET Position2 = 0, Position3 = 0 , Rang = 0 , AktivAthlet = 'n' WHERE xSerienstart = " . $row[0]); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } $z++; } } mysql_query("UNLOCK TABLES"); // change status to heats_done AA_utils_changeRoundStatus($round, $GLOBALS['cfgRoundStatus']['heats_done']); if (!empty($GLOBALS['AA_ERROR'])) { AA_printErrorMsg($GLOBALS['AA_ERROR']); } }
function AA_rankinglist_Combined($category, $formaction, $break, $cover, $sepu23, $cover_timing = false, $date = '%', $disc_nr, $catFrom, $catTo, $ukc) { require './lib/cl_gui_page.lib.php'; require './lib/cl_print_page.lib.php'; require './lib/cl_export_page.lib.php'; require './lib/common.lib.php'; require './lib/results.lib.php'; require './config.inc.php'; if (AA_connectToDB() == FALSE) { // invalid DB connection return; // abort } if (AA_checkMeetingID() == FALSE) { // no meeting selected return; // abort } $contestcat = " "; if (!empty($category)) { // show every category $contestcat = " AND w.xKategorie = {$category}"; } if ($catFrom > 0) { $getSortCat = AA_getSortCat($catFrom, $catTo); if ($getSortCat[0]) { if ($catTo > 0) { $contestcat = " AND k.Anzeige >=" . $getSortCat[$catFrom] . " AND k.Anzeige <=" . $getSortCat[$catTo] . " "; } else { $contestcat = " AND k.Anzeige =" . $getSortCat[$catFrom] . " "; } } } $GroupByUkc = ""; if ($ukc) { $checkyear = date('Y') - 16; $min_age = date('Y') - 7; $selection = " AND at.Jahrgang > {$checkyear} AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") "; $sql_leftjoin = " LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (w.xDisziplin = d.xDisziplin) "; $order = " at.Geschlecht, at.Jahrgang, at.Name, at.Vorname, d.Anzeige"; $disc_nr = 3; } else { $selection = " AND w.Mehrkampfcode > 0 "; $sql_leftjoin = " LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (w.Mehrkampfcode = d.Code)"; $order = " k.Anzeige , w.Mehrkampfcode , ka.Alterslimite DESC"; } $dCode = 0; if ($ukc) { $mk = ",0"; } else { $mk = ",w.Mehrkampfcode"; } // get athlete info per contest category $sql1 = "SELECT DISTINCT \r\n a.xAnmeldung\r\n , at.Name\r\n , at.Vorname\r\n , at.Jahrgang\r\n , k.Name\r\n , IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)\r\n , IF(at.xRegion = 0, at.Land, re.Anzeige)"; $sql2 = ", d.Name\r\n , w.xKategorie\r\n , ka.Code\r\n , ka.Name\r\n , ka.Alterslimite \r\n , d.Code \r\n , at.xAthlet\r\n , at.Geschlecht \r\n FROM\r\n anmeldung AS a\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet )\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein )\r\n LEFT JOIN start as st ON (st.xAnmeldung = a.xAnmeldung ) \r\n LEFT JOIN wettkampf as w ON (w.xWettkampf = st.xWettkampf) " . $sql_leftjoin . "\r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n LEFT JOIN kategorie AS ka ON (ka.xKategorie = a.xKategorie) \r\n LEFT JOIN region as re ON (at.xRegion = re.xRegion) \r\n WHERE a.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n " . $contestcat . " \r\n " . $selection . " \r\n AND st.anwesend = 0 "; $sqlOrder = " ORDER BY " . $order; $sql = $sql1 . $mk . $sql2 . $sqlOrder; $results = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $cat = ''; $catEntry = ''; $catEntryLimit = ""; $u23name = ""; $comb = 0; // hold combined type $combName = ""; $lastTime = ""; // hold start time of last event for print list $a = 0; $info = ''; $points = 0; $sep = ''; $rFrom = 0; $rTo = 0; $limitRank = false; if ($_GET['limitRank'] == "yes" && substr($formaction, 0, 6) == "export") { // check if ranks are limited if (!empty($_GET['limitRankFrom']) && !empty($_GET['limitRankTo'])) { $limitRank = true; $rFrom = $_GET['limitRankFrom']; $rTo = $_GET['limitRankTo']; } } // start a new HTML display page if ($formaction == 'view') { // display page for speaker $list = new GUI_CombinedRankingList($_COOKIE['meeting']); $list->printPageTitle("{$strRankingLists} " . $_COOKIE['meeting']); } elseif ($formaction == "print") { $list = new PRINT_CombinedRankingList($_COOKIE['meeting']); if ($cover == true) { // print cover page $list->printCover($GLOBALS['strResults'], $cover_timing); } } elseif ($formaction == "exportpress") { $list = new EXPORT_CombinedRankingListPress($_COOKIE['meeting'], 'txt'); } elseif ($formaction == "exportdiplom") { $list = new EXPORT_CombinedRankingListDiplom($_COOKIE['meeting'], 'csv'); } if ($ukc) { while ($row = mysql_fetch_row($results)) { if ($roundsUkc[$row[4]][$row[14]] == "") { $roundsUkc[$row[4]][$row[14]] = 0; } $roundsUkc[$row[4]][$row[14]]++; } $GroupByUkc = " GROUP BY at.xAthlet "; $mk = ",w.Mehrkampfcode"; $sql = $sql1 . $mk . $sql2 . $GroupByUkc . $sqlOrder; $results = mysql_query($sql); } while ($row = mysql_fetch_row($results)) { $dCode = $row[13]; $row3_tmp = $row[3]; if ($row3_tmp > $min_age) { $row3_tmp = $min_age; } if ($ukc) { if ($roundsUkc[$row[4]][$row[14]] != 3) { continue; } } // store previous before processing new athlete if ($a != $row[0] && $a > 0) { $points_arr[] = $points; if ($ukc) { $xKatUKC = AA_getCatUkc($birthDate, $sex, true); $points_arr_more_disc_all[$xKatUKC][] = $points_disc; } else { $points_arr_more_disc_all[$row[9]][] = $points_disc; } $name_arr[] = $name; $year_arr[] = $year; $club_arr[] = $club; $info_arr[] = $info; $ioc_arr[] = $ioc; $x_arr[] = $a; if (isset($points_disc_keep) && sizeof($points_disc_keep) < 3 && $ukc) { $rank_arr[] = 0; } else { $rank_arr[] = $rank; } $info = ''; $points = 0; $sep = ''; } // print previous before processing new category if (!empty($cat) && (($row[4] != $cat || $row[7] != $comb) && $ukc == false || $ukc == true && $row3_tmp != $age || ($comb == 410 || $comb == 400) && $catEntry != $row[10] && $row[12] < 23 && !$bU23 && $sepu23)) { $bU23 = false; // set the separate flag! else it will be separated by each category if (($comb == 410 || $comb == 400) && $catEntry != $row[10] && $row[12] < 23) { $bU23 = true; } $u23name = ''; // set the addition for the title if this is the separated cat if (($comb == 410 || $comb == 400) && $catEntryLimit < 23 && $sepu23) { $u23name = " (U 23)"; } $list->endList(); if ($ukc) { $list->printSubTitle($catUKC . ", " . $cfgUKC_Name); } else { $list->printSubTitle($cat . "{$u23name}, " . $combName, "", ""); } $list->startList(); $list->printHeaderLine($lastTime); arsort($points_arr, SORT_NUMERIC); // sort descending by points $rank = 1; // initialize rank $r = 0; // start value for ranking $p = 0; $no_rank = 999999; $max_rank = $no_rank; foreach ($points_arr as $key => $val) { $r++; if ($limitRank && ($r < $rFrom || $r > $rTo)) { // limit ranks if set (export) continue; } if ($p != $val) { // not same points as previous team $rank = $r; // next rank } // not set rank for invalid results if (preg_match("@\\(-[1]{1}@", $info_arr[$key])) { $rank = $max_rank; $max_rank += 1; $r--; } $rank_arr[$key] = $rank; $p = $val; // keep current points } asort($rank_arr, SORT_NUMERIC); // sort descending by rank $rank_keep = 0; $key_keep = ''; foreach ($rank_arr as $key => $v) { $val = $points_arr[$key]; $rank = $v; if ($rank == $rank_keep) { $c = 0; $keep_c = 0; // first rule for ($i = 1; $i <= sizeof($points_disc); $i++) { if ($points_arr_more_disc_all[$xKat][$key_keep][$i] > $points_arr_more_disc_all[$xKat][$key][$i]) { $keep_c++; } else { $c++; } } $more = ceil(sizeof($points_disc) / 2); if (sizeof($points_disc) % 2 == 0) { // combined with even number discs $more++; } if ($keep_c >= $more && $keep_c > $c) { $rank_arr[$key]++; } else { if ($c >= $more && $c > $keep_c) { $rank_arr[$key_keep]++; } else { // second rule // check the best points of the highest points of discipline $k = AA_get_AthletBestPointDisc($points_arr_more_disc_all[$xKat][$key_keep], $points_arr_more_disc_all[$xKat][$key], $key_keep, $key); if ($k != 0) { $rank_arr[$k]++; } // if $k is 0, all points of diszipline are the same --> athletes with same rank } } } $rank_keep = $rank; $key_keep = $key; } asort($rank_arr, SORT_NUMERIC); // sort descending by rank foreach ($rank_arr as $key => $v) { $val = $points_arr[$key]; $rank = $v; if ($rank >= $no_rank) { $rank = ''; } $list->printLine($rank, $name_arr[$key], $year_arr[$key], $club_arr[$key], $val, $ioc_arr[$key]); $list->printInfo($info_arr[$key]); // insert points into combined top performance of entry mysql_query("UPDATE anmeldung SET BestleistungMK = {$val} WHERE xAnmeldung = " . $x_arr[$key]); } unset($points_arr); unset($name_arr); unset($year_arr); unset($club_arr); unset($info_arr); unset($ioc_arr); unset($x_arr); unset($rank_arr); if (is_a($list, "PRINT_CombinedRankingList") && $break == 'category') { // page break after category $list->insertPageBreak(); } } $cat = $row[4]; // keep current category $age = $row3_tmp; if ($ukc) { $catUKC = AA_getCatUkc($row[3], $row[15], false); $xKat = AA_getCatUkc($row[3], $row[15], true); } else { $xKat = $row[9]; } $catEntry = $row[10]; $catEntryLimit = $row[12]; $comb = $row[7]; $combName = $row[8]; if ($ukc) { $order = " d.Anzeige, ru.Datum, ru.Startzeit"; $selectionDisc = " AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") "; $selectionMk = ''; } else { $order = " w.Mehrkampfreihenfolge ASC, ru.Datum, ru.Startzeit"; $selectionMk = " AND w.Mehrkampfcode = " . $row[7]; $selectionDisc = ''; } // events $query = "SELECT\r\n d.Kurzname\r\n , d.Typ\r\n , MAX(IF ((r.Info='-') && (d.Typ = 6) ,0,r.Leistung)) \r\n , r.Info\r\n , MAX(IF ((r.Info='-') && (d.Typ = 6),0,r.Punkte)) AS pts \r\n , s.Wind\r\n , w.Windmessung\r\n , st.xStart\r\n , CONCAT(DATE_FORMAT(ru.Datum,'{$cfgDBdateFormat}'), ' ', TIME_FORMAT(ru.Startzeit, '{$cfgDBtimeFormat}'))\r\n , w.Mehrkampfreihenfolge \r\n , ss.Bemerkung\r\n , w.info\r\n , ss.xSerienstart \r\n , d.Code\r\n FROM\r\n start AS st USE INDEX (Anmeldung)\r\n LEFT JOIN serienstart AS ss ON (ss.xStart = st.xStart )\r\n LEFT JOIN resultat AS r ON (r.xSerienstart = ss.xSerienstart) \r\n LEFT JOIN serie AS s ON (s.xSerie = ss.xSerie)\r\n LEFT JOIN runde AS ru ON (ru.xRunde = s.xRunde)\r\n LEFT JOIN wettkampf AS w ON (w.xWettkampf = st.xWettkampf)\r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " AS d ON (d.xDisziplin = w.xDisziplin)\r\n WHERE st.xAnmeldung = {$row['0']} \r\n {$selectionDisc} \r\n AND ( (r.Info = '" . $cfgResultsHighOut . "' && d.Typ = 6 && r.Leistung < 0) OR (d.Typ = 6 && (r.Info != '" . $cfgResultsHighOut . "' && r.Info != '" . $cfgResultsHighOut1 . "' \r\n && r.Info != '" . $cfgResultsHighOut2 . "' && r.Info != '" . $cfgResultsHighOut3 . "' && r.Info != '" . $cfgResultsHighOut4 . "'\r\n && r.Info != '" . $cfgResultsHighOut5 . "' && r.Info != '" . $cfgResultsHighOut6 . "' && r.Info != '" . $cfgResultsHighOut7 . "' && r.Info != '" . $cfgResultsHighOut7 . "'))\r\n OR (d.Typ != 6 ) ) \r\n \r\n AND w.xKategorie = {$row['9']}\r\n {$selectionMk} \r\n AND ru.Status = " . $cfgRoundStatus['results_done'] . " \r\n GROUP BY\r\n st.xStart\r\n ORDER BY\r\n {$order}"; $res = mysql_query($query); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $count_disc = 0; $remark = ''; $points_disc = array(); while ($pt_row = mysql_fetch_row($res)) { $remark = $pt_row[10]; $lastTime = $pt_row[8]; if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeJump]) { $res2 = mysql_query("SELECT r.Info FROM \r\n\t\t\t\t\t\t\t\tresultat as r\r\n\t\t\t\t\t\t\t\tLEFT JOIN serienstart as ss USING(xSerienstart)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tss.xStart = {$pt_row['7']}\r\n\t\t\t\t\t\t\tAND\tr.Punkte = {$pt_row['4']}"); $row2 = mysql_fetch_array($res2); $pt_row[3] = $row2[0]; } // set wind, if required if ($pt_row[6] == 1) { if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeTrack]) { $wind = " / " . $pt_row[5]; } else { if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeJump]) { $wind = " / " . $pt_row[3]; } } } else { $wind = ''; } // format output if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeJump] || $pt_row[1] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $pt_row[1] == $cfgDisciplineType[$strDiscTypeThrow] || $pt_row[1] == $cfgDisciplineType[$strDiscTypeHigh]) { $perf = AA_formatResultMeter($pt_row[2]); } else { $perf = AA_formatResultTime($pt_row[2], true); } // show only points for number of choosed disciplines if the diszipline is done $count_disc++; if ($count_disc <= $disc_nr) { if ($pt_row[4] > 0 || $ukc) { // any points for this event if ($ukc) { $pointsUKC = AA_utils_calcPointsUKC(0, $pt_row[2], 0, $row[16], $pt_row[12], $row[14], $row[0], $pt_row[13]); $points = $points + $pointsUKC; // calculate points mysql_query("UPDATE resultat SET\r\n Punkte = {$pointsUKC}\r\n WHERE\r\n xSerienstart = {$pt_row['12']}"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } AA_StatusChanged(0, 0, $pt_row[12]); } else { $points = $points + $pt_row[4]; // calculate points } if ($dCode == 408) { // UBS Kids Cup switch ($pt_row[1]) { case 1: case 2: $c = 1; // track break; case 4: case 5: case 6: $c = 2; // jump and high break; case 8: $c = 3; // throw break; default: $c = 0; break; } $points_disc[$c] = $pt_row[4]; } else { if ($ukc) { switch ($pt_row[1]) { case 1: case 2: $c = 1; // track break; case 4: case 5: case 6: $c = 2; // jump and high break; case 8: $c = 3; // throw break; default: $c = 0; break; } $points_disc[$c] = $pointsUKC; } else { $points_disc[$row[9]] = $pt_row[4]; } } if ($ukc) { $info = $info . $sep . $pt_row[0] . " " . " (" . $perf . $wind . ", {$pointsUKC})"; } else { $info = $info . $sep . $pt_row[0] . " " . " (" . $perf . $wind . ", {$pt_row['4']})"; } $sep = ", "; } elseif ($pt_row[4] == 0 && $pt_row[2] >= 0) { // athlete with 0 points $info = $info . $sep . $pt_row[0] . " " . " (" . $perf . $wind . ", {$pt_row['4']})"; $sep = ", "; } else { $count_disc--; $pointTxt = ""; foreach ($cfgInvalidResult as $value) { if ($value['code'] == $perf) { $pointTxt = $value['short']; } } $info = $info . $sep . $pt_row[0] . $pt_row[11] . " (" . $perf . $wind . ", {$pointTxt})"; $sep = ", "; } } } // END WHILE combined events mysql_free_result($res); } $a = $row[0]; $name = $row[1] . " " . $row[2]; $year = AA_formatYearOfBirth($row[3]); $birthDate = $row[3]; $sex = $row[15]; $club = $row[5]; $ioc = $row[6]; $remark_arr[] = $remark; if ($ukc) { $xKat = AA_getCatUkc($row[3], $row[15], true); } else { $xKat = $row[9]; } $points_disc_keep = $points_disc; $dCode_keep = $dCode; } // END WHILE athlete per category if (!empty($a)) { $points_arr[] = $points; $points_arr_more_disc_all[$xKat][] = $points_disc; $name_arr[] = $name; $year_arr[] = $year; $club_arr[] = $club; $info_arr[] = $info; $ioc_arr[] = $ioc; $x_arr[] = $a; $remark_arr[] = $remark; $rank_arr[] = $rank; } if (!empty($cat)) { $u23name = ''; if (($comb == 410 || $comb == 400) && $catEntryLimit < 23 && $sepu23) { $u23name = " (U 23)"; } $list->endList(); if ($ukc) { $list->printSubTitle($catUKC . ", " . $cfgUKC_Name); } else { $list->printSubTitle($cat . "{$u23name}, " . $combName, "", ""); } $list->startList(); $list->printHeaderLine($lastTime); arsort($points_arr, SORT_NUMERIC); // sort descending by points $rank = 1; // initialize rank $r = 0; // start value for ranking $p = 0; $k = 0; $no_rank = 999999; $max_rank = $no_rank; foreach ($points_arr as $key => $val) { $r++; if ($limitRank && ($r < $rFrom || $r > $rTo)) { // limit ranks if set (export) continue; } if ($p != $val) { // not same points as previous athlete $rank = $r; // next rank } // not set rank for invalid results if (preg_match("@\\(-[1]{1}@", $info_arr[$key])) { $rank = $max_rank; $max_rank += 1; $r--; } $p = $val; // keep current points $k = $key; // keep current key $rank_arr[$key] = $rank; } asort($rank_arr, SORT_NUMERIC); // sort descending by rank $rank_keep = 0; foreach ($rank_arr as $key => $v) { $val = $points_arr[$key]; $rank = $v; if ($rank == $rank_keep) { $c = 0; $keep_c = 0; // first rule for ($i = 1; $i <= sizeof($points_disc); $i++) { if ($points_arr_more_disc_all[$xKat][$key_keep][$i] > $points_arr_more_disc_all[$xKat][$key][$i]) { $keep_c++; } else { $c++; } } $more = ceil(sizeof($points_disc) / 2); if (sizeof($points_disc) % 2 == 0) { // combined with even number discs $more++; } if ($keep_c >= $more && $keep_c > $c) { $rank_arr[$key]++; } else { if ($c >= $more && $c > $keep_c) { $rank_arr[$key_keep]++; } else { // second rule // check the best points of the highest points of discipline $k = AA_get_AthletBestPointDisc($points_arr_more_disc_all[$xKat][$key_keep], $points_arr_more_disc_all[$xKat][$key], $key_keep, $key); if ($k != 0) { $rank_arr[$k]++; } // if $k is 0, all points of diszipline are the same --> athletes with same rank } } } $rank_keep = $rank; $key_keep = $key; } asort($rank_arr, SORT_NUMERIC); // sort descending by rank foreach ($rank_arr as $key => $v) { $val = $points_arr[$key]; $rank = $v; if ($rank >= $no_rank) { $rank = ''; } $list->printLine($rank, $name_arr[$key], $year_arr[$key], $club_arr[$key], $val, $ioc_arr[$key]); $list->printInfo($info_arr[$key]); // insert points into combined top performance of entry mysql_query("UPDATE anmeldung SET BestleistungMK = {$val} WHERE xAnmeldung = " . $x_arr[$key]); } } mysql_free_result($results); $list->endList(); $list->endPage(); // end HTML page for printing } // ET DB error all teams }
function AA_rankinglist_Single($category, $event, $round, $formaction, $break, $cover, $biglist = false, $cover_timing = false, $date = '%', $show_efforts = 'none', $heatSeparate, $catFrom, $catTo, $discFrom, $discTo, $heatFrom, $heatTo, $athleteCat, $withStartnr, $ranklistAll, $ukc) { // anstead of remove the function "rankinglist ubs kids cup"", set $ukc for the moment false --> later remove it perhaps // "rankinglist ubs kids cup" is solved in rankinglist_combined.lib.php $ukc = false; require './lib/cl_gui_page.lib.php'; require './lib/cl_print_page.lib.php'; require './lib/cl_export_page.lib.php'; require './lib/common.lib.php'; require './lib/results.lib.php'; require './lib/utils.lib.php'; if (AA_connectToDB() == FALSE) { // invalid DB connection return; // abort } if (AA_checkMeetingID() == FALSE) { // no meeting selected return; // abort } // check teamsm $teamsm = AA_checkTeamsm(0, 0); // set up ranking list selection $selection = ''; $eventMerged = false; $catMerged = false; $flagSubtitle = false; $flagInfoLine1 = false; $flagInfoLine2 = false; $results_ukc = FALSE; $selectionHeats = ''; $orderAthleteCat = ''; $saison = $_SESSION['meeting_infos']['Saison']; if ($saison == '') { $saison = "O"; //if no saison is set take outdoor } if ($round > 0) { // show a specific round $eventMerged = false; $sqlEvents = AA_getMergedEventsFromEvent($event); if ($sqlEvents != '') { $selection = "w.xWettkampf IN " . $sqlEvents . " AND "; $eventMerged = true; } else { $selection = "r.xRunde =" . $round . " AND "; } } elseif ($category == 0) { // show all disciplines for every category $catMerged = true; } elseif ($event == 0) { // show all disciplines for a specific category $catMerged = false; $mergedCat = AA_mergedCat($category); if ($mergedCat != '') { $selection = "w.xKategorie IN " . $mergedCat . " AND "; $catMerged = true; } else { $selection = "w.xKategorie =" . $category . " AND "; } } else { if ($round == 0) { // show all rounds for a specific event $eventMerged = false; $sqlEvents = AA_getMergedEventsFromEvent($event); if ($sqlEvents != '') { $selection = "w.xWettkampf IN " . $sqlEvents . " AND "; $eventMerged = true; } else { $selection = "w.xWettkampf =" . $event . " AND "; } } } if ($catFrom > 0) { // $getSortCat = AA_getSortCat($catFrom, $catTo); if ($getSortCat[0]) { if ($catTo > 0) { $selection = "k.Anzeige >=" . $getSortCat[$catFrom] . " AND k.Anzeige <=" . $getSortCat[$catTo] . " AND "; } else { $selection = "k.Anzeige =" . $getSortCat[$catFrom] . " AND "; } } } if ($discFrom > 0) { // $getSortDisc = AA_getSortDisc($discFrom, $discTo); if ($getSortDisc[0]) { if ($discTo > 0) { $selection .= "d.Anzeige >=" . $getSortDisc[$discFrom] . " AND d.Anzeige <=" . $getSortDisc[$discTo] . " AND "; } else { $selection .= "d.Anzeige =" . $getSortDisc[$discFrom] . " AND "; } } } if ($heatFrom > 0) { $selectionHeats = ' AND s.xSerie >= ' . $heatFrom . ' AND s.xSerie <= ' . $heatTo . ' '; } if ($athleteCat) { $orderAthleteCat = ' k1.Anzeige, '; } if ($catMerged & !$heatSeparate || $eventMerged & !$heatSeparate) { // get event rounds from DB if ($ukc) { $selection = " (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") AND "; } if ($teamsm) { $sql = "SELECT \r\n group_concat(r.xRunde)\r\n , k.Name\r\n , d.Name\r\n , d.Typ\r\n , w.xWettkampf\r\n , r.QualifikationSieger\r\n , r.QualifikationLeistung\r\n , w.Punkteformel\r\n , w.Windmessung\r\n , r.Speakerstatus\r\n , d.Staffellaeufer\r\n , CONCAT(DATE_FORMAT(r.Datum,'{$cfgDBdateFormat}'), ' ', TIME_FORMAT(r.Startzeit, '{$cfgDBtimeFormat}')) \r\n , w.xDisziplin \r\n , w.info \r\n FROM\r\n wettkampf AS w\r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n LEFT JOIN runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n WHERE " . $selection . "\r\n w.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n AND r.Status = " . $cfgRoundStatus['results_done'] . " \r\n AND r.Datum LIKE '" . $date . "'\r\n GROUP BY w.xWettkampf\r\n ORDER BY\r\n k.Anzeige\r\n , d.Anzeige\r\n , r.Datum\r\n , r.Startzeit"; $results = mysql_query($sql); } else { $sql = "SELECT \r\n r.xRunde\r\n , k.Name\r\n , d.Name\r\n , d.Typ\r\n , w.xWettkampf\r\n , r.QualifikationSieger\r\n , r.QualifikationLeistung\r\n , w.Punkteformel\r\n , w.Windmessung\r\n , r.Speakerstatus\r\n , d.Staffellaeufer\r\n , CONCAT(DATE_FORMAT(r.Datum,'{$cfgDBdateFormat}'), ' ', TIME_FORMAT(r.Startzeit, '{$cfgDBtimeFormat}'))\r\n , w.xDisziplin \r\n , w.info \r\n FROM\r\n wettkampf AS w\r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n LEFT JOIN runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n WHERE " . $selection . "\r\n w.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n AND r.Status = " . $cfgRoundStatus['results_done'] . " \r\n AND r.Datum LIKE '" . $date . "'\r\n ORDER BY\r\n k.Anzeige\r\n , d.Anzeige\r\n , r.Datum\r\n , r.Startzeit"; $results = mysql_query($sql); } } else { // heats separate $sql = "SELECT DISTINCT \r\n r.xRunde , \r\n k.Name , \r\n d.Name , \r\n d.Typ , \r\n w.xWettkampf , \r\n r.QualifikationSieger , \r\n r.QualifikationLeistung , \r\n w.Punkteformel , \r\n w.Windmessung , \r\n r.Speakerstatus , \r\n d.Staffellaeufer , \r\n CONCAT(DATE_FORMAT(r.Datum,'%d.%m.%y'), \r\n ' ', \r\n TIME_FORMAT(r.Startzeit, '%H:%i')) ,\r\n w.xDisziplin , \r\n rs.Hauptrunde,\r\n w.info \r\n FROM \r\n wettkampf AS w \r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie) \r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n LEFT JOIN runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n LEFT JOIN rundenset as rs ON (r.xRunde=rs.xRunde ) \r\n WHERE \r\n " . $selection . " \r\n w.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n AND r.Status = 4 \r\n AND r.Datum LIKE '%' \r\n ORDER BY\r\n k.Anzeige\r\n , d.Anzeige\r\n , r.Datum\r\n , r.Startzeit"; $results = mysql_query($sql); } if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $limitRankSQL = ""; $limitRank = false; if ($_GET['limitRank'] == "yes") { // check if ranks are limited, but limitRankSQL will set only if export is pressed if (!empty($_GET['limitRankFrom']) && !empty($_GET['limitRankTo'])) { $limitRank = true; } } // start a new HTML display page if ($formaction == 'view' || $formaction == 'speaker') { // display page $list = new GUI_RankingList($_COOKIE['meeting']); $list->printPageTitle("{$strRankingLists} " . $_COOKIE['meeting']); } elseif ($formaction == "print") { $list = new PRINT_RankingList($_COOKIE['meeting']); if ($cover == true) { // print cover page $list->printCover($GLOBALS['strResults'], $cover_timing); } } elseif ($formaction == "exportpress") { $list = new EXPORT_RankingListPress($_COOKIE['meeting'], 'txt'); if ($limitRank) { $limitRankSQL = " AND ss.Rang <= " . $_GET['limitRankTo'] . " AND ss.Rang >= " . $_GET['limitRankFrom'] . " "; } } elseif ($formaction == "exportdiplom") { $list = new EXPORT_RankingListDiplom($_COOKIE['meeting'], 'csv'); if ($limitRank) { $limitRankSQL = " AND ss.Rang <= " . $_GET['limitRankTo'] . " AND ss.Rang >= " . $_GET['limitRankFrom'] . " "; } } // initialize variables $cat = ''; $evnt = 0; if (mysql_num_rows($results) == 0) { echo "<br><br><b><blockquote>{$strErrNoResults}</blockquote></b>"; } $rounds = array(); $catUkc = ""; $roundsUkc = array(); $discUkc = ""; $roundsInfo = array(); $mergedRounds = ''; while ($row = mysql_fetch_row($results)) { if (!$teamsm) { $mergedRounds = AA_getMergedRounds($row[0]); } if (!empty($mergedRounds)) { if ($pos = strpos($mergedRounds, $row[0])) { $rounds[$i] = $row[0]; if ($heatSeparate) { if (!empty($row[14])) { $roundsInfo[$row[0]] .= $row[14] . " / "; } } else { if (!empty($row[13])) { $roundsInfo[$row[0]] .= $row[13] . " / "; } } } else { if (!empty($row[13])) { $roundsInfo[$row[0]] .= $row[13] . " / "; } } } if ($row[2] != $discUkc) { $roundsUkc[$row[1]][] = $row[0]; } $discUkc = $row[2]; } $results = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } while ($row = mysql_fetch_row($results)) { // for a combined event, the rounds are merged, so jump until the next event if ($cRounds > 1) { $cRounds--; continue; } if ($ukc) { $catUkc = $row[1]; $rounds_in = ""; for ($i = 0; $i < 3; $i++) { if (!empty($roundsUkc[$catUkc][$i])) { $rounds_in .= $roundsUkc[$catUkc][$i] . ","; } } $rounds_in = substr($rounds_in, 0, strlen($rounds_in) - 1); if (!empty($r1)) { } $roundSQL = "s.xRunde IN ({$rounds_in}) "; $GroupByUkc = " Group By at.xAthlet, w.xDisziplin "; } else { $roundSQL = "s.xRunde = {$row['0']}"; $GroupByUkc = ""; } if ($teamsm) { $roundSQL = "s.xRunde IN ({$row['0']}) "; } $cRounds = 0; // check page break if (is_a($list, "PRINT_RankingList") && $cat != '' && ($break == 'discipline' || $break == 'category' && $row[1] != $cat)) { $list->insertPageBreak(); } if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeRelay]) { $eval = $cfgEvalType[$strEvalTypeHeat]; } else { $eval = $cfgEvalType[$strEvalTypeAll]; } $roundName = ''; $type = ''; if ($teamsm) { $res = mysql_query("\r\n SELECT\r\n rt.Name\r\n , rt.Typ\r\n , rt.Wertung\r\n FROM\r\n runde\r\n LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON (rt.xRundentyp = runde.xRundentyp)\r\n WHERE \r\n runde.xRunde IN ({$row['0']}) \r\n "); } else { $res = mysql_query("\r\n SELECT\r\n rt.Name\r\n , rt.Typ\r\n , rt.Wertung\r\n FROM\r\n runde\r\n LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON (rt.xRundentyp = runde.xRundentyp)\r\n WHERE \r\n runde.xRunde = {$row['0']} \r\n "); } if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res) > 0) { $row_rt = mysql_fetch_row($res); if ($row_rt[1] == '0') { $type = " "; $row_rt[0] = ''; } else { $type = $row_rt[0] . " "; } $eval = $row_rt[2]; if ($round != 0) { // specific round selected $roundName = $row_rt[0]; } } mysql_free_result($res); } if ($evnt != $row[4]) { // if this is a combined event, dont fragment list by rounds $combined = AA_checkCombined($row[4]); // not selectet a specific round if ($round == 0 && $combined && !$ukc) { $res_c = mysql_query("SELECT \r\n r.xRunde\r\n FROM\r\n wettkampf as w\r\n LEFT JOIN runde as r ON (r.xWettkampf = w.xWettkampf)\r\n WHERE \r\n w.xWettkampf = {$row['4']}\r\n AND r.status = 4"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $cRounds = mysql_num_rows($res_c); $roundSQL = "s.xRunde IN ("; while ($row_c = mysql_fetch_array($res_c)) { $roundSQL .= $row_c[0] . ","; } $roundSQL = substr($roundSQL, 0, -1) . ")"; } } // set up category and discipline title information $flagSubtitle = true; // set flag to print the subtitle later if ($formaction == 'speaker' && AA_getNextRound($row[4], $row[0]) == 0) { // last round: show ceremony status $list->printCeremonyStatus($row[0], $row[9]); } // print qualification mode if round selected $info = ''; if ($round > 0 && ($row[5] > 0 || $row[6] > 0)) { $info = "{$strQualification}: " . $row[5] . " {$strQualifyTop}, " . $row[6] . " {$strQualifyPerformance}"; $flagInfoLine1 = true; // set flag to print later the qualification mode if round selected $info_save1 = $info; //$list->printInfoLine($info); $qual_mode = TRUE; } // print qualification descriptions if required $info = ''; if ($row[5] > 0 || $row[6] > 0) { foreach ($cfgQualificationType as $qt) { $info = $info . $qt['token'] . " =" . $qt['text'] . " "; } $flagInfoLine2 = true; // set flag to print later the qualification descriptions if required $info_save2 = $info; //$list->printInfoLine($info); $qual_mode = TRUE; } $evnt = $row[4]; // keep event ID } // ET new event $relay = AA_checkRelay($row[4]); // check, if this is a relay event $svm = AA_checkSVM($row[4]); // If round evaluated per heat, group results accordingly $order_heat = ""; if ($eval == $cfgEvalType[$strEvalTypeHeat]) { // eval per heat $order_heat = "heatid, "; } $valid_result = ""; // Order performance depending on discipline type if ($row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow]) { $order_perf = "DESC"; $order_perf2 = "DESC"; } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump]) { if ($row[8] == 1) { // with wind $order_perf = "DESC, r.Info ASC"; $order_perf2 = "DESC , r.Info ASC"; } else { // without wind $order_perf = "DESC"; $order_perf2 = "DESC"; } } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $order_perf = "DESC"; $order_perf2 = "DESC"; $valid_result = " AND (r.Info LIKE '%O%'" . " OR r.Leistung < 0)"; } else { $order_perf = "ASC"; $order_perf1 = "ASC"; } } } $sqlSeparate = ''; if (($catMerged || $eventMerged) & $heatSeparate) { if ($row[0] > 0 && $row[13] != NULL) { $roundSQL = ''; if (empty($limitRankSQL) && empty($valid_result)) { $sqlSeparate = " ss.RundeZusammen = " . $row[0]; } else { if (empty($limitRankSQL)) { $valid_result = substr($valid_result, 4, strlen($valid_result)); } elseif (empty($valid_result)) { $limitRankSQL = substr($limitRankSQL, 4, strlen($limitRankSQL)); } $sqlSeparate = " AND ss.RundeZusammen = " . $row[0]; } } } // get all results ordered by ranking; for invalid results (Rang=0), the // rank is set to max_rank to put them to the end of the list. $oder2 = ""; $max_rank = 999999999; if ($ukc) { $order2 = " d.Anzeige, rank, at.Name, at.Vorname, leistung_neu "; $sql_leistung = $order_perf == 'ASC' ? "max(r.Leistung)" : "IF(r.Leistung<0, (If(r.Leistung = -99, -9, (If (r.Leistung = -98, -8,max(r.Leistung)))) * -1), max(r.Leistung))"; } else { $order2 = " rank, at.Name, at.Vorname, leistung_neu "; $sql_leistung = $order_perf == 'ASC' ? "r.Leistung" : "IF(r.Leistung<0, (If(r.Leistung = -99, -9, (If (r.Leistung = -98, -8,r.Leistung))) * -1), r.Leistung)"; } $order = $order_heat; if ($ukc) { if ($athleteCat) { $order = $orderAthleteCat . $order_heat; } $selection2 = ""; $checkyear = date('Y') - 16; $selection2 = " at.Jahrgang > {$checkyear} AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") AND "; $query = "SELECT ss.xSerienstart, \r\n IF(ss.Rang=0, {$max_rank}, ss.Rang) AS rank, \r\n ss.Qualifikation, \r\n " . $sql_leistung . " AS leistung_neu, \r\n r.Info, \r\n s.Bezeichnung, \r\n s.Wind, \r\n r.Punkte, \r\n IF('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)), \r\n at.Name, \r\n at.Vorname, \r\n at.Jahrgang, \r\n LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n IF(at.xRegion = 0, at.Land, re.Anzeige) AS Land, \r\n at.xAthlet, \r\n ru.Datum, \r\n ru.Startzeit ,\r\n ss.RundeZusammen,\r\n ru.xRunde, \r\n k.Name , \r\n k1.Name , \r\n k1.Anzeige ,\r\n ss.Bemerkung,\r\n w.Punkteformel,\r\n w.info,\r\n a.Startnummer,\r\n w.xWettkampf,\r\n at.Geschlecht\r\n \r\n FROM serie AS s USE INDEX(Runde)\r\n LEFT JOIN serienstart AS ss USING(xSerie) \r\n LEFT JOIN resultat AS r USING(xSerienstart) \r\n LEFT JOIN start AS st ON(ss.xStart = st.xStart) \r\n LEFT JOIN anmeldung AS a USING(xAnmeldung) \r\n LEFT JOIN athlet AS at USING(xAthlet) \r\n LEFT JOIN verein AS v USING(xVerein) \r\n LEFT JOIN region AS re ON(at.xRegion = re.xRegion) \r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN runde AS ru ON(s.xRunde = ru.xRunde) \r\n LEFT JOIN wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n LEFT JOIN kategorie AS k On (w.xKategorie= k.xKategorie)\r\n LEFT JOIN kategorie AS k1 ON (a.xKategorie = k1.xKategorie) \r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n WHERE " . $selection2 . $roundSQL . " \r\n " . $limitRankSQL . " \r\n " . $valid_result . " \r\n " . $sqlSeparate . " \r\n " . $selectionHeats . " \r\n {$GroupByUkc} \r\n ORDER BY " . $order . $order2 . $order_perf1; } else { if ($relay == FALSE) { if ($athleteCat) { $order = $orderAthleteCat . $order_heat; } $selection2 = ""; if ($ukc) { $checkyear = date('Y') - 16; $selection2 = " at.Jahrgang > {$checkyear} AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") AND "; } if ($teamsm) { $query = "SELECT ss.xSerienstart, \r\n IF(ss.Rang=0, {$max_rank}, ss.Rang) AS rank, \r\n ss.Qualifikation, \r\n " . $sql_leistung . " AS leistung_neu, \r\n r.Info, \r\n s.Bezeichnung, \r\n s.Wind, \r\n r.Punkte, \r\n t.Name, \r\n at.Name, \r\n at.Vorname, \r\n at.Jahrgang, \r\n LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n IF(at.xRegion = 0, at.Land, re.Anzeige) AS Land, \r\n at.xAthlet, \r\n ru.Datum, \r\n ru.Startzeit ,\r\n ss.RundeZusammen,\r\n ru.xRunde, \r\n k.Name , \r\n k1.Name , \r\n k1.Anzeige ,\r\n ss.Bemerkung,\r\n w.Punkteformel,\r\n w.info,\r\n a.Startnummer,\r\n w.xWettkampf,\r\n at.Geschlecht\r\n \r\n FROM serie AS s USE INDEX(Runde)\r\n LEFT JOIN serienstart AS ss USING(xSerie) \r\n LEFT JOIN resultat AS r USING(xSerienstart) \r\n LEFT JOIN start AS st ON(ss.xStart = st.xStart) \r\n LEFT JOIN anmeldung AS a USING(xAnmeldung) \r\n LEFT JOIN athlet AS at USING(xAthlet) \r\n LEFT JOIN verein AS v USING(xVerein) \r\n LEFT JOIN region AS re ON(at.xRegion = re.xRegion) \r\n INNER JOIN teamsmathlet AS tat ON(st.xAnmeldung = tat.xAnmeldung)\r\n LEFT JOIN teamsm as t ON (tat.xTeamsm = t.xTeamsm) \r\n LEFT JOIN runde AS ru ON(s.xRunde = ru.xRunde) \r\n LEFT JOIN wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n LEFT JOIN kategorie AS k On (w.xKategorie= k.xKategorie)\r\n LEFT JOIN kategorie AS k1 ON (a.xKategorie = k1.xKategorie) \r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n WHERE " . $selection2 . $roundSQL . " \r\n " . $limitRankSQL . " \r\n " . $valid_result . " \r\n " . $sqlSeparate . " \r\n " . $selectionHeats . " \r\n {$GroupByUkc} \r\n ORDER BY " . $order . $order2 . $order_perf; } else { $query = "SELECT ss.xSerienstart, \r\n IF(ss.Rang=0, {$max_rank}, ss.Rang) AS rank, \r\n ss.Qualifikation, \r\n " . $sql_leistung . " AS leistung_neu, \r\n r.Info, \r\n s.Bezeichnung, \r\n s.Wind, \r\n r.Punkte, \r\n IF('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)), \r\n at.Name, \r\n at.Vorname, \r\n at.Jahrgang, \r\n LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n IF(at.xRegion = 0, at.Land, re.Anzeige) AS Land, \r\n at.xAthlet, \r\n ru.Datum, \r\n ru.Startzeit ,\r\n ss.RundeZusammen,\r\n ru.xRunde, \r\n k.Name , \r\n k1.Name , \r\n k1.Anzeige ,\r\n ss.Bemerkung,\r\n w.Punkteformel,\r\n w.info,\r\n a.Startnummer,\r\n w.xWettkampf,\r\n at.Geschlecht\r\n \r\n FROM serie AS s USE INDEX(Runde)\r\n LEFT JOIN serienstart AS ss USING(xSerie) \r\n LEFT JOIN resultat AS r USING(xSerienstart) \r\n LEFT JOIN start AS st ON(ss.xStart = st.xStart) \r\n LEFT JOIN anmeldung AS a USING(xAnmeldung) \r\n LEFT JOIN athlet AS at USING(xAthlet) \r\n LEFT JOIN verein AS v USING(xVerein) \r\n LEFT JOIN region AS re ON(at.xRegion = re.xRegion) \r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN runde AS ru ON(s.xRunde = ru.xRunde) \r\n LEFT JOIN wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n LEFT JOIN kategorie AS k On (w.xKategorie= k.xKategorie)\r\n LEFT JOIN kategorie AS k1 ON (a.xKategorie = k1.xKategorie) \r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n WHERE " . $selection2 . $roundSQL . " \r\n " . $limitRankSQL . " \r\n " . $valid_result . " \r\n " . $sqlSeparate . " \r\n " . $selectionHeats . " \r\n {$GroupByUkc} \r\n ORDER BY " . $order . $order2 . $order_perf; } } else { // relay event $query = "SELECT ss.xSerienstart, \r\n IF(r.Leistung < 0 , {$max_rank}, if (ss.Rang=0, {$max_rank}-1, ss.Rang)) AS rank, \r\n ss.Qualifikation, \r\n " . $sql_leistung . " AS leistung_neu, \r\n r.Info, \r\n s.Bezeichnung, \r\n s.Wind, \r\n r.Punkte, \r\n IF('" . $svm . "', t.Name, v.Name), \r\n sf.Name, \r\n LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n st.xStart, \r\n ru.Datum, \r\n ru.Startzeit, \r\n ss.RundeZusammen,\r\n ru.xRunde,\r\n k.Name ,\r\n ss.Bemerkung \r\n FROM serie AS s USE INDEX(Runde) \r\n LEFT JOIN serienstart AS ss USING(xSerie) \r\n LEFT JOIN resultat AS r USING(xSerienstart) \r\n LEFT JOIN start AS st ON(ss.xStart = st.xStart) \r\n LEFT JOIN staffel AS sf USING(xStaffel) \r\n LEFT JOIN verein AS v USING(xVerein) \r\n LEFT JOIN team AS t ON(sf.xTeam = t.xTeam) \r\n LEFT JOIN runde AS ru ON(s.xRunde = ru.xRunde) \r\n LEFT JOIN wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n LEFT JOIN kategorie AS k On (w.xKategorie= k.xKategorie) \r\n WHERE " . $roundSQL . " \r\n " . $limitRankSQL . " \r\n " . $valid_result . " \r\n " . $sqlSeparate . " \r\n GROUP BY r.xSerienstart \r\n ORDER BY " . $order . " \r\n rank, \r\n r.Leistung \r\n " . $order_perf . ", \r\n sf.Name;"; } } $res = mysql_query($query); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res) == 0) { continue; } // initialize variables $heat = ''; $h = 0; $info = ''; $id = ''; $r = ''; $count_rank = 0; $perf_save = ''; //$list->startList(); $nr = 0; $atCat = ''; if ($ukc) { $arr_xAthlet = array(); while ($row_at = mysql_fetch_array($res)) { if (array_key_exists($row_at[14], $arr_xAthlet)) { $arr_xAthlet[$row_at[14]]++; } else { $arr_xAthlet[$row_at[14]] = 1; } } } $res = mysql_query($query); // process every result while ($row_res = mysql_fetch_array($res)) { if ($ukc) { if ($arr_xAthlet[$row_res[14]] < 3) { $id = $row_res[0]; // keep current athletes ID if ($relay) { $catM = $row_res[16]; } else { $catM = $row_res[19]; } // keep merged category continue; } if ($row[0] != $row_res[18]) { $id = $row_res[0]; // keep current athletes ID if ($relay) { $catM = $row_res[16]; } else { $catM = $row_res[19]; } // keep merged category continue; } $results_ukc = TRUE; $pointsUKC = AA_utils_calcPointsUKC($row_res[26], $row_res[3], 0, $row_res[27], $row_res[0]); mysql_query("UPDATE resultat SET\r\n Punkte = {$pointsUKC}\r\n WHERE\r\n xSerienstart = {$row_res['0']}"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } AA_StatusChanged(0, 0, $row_res[0]); } if ($flagSubtitle) { $r_info = ''; $mainRound = ''; if (!$teamsm) { $mainRound = AA_getMainRound($row[0]); } if ($mainRound > 0) { if ($heatSeparate) { $r_info = $roundsInfo[$row[0]]; $r_info = substr($r_info, 0, -3); } else { $mergedRounds = AA_getMergedRounds($row[0]); $mRounds = split(',', substr($mergedRounds, 1, -1)); foreach ($mRounds as $key => $val) { $r_info .= $roundsInfo[$val]; } $r_info = substr($r_info, 0, -3); } } else { $r_info = $row_res[24]; } $nr = 0; if ($heatSeparate) { if ($relay) { $list->printSubTitle($row_res[16], $row[2], $roundName, $r_info); } else { if (!$athleteCat) { $list->printSubTitle($row_res[19], $row[2], $roundName, $r_info); } } } else { if (!$athleteCat) { $list->printSubTitle($row[1], $row[2], $roundName, $r_info, $heatFrom, $heatTo, $row_rt[2]); } } $flagSubtitle = false; } if (!$athleteCat) { if ($flagInfoLine1) { $list->printInfoLine($info_save1); $flagInfoLine1 = false; } } if (!$athleteCat) { if ($flagInfoLine2) { $list->printInfoLine($info_save2); $flagInfoLine2 = false; } } $row_res[3] = $row_res[3] == 1 || $row_res[3] == 2 || $row_res[3] == 3 || $row_res[3] == 4 ? $row_res[3] * -1 : ($row_res[3] == 9 ? -99 : ($row_res[3] == 8 ? -98 : $row_res[3])); if ($row_res[0] != $id) { if ($h == 0 || $row_res[5] != $heat && $eval == $cfgEvalType[$strEvalTypeHeat] || $athleteCat && $row_res[21] != $atCat) { $count_rank = 0; $nr = 0; // heat name if ($eval == $cfgEvalType[$strEvalTypeHeat]) { if (empty($type)) { // no round type defined $type = $strFinalround . " "; } $title = $type . $row_res[5]; // heat name with nbr. } else { $title = $type; // heat name withour nbr. } $title = trim($title); // wind per heat if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] && $row[8] == 1 && $eval == $cfgEvalType[$strEvalTypeHeat]) { $heatwind = $row_res[6]; // wind per heat } else { $heatwind = ''; // no wind } $wind = FALSE; if ($row[8] == 1 && $row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeTrack] && $eval == $cfgEvalType[$strEvalTypeAll]) { $wind = TRUE; } // add column header 'points' if required $points = FALSE; if ($row[7] != '0' || $row_res[23] != '0') { $points = TRUE; } elseif ($ukc) { $points = TRUE; } if ($show_efforts == 'sb_pb') { $base_perf = true; } if ($athleteCat && !$relay) { if ($formaction == 'print') { if ($row_res[20] . $row[2] != $atCatName) { $list->printSubTitle($row_res[20], $row[2], $roundName, $row_res[24]); $atCatName = $row_res[20] . $row[2]; if ($flagInfoLine1) { $list->printInfoLine($info_save1); $flagInfoLine1 = false; } if ($flagInfoLine2) { $list->printInfoLine($info_save2); $flagInfoLine2 = false; } } } } $list->startList(); if ($saison == "I") { $heatwind = ''; } if ($relay && !$svm) { $points = false; } $list->printHeaderLine($title, $relay, $points, $wind, $heatwind, $row[11], $svm, $base_perf, $qual_mode, $eval, $withStartnr, $teamsm); if ($athleteCat && !$relay) { if ($formaction == 'view') { if ($row_res[20] . $row[2] != $atCatName) { $list->printSubTitle($row_res[20], $row[2], $roundName, $row_res[24]); $atCatName = $row_res[20] . $row[2]; if ($flagInfoLine1) { $list->printInfoLine($info_save1, $athleteCat); $flagInfoLine1 = false; } if ($flagInfoLine2) { $list->printInfoLine($info_save2, $athleteCat); $flagInfoLine2 = false; } } } } $heat = $row_res[5]; // keep heat description $atCat = $row_res[21]; // keep athlete category $h++; // increment if evaluation per heat } $count_rank++; // rank if ($teamsm) { if ($perf_save != '') { if ($perf_save == $row_res[3]) { $count_rank--; $rank = ''; } else { $rank = $count_rank; } } else { $rank = $count_rank; } } else { if ($heatSeparate) { if ($row_res[1] == $max_rank || $row_res[1] == $max_rank - 1) { // invalid result $rank = ''; } elseif ($r == $row_res[1] && $heat_keep == $row_res[5]) { // same rank as previous $rank = $count_rank--; } else { if ($ukc) { $rank = $count_rank; } else { $rank = $row_res[1]; } } } else { if ($row_res[1] == $max_rank || $row_res[1] == $max_rank - 1 || $r == $row_res[1] && $heat_keep == $row_res[5]) { // same rank as previous $rank = ''; } else { if ($ukc) { $rank = $count_rank; } else { $rank = $row_res[1]; } } } } $r = $row_res[1]; // keep rank $heat_keep = $row_res[5]; // keep heat // name $name = $row_res[9]; if ($relay == FALSE) { $name = $name . " " . $row_res[10]; } // year of birth if ($relay == FALSE) { $year = AA_formatYearOfBirth($row_res[11]); } else { $year = ''; } // year of birth if ($relay == FALSE) { $land = $row_res[13] != '' && $row_res[13] != '-' ? $row_res[13] : ''; } else { $year = ''; } // performance if ($row_res[3] < 0) { // invalid result if ($row_res[3] == '-98') { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow]) { $perf = $cfgInvalidResult['NRS']['short']; } else { $perf = $cfgInvalidResult['NAA']['code']; } } elseif ($row_res[3] == '-99') { $perf = $cfgInvalidResult['WAI']['short']; } else { foreach ($cfgInvalidResult as $value) { if ($value['code'] == $row_res[3]) { $perf = $value['short']; } } } } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow] || $row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $perf = AA_formatResultMeter($row_res[3]); } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind]) { $perf = AA_formatResultTime($row_res[3], true, true); } else { $perf = AA_formatResultTime($row_res[3], true); } } } $qual = ''; if ($row_res[2] > 0) { // Athlete qualified foreach ($cfgQualificationType as $qtype) { if ($qtype['code'] == $row_res[2]) { $qual = $qtype['token']; } } } // ET athlete qualified // points for performance $points = ''; if ($row[7] != '0') { $points = $row_res[7]; } else { if ($row_res[23] != '0') { $points = $row_res[7]; } } // wind info $wind = ''; $secondResult = false; if ($r != $max_rank) { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] && $row[8] == 1) { $wind = $row_res[4]; if ($saison == 'I') { $wind = ''; // indoor: never wind } // // if wind bigger than max wind (2.0) show the next best result without wind too // if ($wind > 2) { $res_wind = mysql_query("\r\n SELECT Info, Leistung FROM\r\n resultat\r\n WHERE\r\n xSerienstart = {$row_res['0']}\r\n ORDER BY\r\n Leistung ASC"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row_wind = mysql_fetch_array($res_wind)) { if ($row_wind[0] <= 2) { $secondResult = true; $wind2 = $row_wind[0] . ")"; $perf2 = "(" . AA_formatResultMeter($row_wind[1]); } } } } } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] && $row[8] == 1 && $eval == $cfgEvalType[$strEvalTypeAll]) { $wind = $row_res[6]; if ($saison == 'I') { $wind = ''; // indoor: never wind } } } } // ioc country code $ioc = ''; if ($relay == false) { $ioc = $row_res[13]; } //show performances from base if ($show_efforts == 'sb_pb' && $relay == false) { $sql = "SELECT \r\n season_effort\r\n , DATE_FORMAT(season_effort_date, '%d.%m.%Y') AS sb_date\r\n , season_effort_event\r\n , best_effort\r\n , DATE_FORMAT(best_effort_date, '%d.%m.%Y') AS pb_date\r\n , best_effort_event\r\n , season\r\n , xAnmeldung\r\n FROM \r\n base_performance\r\n LEFT JOIN \r\n base_athlete USING (id_athlete)\r\n LEFT JOIN \r\n disziplin_" . $_COOKIE['language'] . " ON (discipline = Code)\r\n LEFT JOIN \r\n athlet ON (license = Lizenznummer)\r\n LEFT JOIN\r\n anmeldung USING(xAthlet) \r\n WHERE \r\n athlet.xAthlet = {$row_res['14']}\r\n AND xDisziplin = {$row['12']}\r\n AND season = '{$saison}' \r\n AND xMeeting = " . $_COOKIE['meeting_id'] . ";"; $res_perf = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if ($res_perf) { $row_perf = mysql_fetch_array($res_perf); $is_jump = $row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow] || $row[3] == $cfgDisciplineType[$strDiscTypeHigh]; $order = $is_jump ? 'DESC' : 'ASC'; $best_previous = ''; $previous_date = ''; if ($row_perf !== false) { $best_previous = AA_getBestPrevious($row[12], $row_perf['xAnmeldung'], $order, $row_res['Datum'], $row_res['Startzeit'], &$previous_date); } if ($is_jump) { $sb_perf = AA_formatResultMeter(str_replace(".", "", $row_perf['season_effort'])); $pb_perf = AA_formatResultMeter(str_replace(".", "", $row_perf['best_effort'])); $bp_perf = AA_formatResultMeter(str_replace(".", "", $best_previous)); if ($bp_perf > 0 && $bp_perf > $sb_perf) { $sb_perf = $bp_perf; $row_perf['season_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['sb_date'] = date('d.m.Y', strtotime($previous_date)); } if ($bp_perf > 0 && $bp_perf > $pb_perf) { $pb_perf = $bp_perf; $row_perf['best_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['pb_date'] = date('d.m.Y', strtotime($previous_date)); } //highlight sb or pb if new performance is better if (is_numeric($perf)) { //prevent special-codes (disq, n.a. usw) if ($formaction != 'print') { if ($pb_perf != '' && $perf > $pb_perf) { $perf = "<b>PB {$perf}</b> "; } else { if ($sb_perf != '' && $perf > $sb_perf) { $perf = "<b>SB {$perf}</b>"; } } } else { if ($pb_perf != '' && $perf > $pb_perf) { $perf = "<b>PB</b> {$perf}"; } else { if ($sb_perf != '' && $perf > $sb_perf) { $perf = "<b>SB</b> {$perf}"; } } } } } else { //convert performance-time to milliseconds $timepices = explode(":", $row_perf['season_effort']); $season_effort = $timepices[0] * 360 * 1000 + $timepices[1] * 60 * 1000 + $timepices[2] * 1000 + $timepices[3]; $timepices = explode(":", $row_perf['best_effort']); $best_effort = $timepices[0] * 360 * 1000 + $timepices[1] * 60 * 1000 + $timepices[2] * 1000 + $timepices[3]; $previous_effort = intval($best_previous); if ($previous_effort > 0 && $previous_effort < $season_effort) { $season_effort = $previous_effort; $row_perf['season_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['sb_date'] = date('d.m.Y', strtotime($previous_date)); } if ($previous_effort > 0 && $previous_effort < $best_effort) { $best_effort = $previous_effort; $row_perf['best_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['pb_date'] = date('d.m.Y', strtotime($previous_date)); } if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind]) { $sb_perf = AA_formatResultTime($season_effort, true, true); $pb_perf = AA_formatResultTime($best_effort, true, true); } else { $sb_perf = AA_formatResultTime($season_effort, true); $pb_perf = AA_formatResultTime($best_effort, true); } if ($formaction != 'print') { //highlight sb or pb if new performance is better if ($pb_perf != '' && $perf < $pb_perf) { $perf = "<b>PB {$perf}</b>"; } else { if ($sb_perf != '' && $perf < $sb_perf) { $perf = "<b>SB {$perf}</b>"; } } } else { if ($pb_perf != '' && $perf < $pb_perf) { $perf = "<b>PB</b> {$perf}"; } else { if ($sb_perf != '' && $perf < $sb_perf) { $perf = "<b>SB</b> {$perf}"; } } } } if (!empty($row_perf['season_effort'])) { $sb = "<a href=\"#\" class=\"info\">{$sb_perf}<span>{$row_perf['sb_date']}<br>{$row_perf['season_effort_event']}</span></a>"; } else { $sb = " "; } if (!empty($row_perf['best_effort'])) { $pb = "<a href=\"#\" class=\"info\">{$pb_perf}<span>{$row_perf['pb_date']}<br>{$row_perf['best_effort_event']}</span></a>"; } else { $pb = " "; } } } } if ($heatSeparate && $row_res[17] > 0) { $rank = $count_rank; if ($row_res[3] < 0) { // invalid result $rank = ''; } } if ($athleteCat && !$relay) { $nr++; if ($rank != '') { if ($formaction == "print") { $rank = $nr . ". (" . $rank . ")"; } else { $rank = $nr . " (" . $rank . ")"; } } } else { if ($formaction == "print") { if ($rank != '') { $rank .= "."; } } } if ($relay) { $remark = $row_res[17]; } else { $remark = $row_res[22]; } if ($wind == '-' && $perf == 0) { $wind = ''; } if ($ukc) { $points = $pointsUKC; } $list->printLine($rank, $name, $year, $row_res[8], $perf, $wind, $points, $qual, $ioc, $sb, $pb, $qual_mode, $athleteCat, $remark, '', $withStartnr, $row_res[25]); if ($secondResult) { $list->printLine("", "", "", "", $perf2, $wind2, "", "", "", "", "", $qual_mode, "", "", $secondResult); } $perf_save = $row_res[3]; // keep performance // // if relay, show started ahtletes in right order under the result // if ($relay) { if ($row_res[14] > 0) { $sqlRound = $row_res[14]; } else { $sqlRound = $row[0]; } $res_at = mysql_query("\r\n SELECT at.Vorname, at.Name, at.Jahrgang FROM\r\n staffelathlet as sfat\r\n LEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n LEFT JOIN anmeldung as a USING(xAnmeldung)\r\n LEFT JOIN athlet as at USING(xAthlet)\r\n WHERE\r\n sfat.xStaffelstart = {$row_res['11']}\r\n AND sfat.xRunde = {$sqlRound} \r\n ORDER BY\r\n sfat.Position\r\n LIMIT {$row['10']}\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $text_at = ""; while ($row_at = mysql_fetch_array($res_at)) { $text_at .= $row_at[1] . " " . $row_at[0] . " " . AA_formatYearOfBirth($row_at[2]) . " / "; } $text_at = substr($text_at, 0, strlen($text_at) - 2); $text_at = trim($text_at) != '' ? '(' . $text_at . ')' : ''; $list->printAthletesLine($text_at); } } // // if biglist, show all attempts // if ($biglist) { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow] || $row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $query_sort = $row[3] == $cfgDisciplineType[$strDiscTypeHigh] ? "ORDER BY Leistung ASC" : ""; $res_att = mysql_query("\r\n SELECT * FROM \r\n resultat \r\n WHERE xSerienstart = {$row_res['0']}\r\n " . $query_sort . "\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $text_att = ""; while ($row_att = mysql_fetch_array($res_att)) { if ($row_att['Leistung'] < 0) { $perf3 = $row_att['Leistung']; if ($perf3 == $GLOBALS['cfgMissedAttempt']['db']) { // $perf3 = '-'; $perf3 = $GLOBALS['cfgMissedAttempt']['code']; } elseif ($perf3 == $GLOBALS['cfgMissedAttempt']['dbx']) { $perf3 = $GLOBALS['cfgMissedAttempt']['codeX']; } foreach ($cfgInvalidResult as $value) { if ($value['code'] == $perf3) { $text_att .= $value['short']; } } $text_att .= " / "; } else { $text_att .= $row_att['Leistung'] == '-' ? '-' : AA_formatResultMeter($row_att['Leistung']); if ($saison == "O" || $saison == "I" && $row[3] != $cfgDisciplineType[$strDiscTypeJump]) { // outdoor or (indoor and not jump) if ($row_att['Info'] != "-" && !empty($row_att['Info']) && $row[3] != $cfgDisciplineType[$strDiscTypeThrow]) { if ($row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $text_att .= " , " . $row_att['Info']; } else { if ($row[8] != 0) { $text_att .= " , " . $row_att['Info']; } } } elseif ($row_att['Info'] == "-" && $row[3] != $cfgDisciplineType[$strDiscTypeThrow] && $row_att['Leistung'] > 0) { $text_att .= " , " . $row_att['Info']; } } $text_att .= " / "; } } $text_att = substr($text_att, 0, strlen($text_att) - 2); $list->printAthletesLine("{$strAttempts}: ( {$text_att} )"); } } } } // ET athlete processed $id = $row_res[0]; // keep current athletes ID if ($relay) { $catM = $row_res[16]; } else { $catM = $row_res[19]; } // keep merged category } // END WHILE result lines mysql_free_result($res); $list->endList(); } // ET DB error result rows $cat = $row[1]; // keep category $round_keep = $row[0]; } // END WHILE event rounds mysql_free_result($results); if ($ukc && !$results_ukc) { echo "<br><br><b><blockquote>{$strErrNoResults}</blockquote></b>"; } //************** rankinglist over all series if ($ranklistAll) { if ($catMerged & !$heatSeparate || $eventMerged & !$heatSeparate) { // get event rounds from DB $results = mysql_query("\r\n SELECT \r\n r.xRunde\r\n , k.Name\r\n , d.Name\r\n , d.Typ\r\n , w.xWettkampf\r\n , r.QualifikationSieger\r\n , r.QualifikationLeistung\r\n , w.Punkteformel\r\n , w.Windmessung\r\n , r.Speakerstatus\r\n , d.Staffellaeufer\r\n , CONCAT(DATE_FORMAT(r.Datum,'{$cfgDBdateFormat}'), ' ', TIME_FORMAT(r.Startzeit, '{$cfgDBtimeFormat}'))\r\n , w.xDisziplin \r\n FROM\r\n wettkampf AS w\r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n LEFT JOIN runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n WHERE " . $selection . "\r\n w.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n AND r.Status = " . $cfgRoundStatus['results_done'] . " \r\n AND r.Datum LIKE '" . $date . "'\r\n AND (d.Typ = " . $cfgDisciplineType[$strDiscTypeTrack] . " OR d.Typ = " . $cfgDisciplineType[$strDiscTypeTrackNoWind] . " \r\n OR d.Typ = " . $cfgDisciplineType[$strDiscTypeRelay] . " OR d.Typ = " . $cfgDisciplineType[$strDiscTypeDistance] . ") \r\n ORDER BY\r\n k.Anzeige\r\n , d.Anzeige\r\n , r.Datum\r\n , r.Startzeit\r\n "); } else { // heats separate $results = mysql_query("\r\n SELECT DISTINCT \r\n r.xRunde , \r\n k.Name , \r\n d.Name , \r\n d.Typ , \r\n w.xWettkampf , \r\n r.QualifikationSieger , \r\n r.QualifikationLeistung , \r\n w.Punkteformel , \r\n w.Windmessung , \r\n r.Speakerstatus , \r\n d.Staffellaeufer , \r\n CONCAT(DATE_FORMAT(r.Datum,'%d.%m.%y'), \r\n ' ', \r\n TIME_FORMAT(r.Startzeit, '%H:%i')) ,\r\n w.xDisziplin , \r\n rs.Hauptrunde \r\n FROM \r\n wettkampf AS w \r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie) \r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n LEFT JOIN runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n LEFT JOIN rundenset as rs ON (r.xRunde=rs.xRunde ) \r\n WHERE \r\n " . $selection . " \r\n w.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n AND r.Status = 4 \r\n AND r.Datum LIKE '%' \r\n ORDER BY\r\n k.Anzeige\r\n , d.Anzeige\r\n , r.Datum\r\n , r.Startzeit\r\n "); } if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $limitRankSQL = ""; $limitRank = false; if ($_GET['limitRank'] == "yes") { // check if ranks are limited, but limitRankSQL will set only if export is pressed if (!empty($_GET['limitRankFrom']) && !empty($_GET['limitRankTo'])) { $limitRank = true; } } // start a new HTML display page if ($formaction == 'view' || $formaction == 'speaker') { // display page $list->printPageTitle("{$strRanklistAll} " . $_COOKIE['meeting']); } elseif ($formaction == "print") { $list->insertPageBreak(); $list->printPageTitle("{$strRanklistAll}"); } // initialize variables $cat = ''; $evnt = 0; if (mysql_num_rows($results) == 0) { echo "<br><br><b><blockquote>{$strErrNoResults}</blockquote></b>"; } while ($row = mysql_fetch_row($results)) { // for a combined event, the rounds are merged, so jump until the next event if ($cRounds > 1) { $cRounds--; continue; } $roundSQL = "s.xRunde = {$row['0']}"; $cRounds = 0; // check page break if (is_a($list, "PRINT_RankingList") && $cat != '' && ($break == 'discipline' || $break == 'category' && $row[1] != $cat)) { $list->insertPageBreak(); } if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeRelay]) { $eval = $cfgEvalType[$strEvalTypeHeat]; } else { $eval = $cfgEvalType[$strEvalTypeAll]; } $roundName = ''; $type = ''; $res = mysql_query("\r\n SELECT\r\n rt.Name\r\n , rt.Typ\r\n , rt.Wertung\r\n FROM\r\n runde\r\n LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON (rt.xRundentyp = runde.xRundentyp)\r\n WHERE \r\n runde.xRunde = {$row['0']}"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res) > 0) { $row_rt = mysql_fetch_row($res); if ($row_rt[1] == '0') { $type = " "; $row_rt[0] = ''; } else { $type = $row_rt[0] . " "; } $eval = $row_rt[2]; if ($round != 0) { // specific round selected $roundName = $row_rt[0]; } } mysql_free_result($res); } $flagSubtitle = false; // set flag to print the subtitle later if ($evnt != $row[4]) { // if this is a combined event, dont fragment list by rounds $combined = AA_checkCombined($row[4]); // not selectet a specific round if ($round == 0 && $combined) { $sql = "SELECT \r\n r.xRunde\r\n FROM\r\n wettkampf as w\r\n LEFT JOIN runde as r ON (r.xWettkampf = w.xWettkampf)\r\n WHERE \r\n w.xWettkampf = {$row['4']}\r\n AND r.status = 4"; $res_c = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $cRounds = mysql_num_rows($res_c); $roundSQL = "s.xRunde IN ("; while ($row_c = mysql_fetch_array($res_c)) { $roundSQL .= $row_c[0] . ","; } $roundSQL = substr($roundSQL, 0, -1) . ")"; } } // set up category and discipline title information $flagSubtitle = true; // set flag to print the subtitle later if ($formaction == 'speaker' && AA_getNextRound($row[4], $row[0]) == 0) { // last round: show ceremony status $list->printCeremonyStatus($row[0], $row[9]); } // print qualification mode if round selected $info = ''; if ($round > 0 && ($row[5] > 0 || $row[6] > 0)) { $info = "{$strQualification}: " . $row[5] . " {$strQualifyTop}, " . $row[6] . " {$strQualifyPerformance}"; $flagInfoLine1 = true; // set flag to print later the qualification mode if round selected $info_save1 = $info; //$list->printInfoLine($info); $qual_mode = TRUE; } // print qualification descriptions if required $info = ''; if ($row[5] > 0 || $row[6] > 0) { foreach ($cfgQualificationType as $qt) { $info = $info . $qt['token'] . " =" . $qt['text'] . " "; } $flagInfoLine2 = true; // set flag to print later the qualification descriptions if required $info_save2 = $info; //$list->printInfoLine($info); $qual_mode = TRUE; } $evnt = $row[4]; // keep event ID } // ET new event $relay = AA_checkRelay($row[4]); // check, if this is a relay event $svm = AA_checkSVM($row[4]); // If round evaluated per heat, group results accordingly $order_heat = ""; if ($eval == $cfgEvalType[$strEvalTypeHeat]) { // eval per heat $order_heat = "heatid, "; } $valid_result = ""; // Order performance depending on discipline type if ($row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow]) { $order_perf = "DESC"; } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump]) { if ($row[8] == 1) { // with wind $order_perf = "DESC, r.Info ASC"; } else { // without wind $order_perf = "DESC"; } } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $order_perf = "DESC"; $valid_result = " AND (r.Info LIKE '%O%'" . " OR r.Leistung < 0)"; } else { $order_perf = "ASC"; } } } $sqlSeparate = ''; if (($catMerged || $eventMerged) & $heatSeparate) { if ($row[0] > 0 && $row[13] != NULL) { $roundSQL = ''; if (empty($limitRankSQL) && empty($valid_result)) { $sqlSeparate = " ss.RundeZusammen = " . $row[0]; } else { if (empty($limitRankSQL)) { $valid_result = substr($valid_result, 4, strlen($valid_result)); } elseif (empty($valid_result)) { $limitRankSQL = substr($limitRankSQL, 4, strlen($limitRankSQL)); } $sqlSeparate = " AND ss.RundeZusammen = " . $row[0]; } } } // get all results ordered by ranking; for invalid results (Rang=0), the // rank is set to max_rank to put them to the end of the list. $max_rank = 999999999; $sql_leistung = $order_perf == 'ASC' ? "r.Leistung" : "IF(r.Leistung<0, (If(r.Leistung = -99, -9, (If (r.Leistung = -98, -8,r.Leistung))) * -1), r.Leistung)"; $sql_leistung_order = "IF(r.Leistung is NULL, 999999999 , (IF (r.Leistung < 0,999999999 - r.Leistung, r.Leistung )))"; $order = $order_heat; if ($relay == FALSE) { if ($athleteCat) { $order = $orderAthleteCat . $order_heat; } $query = "SELECT ss.xSerienstart, \r\n IF(ss.Rang=0, {$max_rank}, ss.Rang) AS rank, \r\n ss.Qualifikation, \r\n " . $sql_leistung . " AS leistung_neu, \r\n r.Info, \r\n s.Bezeichnung, \r\n s.Wind, \r\n r.Punkte, \r\n IF('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)), \r\n at.Name, \r\n at.Vorname, \r\n at.Jahrgang, \r\n LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n IF(at.xRegion = 0, at.Land, re.Anzeige) AS Land, \r\n at.xAthlet, \r\n ru.Datum, \r\n ru.Startzeit ,\r\n ss.RundeZusammen,\r\n ru.xRunde, \r\n k.Name , \r\n k1.Name , \r\n k1.Anzeige ,\r\n ss.Bemerkung,\r\n w.Punkteformel,\r\n w.info,\r\n a.Startnummer,\r\n " . $sql_leistung_order . " AS leistung_order, \r\n r.Leistung\r\n FROM serie AS s USE INDEX(Runde)\r\n LEFT JOIN serienstart AS ss USING(xSerie) \r\n LEFT JOIN resultat AS r USING(xSerienstart) \r\n LEFT JOIN start AS st ON(ss.xStart = st.xStart) \r\n LEFT JOIN anmeldung AS a USING(xAnmeldung) \r\n LEFT JOIN athlet AS at USING(xAthlet) \r\n LEFT JOIN verein AS v USING(xVerein) \r\n LEFT JOIN region AS re ON(at.xRegion = re.xRegion) \r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN runde AS ru ON(s.xRunde = ru.xRunde) \r\n LEFT JOIN wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n LEFT JOIN kategorie AS k On (w.xKategorie= k.xKategorie)\r\n LEFT JOIN kategorie AS k1 ON (a.xKategorie = k1.xKategorie) \r\n WHERE " . $roundSQL . " \r\n " . $limitRankSQL . " \r\n " . $valid_result . " \r\n " . $sqlSeparate . " \r\n " . $selectionHeats . " \r\n ORDER BY leistung_order " . $order_perf; } else { // relay event $query = "SELECT ss.xSerienstart, \r\n IF(r.Leistung < 0 , {$max_rank}, if (ss.Rang=0, {$max_rank}-1, ss.Rang)) AS rank, \r\n ss.Qualifikation, \r\n " . $sql_leistung . " AS leistung_neu, \r\n r.Info, \r\n s.Bezeichnung, \r\n s.Wind, \r\n r.Punkte, \r\n IF('" . $svm . "', t.Name, v.Name), \r\n sf.Name, \r\n LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n st.xStart, \r\n ru.Datum, \r\n ru.Startzeit, \r\n ss.RundeZusammen,\r\n ru.xRunde,\r\n k.Name ,\r\n ss.Bemerkung \r\n FROM serie AS s USE INDEX(Runde) \r\n LEFT JOIN serienstart AS ss USING(xSerie) \r\n LEFT JOIN resultat AS r USING(xSerienstart) \r\n LEFT JOIN start AS st ON(ss.xStart = st.xStart) \r\n LEFT JOIN staffel AS sf USING(xStaffel) \r\n LEFT JOIN verein AS v USING(xVerein) \r\n LEFT JOIN team AS t ON(sf.xTeam = t.xTeam) \r\n LEFT JOIN runde AS ru ON(s.xRunde = ru.xRunde) \r\n LEFT JOIN wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n LEFT JOIN kategorie AS k On (w.xKategorie= k.xKategorie) \r\n WHERE " . $roundSQL . " \r\n " . $limitRankSQL . " \r\n " . $valid_result . " \r\n " . $sqlSeparate . " \r\n GROUP BY r.xSerienstart \r\n ORDER BY " . $order . " \r\n rank, \r\n r.Leistung \r\n " . $order_perf . ", \r\n sf.Name;"; } $res = mysql_query($query); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res) == 0) { continue; } // initialize variables $heat = ''; $h = 0; $info = ''; $id = ''; $r = ''; $count_rank = 0; $perf_save = ''; $nr = 0; if ($formaction == 'view') { $list->startList(); } $atCat = ''; // process every result while ($row_res = mysql_fetch_array($res)) { if ($flagSubtitle) { $nr = 0; if ($heatSeparate) { if ($relay) { $list->printSubTitle($row_res[16], $row2_keep, $roundName, $row_res[24]); } else { if (!$athleteCat) { $list->printSubTitle($row_res[19], $row2_keep, $roundName, $row_res[24]); } } } else { if (!$athleteCat) { if ($formaction == 'print') { $list->printSubTitle($row[1], $row[2], $roundName, $row_res[24]); } else { $list->printSubTitle($row[1], $row[2], $roundName, $row_res[24]); } } } $flagSubtitle = false; if ($formaction == 'print') { $list->startList(); } } /* if (!$athleteCat){ if ($flagInfoLine1){ $list->printInfoLine($info_save1); $flagInfoLine1=false; } } if (!$athleteCat){ if ($flagInfoLine2){ $list->printInfoLine($info_save2); $flagInfoLine2=false; } } */ $row_res[3] = $row_res[3] == 1 || $row_res[3] == 2 || $row_res[3] == 3 || $row_res[3] == 4 ? $row_res[3] * -1 : ($row_res[3] == 9 ? -99 : ($row_res[3] == 8 ? -98 : $row_res[3])); $nr = 0; $title = trim($title); if ($row_res[0] != $id) { if ($h == 0) { $count_rank = 0; $nr = 0; // heat name if ($eval == $cfgEvalType[$strEvalTypeHeat]) { if (empty($type)) { // no round type defined $type = $strFinalround . " "; } $title = $type; // heat name withour nbr. } else { $title = $type; // heat name withour nbr. } $title = trim($title); // wind per heat if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] && $row[8] == 1 && $eval == $cfgEvalType[$strEvalTypeHeat]) { $heatwind = $row_res[6]; // wind per heat } else { $heatwind = ''; // no wind } $wind = FALSE; if ($row[8] == 1 && $row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeTrack] && $eval == $cfgEvalType[$strEvalTypeAll]) { $wind = TRUE; } // add column header 'points' if required $points = FALSE; if ($row[7] != '0' || $row_res[23] != '0') { $points = TRUE; } if ($show_efforts == 'sb_pb') { $base_perf = true; } if ($athleteCat && !$relay) { if ($formaction == 'print') { if ($row_res[20] . $row[2] != $atCatName) { $list->printSubTitle($row_res[20], $row2_keep, $roundName, $row_res[24]); $atCatName = $row_res[20] . $row[2]; if ($flagInfoLine1) { $list->printInfoLine($info_save1); $flagInfoLine1 = false; } if ($flagInfoLine2) { $list->printInfoLine($info_save2); $flagInfoLine2 = false; } } } } // $list->startList(); if ($saison == "I") { $heatwind = ''; } $list->printHeaderLine($title, $relay, $points, $wind, $heatwind, $row[11], $svm, $base_perf, $qual_mode, $eval, $withStartnr); if ($athleteCat && !$relay) { if ($formaction == 'view') { if ($row_res[20] . $row[2] != $atCatName) { $list->printSubTitle($row_res[20], $row[2], $roundName, $row_res[24]); $atCatName = $row_res[20] . $row[2]; if ($flagInfoLine1) { $list->printInfoLine($info_save1, $athleteCat); $flagInfoLine1 = false; } if ($flagInfoLine2) { $list->printInfoLine($info_save2, $athleteCat); $flagInfoLine2 = false; } } } } $heat = $row_res[5]; // keep heat description $atCat = $row_res[21]; // keep athlete category $h++; // increment if evaluation per heat } $count_rank++; // rank if ($row_res[1] == $max_rank || $row_res[1] == $max_rank - 1 || $r == $row_res[1] && $heat_keep == $row_res[5]) { // same rank as previous $rank = ''; } else { $rank = $row_res[1]; } $r = $row_res[1]; // keep rank $heat_keep = $row_res[5]; // keep rank // name $name = $row_res[9]; if ($relay == FALSE) { $name = $name . " " . $row_res[10]; } // year of birth if ($relay == FALSE) { $year = AA_formatYearOfBirth($row_res[11]); } else { $year = ''; } // year of birth if ($relay == FALSE) { $land = $row_res[13] != '' && $row_res[13] != '-' ? $row_res[13] : ''; } else { $year = ''; } // performance if ($row_res[3] < 0) { // invalid result if ($row_res[3] == '-98') { $perf = $cfgInvalidResult['NAA']['code']; } elseif ($row_res[3] == '-99') { $perf = $cfgInvalidResult['WAI']['short']; } else { foreach ($cfgInvalidResult as $value) { if ($value['code'] == $row_res[3]) { $perf = $value['short']; } } } } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow] || $row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $perf = AA_formatResultMeter($row_res[3]); } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind]) { $perf = AA_formatResultTime($row_res[3], true, true); } else { $perf = AA_formatResultTime($row_res[3], true); } } } $qual = ''; if ($row_res[2] > 0) { // Athlete qualified foreach ($cfgQualificationType as $qtype) { if ($qtype['code'] == $row_res[2]) { $qual = $qtype['token']; } } } // ET athlete qualified // points for performance $points = ''; if ($row[7] != '0') { $points = $row_res[7]; } else { if ($row_res[23] != '0') { $points = $row_res[7]; } } // wind info $wind = ''; $secondResult = false; if ($r != $max_rank) { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] && $row[8] == 1) { $wind = $row_res[4]; if ($saison == 'I') { $wind = ''; // indoor: never wind } // // if wind bigger than max wind (2.0) show the next best result without wind too // if ($wind > 2) { $res_wind = mysql_query("\r\n SELECT Info, Leistung FROM\r\n resultat\r\n WHERE\r\n xSerienstart = {$row_res['0']}\r\n ORDER BY\r\n Leistung ASC"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row_wind = mysql_fetch_array($res_wind)) { if ($row_wind[0] <= 2) { $secondResult = true; $wind2 = $row_wind[0] . ")"; $perf2 = "(" . AA_formatResultMeter($row_wind[1]); } } } } } else { if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] && $row[8] == 1 && $eval == $cfgEvalType[$strEvalTypeAll]) { $wind = $row_res[6]; if ($saison == 'I') { $wind = ''; // indoor: never wind } } } } // ioc country code $ioc = ''; if ($relay == false) { $ioc = $row_res[13]; } //show performances from base if ($show_efforts == 'sb_pb' && $relay == false) { $sql = "SELECT \r\n season_effort\r\n , DATE_FORMAT(season_effort_date, '%d.%m.%Y') AS sb_date\r\n , season_effort_event\r\n , best_effort\r\n , DATE_FORMAT(best_effort_date, '%d.%m.%Y') AS pb_date\r\n , best_effort_event\r\n , season\r\n , xAnmeldung\r\n FROM \r\n base_performance\r\n LEFT JOIN \r\n base_athlete USING (id_athlete)\r\n LEFT JOIN \r\n disziplin_" . $_COOKIE['language'] . " ON (discipline = Code)\r\n LEFT JOIN \r\n athlet ON (license = Lizenznummer)\r\n LEFT JOIN\r\n anmeldung USING(xAthlet) \r\n WHERE \r\n athlet.xAthlet = {$row_res['14']}\r\n AND xDisziplin = {$row['12']}\r\n AND season = '{$saison}' \r\n AND xMeeting = " . $_COOKIE['meeting_id'] . ";"; $res_perf = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if ($res_perf) { $row_perf = mysql_fetch_array($res_perf); $is_jump = $row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow] || $row[3] == $cfgDisciplineType[$strDiscTypeHigh]; $order = $is_jump ? 'DESC' : 'ASC'; $best_previous = ''; $previous_date = ''; if ($row_perf !== false) { $best_previous = AA_getBestPrevious($row[12], $row_perf['xAnmeldung'], $order, $row_res['Datum'], $row_res['Startzeit'], &$previous_date); } if ($is_jump) { $sb_perf = AA_formatResultMeter(str_replace(".", "", $row_perf['season_effort'])); $pb_perf = AA_formatResultMeter(str_replace(".", "", $row_perf['best_effort'])); $bp_perf = AA_formatResultMeter(str_replace(".", "", $best_previous)); if ($bp_perf > 0 && $bp_perf > $sb_perf) { $sb_perf = $bp_perf; $row_perf['season_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['sb_date'] = date('d.m.Y', strtotime($previous_date)); } if ($bp_perf > 0 && $bp_perf > $pb_perf) { $pb_perf = $bp_perf; $row_perf['best_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['pb_date'] = date('d.m.Y', strtotime($previous_date)); } //highlight sb or pb if new performance is better if (is_numeric($perf)) { //prevent special-codes (disq, n.a. usw) if ($formaction != 'print') { if ($pb_perf != '' && $perf > $pb_perf) { $perf = "<b>PB {$perf}</b> "; } else { if ($sb_perf != '' && $perf > $sb_perf) { $perf = "<b>SB {$perf}</b>"; } } } else { if ($pb_perf != '' && $perf > $pb_perf) { $perf = "<b>PB</b> {$perf}"; } else { if ($sb_perf != '' && $perf > $sb_perf) { $perf = "<b>SB</b> {$perf}"; } } } } } else { //convert performance-time to milliseconds $timepices = explode(":", $row_perf['season_effort']); $season_effort = $timepices[0] * 360 * 1000 + $timepices[1] * 60 * 1000 + $timepices[2] * 1000 + $timepices[3]; $timepices = explode(":", $row_perf['best_effort']); $best_effort = $timepices[0] * 360 * 1000 + $timepices[1] * 60 * 1000 + $timepices[2] * 1000 + $timepices[3]; $previous_effort = intval($best_previous); if ($previous_effort > 0 && $previous_effort < $season_effort) { $season_effort = $previous_effort; $row_perf['season_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['sb_date'] = date('d.m.Y', strtotime($previous_date)); } if ($previous_effort > 0 && $previous_effort < $best_effort) { $best_effort = $previous_effort; $row_perf['best_effort_event'] = $_SESSION['meeting_infos']['Name']; $row_perf['pb_date'] = date('d.m.Y', strtotime($previous_date)); } if ($row[3] == $cfgDisciplineType[$strDiscTypeTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind]) { $sb_perf = AA_formatResultTime($season_effort, true, true); $pb_perf = AA_formatResultTime($best_effort, true, true); } else { $sb_perf = AA_formatResultTime($season_effort, true); $pb_perf = AA_formatResultTime($best_effort, true); } if ($formaction != 'print') { //highlight sb or pb if new performance is better if ($pb_perf != '' && $perf < $pb_perf) { $perf = "<b>PB {$perf}</b>"; } else { if ($sb_perf != '' && $perf < $sb_perf) { $perf = "<b>SB {$perf}</b>"; } } } else { if ($pb_perf != '' && $perf < $pb_perf) { $perf = "<b>PB</b> {$perf}"; } else { if ($sb_perf != '' && $perf < $sb_perf) { $perf = "<b>SB</b> {$perf}"; } } } } if (!empty($row_perf['season_effort'])) { $sb = "<a href=\"#\" class=\"info\">{$sb_perf}<span>{$row_perf['sb_date']}<br>{$row_perf['season_effort_event']}</span></a>"; } else { $sb = " "; } if (!empty($row_perf['best_effort'])) { $pb = "<a href=\"#\" class=\"info\">{$pb_perf}<span>{$row_perf['pb_date']}<br>{$row_perf['best_effort_event']}</span></a>"; } else { $pb = " "; } } } } if ($heatSeparate && $row_res[17] > 0) { $rank = $count_rank; if ($row_res[3] < 0) { // invalid result $rank = ''; } } if ($athleteCat && !$relay) { $nr++; if ($rank != '') { if ($formaction == "print") { $rank = $nr . ". (" . $rank . ")"; } else { $rank = $nr . " (" . $rank . ")"; } } } else { if ($formaction == "print") { if ($rank != '') { $rank .= "."; } } } if ($relay) { $remark = $row_res[17]; } else { $remark = $row_res[22]; } if ($wind == '-' && $perf == 0) { $wind = ''; } if ($row_res[1] == 999999999) { $count_show = ''; } else { $count_show = $count_rank; } $list->printLine($count_show, $name, $year, $row_res[8], $perf, $wind, $points, $qual, $ioc, $sb, $pb, $qual_mode, $athleteCat, $remark, '', $withStartnr, $row_res[25]); if ($secondResult) { $list->printLine("", "", "", "", $perf2, $wind2, "", "", "", "", "", $qual_mode, "", "", $secondResult); } $perf_save = $row_res[3]; // keep performance // // if relay, show started ahtletes in right order under the result // if ($relay) { if ($row_res[14] > 0) { $sqlRound = $row_res[14]; } else { $sqlRound = $row[0]; } $res_at = mysql_query("\r\n SELECT at.Vorname, at.Name, at.Jahrgang FROM\r\n staffelathlet as sfat\r\n LEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n LEFT JOIN anmeldung as a USING(xAnmeldung)\r\n LEFT JOIN athlet as at USING(xAthlet)\r\n WHERE\r\n sfat.xStaffelstart = {$row_res['11']}\r\n AND sfat.xRunde = {$sqlRound} \r\n ORDER BY\r\n sfat.Position\r\n LIMIT {$row['10']}\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $text_at = ""; while ($row_at = mysql_fetch_array($res_at)) { $text_at .= $row_at[1] . " " . $row_at[0] . " " . AA_formatYearOfBirth($row_at[2]) . " / "; } $text_at = substr($text_at, 0, strlen($text_at) - 2); $text_at = trim($text_at) != '' ? '(' . $text_at . ')' : ''; $list->printAthletesLine($text_at); } } // // if biglist, show all attempts // if ($biglist) { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] || $row[3] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeThrow] || $row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $query_sort = $row[3] == $cfgDisciplineType[$strDiscTypeHigh] ? "ORDER BY Leistung ASC" : ""; $res_att = mysql_query("\r\n SELECT * FROM \r\n resultat \r\n WHERE xSerienstart = {$row_res['0']}\r\n " . $query_sort . "\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $text_att = ""; while ($row_att = mysql_fetch_array($res_att)) { if ($row_att['Leistung'] < 0) { $perf3 = $row_att['Leistung']; if ($perf3 == $GLOBALS['cfgMissedAttempt']['db']) { // $perf3 = '-'; $perf3 = $GLOBALS['cfgMissedAttempt']['code']; } elseif ($perf3 == $GLOBALS['cfgMissedAttempt']['dbx']) { $perf3 = $GLOBALS['cfgMissedAttempt']['codeX']; } foreach ($cfgInvalidResult as $value) { if ($value['code'] == $perf3) { $text_att .= $value['short']; } } $text_att .= " / "; } else { $text_att .= $row_att['Leistung'] == '-' ? '-' : AA_formatResultMeter($row_att['Leistung']); if ($saison == "O" || $saison == "I" && $row[3] != $cfgDisciplineType[$strDiscTypeJump]) { // outdoor or (indoor and not jump) if ($row_att['Info'] != "-" && !empty($row_att['Info']) && $row[3] != $cfgDisciplineType[$strDiscTypeThrow]) { if ($row[3] == $cfgDisciplineType[$strDiscTypeHigh]) { $text_att .= " , " . $row_att['Info']; } else { if ($row[8] != 0) { $text_att .= " , " . $row_att['Info']; } } } elseif ($row_att['Info'] == "-" && $row[3] != $cfgDisciplineType[$strDiscTypeThrow] && $row_att['Leistung'] > 0) { $text_att .= " , " . $row_att['Info']; } } $text_att .= " / "; } } $text_att = substr($text_att, 0, strlen($text_att) - 2); $list->printAthletesLine("{$strAttempts}: ( {$text_att} )"); } } } } // ET athlete processed $id = $row_res[0]; // keep current athletes ID if ($relay) { $catM = $row_res[16]; } else { $catM = $row_res[19]; } // keep merged category $info_save1_keep = $info_save1; $info_save2_keep = $info_save2; } // END WHILE result lines } $row1_keep = $row[1]; $row2_keep = $row[2]; } } $list->endList(); } //******************************* if ($ukc) { AA_rankinglist_Combined($category, $formaction, $break, $cover, $sepu23, $cover_timing, $date, $disc_nr, $catFrom, $catTo, $ukc); } $list->endPage(); // end HTML page for printing } // ET DB error event rounds }
function delete() { $GLOBALS['AA_ERROR'] = ''; $query = ''; $reply = new ResultReturn(); AA_utils_changeRoundStatus($this->round, $GLOBALS['cfgRoundStatus']['results_in_progress']); if (!empty($GLOBALS['AA_ERROR'])) { return; } mysql_query("LOCK TABLES resultat WRITE, resultat AS re READ , serienstart AS ss READ, serie AS s READ, runde WRITE, runde AS r WRITE"); mysql_query("\r\n\t\t\tDELETE FROM resultat\r\n\t\t\tWHERE xResultat= " . $this->resultID); if (mysql_errno() > 0) { $GLOBALS['AA_ERROR'] = mysql_errno() . ": " . mysql_error(); } else { AA_StatusChanged($this->resultID); $reply->setKey($this->resultID); $reply->setAction(RES_ACT_DELETE); } mysql_query("UNLOCK TABLES"); return $reply; }
function AA_heats_delete($round) { require './lib/common.lib.php'; mysql_query("LOCK TABLES runde READ ,rundenset READ, serie WRITE, serienstart WRITE, hoehe WRITE, runde WRITE, runde as r READ, serie as s READ, serienstart as ss READ, resultat as re READ"); // delete only possible if no results entered yet if (AA_getRoundStatus($round) > $GLOBALS['cfgRoundStatus']['heats_done']) { AA_printErrorMsg($GLOBALS['strErrResultsEntered']); } else { // get this round's heats $result = mysql_query("SELECT xSerie" . " FROM serie" . " WHERE xRunde = {$round}"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // delete every start per heat $err = ''; while ($row = mysql_fetch_row($result)) { mysql_query("DELETE FROM serienstart" . " WHERE xSerie = {$row['0']}"); if (mysql_errno() > 0) { $err = mysql_errno() . ": " . mysql_error(); } AA_StatusChanged(0, $row[0]); $sql = "DELETE FROM hoehe \r\n WHERE xRunde = " . $round . " \r\n AND xSerie = " . $row[0]; mysql_query($sql); if (mysql_errno() > 0) { $err = mysql_errno() . ": " . mysql_error(); } } if ($err != '') { AA_printErrorMsg($err); } else { // delete heat mysql_query("DELETE FROM serie" . " WHERE xRunde = {$round}"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // reset round status AA_utils_changeRoundStatus($round, $GLOBALS['cfgRoundStatus']['open']); if (!empty($GLOBALS['AA_ERROR'])) { AA_printErrorMsg($GLOBALS['AA_ERROR']); } } } // ET DB Error while deleting starts } // ET DB error while reading hests mysql_free_result($result); } // ET results already entered mysql_query("UNLOCK TABLES"); }
function gen_result_xml_UKC_CM($file, $meeting_nr) { //function returns containing number of results in xml-file $nbr_effort_ukc = 0; global $cfgDisciplineType, $cfgEventType, $strEventTypeSingleCombined, $strEventTypeClubCombined, $strDiscTypeTrack, $strDiscTypeTrackNoWind, $strDiscTypeRelay, $strDiscTypeDistance, $cfgRoundStatus, $strDiscTypeJump, $strDiscTypeJumpNoWind, $strDiscTypeThrow, $strDiscTypeHigh, $cfgCombinedWO, $cfgCombinedDef, $cfgUKC_disc; $this->gzip_open($file); // begin xml $this->write_xml_open("kidDataset", array('version' => date('y-m-d'))); $this->write_xml_open("event"); // // output contest data // $indoor = '0'; $query = "\r\n SELECT\r\n m.*\r\n , s.Name as Stadion\r\n , s.Ueber1000m\r\n , s.Halle\r\n FROM \r\n meeting as m \r\n LEFT JOIN stadion as s ON m.xStadion = s.xStadion \r\n WHERE xMeeting = " . $_COOKIE['meeting_id']; $res = mysql_query($query); if (mysql_errno() > 0) { echo mysql_errno() . ": " . mysql_error(); } else { $row = mysql_fetch_assoc($res); mysql_free_result($res); if (empty($meeting_nr)) { $this->write_xml_finished("eventNumber", $row['Nummer']); // not xControl for UBS kidscup } else { $this->write_xml_finished("eventNumber", $meeting_nr); } $this->write_xml_finished("name", str_replace('&', '&', $row['Name'])); $this->write_xml_finished("eventStart", $row['DatumVon']); $this->write_xml_finished("eventEnd", $row['DatumBis']); $this->write_xml_finished("location", $row['Ort']); $this->write_xml_finished("stadium", $row['Stadion']); $this->write_xml_finished("amountSpectators", " "); $this->write_xml_open("athletes"); if ($row['Ueber1000m'] == 'y') { $global_rankadd = "A"; } if ($row['Saison'] == 'I') { $indoor = "1"; } // 1 = indoor , 0 = outdoor } // get enrolement per athlete $checkyear = date('Y') - 16; $sql = "SELECT DISTINCT \r\n a.xAnmeldung\r\n , at.Name\r\n , at.Vorname\r\n , at.Jahrgang\r\n \r\n , IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)\r\n , IF(at.xRegion = 0, at.Land, re.Anzeige)\r\n , 0\r\n , d.Name\r\n \r\n \r\n \r\n , ka.Alterslimite \r\n , d.Code \r\n , at.xAthlet\r\n , at.Geschlecht \r\n FROM\r\n anmeldung AS a\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet )\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein )\r\n LEFT JOIN start as st ON (st.xAnmeldung = a.xAnmeldung ) \r\n LEFT JOIN wettkampf as w ON (w.xWettkampf = st.xWettkampf) \r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (w.xDisziplin = d.xDisziplin)\r\n LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n LEFT JOIN kategorie AS ka ON (ka.xKategorie = a.xKategorie) \r\n LEFT JOIN region as re ON (at.xRegion = re.xRegion) \r\n WHERE a.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n AND at.Jahrgang > {$checkyear} AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ")\r\n AND st.anwesend = 0 \r\n ORDER BY at.Geschlecht, at.Jahrgang, at.Name, at.Vorname, d.Anzeige"; $results = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row = mysql_fetch_row($results)) { if ($roundsUkc[$row[10]] == "") { $roundsUkc[$row[10]] = 0; } $roundsUkc[$row[10]]++; } } // // get all disciplines // $selection = " (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") AND "; $sql = " SELECT \r\n w.Typ,\r\n w.Windmessung,\r\n d.Typ,\r\n d.Code,\r\n k.Code,\r\n w.xWettkampf,\r\n d.Kurzname,\r\n w.Mehrkampfcode,\r\n 0,\r\n d.Staffellaeufer, \r\n r.xRunde,\r\n w.info \r\n FROM \r\n wettkampf as w \r\n LEFT JOIN runde as r ON (w.xWettkampf = r.xWettkampf) \r\n LEFT JOIN\r\n disziplin_" . $_COOKIE['language'] . " as d ON d.xDisziplin = w.xDisziplin\r\n LEFT JOIN\r\n kategorie as k ON k.xKategorie = w.xKategorie \r\n WHERE {$selection} r.xRunde > 0 AND \r\n \r\n w.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n ORDER BY\r\n k.Code \r\n , w.info\r\n , w.xKategorie\r\n , d.Anzeige"; // the order "k.Code, w.xKategorie" makes sense if there are multiple self made categories (without any code) $res = mysql_query($sql); if (mysql_errno() > 0) { echo mysql_errno() . ": " . mysql_error(); } else { $current_type = ""; $combined = ""; $current_cat = ""; $current_xcat = 0; $GLOBALS['rounds'] = array(); $combined = array(); $fetched_events = array(); while ($row = mysql_fetch_array($res)) { // // generate results for combined events // // // first of all, print all single results (athletes and relays) // $order_perf = ""; $valid_result = ""; if ($row[2] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeThrow]) { $order_perf = "DESC"; } else { if ($row[2] == $cfgDisciplineType[$strDiscTypeJump]) { if ($row[1] == 1) { // with wind $order_perf = "DESC"; } else { // without wind $order_perf = "DESC"; } } else { if ($row[2] == $cfgDisciplineType[$strDiscTypeHigh]) { $order_perf = "DESC"; $valid_result = " AND (r.Info LIKE '%O%') "; } else { $order_perf = "ASC"; } } } // check if merged rounds $sqlEvents = AA_getMergedEventsFromEvent($row[5]); if (empty($sqlEvents)) { $sqlSeparate = "ru.xRunde = " . $row[10]; } else { $sqlSeparate = "ss.RundeZusammen = " . $row[10]; } $checkyear = date('Y') - 16; $selection = " at.Jahrgang > {$checkyear} AND "; // by merged rounds the result must be uploded separate $query = "\r\n SELECT\r\n ss.xSerienstart\r\n , ss.Rang\r\n , ss.Qualifikation\r\n , r.Leistung\r\n , r.Info\r\n , s.Bezeichnung\r\n , s.Wind\r\n , r.Punkte\r\n , v.Name\r\n , at.Name\r\n , at.Vorname\r\n , at.Jahrgang\r\n , at.Land\r\n , at.xAthlet\r\n , at.Lizenznummer\r\n , ru.Datum\r\n , rt.Code as Typ\r\n , at.Bezahlt\r\n , at.Geburtstag\r\n , at.Geschlecht\r\n , v.xCode as Vereincode\r\n , k.Code as Katathlet\r\n , ru.xRunde\r\n , s.Handgestoppt\r\n , at.Lizenztyp\r\n , a.Vereinsinfo\r\n , rt.Typ\r\n \r\n , if (ss.RundeZusammen > 0,ss.RundeZusammen,ru.xRunde) as spezRound \r\n , a.kidID\r\n , at.Adresse\r\n , at.Plz\r\n , at.Ort\r\n , at.Email \r\n , re.Anzeige as Kanton \r\n , v.Name as Vereinname\r\n , a.xAnmeldung\r\n FROM\r\n runde as ru\r\n LEFT JOIN serie AS s ON (ru.xRunde = s.xRunde)\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN resultat AS r ON (r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein )\r\n LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON (ru.xRundentyp = rt.xRundentyp)\r\n LEFT JOIN kategorie AS k ON (a.xKategorie = k.xKategorie) \r\n LEFT JOIN region AS re ON (re.xRegion = at.xRegion) \r\n WHERE {$selection} {$sqlSeparate}\r\n AND ru.Status = " . $cfgRoundStatus['results_done'] . "\r\n AND ru.StatusUploadUKC = 0\r\n AND r.Leistung >= " . $GLOBALS['cfgInvalidResult']['DNS']['code'] . "\r\n \r\n {$valid_result}\r\n ORDER BY \r\n at.Jahrgang\r\n , at.xAthlet\r\n , ru.xRunde\r\n , r.Leistung " . $order_perf; $res_results = mysql_query($query); if (mysql_errno() > 0) { echo mysql_Error(); } else { $id = 0; // athletes id $ru = 0; // round id while ($row_results = mysql_fetch_assoc($res_results)) { // store round ids for later purpose $GLOBALS['rounds'][] = $row_results['xRunde']; // // athlete results // if ($ru == $row_results['xRunde'] && $id == $row_results['xAthlet']) { continue; } $ru = $row_results['xRunde']; if ($id != $row_results['xAthlet']) { // new athlete $id = $row_results['xAthlet']; if (empty($row_results['Lizenznummer']) && empty($row_results['kidID'])) { $inMasterData = 1; $licensePaid = 1; } else { $inMasterData = 0; if ($row_results['Bezahlt'] == 'y') { $licensePaid = 1; } else { $licensePaid = 0; } } } $perf = 0; // result for alabus $wind = ""; $perfRounded = 0; // result for combined detail text // add effort parameters $wind = ""; if ($row[2] == $cfgDisciplineType[$strDiscTypeJump] || $row[2] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeThrow] || $row[2] == $cfgDisciplineType[$strDiscTypeHigh]) { $perf = AA_alabusDistance($row_results['Leistung']); $perfRounded = AA_formatResultMeter($row_results['Leistung']); $wind = strtr($row_results['Info'], ",", "."); } else { $perf = AA_alabusTime($row_results['Leistung']); $perfRounded = AA_formatResultTime($row_results['Leistung'], true); $wind = strtr($row_results['Wind'], ",", "."); } if ($row[1] == 0 || $wind == "-" || $wind == "") { $wind = " "; } if (is_numeric($row_results['Bezeichnung'])) { $row_results['Bezeichnung'] = sprintf("%02s", $row_results['Bezeichnung']); } else { if (strlen($row_results['Bezeichnung']) == 1) { $row_results['Bezeichnung'] .= "_"; } } $rank = " "; $row_results['Bezeichnung'] = " "; // //add points for combined contests if ($combined[$row_results['xAthlet']][$row[3]]['points'] < $row_results['Punkte']) { $license = $row_results['Lizenznummer']; if ($row_results['Lizenznummer'] == 0) { $license = ''; } $kidsID_upload = $row_results['kidID']; if ($row_results['kidID'] == 0) { $kidsID_upload = ''; } if ($row[3] == 30) { $perfRounded = "r" . $perfRounded; // r = run } if ($row[3] == 331) { $perfRounded = "j" . $perfRounded; // j = jump } if ($row[3] == 386) { $perfRounded = "t" . $perfRounded; // t = throw } $combined[$row_results['xAthlet']][$row[3]] = array('wind' => $wind, 'kindOfLap' => " " . $row_results['Typ'], 'lap' => $row_results['Bezeichnung'], 'placeAddon' => $rankadd, 'indoor' => $indoor, 'points' => $row_results['Punkte'], 'effort' => $perfRounded, 'discipline' => $row[6], 'license' => $license, 'kidID' => $kidsID_upload, 'inMasterData' => $inMasterData, 'licensePaid' => $licensePaid, 'DateOfEffort' => $row_results['Datum'], 'lastName' => htmlspecialchars($row_results['Name']), 'firstName' => htmlspecialchars($row_results['Vorname']), 'birthDate' => $row_results['Jahrgang'], 'sex' => strtoupper($row_results['Geschlecht']), 'nationality' => $row_results['Land'], 'adress' => htmlspecialchars($row_results['Adresse']), 'plz' => $row_results['Plz'], 'city' => htmlspecialchars($row_results['Ort']), 'email' => $row_results['Email'], 'canton' => $row_results['Kanton'], 'accountName' => htmlspecialchars($row_results['Vereinname']), 'priority' => $combinedPriority, 'licenseType' => $row_results['Lizenztyp'], 'dCode' => $row_results['dCode'], 'xAnmeldung' => $row_results['xAnmeldung'], 'xSerienstart' => $row_results['xSerienstart'], 'Leistung' => $row_results['Leistung'], 'xathlete' => $row_results['xAthlet']); // category of athlete, used for calculating the rankings $combined[$row_results['xAthlet']]['catathlete'] = $row_results['Jahrgang']; } // check on relevant for bestlist $relevant = 1; if ($row_results['Typ'] == '0') { // (ohne) $row_results['Bezeichnung'] = ''; } // output result data if ($wind > "2" && $row[2] == $cfgDisciplineType[$strDiscTypeJump]) { // since we get only the best result per xSerienstart, // here we'll get the next with valid wind $res_wind = mysql_query("\r\n SELECT Info, Leistung FROM\r\n resultat\r\n WHERE\r\n xSerienstart = " . $row_results['xSerienstart'] . "\r\n ORDER BY\r\n Leistung DESC"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row_wind = mysql_fetch_array($res_wind)) { if ($row_wind[0] <= 2) { $perf = AA_alabusDistance($row_wind[1]); if ($perf == -98) { // -98 = Fehlversuch break; } $nbr_effort_ukc++; break; } } } } // end if wind > 2 } // end while res_results } } $min_age = date('Y') - 7; // check on last combined event if (!empty($combined) && $combined_dis < 9000) { // combined codes 9000 and above are self made disciplines // calc points foreach ($combined as $xathlet => $disc) { $points = 0; $eDetails = ""; foreach ($disc as $xdisc => $tmp) { if ($xdisc == "catathlete") { continue; } $pointsUKC = AA_utils_calcPointsUKC(0, $tmp['Leistung'], 0, $tmp['sex'], $tmp['xSerienstart'], $xathlet, $tmp['xAnmeldung'], $xdisc); $points += $pointsUKC; mysql_query("UPDATE resultat SET\r\n Punkte = {$pointsUKC}\r\n WHERE\r\n xSerienstart = " . $tmp['xSerienstart']); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } AA_StatusChanged(0, 0, $tmp['xSerienstart']); if ($tmp['wind'] == " ") { $tmp['wind'] = ""; } else { if ($tmp['wind'] >= 0) { $tmp['wind'] = "+" . $tmp['wind']; } else { $tmp['wind'] = $tmp['wind']; } } $eDetails .= $tmp['effort'] . $tmp['wind'] . "/"; $birthDate = $tmp['birthDate']; $sex = $tmp['sex']; $tmp_xathlete = $tmp['xathlete']; } $eDetails = substr($eDetails, 0, -1); $points = sprintf("%05d", $points); $combined[$xathlet]['points'] = $points; $combined[$xathlet]['edetails'] = $eDetails; if ($birthDate > $min_age) { $birthDate = $min_age; } $combined[$xathlet]['birthDate'] = $sex . $birthDate; // need for sort in combination $combined[$xathlet]['xathlete'] = $tmp_xathlete; } // sort for points array_sort($combined, '!birthDate', '!points'); // write $cRank = 0; // rank counter $lp = 0; // remembers points of last athlete foreach ($combined as $xathlet => $disc) { if ($roundsUkc[$disc['xathlete']] != 3) { // enrolement for 3 kids cup disciplines continue; } if ($disc['birthDate'] != $birthDate_keep) { // in combination sex and birthdate $cRank = 0; } $cRank++; if ($lp != $disc['points'] || $disc['points'] == 0) { $lp = $disc['points']; $combined[$xathlet]['rank'] = $cRank; } else { // same total points $c = 0; $keep_c = 0; for ($i = 0; $i < sizeof($cfgUKC_disc); $i++) { if ($disc_keep[$cfgUKC_disc[$i]]['points'] > $disc[$cfgUKC_disc[$i]]['points']) { $keep_c++; } else { $c++; } } $more = ceil(sizeof($cfgUKC_disc) / 2); if (sizeof($cfgUKC_disc) % 2 == 0) { // combined with even number discs $more++; } if ($keep_c >= $more && $keep_c > $c) { $lp = $disc['points']; $combined[$xathlet]['rank'] = $cRank; } else { if ($c >= $more && $c > $keep_c) { $combined[$xathlet_keep]['rank'] = $cRank; $combined[$xathlet]['rank'] = $cRank - 1; } } } // get information for athlete $tmp = $disc; $tmp['points'] = null; $tmp['edetails'] = null; $tmp['birthDate'] = substr($tmp['birthDate'], 1, 4); $tmp['catathlete'] = null; $tmp = array_values($tmp); usort($tmp, array($this, "sort_perdate")); $tmp = $tmp[0]; $run = ''; $jump = ''; $throw = ''; list($perf1, $perf2, $perf3) = split('[/]', $disc['edetails']); if (substr($perf1, 0, 1) == 'r') { $run = substr($perf1, 1); } elseif (substr($perf1, 0, 1) == 'j') { $jump = substr($perf1, 1); } elseif (substr($perf1, 0, 1) == 't') { $throw = substr($perf1, 1); } if (substr($perf2, 0, 1) == 'r') { $run = substr($perf2, 1); } elseif (substr($perf2, 0, 1) == 'j') { $jump = substr($perf2, 1); } elseif (substr($perf2, 0, 1) == 't') { $throw = substr($perf2, 1); } if (substr($perf3, 0, 1) == 'r') { $run = substr($perf3, 1); } elseif (substr($perf3, 0, 1) == 'j') { $jump = substr($perf3, 1); } elseif (substr($perf3, 0, 1) == 't') { $throw = substr($perf3, 1); } if ($run == -1 || $jump == -1 || $throw == -1) { $cRank = $cRank - 1; continue; } $xathlet_keep = $xathlet; $disc_keep = $disc; $birthDate_keep = $disc['birthDate']; } foreach ($combined as $xathlet => $disc) { if ($roundsUkc[$disc['xathlete']] != 3) { // enrolement for 3 kids cup disciplines continue; } // get information for athlete $tmp = $disc; $tmp['points'] = null; $tmp['edetails'] = null; $tmp['birthDate'] = substr($tmp['birthDate'], 1, 4); $tmp['catathlete'] = null; $tmp = array_values($tmp); // usort($tmp, array($this, "sort_perdate")); $tmp = $tmp[0]; $run = ''; $jump = ''; $throw = ''; list($perf1, $perf2, $perf3) = split('[/]', $disc['edetails']); if (substr($perf1, 0, 1) == 'r') { $run = substr($perf1, 1); } elseif (substr($perf1, 0, 1) == 'j') { $jump = substr($perf1, 1); } elseif (substr($perf1, 0, 1) == 't') { $throw = substr($perf1, 1); } if (substr($perf2, 0, 1) == 'r') { $run = substr($perf2, 1); } elseif (substr($perf2, 0, 1) == 'j') { $jump = substr($perf2, 1); } elseif (substr($perf2, 0, 1) == 't') { $throw = substr($perf2, 1); } if (substr($perf3, 0, 1) == 'r') { $run = substr($perf3, 1); } elseif (substr($perf3, 0, 1) == 'j') { $jump = substr($perf3, 1); } elseif (substr($perf3, 0, 1) == 't') { $throw = substr($perf3, 1); } if ($run == -1 || $jump == -1 || $throw == -1) { continue; } $this->write_xml_open("athlete", array('license' => $tmp['license'], 'kidID' => $tmp['kidID'])); $this->write_xml_open("efforts"); $this->write_xml_finished("run", $run); $this->write_xml_finished("throw", $throw); $this->write_xml_finished("jump", $jump); $this->write_xml_finished("totalPoints", AA_alabusScore($disc['points'])); $this->write_xml_finished("position", $disc['rank']); $this->write_xml_close("efforts"); if (empty($tmp['license']) && empty($tmp['kidID'])) { $this->write_xml_open("personalData"); $this->write_xml_finished("lastName", $tmp['lastName']); $this->write_xml_finished("firstName", $tmp['firstName']); $this->write_xml_finished("ageGroup", $tmp['birthDate']); $this->write_xml_finished("sex", $tmp['sex']); $this->write_xml_finished("street", $tmp['adress']); $this->write_xml_finished("zipCode", $tmp['plz']); $this->write_xml_finished("city", $tmp['city']); $this->write_xml_finished("club", $tmp['accountName']); $this->write_xml_finished("email", $tmp['email']); $this->write_xml_finished("canton", $tmp['canton']); $this->write_xml_close("personalData"); } $this->write_xml_close("athlete"); $nbr_effort_ukc++; $birthDate_keep = $disc['birthDate']; } } $combined = array(); // get the svm results mysql_free_result($res); $res = mysql_query("\r\n SELECT\r\n w.Typ,\r\n w.Windmessung,\r\n d.Typ,\r\n d.Code,\r\n k.Code,\r\n w.xWettkampf,\r\n d.Kurzname,\r\n w.Mehrkampfcode,\r\n w.xKategorie,\r\n ks.Code,\r\n MAX(r.Datum)\r\n FROM \r\n runde as r\r\n LEFT JOIN \r\n wettkampf as w USING(xWettkampf) \r\n LEFT JOIN\r\n disziplin_" . $_COOKIE['language'] . " as d ON d.xDisziplin = w.xDisziplin\r\n LEFT JOIN\r\n kategorie as k ON k.xKategorie = w.xKategorie\r\n LEFT JOIN\r\n kategorie_svm as ks ON ks.xKategorie_svm = w.xKategorie_svm\r\n WHERE xMeeting = " . $_COOKIE['meeting_id'] . "\r\n GROUP BY w.xKategorie\r\n ORDER BY\r\n w.xWettkampf\r\n "); if (mysql_errno() > 0) { echo mysql_errno() . ": " . mysql_error(); } else { while ($row = mysql_fetch_array($res)) { // // open rankinlist_team lib for calculating the svm points // if ($row[0] > $cfgEventType[$strEventTypeSingleCombined]) { $this->write_xml_open("discipline", array('sportDiscipline' => $row[9], 'licenseCategory' => $row[4])); $this->write_xml_open("teams"); $GLOBALS['doe'] = $row[10]; // date of team effort (last round date) $GLOBALS['rankadd'] = $global_rankadd; AA_rankinglist_Team($row[8], 'xml', "", false, $this); } } } // close last tags $this->close_open_tags(); } $this->gzip_close(); return $nbr_effort_ukc; }
function AA_meeting_resetResults($event, $formula, $conv = '') { global $strConvtableRankingPoints; global $strConvtableRankingPointsU20; require './lib/common.lib.php'; require './lib/utils.lib.php'; $sql = "\r\n SELECT\r\n re.xResultat\r\n , re.Leistung\r\n , re.Info\r\n , at.Geschlecht\r\n FROM\r\n resultat AS re\r\n LEFT JOIN serienstart AS ss ON (ss.xSerienstart = re.xSerienstart)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n LEFT JOIN anmeldung AS a ON (st.xAnmeldung = a.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (a.xAthlet = at.xAthlet)\r\n WHERE \r\n st.xWettkampf = {$event} \r\n AND re.Info != 'XXX'"; $result = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if ($formula == '0') { // reset all result points to zero while ($row = mysql_fetch_row($result)) { mysql_query("\r\n\t\t\t\t\tUPDATE resultat SET\r\n\t\t\t\t\t\tPunkte=0\r\n\t\t\t\t\tWHERE xResultat = {$row['0']}\r\n\t\t\t\t"); // Check if any error returned from DB if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } AA_StatusChanged($row[0]); } // end while every result for this category } else { // if ranking points are set -> calc special if (empty($conv)) { $rp = $GLOBALS['cvtFormulas'][$GLOBALS['cvtTable'][$strConvtableRankingPoints]]; // formulas for ranking points } else { if ($conv == $cvtTable[$strConvtableRankingPointsU20]) { $rp = $GLOBALS['cvtFormulas'][$GLOBALS['cvtTable'][$strConvtableRankingPointsU20]]; // formulas for ranking points } else { $rp = $GLOBALS['cvtFormulas'][$GLOBALS['cvtTable'][$strConvtableRankingPoints]]; // formulas for ranking points } } if (array_key_exists($formula, $rp)) { mysql_free_result($result); $result = mysql_query("SELECT xRunde FROM\r\n\t\t\t\t\t\t\t\trunde\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\txWettkampf = {$event}"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // update each round while ($row = mysql_fetch_array($result)) { AA_utils_calcRankingPoints($row[0]); } } } else { // normal point formula // recalculate result points while ($row = mysql_fetch_row($result)) { $points = AA_utils_calcPoints($event, $row[1], 0, $row[3]); mysql_query("\r\n\t\t\t\t\t\tUPDATE resultat SET\r\n\t\t\t\t\t\t\tPunkte = {$points}\r\n\t\t\t\t\t\tWHERE xResultat = {$row['0']}\r\n\t\t\t\t\t"); // Check if any error returned from DB if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } AA_StatusChanged($row[0]); } // end while every result for this category } // end if ranking points } // ET formula change mysql_free_result($result); } // ET DB error }