Exemplo n.º 1
0
    $athleteCat = true;
}
$show_ukc = false;
if ($_GET['show_ukc'] == "ukc") {
    $show_ukc = true;
}
// Ranking list single event
if ($type == 'single') {
    AA_rankinglist_Single($category, $event, $round, $formaction, $break, $cover, $biglist, $cover_timing, $date, $show_efforts, $heatSeparate, $catFrom, $catTo, $discFrom, $discTo, $heatFrom, $heatTo, $athleteCat, $withStartnr, $ranklistAll, $show_ukc);
} else {
    if ($type == 'combined' || $type == 'ukc') {
        if ($type == 'ukc') {
            $show_ukc = true;
        } else {
            $show_ukc = false;
        }
        AA_rankinglist_Combined($category, $formaction, $break, $cover, $sepu23, $cover_timing, $date, $disc_nr, $catFrom, $catTo, $show_ukc);
    } else {
        if ($type == 'team' || $type == 'teamAll' || $type == 'teamP') {
            @AA_rankinglist_Team($category, $formaction, $break, $cover, $parser = false, $event, $heatSeparate, $type, $catFrom, $catTo);
        } else {
            if ($type == 'sheets') {
                AA_rankinglist_Sheets($category, $event, $formaction, $cover, '', $heatSeparate, $catFrom, $catTo, $discFrom, $discTo);
            } else {
                if ($type == 'teamsm') {
                    AA_rankinglist_TeamSM($category, $event, $formaction, $break, $cover, $cover_timing, $date);
                }
            }
        }
    }
}
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 function gen_result_xml($file)
 {
     //global	$opentags;
     global $cfgDisciplineType, $cfgEventType, $strEventTypeSingleCombined, $strEventTypeClubCombined, $strDiscTypeTrack, $strDiscTypeTrackNoWind, $strDiscTypeRelay, $strDiscTypeDistance, $cfgRoundStatus, $strDiscTypeJump, $strDiscTypeJumpNoWind, $strDiscTypeThrow, $strDiscTypeHigh, $cfgCombinedWO, $cfgCombinedDef;
     $this->gzip_open($file);
     // begin xml
     $this->write_xml_open("watDataset", array('version' => date('y-m-d')));
     $this->write_xml_open("event");
     //
     // output contest data
     //
     $global_rankadd = "";
     $query = "\r\n\t\t\tSELECT\r\n\t\t\t\tm.*\r\n\t\t\t\t, s.Name as Stadion\r\n\t\t\t\t, s.Ueber1000m\r\n\t\t\t\t, s.Halle\r\n\t\t\tFROM \r\n\t\t\t\tmeeting as m LEFT JOIN stadion as s ON m.xStadion = s.xStadion \r\n\t\t\tWHERE 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);
         $this->write_xml_finished("eventNumber", $row['xControl']);
         $this->write_xml_finished("name", str_replace('&', '&amp;', $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", " ");
         if ($row['Ueber1000m'] == 'y') {
             $global_rankadd = "A";
         }
         //if($row['Halle'] == 'y'){ $global_rankadd .= "i"; }
         if ($row['Saison'] == 'I') {
             $global_rankadd .= "i";
         }
     }
     //
     // output all athletica generated teams (relays, svm)
     //
     $this->write_xml_open("accounts");
     $query = "\r\n\t\t\tSELECT \r\n\t\t\t\ts.xStaffel\r\n\t\t\t\t, s.Name\r\n\t\t\t\t, v.xCode as Verein\r\n\t\t\t\t, k.Code as Kat\r\n\t\t\t\t, d.Code as Dis\r\n\t\t\tFROM\r\n\t\t\t\tstaffel as s\r\n\t\t\t\t, verein as v \r\n\t\t\t\t, kategorie as k\r\n\t\t\t\t, start as st\r\n\t\t\t\t, wettkampf as w\r\n\t\t\t\t, disziplin as d\r\n\t\t\tWHERE Athleticagen = 'y'\r\n\t\t\tAND s.xVerein = v.xVerein \r\n\t\t\tAND k.xKategorie = s.xKategorie\r\n\t\t\tAND st.xStaffel = s.xStaffel\r\n\t\t\tAND w.xWettkampf = st.xWettkampf\r\n\t\t\tAND d.xDisziplin = w.xDisziplin\r\n\t\t\tAND s.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n\t\t\tORDER BY \r\n\t\t\t\tv.xVerein";
     $res_teams = mysql_query($query);
     if (mysql_errno() > 0) {
         echo mysql_errno() . ": " . mysql_error();
     } else {
         $account = 0;
         while ($row_teams = mysql_fetch_assoc($res_teams)) {
             if (empty($row_teams['Verein']) || $row_teams['Verein'] == '999999') {
                 continue;
             }
             if ($account != $row_teams['Verein']) {
                 $this->close_open_tags("accounts");
                 $this->write_xml_open("account");
                 $this->write_xml_finished("accountCode", $row_teams['Verein']);
                 $this->write_xml_open("relays");
             }
             //$licenseCategory = ($row_teams['Kat']=='MASM' || $row_teams['Kat']=='MASW') ? '' : $row_teams['Kat'];
             $licenseCategory = $row_teams['Kat'];
             $this->write_xml_open("relay", array('id' => $row_teams['xStaffel'], 'isAthleticaGenerated' => '1'));
             $this->write_xml_finished("relayName", $row_teams['Name']);
             $this->write_xml_finished("licenseCategory", $licenseCategory);
             $this->write_xml_finished("sportDiscipline", $row_teams['Dis']);
             $this->close_open_tags("relays");
         }
     }
     $query = "\r\n\t\t\tSELECT \r\n\t\t\t\tt.xTeam\r\n\t\t\t\t, t.Name\r\n\t\t\t\t, v.xCode as Verein\r\n\t\t\t\t, k.Code as Kat\r\n\t\t\tFROM\r\n\t\t\t\tteam as t\r\n\t\t\t\t, verein as v \r\n\t\t\t\t, kategorie_svm as k\r\n\t\t\t\t, wettkampf as w\r\n\t\t\tWHERE Athleticagen = 'y'\r\n\t\t\tAND t.xVerein = v.xVerein\r\n\t\t\tAND t.xKategorie = w.xKategorie\r\n\t\t\tAND w.xKategorie_svm = k.xKategorie_svm\r\n\t\t\tAND w.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n\t\t\tGROUP BY\r\n\t\t\t\tt.xTeam\r\n\t\t\tORDER BY \r\n\t\t\t\tv.xVerein";
     $res_teams = mysql_query($query);
     if (mysql_errno() > 0) {
         echo mysql_errno() . ": " . mysql_error();
     } else {
         $account = 0;
         while ($row_teams = mysql_fetch_assoc($res_teams)) {
             if (empty($row_teams['Verein']) || $row_teams['Verein'] == '999999') {
                 continue;
             }
             if ($account != $row_teams['Verein']) {
                 $this->close_open_tags("accounts");
                 $this->write_xml_open("account");
                 $this->write_xml_finished("accountCode", $row_teams['Verein']);
                 $this->write_xml_open("svms");
             }
             $this->write_xml_open("svm", array('id' => $row_teams['xTeam'], 'isAthleticaGenerated' => '1'));
             $this->write_xml_finished("svmName", $row_teams['Name']);
             $this->write_xml_finished("svmCategory", $row_teams['Kat']);
             $this->close_open_tags("svms");
         }
     }
     $this->close_open_tags("event");
     //
     // get all disciplines
     //
     $this->write_xml_open("disciplines");
     $res = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tw.Typ,\r\n\t\t\t\t\tw.Windmessung,\r\n\t\t\t\t\td.Typ,\r\n\t\t\t\t\td.Code,\r\n\t\t\t\t\tk.Code,\r\n\t\t\t\t\tw.xWettkampf,\r\n\t\t\t\t\td.Kurzname,\r\n\t\t\t\t\tw.Mehrkampfcode,\r\n\t\t\t\t\tw.xKategorie,\r\n\t\t\t\t\td.Staffellaeufer\r\n\t\t\t\tFROM \r\n\t\t\t\t\twettkampf as w \r\n\t\t\t\t\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tdisziplin as d ON d.xDisziplin = w.xDisziplin\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tkategorie as k ON k.xKategorie = w.xKategorie\r\n\t\t\t\t\r\n\t\t\t\tWHERE\txMeeting = " . $_COOKIE['meeting_id'] . "\r\n\t\t\t\t\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tk.Code\r\n\t\t\t\t\t, w.xKategorie\r\n\t\t\t\t\t, w.Mehrkampfcode\r\n\t\t\t\t\t, w.Mehrkampfreihenfolge\r\n\t\t\t");
     // the order "k.Code, w.xKategorie" makes sense if there are multiple self made categories (without any code)
     if (mysql_errno() > 0) {
         echo mysql_errno() . ": " . mysql_error();
     } else {
         $current_type = "";
         $combined = "";
         $current_cat = "";
         $current_xcat = 0;
         $fetched_events = array();
         // used for combined events
         // if an athlete has no result for one discipline of a combined event,
         // the detail text has to include a 'null' result
         $GLOBALS['rounds'] = array();
         while ($row = mysql_fetch_array($res)) {
             /*if(empty($row[3]) || empty($row[4])){
             			// self made discipline or category
             			continue;
             		}*/
             if (empty($row[3])) {
                 // self made discipline
                 continue;
             }
             if (empty($row[4])) {
                 // self made category
                 $row[4] = "";
             }
             //
             // generate results for combined events
             //
             if ($current_xcat != $row[8] || $combined_dis != $row[7]) {
                 // cat or combcode changed, print combined results
                 if (!empty($combined) && $combined_dis < 9000) {
                     // combined codes 9000 and above are self made disciplines
                     $this->write_xml_open("discipline", array('sportDiscipline' => $combined_dis, 'licenseCategory' => $combined_cat));
                     $this->write_xml_open("athletes");
                     // calc points
                     foreach ($combined as $xathlet => $disc) {
                         $points = 0;
                         $eDetails = "";
                         $tmp_fe = $fetched_events;
                         // temp array for fetched events
                         foreach ($disc as $xdisc => $tmp) {
                             if ($xdisc == "catathlete") {
                                 continue;
                             }
                             // check if there are events missing for the current athlete and add 'null' entries
                             while ($tmp_fe[0][3] != $xdisc) {
                                 //$eDetails .= $tmp_fe[0][6]." (0); ";
                                 $eDetails .= "0/";
                                 array_shift($tmp_fe);
                             }
                             array_shift($tmp_fe);
                             $points += $tmp['points'];
                             if ($tmp['wind'] == " ") {
                                 $tmp['wind'] = "";
                             } else {
                                 if ($tmp['wind'] >= 0) {
                                     $tmp['wind'] = "+" . $tmp['wind'];
                                 } else {
                                     $tmp['wind'] = $tmp['wind'];
                                 }
                             }
                             //$eDetails .= $tmp['discipline']." (".$tmp['effort'].$tmp['wind']."); ";
                             $eDetails .= $tmp['discipline'] . ' ' . $tmp['effort'] . $tmp['wind'] . "/";
                         }
                         // check if last events are missing
                         while (isset($tmp_fe[0][3])) {
                             $eDetails .= "0/";
                             array_shift($tmp_fe);
                         }
                         $eDetails = substr($eDetails, 0, -1);
                         $combined[$xathlet]['points'] = $points;
                         $combined[$xathlet]['edetails'] = $eDetails;
                     }
                     // sort for points
                     usort($combined, array($this, "sort_combined"));
                     // write
                     //$rank = array();
                     //$curr_athlete_cat = "";
                     $rank = 0;
                     // athletes rank
                     $cRank = 0;
                     // rank counter
                     $lp = 0;
                     // remembers points of last athlete
                     foreach ($combined as $xathlet => $disc) {
                         $this->close_open_tags("athletes");
                         // count place for each athlete category
                         /*$curr_athlete_cat = $combined[$xathlet]['catathlete'];
                         		if(!isset($rank[$curr_athlete_cat])){
                         			$rank[$curr_athlete_cat] = 1;
                         		}else{
                         			$rank[$curr_athlete_cat]++;
                         		}*/
                         $cRank++;
                         if ($lp != $disc['points']) {
                             $rank = $cRank;
                             $lp = $disc['points'];
                         }
                         // get information for athlete, remove not needed information and sort per DateOfEffort
                         $tmp = $disc;
                         $tmp['points'] = null;
                         $tmp['edetails'] = null;
                         $tmp['catathlete'] = null;
                         $tmp = array_values($tmp);
                         usort($tmp, array($this, "sort_perdate"));
                         $tmp = $tmp[0];
                         // filter athletes not from switzerland and athletes without license
                         if ($tmp['accountCode'] == '' || $tmp['accountCode'] == '999999' || $tmp['licenseType'] == 3) {
                             continue;
                         }
                         $this->write_xml_open("athlete", array('license' => $tmp['license'], 'licensePaid' => $tmp['licensePaid'], 'licenseCat' => '', 'inMasterData' => $tmp['inMasterData']));
                         if (!$tmp['inMasterData']) {
                             $this->write_xml_finished("lastName", $tmp['lastName']);
                             $this->write_xml_finished("firstName", $tmp['firstName']);
                             $this->write_xml_finished("birthDate", $tmp['birthDate']);
                             $this->write_xml_finished("sex", $tmp['sex']);
                             $this->write_xml_finished("nationality", $tmp['nationality']);
                             $this->write_xml_finished("accountCode", $tmp['accountCode']);
                             $this->write_xml_finished("secondaccountCode", " ");
                         }
                         $this->write_xml_open("efforts");
                         $this->write_xml_open("effort");
                         $this->write_xml_finished("DateOfEffort", $tmp['DateOfEffort']);
                         $this->write_xml_finished("scoreResult", AA_alabusScore($disc['points']));
                         $this->write_xml_finished("wind", " ");
                         $this->write_xml_finished("kindOfLap", " ");
                         // round type combined (D)
                         $this->write_xml_finished("lap", " ");
                         // heat name (A_, B_, 01, 02 ..)
                         //$this->write_xml_finished("place",$rank[$curr_athlete_cat]);
                         $this->write_xml_finished("place", $rank);
                         $this->write_xml_finished("placeAddon", $tmp['placeAddon']);
                         $this->write_xml_finished("relevant", "1");
                         $this->write_xml_finished("effortDetails", $disc['edetails']);
                         $this->write_xml_close("effort");
                     }
                     $this->close_open_tags("disciplines");
                 }
                 $combined = array();
                 $fetched_events = array();
                 $combined_dis = $row[7];
                 $combined_cat = $row[4];
                 $current_cat = $row[4];
                 $current_xcat = $row[8];
             }
             // keep events rows of combined events to check on missing results after
             if ($row[0] == $cfgEventType[$strEventTypeSingleCombined]) {
                 $fetched_events[] = $row;
             }
             //
             // first of all, print all single results (athletes and relays)
             //
             $relay = AA_checkRelay($row[5]);
             // check, if this is a relay event
             $order_perf = "";
             $valid_result = "";
             $best_perf = "";
             //$highjump = false;
             if ($row[2] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeThrow]) {
                 $order_perf = "DESC";
                 $best_perf = ", max(r.Leistung) as Leistung";
             } else {
                 if ($row[2] == $cfgDisciplineType[$strDiscTypeJump]) {
                     if ($row[1] == 1) {
                         // with wind
                         //$order_perf = "DESC, r.Info ASC";
                         $order_perf = "DESC";
                     } else {
                         // without wind
                         $order_perf = "DESC";
                     }
                     $best_perf = ", max(r.Leistung) as Leistung";
                 } else {
                     if ($row[2] == $cfgDisciplineType[$strDiscTypeHigh]) {
                         $order_perf = "DESC";
                         $valid_result = " AND (r.Info LIKE '%O%') ";
                         //$highjump = true;
                         $best_perf = ", max(r.Leistung) as Leistung";
                     } else {
                         $order_perf = "ASC";
                         $best_perf = ", min(r.Leistung) as Leistung";
                     }
                 }
             }
             if ($relay == FALSE) {
                 $query = "\r\n\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\tss.xSerienstart\r\n\t\t\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t\t\t, ss.Qualifikation\r\n\t\t\t\t\t\t\t, r.Leistung\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, v.Name\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, at.Land\r\n\t\t\t\t\t\t\t, at.xAthlet\r\n\t\t\t\t\t\t\t, at.Lizenznummer\r\n\t\t\t\t\t\t\t, ru.Datum\r\n\t\t\t\t\t\t\t, rt.Code as Typ\r\n\t\t\t\t\t\t\t, at.Bezahlt\r\n\t\t\t\t\t\t\t, at.Geburtstag\r\n\t\t\t\t\t\t\t, at.Geschlecht\r\n\t\t\t\t\t\t\t, v.xCode as Vereincode\r\n\t\t\t\t\t\t\t, k.Code as Katathlet\r\n\t\t\t\t\t\t\t, ru.xRunde\r\n\t\t\t\t\t\t\t, s.Handgestoppt\r\n\t\t\t\t\t\t\t, at.Lizenztyp\r\n\t\t\t\t\t\t\t, a.Vereinsinfo\r\n                            , rt.Typ\r\n                            , ba.license_paid    \r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\trunde as ru\r\n\t\t\t\t\t\t\t, serie AS s USE INDEX (Runde)\r\n\t\t\t\t\t\t\t, serienstart AS ss\r\n\t\t\t\t\t\t\t, resultat AS r\r\n\t\t\t\t\t\t\t, start AS st\r\n\t\t\t\t\t\t\t, anmeldung AS a\r\n\t\t\t\t\t\t\t, athlet AS at\r\n\t\t\t\t\t\t\t, verein AS v\r\n\t\t\t\t\t\t\t, rundentyp AS rt\r\n\t\t\t\t\t\t\t, kategorie AS k\r\n                            LEFT JOIN base_athlete AS ba ON (ba.license = at.Lizenznummer)\r\n\t\t\t\t\t\tWHERE ru.xWettkampf = {$row['5']}\r\n\t\t\t\t\t\tAND s.xRunde = ru.xRunde\r\n\t\t\t\t\t\tAND ss.xSerie = s.xSerie\r\n\t\t\t\t\t\tAND r.xSerienstart = ss.xSerienstart\r\n\t\t\t\t\t\tAND st.xStart = ss.xStart\r\n\t\t\t\t\t\tAND a.xAnmeldung = st.xAnmeldung\r\n\t\t\t\t\t\tAND at.xAthlet = a.xAthlet\r\n\t\t\t\t\t\tAND v.xVerein = at.xVerein\r\n\t\t\t\t\t\tAND ru.xRundentyp = rt.xRundentyp\r\n\t\t\t\t\t\tAND a.xKategorie = k.xKategorie\r\n\t\t\t\t\t\tAND ru.Status = " . $cfgRoundStatus['results_done'] . "\r\n\t\t\t\t\t\tAND ru.StatusUpload = 0\r\n\t\t\t\t\t\tAND r.Leistung > 0\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t{$valid_result}\r\n\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\tat.xAthlet\r\n\t\t\t\t\t\t\t, ru.xRunde\r\n\t\t\t\t\t\t\t, r.Leistung " . $order_perf;
             } else {
                 // relay event
                 $query = "\r\n\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\tss.xSerienstart\r\n\t\t\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t\t\t, ss.Qualifikation\r\n\t\t\t\t\t\t\t, r.Leistung\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, v.Name\r\n\t\t\t\t\t\t\t, sf.Name\r\n\t\t\t\t\t\t\t, sf.xStaffel\r\n\t\t\t\t\t\t\t, ru.Datum\r\n\t\t\t\t\t\t\t, rt.Code as Typ\r\n\t\t\t\t\t\t\t, st.xStart\r\n\t\t\t\t\t\t\t, ru.xRunde\r\n\t\t\t\t\t\t\t, s.Handgestoppt\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\trunde as ru\r\n\t\t\t\t\t\t\t, serie AS s USE INDEX (Runde)\r\n\t\t\t\t\t\t\t, serienstart AS ss\r\n\t\t\t\t\t\t\t, resultat AS r\r\n\t\t\t\t\t\t\t, start AS st\r\n\t\t\t\t\t\t\t, staffel AS sf\r\n\t\t\t\t\t\t\t, verein AS v\r\n\t\t\t\t\t\t\t, rundentyp as rt\r\n\t\t\t\t\t\tWHERE ru.xWettkampf = {$row['5']}\r\n\t\t\t\t\t\tAND s.xRunde = ru.xRunde\r\n\t\t\t\t\t\tAND ss.xSerie = s.xSerie\r\n\t\t\t\t\t\tAND r.xSerienstart = ss.xSerienstart\r\n\t\t\t\t\t\tAND st.xStart = ss.xStart\r\n\t\t\t\t\t\tAND sf.xStaffel = st.xStaffel\r\n\t\t\t\t\t\tAND v.xVerein = sf.xVerein\r\n\t\t\t\t\t\tAND ru.xRundentyp = rt.xRundentyp\r\n\t\t\t\t\t\tAND ru.Status = " . $cfgRoundStatus['results_done'] . "\r\n\t\t\t\t\t\tAND ru.StatusUpload = 0\r\n\t\t\t\t\t\tAND r.Leistung > 0\r\n\t\t\t\t\t\tAND v.xCode != ''\r\n\t\t\t\t\t\tAND v.xCode != '999999'\r\n\t\t\t\t\t\t{$valid_result}\r\n\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\tr.xSerienstart\r\n\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\tst.xStaffel\r\n\t\t\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t\t\t " . $order_perf;
             }
             $res_results = mysql_query($query);
             if (mysql_errno() > 0) {
                 echo mysql_Error();
             } else {
                 if (mysql_num_rows($res_results) > 0) {
                     $this->write_xml_open("discipline", array('sportDiscipline' => $row[3], 'licenseCategory' => $row[4]));
                     if ($relay) {
                         $this->write_xml_open("teams");
                     } else {
                         $this->write_xml_open("athletes");
                     }
                 }
                 $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'];
                     // set "rangzusatz"
                     /*switch($row_results['Typ']){
                     			case "D":
                     			break;
                     			case "S":
                     			$rankadd = "r";
                     			break;
                     			case "V":
                     			$rankadd = "h";
                     			break;
                     			case "Z":
                     			$rankadd = "qf";
                     			break;
                     			case "X":
                     			$rankadd = "sf";
                     			break;
                     			case "Q":
                     			$rankadd = "Q";
                     			break;
                     			case "F":
                     			$rankadd = "A";
                     			break;
                     			default:
                     			$rankadd = " ";
                     		}*/
                     $season = $_SESSION['meeting_infos']['Saison'];
                     if ($saison == '') {
                         $saison = "O";
                         //if no saison is set take outdoor
                     }
                     $rankadd = " ";
                     // set "no wind" flag if not measured or wind is equal "-"
                     if ($season == 'O') {
                         // only outdoor  (indoor: never a '*' )
                         if ($row[2] == $cfgDisciplineType[$strDiscTypeJump]) {
                             if ($row[1] == 0 || $row_results['Info'] == "-" || $row_results['Info'] == "") {
                                 $rankadd .= "*";
                             }
                         }
                         if ($row[2] == $cfgDisciplineType[$strDiscTypeTrack]) {
                             if ($row[1] == 0 || $row_results['Wind'] == "-" || $row_results['Wind'] == "") {
                                 $rankadd .= "*";
                             }
                         }
                     }
                     // set "hand stopped" flag if set
                     if ($row[2] == $cfgDisciplineType[$strDiscTypeNone] || $row[2] == $cfgDisciplineType[$strDiscTypeTrack] || $row[2] == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeDistance] || $row[2] == $cfgDisciplineType[$strDiscTypeRelay]) {
                         if ($row_results['Handgestoppt'] == 1) {
                             $rankadd .= "m";
                         }
                     }
                     $rankadd .= $global_rankadd;
                     if ($relay) {
                         //
                         // relay results
                         //
                         if ($id != $row_results['xStaffel']) {
                             // new relay
                             $id = $row_results['xStaffel'];
                             $this->close_open_tags("teams");
                             $this->write_xml_open("team", array('teamCode' => 'S'));
                             $this->write_xml_finished("relayId", $id);
                             // staffel id
                             $this->write_xml_open("efforts");
                         }
                         $this->write_xml_open("effort");
                         // add effort parameters
                         $this->write_xml_finished("DateOfEffort", $row_results['Datum']);
                         if ($row[2] == $cfgDisciplineType[$strDiscTypeJump] || $row[2] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeThrow] || $row[2] == $cfgDisciplineType[$strDiscTypeHigh]) {
                             $perf = AA_alabusDistance($row_results['Leistung']);
                             $this->write_xml_finished("distanceResult", $perf);
                         } else {
                             $perf = AA_alabusTime($row_results['Leistung']);
                             $this->write_xml_finished("timeResult", $perf);
                         }
                         $wind = "";
                         if ($row[1] == 1) {
                             $wind = strtr($row_results['Wind'], ",", ".");
                         } else {
                             $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'] .= "_";
                             }
                         }
                         // check on relevant for bestlist
                         $relevant = 1;
                         if ($wind > "2") {
                             //$relevant = 0;
                         }
                         if ($row_results['Typ'] == '0') {
                             // (ohne)
                             $row_results['Bezeichnung'] = '';
                         }
                         //$this->write_xml_finished("timeResult"," ");
                         //$this->write_xml_finished("distanceResult"," ");
                         //$this->write_xml_finished("scoreResult"," ");
                         $this->write_xml_finished("wind", $wind);
                         $this->write_xml_finished("kindOfLap", " " . $row_results['Typ']);
                         // round type
                         $this->write_xml_finished("lap", $row_results['Bezeichnung']);
                         // heat name (A_, B_, 01, 02 ..)
                         $this->write_xml_finished("place", $row_results['Rang']);
                         $this->write_xml_finished("placeAddon", $rankadd);
                         $this->write_xml_finished("relevant", $relevant);
                         // get athletes for effort details
                         $cRelayAt = 4;
                         if ($row[9] > 0) {
                             // staffelläufer count of discipline
                             $cRelayAt = $row[9];
                         }
                         $query = "\r\n\t\t\t\t\t\t\t\tSELECT at.Name, at.Vorname, st.Position FROM\r\n\t\t\t\t\t\t\t\t\tstaffelathlet as st\r\n\t\t\t\t\t\t\t\t\t, start as s\r\n\t\t\t\t\t\t\t\t\t, anmeldung as a\r\n\t\t\t\t\t\t\t\t\t, athlet as at\r\n\t\t\t\t\t\t\t\tWHERE st.xStaffelstart = " . $row_results['xStart'] . "\r\n\t\t\t\t\t\t\t\tAND st.xRunde = " . $row_results['xRunde'] . "\r\n\t\t\t\t\t\t\t\tAND st.xAthletenstart = s.xStart\r\n\t\t\t\t\t\t\t\tAND s.xAnmeldung = a.xAnmeldung\r\n\t\t\t\t\t\t\t\tAND a.xAthlet = at.xAthlet\r\n\t\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\t\tst.Position ASC\r\n\t\t\t\t\t\t\t\tLIMIT {$cRelayAt}";
                         $res_relayat = mysql_query($query);
                         if (mysql_errno() > 0) {
                             echo mysql_error();
                         } else {
                             $eDetails = "";
                             while ($row_relayat = mysql_fetch_assoc($res_relayat)) {
                                 $eDetails .= trim($row_relayat['Name']) . " " . trim($row_relayat['Vorname']) . " / ";
                             }
                             $eDetails = substr($eDetails, 0, strlen($eDetails) - 3);
                             $this->write_xml_finished("effortDetails", $eDetails);
                         }
                         $this->write_xml_close("effort");
                     } else {
                         //
                         // athlete results
                         //
                         if ($ru == $row_results['xRunde'] && $id == $row_results['xAthlet']) {
                             continue;
                         }
                         $ru = $row_results['xRunde'];
                         // array for ordering (order after WO) combined events
                         $combinedPriority = 0;
                         /*$combinedPrio = $cfgCombinedWO[$cfgCombinedDef[$row[7]]];
                         		$combinedPriority = array_keys($combinedPrio, $row[3]);
                         		if(count($combinedPriority) > 0){
                         			$combinedPriority = $combinedPriority[0];
                         		}else{
                         			$combinedPriority = 999; // not a official discipline for this combined event
                         		}*/
                         if ($id != $row_results['xAthlet']) {
                             // new athlete
                             $id = $row_results['xAthlet'];
                             $this->close_open_tags("athletes");
                             // if athlete is not from switzerland filter him but add to combined array for correct ranking
                             // the same for athletes without license (type 3)
                             // these rules have also to be present in the parsing section of combined events (before and after result loop)
                             /*if($row_results['Vereincode'] == '' || $row_results['Vereincode'] == '999999'
                             		|| $row_results['Lizenztyp'] == 3){*/
                             if ($row_results['Lizenztyp'] == 3) {
                                 if ($row[0] == $cfgEventType[$strEventTypeSingleCombined]) {
                                     $rank = " ";
                                     $row_results['Bezeichnung'] = " ";
                                     //
                                     //add points for combined contests
                                     if ($combined[$row_results['xAthlet']][$row[3]]['points'] < $row_results['Punkte']) {
                                         $combined[$row_results['xAthlet']][$row[3]] = array('kindOfLap' => " " . $row_results['Typ'], 'lap' => $row_results['Bezeichnung'], 'placeAddon' => $rankadd, 'points' => $row_results['Punkte'], 'discipline' => $row[6], 'license' => $row_results['Lizenznummer'], 'DateOfEffort' => $row_results['Datum'], 'lastName' => $row_results['Name'], 'firstName' => $row_results['Vorname'], 'birthDate' => $birthday, 'sex' => $row_results['Geschlecht'], 'nationality' => $row_results['Land'], 'accountCode' => $row_results['Vereincode'], 'priority' => $combinedPriority, 'licenseType' => $row_results['Lizenztyp']);
                                         // category of athlete, used for calculating the rankings
                                         $combined[$row_results['xAthlet']]['catathlete'] = $row_results['Katathlet'];
                                     }
                                 }
                                 $id = 0;
                                 // if this is not set, results for the skipped athlete will be written
                                 continue;
                                 // next result/athlete
                             }
                             // license_paid = license printed (information from basa data)
                             // only upload results from athletes with license available (=license printed)
                             if ($row_results['Lizenztyp'] <= 1 && $row_results['license_paid'] == 'n') {
                                 $id = 0;
                                 // if this is not set, results for the skipped athlete will be written
                                 continue;
                                 // next result/athlete
                             }
                             if (!empty($row_results['Lizenznummer'])) {
                                 $inMasterData = 1;
                                 $licensePaid = 1;
                             } else {
                                 $inMasterData = 0;
                                 if ($row_results['Bezahlt'] == 'y') {
                                     $licensePaid = 1;
                                 } else {
                                     $licensePaid = 0;
                                 }
                             }
                             //$this->close_open_tags("athletes");
                             $this->write_xml_open("athlete", array('license' => $row_results['Lizenznummer'], 'licensePaid' => $licensePaid, 'licenseCat' => '', 'inMasterData' => $inMasterData));
                             // write athletes data if athletica generated
                             //
                             if (!$inMasterData) {
                                 if ($row_results['Land'] == "-") {
                                     $row_results['Land'] = " ";
                                 }
                                 $this->write_xml_finished("lastName", $row_results['Name']);
                                 $this->write_xml_finished("firstName", $row_results['Vorname']);
                                 $birthday = $row_results['Geburtstag'];
                                 if ($birthday == "0000-00-00") {
                                     $birthday = $row_results['Jahrgang'] . "-01-01";
                                 }
                                 $this->write_xml_finished("birthDate", $birthday);
                                 $this->write_xml_finished("sex", $row_results['Geschlecht']);
                                 $this->write_xml_finished("nationality", $row_results['Land']);
                                 $this->write_xml_finished("accountCode", $row_results['Vereincode']);
                                 $this->write_xml_finished("secondaccountCode", " ");
                             }
                             $this->write_xml_open("efforts");
                         }
                         $perf = 0;
                         // result for alabus
                         $wind = "";
                         $perfRounded = 0;
                         // result for combined detail text
                         $this->write_xml_open("effort");
                         // add effort parameters
                         $this->write_xml_finished("DateOfEffort", $row_results['Datum']);
                         $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']);
                             $this->write_xml_finished("distanceResult", $perf);
                             $wind = strtr($row_results['Info'], ",", ".");
                         } else {
                             $perf = AA_alabusTime($row_results['Leistung']);
                             $perfRounded = AA_formatResultTime($row_results['Leistung'], true);
                             $this->write_xml_finished("timeResult", $perf);
                             $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'] .= "_";
                             }
                         }
                         if ($row[0] == $cfgEventType[$strEventTypeSingleCombined]) {
                             //$rankadd = "D)".$rankadd;
                             if ($wind > 4) {
                                 // if any result has a wind of over 4 m/s, the combined result gets a flag 'w'
                                 $rankadd .= "w";
                             }
                             $rank = " ";
                             $row_results['Bezeichnung'] = " ";
                             //
                             //add points for combined contests
                             if ($combined[$row_results['xAthlet']][$row[3]]['points'] < $row_results['Punkte']) {
                                 $combined[$row_results['xAthlet']][$row[3]] = array('wind' => $wind, 'kindOfLap' => " " . $row_results['Typ'], 'lap' => $row_results['Bezeichnung'], 'placeAddon' => $rankadd, 'points' => $row_results['Punkte'], 'effort' => $perfRounded, 'discipline' => $row[6], 'license' => $row_results['Lizenznummer'], 'inMasterData' => $inMasterData, 'licensePaid' => $licensePaid, 'DateOfEffort' => $row_results['Datum'], 'lastName' => $row_results['Name'], 'firstName' => $row_results['Vorname'], 'birthDate' => $birthday, 'sex' => $row_results['Geschlecht'], 'nationality' => $row_results['Land'], 'accountCode' => $row_results['Vereincode'], 'priority' => $combinedPriority, 'licenseType' => $row_results['Lizenztyp']);
                                 // category of athlete, used for calculating the rankings
                                 $combined[$row_results['xAthlet']]['catathlete'] = $row_results['Katathlet'];
                             }
                         } else {
                             $rank = $row_results['Rang'];
                         }
                         // check on relevant for bestlist
                         $relevant = 1;
                         if ($row_results['Typ'] == '0') {
                             // (ohne)
                             $row_results['Bezeichnung'] = '';
                         }
                         // output result data
                         $this->write_xml_finished("wind", $wind);
                         $this->write_xml_finished("kindOfLap", " " . $row_results['Typ']);
                         // round type
                         $this->write_xml_finished("lap", $row_results['Bezeichnung']);
                         // heat name (A_, B_, 01, 02 ..)
                         $this->write_xml_finished("place", $rank);
                         $this->write_xml_finished("placeAddon", $rankadd);
                         $this->write_xml_finished("relevant", $relevant);
                         $this->write_xml_finished("effortDetails", " ");
                         $this->write_xml_finished("accountinfo", " " . $row_results['Vereinsinfo']);
                         $this->write_xml_finished("homologate", "1");
                         // not yet implemented -> TODO
                         $this->write_xml_close("effort");
                         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\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_results['xSerienstart'] . "\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 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;
                                         }
                                         $this->write_xml_open("effort");
                                         $this->write_xml_finished("DateOfEffort", $row_results['Datum']);
                                         $this->write_xml_finished("distanceResult", $perf);
                                         $wind = strtr($row_wind[0], ",", ".");
                                         if ($wind == "-") {
                                             $wind = " ";
                                         }
                                         $this->write_xml_finished("wind", $wind);
                                         $this->write_xml_finished("kindOfLap", " " . $row_results['Typ']);
                                         // round type
                                         $this->write_xml_finished("lap", $row_results['Bezeichnung']);
                                         // heat name (A_, B_, 01, 02 ..)
                                         $this->write_xml_finished("place", " ");
                                         $this->write_xml_finished("placeAddon", $rankadd);
                                         $this->write_xml_finished("relevant", $relevant);
                                         $this->write_xml_finished("effortDetails", " ");
                                         $this->write_xml_close("effort");
                                         break;
                                     }
                                 }
                             }
                         }
                         // end if wind > 2
                     }
                     // end if relay or athlete
                 }
                 // end while res_results
             }
             $this->close_open_tags("disciplines");
         }
         // check on last combined event
         if (!empty($combined) && $combined_dis < 9000) {
             // combined codes 9000 and above are self made disciplines
             $this->write_xml_open("discipline", array('sportDiscipline' => $combined_dis, 'licenseCategory' => $combined_cat));
             $this->write_xml_open("athletes");
             // calc points
             foreach ($combined as $xathlet => $disc) {
                 $points = 0;
                 $eDetails = "";
                 $tmp_fe = $fetched_events;
                 foreach ($disc as $xdisc => $tmp) {
                     if ($xdisc == "catathlete") {
                         continue;
                     }
                     // check if there are events missing for the current athlete and add 'null' entries
                     while ($tmp_fe[0][3] != $xdisc) {
                         //$eDetails .= $tmp_fe[0][6]." (0); ";
                         $eDetails .= "0/";
                         array_shift($tmp_fe);
                     }
                     array_shift($tmp_fe);
                     $points += $tmp['points'];
                     if ($tmp['wind'] == " ") {
                         $tmp['wind'] = "";
                     } else {
                         //$tmp['wind'] = " / ".$tmp['wind'];
                         if ($tmp['wind'] >= 0) {
                             $tmp['wind'] = "+" . $tmp['wind'];
                         } else {
                             $tmp['wind'] = $tmp['wind'];
                         }
                     }
                     //$eDetails .= $tmp['discipline']." (".$tmp['effort'].$tmp['wind']."); ";
                     $eDetails .= $tmp['effort'] . $tmp['wind'] . "/";
                 }
                 // check if last events are missing
                 while (isset($tmp_fe[0][3])) {
                     $eDetails .= "0/";
                     array_shift($tmp_fe);
                 }
                 $eDetails = substr($eDetails, 0, -1);
                 $combined[$xathlet]['points'] = $points;
                 $combined[$xathlet]['edetails'] = $eDetails;
             }
             // sort for points
             usort($combined, array($this, "sort_combined"));
             // write
             //$rank = array();
             //$curr_athlete_cat = "";
             $rank = 0;
             // athletes rank
             $cRank = 0;
             // rank counter
             $lp = 0;
             // remembers points of last athlete
             foreach ($combined as $xathlet => $disc) {
                 $this->close_open_tags("athletes");
                 // count place for each athlete category
                 /*$curr_athlete_cat = $combined[$xathlet]['catathlete'];
                 		if(!isset($rank[$curr_athlete_cat])){
                 			$rank[$curr_athlete_cat] = 1;
                 		}else{
                 			$rank[$curr_athlete_cat]++;
                 		}*/
                 $cRank++;
                 if ($lp != $disc['points']) {
                     $rank = $cRank;
                     $lp = $disc['points'];
                 }
                 // get information for athlete
                 $tmp = $disc;
                 $tmp['points'] = null;
                 $tmp['edetails'] = null;
                 $tmp['catathlete'] = null;
                 $tmp = array_values($tmp);
                 usort($tmp, array($this, "sort_perdate"));
                 $tmp = $tmp[0];
                 // filter athletes not from switzerland and athletes without license
                 if ($tmp['accountCode'] == '' || $tmp['accountCode'] == '999999' || $tmp['licenseType'] == 3) {
                     continue;
                 }
                 $this->write_xml_open("athlete", array('license' => $tmp['license'], 'licensePaid' => $tmp['licensePaid'], 'licenseCat' => '', 'inMasterData' => $tmp['inMasterData']));
                 if (!$tmp['inMasterData']) {
                     $this->write_xml_finished("lastName", $tmp['lastName']);
                     $this->write_xml_finished("firstName", $tmp['firstName']);
                     $this->write_xml_finished("birthDate", $tmp['birthDate']);
                     $this->write_xml_finished("sex", $tmp['sex']);
                     $this->write_xml_finished("nationality", $tmp['nationality']);
                     $this->write_xml_finished("accountCode", $tmp['accountCode']);
                     $this->write_xml_finished("secondaccountCode", " ");
                 }
                 $this->write_xml_open("efforts");
                 $this->write_xml_open("effort");
                 $this->write_xml_finished("DateOfEffort", $tmp['DateOfEffort']);
                 $this->write_xml_finished("scoreResult", AA_alabusScore($disc['points']));
                 $this->write_xml_finished("wind", " ");
                 $this->write_xml_finished("kindOfLap", " ");
                 // round type combined (D)
                 $this->write_xml_finished("lap", " ");
                 // heat name (A_, B_, 01, 02 ..)
                 //$this->write_xml_finished("place",$rank[$curr_athlete_cat]);
                 $this->write_xml_finished("place", $rank);
                 $this->write_xml_finished("placeAddon", $tmp['placeAddon']);
                 $this->write_xml_finished("relevant", "1");
                 $this->write_xml_finished("effortDetails", $disc['edetails']);
                 $this->write_xml_close("effort");
             }
             $this->close_open_tags("disciplines");
         }
         $combined = array();
         // get the svm results
         mysql_free_result($res);
         $res = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tw.Typ,\r\n\t\t\t\t\tw.Windmessung,\r\n\t\t\t\t\td.Typ,\r\n\t\t\t\t\td.Code,\r\n\t\t\t\t\tk.Code,\r\n\t\t\t\t\tw.xWettkampf,\r\n\t\t\t\t\td.Kurzname,\r\n\t\t\t\t\tw.Mehrkampfcode,\r\n\t\t\t\t\tw.xKategorie,\r\n\t\t\t\t\tks.Code,\r\n\t\t\t\t\tMAX(r.Datum)\r\n\t\t\t\tFROM \r\n\t\t\t\t\trunde as r\r\n\t\t\t\tLEFT JOIN \r\n\t\t\t\t\twettkampf as w USING(xWettkampf) \r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tdisziplin as d ON d.xDisziplin = w.xDisziplin\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tkategorie as k ON k.xKategorie = w.xKategorie\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tkategorie_svm as ks ON ks.xKategorie_svm = w.xKategorie_svm\r\n\t\t\t\tWHERE\txMeeting = " . $_COOKIE['meeting_id'] . "\r\n\t\t\t\tGROUP BY w.xKategorie\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tw.xWettkampf\r\n\t\t\t");
         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);
                     $this->close_open_tags("disciplines");
                 }
             }
         }
         // close last tags
         $this->close_open_tags();
     }
     $this->gzip_close();
 }