' /> </a> </th> <?php } ?> </tr> <?php // // read merged rounds and select all events // $sqlEvents = AA_getMergedEvents($round); if ($sqlEvents == '' && $round == 0) { $sqlEvents = AA_getMergedEventsFromEvent($event); } if ($event > 0 && $sqlEvents != '') { $sqlEventComb = " w.xWettkampf IN " . $sqlEvents; } if ($sqlEvents == '') { if ($event > 0) { $sqlEvents = " s.xWettkampf = " . $event . " "; $sqlEvents .= " AND w.xMeeting = " . $_COOKIE['meeting_id']; } else { $sqlEvents .= " w.xMeeting = " . $_COOKIE['meeting_id']; } } else { $sqlEvents = " s.xWettkampf IN " . $sqlEvents . " "; $sqlEvents .= " AND w.xMeeting = " . $_COOKIE['meeting_id']; }
/** * Form to add additional athlete/relay * ------------------------------------ */ function AA_heats_printNewStart($event, $round, $action) { include './config.inc.php'; $mergedRounds = AA_getMergedRounds($round); if ($mergedRounds != '') { $SqlRounds = " IN " . $mergedRounds; } else { $SqlRounds = " = " . $round; } // set up key list containing this round's starts $result = mysql_query("SELECT ss.xStart" . " FROM runde AS r" . ", serie AS s" . ", serienstart AS ss" . " WHERE r.xRunde " . $SqlRounds . " AND s.xRunde = r.xRunde" . " AND ss.xSerie = s.xSerie"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $keys = ""; $sep = ""; while ($row = mysql_fetch_row($result)) { $keys = $keys . $sep . $row[0]; $sep = ","; } mysql_free_result($result); } $relay = AA_checkRelay($event); $mergedEvents = AA_getMergedEventsFromEvent($event); if ($mergedEvents != '') { $SqlEvents = " IN " . $mergedEvents; } else { $SqlEvents = " = " . $event; } // get athletes entered for this event but not qualified for this round if ($relay == FALSE) { // single event $title = $GLOBALS['strAthlete']; $query = "SELECT st.xStart" . ", CONCAT(a.Startnummer, ' ', at.Name , ' ', at.Vorname" . ", ', ', at.Jahrgang, ', ', v.Name)" . " FROM start AS st" . ", anmeldung AS a" . ", athlet AS at" . ", verein AS v" . " WHERE st.xWettkampf " . $SqlEvents . " AND st.xStart NOT IN (" . $keys . ") AND a.xAnmeldung = st.xAnmeldung" . " AND at.xAthlet = a.xAthlet" . " AND v.xVerein = at.xVerein" . " ORDER BY at.Name, at.Vorname"; } else { // relay event $title = $GLOBALS['strRelay']; $query = "SELECT st.xStart" . ", CONCAT(sf.Name, ', ', v.Name)" . " FROM start AS st" . ", staffel AS sf" . ", verein AS v" . " WHERE st.xWettkampf " . $SqlEvents . " AND st.xStart NOT IN (" . $keys . ") AND sf.xStaffel = st.xStaffel" . " AND v.xVerein = sf.xVerein" . " ORDER BY sf.Name"; } $result = mysql_query($query); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($result) > 0) { ?> <form action='<?php echo $action; ?> ' method='post'> <table> <tr> <th class='dialog'><?php echo $GLOBALS['strNew']; ?> </th> <td class='dialog'> <input name='arg' type='hidden' value='add_start' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <?php echo $title; ?> :</td> <td class='forms'> <?php // print drop down list of athletes $dd = new GUI_Select('start', 1); $dd->addOptionNone(); while ($row = mysql_fetch_row($result)) { $dd->addOption($row[1], $row[0]); } $dd->printList(); ?> </td> <td class='dialog'><?php echo $GLOBALS['strHeat']; ?> :</td> <?php // print drop down list of heats $dd = new GUI_HeatDropDown($round); ?> <td class='dialog'><?php echo $GLOBALS['strPosition']; ?> :</td> <td class='forms'> <input class='nbr' name='pos' type='text' maxlength='4' value='0' /> </td> <td class='forms'> <td class='forms'> <button type='submit'> <?php echo $GLOBALS['strAdd']; ?> </button> </td> </tr> </table> </form> <?php } // ET athletes found mysql_free_result($result); } // ET DB error }
$argument = "w.xKategorie >= " . $_GET['catFrom'] . " AND w.xKategorie <= " . $_GET['catTo'] . " AND w.xMeeting = " . $_COOKIE['meeting_id']; } else { if ($_GET['discFrom'] > 0) { $discFrom = $_GET['discFrom']; $discTo = $_GET['discTo']; $argument = " w.xDisziplin >= " . $_GET['discFrom'] . " AND w.xDisziplin <= " . $_GET['discTo'] . " AND w.xMeeting = " . $_COOKIE['meeting_id']; } } } if (!empty($_GET['mDate'])) { $mDate = $_GET['mDate']; $argument .= " AND r.Datum = '" . $_GET['mDate'] . "'"; } } else { if (!empty($_GET['event'])) { $sqlEvents = AA_getMergedEventsFromEvent($_GET['event']); if ($sqlEvents == '') { $argument .= " AND w.xWettkampf = " . $_GET['event'] . " "; } else { $argument .= " AND w.xWettkampf IN " . $sqlEvents . " "; } } else { if (!empty($_GET['category'])) { $argument .= " AND w.xKategorie = " . $_GET['category'] . " AND d.Appellzeit > 0"; } elseif (!empty($_GET['comb'])) { list($cCat, $cCode) = explode("_", $_GET['comb']); $argument .= " AND w.xKategorie = {$cCat}\r\n\t\t\tAND w.Mehrkampfcode = {$cCode}"; } } } $pagebreak = "no";
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, $content_navi) { require './lib/cl_gui_page.lib.php'; require './lib/common.lib.php'; require './config.inc.php'; require './config.inc.end.php'; if (AA_connectToDB() == FALSE) { // invalid DB connection return; // abort } if (AA_checkMeetingID() == FALSE) { // no meeting selected return; // abort } $p = "./tmp"; $fp = @fopen($p . "/live" . $round . ".html", 'w'); if (!$fp) { AA_printErrorMsg($GLOBALS['strErrFileOpenFailed']); return; } // set up ranking list selection $selection = ''; $eventMerged = false; $catMerged = false; $flagSubtitle = false; $flagInfoLine1 = false; $flagInfoLine2 = 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 = "w.xWettkampf =" . $event . " AND "; } } else { if ($category == 0) { // show all disciplines for every category $catMerged = true; } else { if ($event == 0) { // show all disciplines for a specific category $catMerged = false; $mergedCat = AA_mergedCat($category); if ($mergedCat != '') { $selection = "w.xKategorie =" . $category . " 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 $results = mysql_query("\r\n\tSELECT \r\n\t\tr.xRunde\r\n\t\t, k.Name\r\n\t\t, d.Name\r\n\t\t, d.Typ\r\n\t\t, w.xWettkampf\r\n\t\t, r.QualifikationSieger\r\n\t\t, r.QualifikationLeistung\r\n\t\t, w.Punkteformel\r\n\t\t, w.Windmessung\r\n\t\t, r.Speakerstatus\r\n\t\t, d.Staffellaeufer\r\n\t\t, CONCAT(DATE_FORMAT(r.Datum,'{$cfgDBdateFormat}'), ' ', TIME_FORMAT(r.Startzeit, '{$cfgDBtimeFormat}'))\r\n\t\t, w.xDisziplin \r\n\tFROM\r\n\t\tathletica.wettkampf AS w\r\n\t\tLEFT JOIN athletica.kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n \t\tLEFT JOIN athletica.disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n \t\tLEFT JOIN athletica.runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n\tWHERE " . $selection . "\r\n\tw.xMeeting = " . $_COOKIE['meeting_id'] . " \t\r\n\tAND (r.Status = " . $cfgRoundStatus['results_done'] . " OR r.Status = " . $cfgRoundStatus['results_in_progress'] . ") \r\n\tAND r.Datum LIKE '" . $date . "'\r\n\tORDER BY\r\n\t\tk.Anzeige\r\n\t\t, d.Anzeige\r\n\t\t, r.Datum\r\n\t\t, 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 athletica.wettkampf AS w \r\n LEFT JOIN athletica.kategorie AS k ON (k.xKategorie = w.xKategorie) \r\n LEFT JOIN athletica.disziplin_" . $_COOKIE['language'] . " as d ON (d.xDisziplin = w.xDisziplin) \r\n LEFT JOIN athletica.runde AS r ON (r.xWettkampf = w.xWettkampf) \r\n LEFT JOIN athletica.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 = " . $cfgRoundStatus['results_done'] . " OR r.Status = " . $cfgRoundStatus['results_in_progress'] . ") \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; } } // get url $url = ''; $result = mysql_query("\r\n SELECT\r\n url\r\n FROM\r\n athletica_liveResultate.config"); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $row = mysql_fetch_row($result); $url = $row[0]; } // start a new HTML display page if ($formaction == 'view' || $formaction == 'speaker') { // display page $list = new GUI_RankingList($_COOKIE['meeting']); $list->content = $cfgHtmlStart1; if (empty($GLOBALS['cfgDir'])) { $list->content .= "<meta http-equiv='refresh' content='" . $GLOBALS['cfgMonitorReload'] . "; url=http://" . $url . "/live" . $round . ".html'>"; } else { $list->content .= "<meta http-equiv='refresh' content='" . $GLOBALS['cfgMonitorReload'] . "; url=http://" . $url . "/" . $GLOBALS['cfgDir'] . "/live" . $round . ".html'>"; } $list->content .= $cfgHtmlStart2; $list->content .= $content_navi; $list->content .= "</div ><div id='content_pc'><div id='content_pda'>"; $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; 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[$strDiscTypeTrackTrack] || $row[3] == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $row[3] == $cfgDisciplineType[$strDiscTypeRelay]) { $eval = $cfgEvalType[$strEvalTypeHeat]; } else { $eval = $cfgEvalType[$strEvalTypeAll]; } $roundName = ''; $type = ''; $res = mysql_query("\r\n\t\t\tSELECT\r\n rt.Name\r\n , rt.Typ\r\n , rt.Wertung\r\n FROM\r\n athletica.runde\r\n LEFT JOIN athletica.rundentyp_" . $_COOKIE['language'] . " AS rt ON (rt.xRundentyp = runde.xRundentyp)\r\n WHERE \r\n runde.xRunde = {$row['0']} \r\n\t\t"); 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) { $res_c = mysql_query("SELECT \r\n\t\t\t\t\t\t\t\tr.xRunde\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tathletica.wettkampf as w\r\n\t\t\t\t\t\t\t\t LEFT JOIN athletica.runde as r ON (r.xWettkampf = w.xWettkampf)\r\n\t\t\t\t\t\t\tWHERE\tw.xWettkampf = " . $row[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 = $GLOBALS['strQualification'] .": " // . $row[5] . " " . $GLOBALS['$strQualifyTop'] .", " // . $row[6] . " " . $GLOBALS['strQualifyPerformance']; $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($GLOBALS['cfgQualificationType'] as $qt) 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 //$roundM = $row[13]; } // ET new event //else { // if ($roundM!=$row[13]){ // set up subtitle when merged round are separated // $flagSubtitle=true; // set flag to print the subtitle later // } //} $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)"; $order = $order_heat; if ($relay == FALSE) { if ($athleteCat) { $order = $orderAthleteCat . $order_heat; } $query = "SELECT ss.xSerienstart, \r\n\t\t\t\t\t\t\t IF(ss.Rang=0, {$max_rank}, ss.Rang) AS rank, \r\n\t\t\t\t\t\t\t ss.Qualifikation, \r\n\t\t\t\t\t\t\t " . $sql_leistung . " AS leistung_neu, \r\n\t\t\t\t\t\t\t r.Info, \r\n\t\t\t\t\t\t\t s.Bezeichnung, \r\n\t\t\t\t\t\t\t s.Wind, \r\n\t\t\t\t\t\t\t r.Punkte, \r\n\t\t\t\t\t\t\t IF('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)), \r\n\t\t\t\t\t\t\t at.Name, \r\n\t\t\t\t\t\t\t at.Vorname, \r\n\t\t\t\t\t\t\t at.Jahrgang, \r\n\t\t\t\t\t\t\t LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n\t\t\t\t\t\t\t IF(at.xRegion = 0, at.Land, re.Anzeige) AS Land, \r\n\t\t\t\t\t\t\t at.xAthlet, \r\n\t\t\t\t\t\t\t ru.Datum, \r\n\t\t\t\t\t\t\t ru.Startzeit ,\r\n\t\t\t\t\t\t\t ss.RundeZusammen,\r\n\t\t\t\t\t\t\t ru.xRunde, \r\n\t\t\t\t\t\t\t k.Name , \r\n\t\t\t\t\t\t\t k1.Name , \t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t k1.Anzeige ,\r\n ss.Bemerkung ,\r\n w.Punkteformel,\r\n w.info,\r\n a.Startnummer \r\n\t\t\t\t\t\tFROM athletica.serie AS s USE INDEX(Runde)\r\n\t\t\t\t LEFT JOIN athletica.serienstart AS ss USING(xSerie) \r\n\t\t\t\t LEFT JOIN athletica.resultat AS r USING(xSerienstart) \r\n\t\t\t\t LEFT JOIN athletica.start AS st ON(ss.xStart = st.xStart) \r\n\t\t\t\t LEFT JOIN athletica.anmeldung AS a USING(xAnmeldung) \r\n\t\t\t\t LEFT JOIN athletica.athlet AS at USING(xAthlet) \r\n\t\t\t\t LEFT JOIN athletica.verein AS v USING(xVerein) \r\n\t\t\t\t LEFT JOIN athletica.region AS re ON(at.xRegion = re.xRegion) \r\n\t\t\t\t LEFT JOIN athletica.team AS t ON(a.xTeam = t.xTeam) \r\n\t\t\t\t LEFT JOIN athletica.runde AS ru ON(s.xRunde = ru.xRunde) \r\n\t\t\t\t LEFT JOIN athletica.wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n\t\t\t\t LEFT JOIN athletica.kategorie AS k On (w.xKategorie= k.xKategorie)\r\n\t\t\t\t LEFT JOIN athletica.kategorie AS k1 ON (a.xKategorie = k1.xKategorie) \r\n\t\t\t\t\t WHERE " . $roundSQL . " \r\n\t\t\t\t\t " . $limitRankSQL . " \r\n\t\t\t\t\t " . $valid_result . " \r\n\t\t\t\t\t " . $sqlSeparate . " \r\n\t\t\t\t\t " . $selectionHeats . " \r\n\t\t\t\t\tORDER BY " . $order . " \t\t\t\t\t \r\n\t\t\t\t\t\t\t rank, \r\n\t\t\t\t\t\t\t at.Name, \r\n\t\t\t\t\t\t\t at.Vorname,\r\n\t\t\t\t\t\t\t leistung_neu " . $order_perf; } else { // relay event $query = "SELECT ss.xSerienstart, \t\t\t\t\t\t\r\n\t\t\t\t\t\t\t IF(r.Leistung < 0 , {$max_rank}, if (ss.Rang=0, {$max_rank}-1, ss.Rang)) AS rank, \r\n\t\t\t\t\t\t\t ss.Qualifikation, \r\n\t\t\t\t\t\t\t " . $sql_leistung . " AS leistung_neu, \r\n\t\t\t\t\t\t\t r.Info, \r\n\t\t\t\t\t\t\t s.Bezeichnung, \r\n\t\t\t\t\t\t\t s.Wind, \r\n\t\t\t\t\t\t\t r.Punkte, \r\n\t\t\t\t\t\t\t IF('" . $svm . "', t.Name, v.Name), \r\n\t\t\t\t\t\t\t sf.Name, \r\n\t\t\t\t\t\t\t LPAD(s.Bezeichnung, 5, '0') AS heatid, \r\n\t\t\t\t\t\t\t st.xStart, \r\n\t\t\t\t\t\t\t ru.Datum, \r\n\t\t\t\t\t\t\t ru.Startzeit, \r\n\t\t\t\t\t\t\t ss.RundeZusammen,\r\n\t\t\t\t\t\t\t ru.xRunde,\r\n\t\t\t\t\t\t\t k.Name ,\r\n ss.Bemerkung \r\n\t\t\t\t\t\tFROM athletica.serie AS s USE INDEX(Runde) \r\n\t\t\t\t LEFT JOIN athletica.serienstart AS ss USING(xSerie) \r\n\t\t\t\t LEFT JOIN athletica.resultat AS r USING(xSerienstart) \r\n\t\t\t\t LEFT JOIN athletica.start AS st ON(ss.xStart = st.xStart) \r\n\t\t\t\t LEFT JOIN athletica.staffel AS sf USING(xStaffel) \r\n\t\t\t\t LEFT JOIN athletica.verein AS v USING(xVerein) \r\n\t\t\t\t LEFT JOIN athletica.team AS t ON(sf.xTeam = t.xTeam) \r\n\t\t\t\t LEFT JOIN athletica.runde AS ru ON(s.xRunde = ru.xRunde) \r\n\t\t\t\t LEFT JOIN athletica.wettkampf AS w On (w.xWettkampf= st.xWettkampf) \r\n\t\t\t\t LEFT JOIN athletica.kategorie AS k On (w.xKategorie= k.xKategorie) \r\n\t\t\t\t\t WHERE " . $roundSQL . " \r\n\t\t\t\t\t " . $limitRankSQL . " \r\n\t\t\t\t\t " . $valid_result . " \r\n\t\t\t\t\t " . $sqlSeparate . " \r\n\t\t\t\t\tGROUP BY r.xSerienstart \r\n\t\t\t\t\tORDER BY " . $order . " \r\n\t\t\t\t\t\t\t rank, \r\n\t\t\t\t\t\t\t r.Leistung \r\n\t\t\t\t\t\t\t " . $order_perf . ", \r\n\t\t\t\t\t\t\t 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 = ''; // process every result while ($row_res = mysql_fetch_array($res)) { if ($flagSubtitle) { $nr = 0; if ($heatSeparate) { if ($relay) { $list->printSubTitle($row_res[16], $row[2], $roundName); } else { if (!$athleteCat) { $list->printSubTitle($row_res[19], $row[2], $roundName); } } } else { if (!$athleteCat) { $list->printSubTitle($row[1], $row[2], $roundName); } } $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]); 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') { $points = TRUE; } if ($show_efforts == 'sb_pb') { $base_perf = true; } if ($athleteCat && !$relay) { if ($formaction == 'print') { if ($row_res[20] != $atCatName) { $list->printSubTitle($row_res[20], $row[2], $roundName, $row_res[24]); $atCatName_keep = $atCatName; if ($flagInfoLine1) { $list->printInfoLine($info_save1); $flagInfoLine1 = false; } if ($flagInfoLine2) { $list->printInfoLine($info_save2); $flagInfoLine2 = false; } } } } $list->startList(); $list->printHeaderLine($title, $relay, $points, $wind, $heatwind, $row[11], $svm, $base_perf, $qual_mode); if ($athleteCat && !$relay) { if ($formaction == 'view') { if ($row_res[20] != $atCatName) { $list->printSubTitle($row_res[20], $row[2], $roundName, $row_res[24]); $atCatName_keep = $atCatName; 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 $atCatName = $row_res[20]; // keep athlete category name // 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 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]; } // wind info $wind = ''; $secondResult = false; if ($r != $max_rank) { if ($row[3] == $cfgDisciplineType[$strDiscTypeJump] && $row[8] == 1) { $wind = $row_res[4]; // // 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\t\t\t\t\t\t\t\t\t\tSELECT Info, Leistung FROM\r\n\t\t\t\t\t\t\t\t\t\t\tresultat\r\n\t\t\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\t\t\txSerienstart = {$row_res['0']}\r\n\t\t\t\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\t\t\t\tLeistung 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]; } } } // ioc country code $ioc = ''; if ($relay == false) { $ioc = $row_res[13]; } //show performances from base if ($show_efforts == 'sb_pb' && $relay == false) { $saison = $_SESSION['meeting_infos']['Saison']; if ($saison == '') { $saison = "O"; //if no saison is set take outdoor } $sql = "SELECT \r\n\t\t\t\t\t\t\t\t\tseason_effort\r\n\t\t\t\t\t\t\t\t\t, DATE_FORMAT(season_effort_date, '%d.%m.%Y') AS sb_date\r\n\t\t\t\t\t\t\t\t\t, season_effort_event\r\n\t\t\t\t\t\t\t\t\t, best_effort\r\n\t\t\t\t\t\t\t\t\t, DATE_FORMAT(best_effort_date, '%d.%m.%Y') AS pb_date\r\n\t\t\t\t\t\t\t\t\t, best_effort_event\r\n\t\t\t\t\t\t\t\t\t, season\r\n\t\t\t\t\t\t\t\t\t, xAnmeldung\r\n\t\t\t\t\t\tFROM \r\n\t\t\t\t\t\t\tathletica.base_performance\r\n\t\t\t\t\t\tLEFT JOIN \r\n\t\t\t\t\t\t\tathletica.base_athlete USING (id_athlete)\r\n\t\t\t\t\t\tLEFT JOIN \r\n\t\t\t\t\t\t\tathletica.disziplin_" . $_COOKIE['language'] . " ON (discipline = Code)\r\n\t\t\t\t\t\tLEFT JOIN \r\n\t\t\t\t\t\t\tathletica.athlet ON (license = Lizenznummer)\r\n\t\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\t\tathletica.anmeldung USING(xAthlet) \r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\tathlet.xAthlet = {$row_res['14']}\r\n\t\t\t\t\t\t\tAND xDisziplin = {$row['12']}\r\n\t\t\t\t\t\t\tAND season = '{$saison}' \r\n\t\t\t\t\t\t\tAND 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) { $rank = $count_rank; if ($perf == $perf_save || $row_res[3] < 0) { // same rank or 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]; } $list->printLine($rank, $name, $year, $row_res[8], $perf, $wind, $points, $qual, $ioc, $sb, $pb, $qual_mode, $athleteCat, $remark); if ($secondResult) { $list->printLine("", "", "", "", $perf2, $wind2, "", "", "", "", "", $qual_mode); } $perf_save = $perf; // 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\t\t\t\t\t\t\t\tSELECT at.Vorname, at.Name, at.Jahrgang FROM\r\n\t\t\t\t\t\t\t\t\tathletica.staffelathlet as sfat\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN athletica.start as st ON sfat.xAthletenstart = st.xStart\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN athletica.anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN athletica.athlet as at USING(xAthlet)\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tsfat.xStaffelstart = {$row_res['11']}\r\n\t\t\t\t\t\t\t\tAND\tsfat.xRunde = {$sqlRound} \r\n\t\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\t\tsfat.Position\r\n\t\t\t\t\t\t\t\tLIMIT {$row['10']}\r\n\t\t\t\t\t\t"); 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\t\t\t\t\t\t\t\tSELECT * FROM \r\n\t\t\t\t\t\t\t\t\tathletica.resultat \r\n\t\t\t\t\t\t\t\tWHERE xSerienstart = {$row_res['0']}\r\n\t\t\t\t\t\t\t\t" . $query_sort . "\r\n\t\t\t\t\t\t\t\t"); 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 } // END WHILE event rounds mysql_free_result($results); $list->endPage(); // end HTML page for printing $list->content .= $cfgHtmlFooter; $list->content .= " </div ></div>"; $list->content .= $cfgHtmlEnd; if (!fwrite($fp, $list->content)) { AA_printErrorMsg($GLOBALS['strErrFileWriteFailed']); return; } fclose($fp); } // ET DB error event rounds // will not be uploaded the next time per ftp AA_UpdateStatusChanged($round); }
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 }
if ($relay == FALSE) { // single event $argument = "at.Name, at.Vorname"; $img_name = "img/sort_act.gif"; } else { // relay event $argument = "st.Name"; $img_name = "img/sort_act.gif"; } } } } } } } $mergedEvents = AA_getMergedEventsFromEvent($presets['event']); if ($mergedEvents != '') { $sqlEvent = " IN " . $mergedEvents; } else { $sqlEvent = " = " . $presets['event']; } $sqlGroup = ''; if ($group != '') { $sqlGroup = " AND a.Gruppe = " . $group; } if ($relay == FALSE) { $query = "\r\n\t\t\tSELECT\r\n\t\t\t\ta.xAnmeldung\r\n\t\t\t\t, a.Startnummer\r\n\t\t\t\t, at.Name\r\n\t\t\t\t, at.Vorname\r\n\t\t\t\t, at.Jahrgang\r\n\t\t\t\t, v.Name \r\n , at.xAthlet\r\n\t\t\t\t, s.Bestleistung\r\n\t\t\t\t, w.xDisziplin\r\n\t\t\t\t, d.Typ\r\n\t\t\tFROM\r\n\t\t\t\tanmeldung AS a\r\n\t\t\t\t, athlet AS at\r\n\t\t\t\t, start AS s\r\n\t\t\t\t, verein AS v\r\n\t\t\t\t, wettkampf AS w\r\n\t\t\t\t, disziplin AS d\r\n\t\t\tWHERE s.xWettkampf " . $sqlEvent . "\r\n " . $sqlGroup . "\r\n\t\t\t AND a.xAnmeldung = s.xAnmeldung\r\n\t\t\t AND at.xAthlet = a.xAthlet\r\n\t\t\t AND v.xVerein = at.xVerein\r\n AND s.Anwesend = 0\r\n\t\t\t\tAND w.xWettkampf = s.xWettkampf\r\n\t\t\t\tAND d.xDisziplin = w.xDisziplin\r\n\t\t\tORDER BY " . $argument; } else { // relay event $query = "\r\n\t\t\tSELECT\r\n\t\t\t\ts.xStaffel\r\n\t\t\t\t, st.Name\r\n\t\t\t\t, v.Name\r\n\t\t\tFROM\r\n\t\t\t\tstaffel AS st\r\n\t\t\t\t, start AS s\r\n\t\t\t\t, verein AS v\r\n\t\t\tWHERE s.xWettkampf " . $sqlEvent . "\r\n\t\t\tAND st.xStaffel = s.xStaffel\r\n\t\t\tAND v.xVerein = st.xVerein\r\n AND s.Anwesend = 0 \r\n\t\t\tORDER BY " . $argument; }
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; }