コード例 #1
0
    function AA_results_Track($round, $layout, $autoRank = '')
    {
        require './lib/cl_gui_button.lib.php';
        require './lib/cl_gui_dropdown.lib.php';
        require './lib/cl_gui_select.lib.php';
        require './config.inc.php';
        require './lib/common.lib.php';
        require './lib/heats.lib.php';
        require './lib/results.lib.php';
        require './lib/utils.lib.php';
        require './lib/timing.lib.php';
        $presets = AA_results_getPresets($round);
        // read GET/POST variables
        $relay = AA_checkRelay($presets['event']);
        // check, if this is a relay event
        $svm = AA_checkSVM(0, $round);
        // decide whether to show club or team name
        // $flagMain=AA_getMainRound($round);
        //   if ($flagMain) {
        //
        // terminate result processing
        //
        if ($_GET['arg'] == 'results_done') {
            $eval = AA_results_getEvaluationType($round);
            $combined = AA_checkCombined(0, $round);
            $eventType = AA_getEventTypes($round);
            mysql_query("\r\n\t\tLOCK TABLES\r\n\t\t\trundentyp READ\r\n\t\t\t, runde READ\r\n\t\t\t, serie READ\r\n\t\t\t, resultat READ\r\n\t\t\t, wettkampf READ\r\n\t\t\t, start WRITE\r\n\t\t\t, serienstart WRITE\r\n\t");
            if ($eval == $cfgEvalType[$strEvalTypeAll] || $eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club'])) {
                // eval all heats together
                $heatorder = "";
            } else {
                // default: rank results per heat
                $heatorder = "serie.xSerie, ";
            }
            $nextRound = AA_getNextRound($presets['event'], $round);
            // if this is a combined event, rank all rounds togheter
            $roundSQL = "";
            if ($combined) {
                $roundSQL = "WHERE serie.xRunde IN (";
                $res_c = mysql_query("SELECT xRunde FROM runde WHERE xWettkampf = " . $presets['event']);
                while ($row_c = mysql_fetch_array($res_c)) {
                    $roundSQL .= $row_c[0] . ",";
                }
                $roundSQL = substr($roundSQL, 0, -1) . ")";
            } else {
                $roundSQL = "WHERE serie.xRunde = {$round}";
            }
            /*$result = mysql_query("
            		SELECT
            			resultat.Leistung
            			, serienstart.xSerienstart
            			, serienstart.xSerie
            			, serienstart.xStart
            			, serie.Wind
            		FROM
            			resultat
            			, serienstart
            			, serie
            		WHERE resultat.xSerienstart = serienstart.xSerienstart
            		
            		AND serienstart.xSerie = serie.xSerie
            		$roundSQL
            		ORDER BY
            			$heatorder
            			resultat.Leistung ASC
            	");  */
            $sql = "SELECT DISTINCT \r\n\t\t\t\t   resultat.Leistung, \r\n\t\t\t\t   serienstart.xSerienstart, \r\n\t\t\t\t   serienstart.xSerie, \r\n\t\t\t\t   serienstart.xStart, \r\n\t\t\t\t   serie.Wind \r\n\t\t\t  FROM resultat \r\n\t\t LEFT JOIN serienstart USING(xSerienstart) \r\n\t\t LEFT JOIN serie USING(xSerie) \r\n\t\t\t " . $roundSQL . " \r\n\t\t  ORDER BY " . $heatorder . "\r\n\t\t\t\t   resultat.Leistung ASC;";
            $result = mysql_query($sql);
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            } else {
                $heat = 0;
                $perf = 0;
                $i = 0;
                $rank = 0;
                while ($row = mysql_fetch_row($result)) {
                    // check on codes < 0
                    if ($row[0] < 0) {
                        mysql_query("UPDATE serienstart SET" . " Rang = 0" . " WHERE xSerienstart = " . $row[1]);
                    } else {
                        if (!($eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club']))) {
                            if ($eval != $cfgEvalType[$strEvalTypeAll] && $heat != $row[2]) {
                                $i = 0;
                                // restart ranking   (not SVM with single heat)
                                $perf = 0;
                            }
                        }
                        $i++;
                        // increment ranking
                        if ($perf < $row[0]) {
                            // compare with previous performance
                            $rank = $i;
                            // next rank (only if not same performance)
                        }
                        mysql_query("UPDATE serienstart SET" . " Rang = " . $rank . " WHERE xSerienstart = " . $row[1]);
                        if (mysql_errno() > 0) {
                            AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                        }
                        // keep performance for information (heat seeding)
                        if ($nextRound > 0) {
                            mysql_query("\r\n\t\t\t\t\t\tUPDATE start SET\r\n\t\t\t\t\t\t\tstart.Bestleistung = {$row['0']}\r\n\t\t\t\t\t\tWHERE start.xStart = {$row['3']}\r\n\t\t\t\t\t");
                        }
                        if (mysql_errno() > 0) {
                            AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                        }
                        $heat = $row[2];
                        // keep current heat ID
                        $perf = $row[0];
                        // keep current performance
                    }
                }
                mysql_free_result($result);
            }
            mysql_query("UNLOCK TABLES");
            AA_results_setNotStarted($round);
            // update athletes with no result
            AA_utils_changeRoundStatus($round, $cfgRoundStatus['results_done']);
            if (!empty($GLOBALS['AA_ERROR'])) {
                AA_printErrorMsg($GLOBALS['AA_ERROR']);
            }
            AA_results_resetQualification($round);
        }
        // ET terminate results
        //
        // Qualify athletes after ranks are set
        //
        if ($_GET['arg'] == 'results_done' || $_POST['arg'] == 'save_rank' || $_POST['arg'] == 'set_qual') {
            // read qualification criteria
            $qual_top = 0;
            $qual_perf = 0;
            $result = mysql_query("SELECT QualifikationSieger" . ", QualifikationLeistung" . " FROM runde" . " WHERE xRunde = " . $round);
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            } else {
                if (($row = mysql_fetch_row($result)) == TRUE) {
                }
                $qual_top = $row[0];
                $qual_perf = $row[1];
                mysql_free_result($result);
            }
            // ET DB error
            // qualify top athletes for next round
            if ($qual_top > 0) {
                mysql_query("LOCK TABLES serie READ, serienstart WRITE");
                // get athletes by qualifying rank (random order if same rank)
                $result = mysql_query("SELECT serienstart.xSerienstart" . ", serienstart.xSerie" . ", serienstart.Rang" . " FROM serienstart" . ", serie" . " WHERE serienstart.Rang > 0" . " AND serienstart.xSerie = serie.xSerie" . " AND serie.xRunde = " . $round . " AND serienstart.Qualifikation = 0" . " ORDER BY serienstart.xSerie" . ", serienstart.Rang ASC" . ", RAND()");
                if (mysql_errno() > 0) {
                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                } else {
                    $h = 0;
                    unset($heats);
                    // clear array containing heats
                    while ($row = mysql_fetch_row($result)) {
                        if ($h != $row[1]) {
                            // new heat
                            if (count($starts) > 0) {
                                // count athletes
                                $heats[] = $starts;
                                // keep athletes per heat
                            }
                            unset($starts);
                            $c = 0;
                        }
                        $starts[$row[0]] = $row[2];
                        // keep athlete's rank
                        $h = $row[1];
                        // keep heat
                    }
                    $heats[] = $starts;
                    // keep remaining athletes
                    mysql_free_result($result);
                    foreach ($heats as $starts) {
                        $rankcount = array_count_values($starts);
                        // count athletes/rank
                        $q = 0;
                        foreach ($starts as $id => $rank) {
                            // check if more athletes per rank than qualifying spots
                            if ($rankcount[$rank] > $qual_top - $rank + 1) {
                                $qual = $cfgQualificationType['top_rand']['code'];
                            } else {
                                $qual = $cfgQualificationType['top']['code'];
                            }
                            if ($q < $qual_top) {
                                mysql_query("UPDATE serienstart SET" . " Qualifikation = " . $qual . " WHERE xSerienstart = " . $id);
                                if (mysql_errno() > 0) {
                                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                }
                                $q++;
                                // count nbr of qualified athletes
                            }
                        }
                    }
                    // END loop every heat
                }
                // ET DB error
                mysql_query("UNLOCK TABLES");
            }
            // ET top athletes
            // qualify top performing athletes for next round
            if ($qual_perf > 0) {
                mysql_query("LOCK TABLES resultat READ, serie READ, serienstart WRITE");
                // get remaining athletes by performance (random order if equal performance)
                /* other possible criteria to order equal performances:
                 * - ranking within heat (not implemented)
                 * - wind (not implemented)
                 */
                $result = mysql_query("SELECT serienstart.xSerienstart" . ", resultat.Leistung" . ", serienstart.Qualifikation" . " FROM resultat" . ", serienstart" . ", serie" . " WHERE resultat.xSerienstart = serienstart.xSerienstart" . " AND resultat.Leistung > 0" . " AND (serienstart.Qualifikation = 0 " . " OR serienstart.Qualifikation = " . $cfgQualificationType['waived']['code'] . ")" . " AND serienstart.xSerie = serie.xSerie" . " AND serie.xRunde = " . $round . " ORDER BY resultat.Leistung ASC" . ", RAND()");
                if (mysql_errno() > 0) {
                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                } else {
                    $i = 1;
                    $perf = 0;
                    $cWaived = 0;
                    while ($row = mysql_fetch_row($result)) {
                        // count waived qualifyings
                        if ($row[2] == $cfgQualificationType['waived']['code']) {
                            $cWaived++;
                            continue;
                        }
                        if ($i > $qual_perf) {
                            // terminate if enough top performers found
                            if ($perf != $row[1]) {
                                // last perf. worse than last qualified
                                $perf = 0;
                            }
                            break;
                        }
                        // if athletes waived on qualifying, set random code for next best athletes
                        $code = $cfgQualificationType['perf']['code'];
                        if ($i + $cWaived > $qual_perf) {
                            $code = $cfgQualificationType['perf_rand']['code'];
                        }
                        mysql_query("UPDATE serienstart SET" . " Qualifikation = " . $code . " WHERE xSerienstart = " . $row[0]);
                        if (mysql_errno() > 0) {
                            AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                        }
                        $i++;
                        $perf = $row[1];
                        // keep performance
                    }
                    // reset performance if enough qualifing spots
                    if (mysql_num_rows($result) <= $qual_perf) {
                        $perf = 0;
                    }
                    mysql_free_result($result);
                    // Change qualification type to "perf_rand" for athletes with same
                    // performance as the 1st unqualified athlete
                    if ($perf != 0) {
                        $result = mysql_query("SELECT serienstart.xSerienstart" . " FROM resultat" . ", serienstart" . ", serie" . " WHERE resultat.xSerienstart = serienstart.xSerienstart" . " AND resultat.Leistung = " . $perf . " AND serienstart.Qualifikation > 0" . " AND serienstart.xSerie = serie.xSerie" . " AND serie.xRunde = " . $round);
                        if (mysql_errno() > 0) {
                            AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                        } else {
                            while ($row = mysql_fetch_row($result)) {
                                mysql_query("UPDATE serienstart SET" . " Qualifikation = " . $cfgQualificationType['perf_rand']['code'] . " WHERE xSerienstart = " . $row[0]);
                                if (mysql_errno() > 0) {
                                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                }
                            }
                            mysql_free_result($result);
                        }
                    }
                    // ET unqualified athlete
                }
                // ET DB error qualified by performance
                mysql_query("UNLOCK TABLES");
            }
            // ET top performances
        }
        //
        // calculate ranking points if needed
        //
        if ($_GET['arg'] == 'results_done' || $_POST['arg'] == 'save_rank') {
            AA_utils_calcRankingPoints($round);
            // only for SVM with heat single --> set back the ranks per heat
            if ($eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club'])) {
                mysql_query("\r\n\t\tLOCK TABLES\r\n\t\t\trundentyp READ\r\n\t\t\t, runde READ\r\n\t\t\t, serie READ\r\n\t\t\t, resultat READ   \r\n\t\t\t, serienstart WRITE\r\n\t");
                // if this is a combined event, rank all rounds togheter
                $heatorder = "serie.xSerie, ";
                $roundSQL = "";
                if ($combined) {
                    $roundSQL = "AND serie.xRunde IN (";
                    $res_c = mysql_query("SELECT xRunde FROM runde WHERE xWettkampf = " . $presets['event']);
                    while ($row_c = mysql_fetch_array($res_c)) {
                        $roundSQL .= $row_c[0] . ",";
                    }
                    $roundSQL = substr($roundSQL, 0, -1) . ")";
                } else {
                    $roundSQL = "AND serie.xRunde = {$round}";
                }
                $result = mysql_query("\r\n\t\tSELECT \r\n\t\t\tresultat.Leistung\r\n\t\t\t, serienstart.xSerienstart\r\n\t\t\t, serienstart.xSerie\r\n\t\t\t, serienstart.xStart\r\n\t\t\t, serie.Wind\r\n\t\t\t, serienstart.Rang\t\t\t\r\n\t\tFROM\r\n\t\t\tresultat\r\n\t\t\t, serienstart\r\n\t\t\t, serie\r\n\t\tWHERE resultat.xSerienstart = serienstart.xSerienstart\r\n\t\t\r\n\t\tAND serienstart.xSerie = serie.xSerie\r\n\t\t{$roundSQL}\r\n\t\tORDER BY\r\n\t\t\t{$heatorder}\r\n\t\t\tresultat.Leistung ASC\r\n\t");
                if (mysql_errno() > 0) {
                    // DB error
                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                } else {
                    $heat = 0;
                    $perf = 0;
                    $i = 0;
                    $rank = 0;
                    while ($row = mysql_fetch_row($result)) {
                        // check on codes < 0
                        if ($row[0] < 0) {
                            mysql_query("UPDATE serienstart SET" . " Rang = 0" . " WHERE xSerienstart = " . $row[1]);
                        } else {
                            if ($eval != $cfgEvalType[$strEvalTypeAll] && $heat != $row[2]) {
                                $i = 0;
                                // restart ranking
                                $perf = 0;
                            }
                            if ($row[5] != 0) {
                                // rank
                                $i++;
                                // increment ranking
                                if ($perf < $row[0]) {
                                    // compare with previous performance
                                    $rank = $i;
                                    // next rank (only if not same performance)
                                }
                                mysql_query("UPDATE serienstart SET" . " Rang = " . $rank . " WHERE xSerienstart = " . $row[1]);
                                if (mysql_errno() > 0) {
                                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                }
                            }
                            $heat = $row[2];
                            // keep current heat ID
                            $perf = $row[0];
                            // keep current performance
                        }
                    }
                    mysql_free_result($result);
                }
                mysql_query("UNLOCK TABLES");
            }
            // end:   only for SVM with heat single --> set back the ranks per heat
        }
        if ($autoRank) {
            // automatic ranking returns to event monitor
            return;
        }
        //
        // get results from timing system
        //  - save directly in database
        //
        if ($_GET['arg'] == "time_measurement") {
            AA_timing_getResultsManual($round);
        }
        //
        // print HTML page header
        //
        AA_results_printHeader($presets['category'], $presets['event'], $round);
        $mergedMain = AA_checkMainRound($round);
        if ($mergedMain != 1) {
            // read round data
            if ($round > 0) {
                $status = AA_getRoundStatus($round);
                // No action yet
                if ($status == $cfgRoundStatus['open'] || $status == $cfgRoundStatus['enrolement_done'] || $status == $cfgRoundStatus['heats_in_progress']) {
                    AA_printWarningMsg($strHeatsNotDone);
                } else {
                    if ($status == $cfgRoundStatus['enrolement_pending']) {
                        AA_printWarningMsg($strEnrolementNotDone);
                    } else {
                        if ($status >= $cfgRoundStatus['heats_done']) {
                            AA_heats_printNewStart($presets['event'], $round, "event_results.php");
                            $nextRound = AA_getNextRound($presets['event'], $round);
                            // show qualification form if another round follows
                            if ($nextRound > 0) {
                                $result = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tQualifikationSieger\r\n\t\t\t\t\t, QualifikationLeistung\r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde\r\n\t\t\t\tWHERE xRunde = {$round}\r\n\t\t\t");
                                if (mysql_errno() > 0) {
                                    // DB error
                                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                } else {
                                    if (($row = mysql_fetch_row($result)) == TRUE) {
                                    }
                                    ?>
<p/>
<table class='dialog'>
	<tr>
	<form action='event_results.php' method='post' name='qualification'>
		<td class='dialog'>
			<input type='hidden' name='arg' value='set_qual' />
			<input type='hidden' name='round' value='<?php 
                                    echo $round;
                                    ?>
' />
			<?php 
                                    echo $strQualification . " " . $strQualifyTop;
                                    ?>
</td>
		<td class='dialog'>
			<input class='nbr' name='qual_top' type='text' maxlength='4'
				value='<?php 
                                    echo $row[0];
                                    ?>
' /></td>
		<td class='dialog'>
			<?php 
                                    echo $strQualification . " " . $strQualifyPerformance;
                                    ?>
</td>
		<td class='dialog'>
			<input class='nbr' name='qual_perf' type='text' maxlength='4'
				value='<?php 
                                    echo $row[1];
                                    ?>
' /></td>
		<td>
			<button type='submit'>
				<?php 
                                    echo $strChange;
                                    ?>
			</button>
		</td>
	</form>
	</tr>
</table>
<p/>
<?php 
                                    $printed = TRUE;
                                    // qualification parameters printed
                                    // ET round found
                                    mysql_free_result($result);
                                }
                                // ET DB error
                            }
                            // ET next round
                            // check if round is final
                            $sql_r = "SELECT \r\n                    rt.Typ\r\n                FROM\r\n                    runde as r\r\n                    LEFT JOIN rundentyp as rt USING (xRundentyp)\r\n                WHERE\r\n                    r.xRunde=" . $round;
                            $res_r = mysql_query($sql_r);
                            if (mysql_errno() > 0) {
                                // DB error
                                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                            }
                            $order = "ASC";
                            if (mysql_num_rows($res_r) == 1) {
                                $row_r = mysql_fetch_row($res_r);
                                if ($row_r[0] == 'F') {
                                    $order = "DESC";
                                }
                            }
                            // display all athletes
                            if ($relay == FALSE) {
                                // single event
                                $query = "SELECT r.Bahnen" . ", rt.Name" . ", rt.Typ" . ", s.xSerie" . ", s.Bezeichnung" . ", s.Wind" . ", s.Film" . ", an.Bezeichnung" . ", ss.xSerienstart" . ", ss.Position" . ", ss.Rang" . ", ss.Qualifikation" . ", a.Startnummer" . ", at.Name" . ", at.Vorname" . ", at.Jahrgang" . ", if('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo))" . ", LPAD(s.Bezeichnung,5,'0') as heatid" . ", s.Handgestoppt" . ", at.Land" . ", ss.Bemerkung" . ", at.xAthlet" . " FROM runde AS r" . ", serie AS s" . ", serienstart AS ss" . ", start AS st" . ", anmeldung AS a" . ", athlet AS at" . ", verein AS v" . " LEFT JOIN team AS t ON(a.xTeam = t.xTeam)" . " LEFT JOIN rundentyp AS rt" . " ON rt.xRundentyp = r.xRundentyp" . " LEFT JOIN anlage AS an" . " ON an.xAnlage = s.xAnlage" . " WHERE r.xRunde = " . $round . " AND s.xRunde = r.xRunde" . " AND ss.xSerie = s.xSerie" . " AND st.xStart = ss.xStart" . " AND a.xAnmeldung = st.xAnmeldung" . " AND at.xAthlet = a.xAthlet" . " AND v.xVerein = at.xVerein" . " ORDER BY heatid " . $order . ", ss.Position";
                            } else {
                                // relay event
                                $query = "SELECT r.Bahnen" . ", rt.Name" . ", rt.Typ" . ", s.xSerie" . ", s.Bezeichnung" . ", s.Wind" . ", s.Film" . ", an.Bezeichnung" . ", ss.xSerienstart" . ", ss.Position" . ", ss.Rang" . ", ss.Qualifikation" . ", sf.Name" . ", if('" . $svm . "', t.Name, v.Name)" . ", LPAD(s.Bezeichnung,5,'0') as heatid" . ", s.Handgestoppt" . ", ss.Bemerkung" . " FROM runde AS r" . ", serie AS s" . ", serienstart AS ss" . ", start AS st" . ", staffel AS sf" . ", verein AS v" . " LEFT JOIN team AS t ON(sf.xTeam = t.xTeam)" . " LEFT JOIN rundentyp AS rt" . " ON rt.xRundentyp = r.xRundentyp" . " LEFT JOIN anlage AS an" . " ON an.xAnlage = s.xAnlage" . " WHERE r.xRunde = " . $round . " AND s.xRunde = r.xRunde" . " AND ss.xSerie = s.xSerie" . " AND st.xStart = ss.xStart" . " AND sf.xStaffel = st.xStaffel" . " AND v.xVerein = sf.xVerein" . " ORDER BY heatid " . $order . ", ss.Position";
                            }
                            $result = mysql_query($query);
                            if (mysql_errno() > 0) {
                                // DB error
                                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                            } else {
                                AA_results_printMenu($round, $status, $prog_mode, 'track');
                                // initialize variables
                                $h = 0;
                                // heat counter
                                $p = 0;
                                // position counter (to evaluate empty heats
                                $i = 0;
                                // input counter (an individual id is assigned to each
                                // input field, focus is then moved to the next input
                                // field by calling $i+1)
                                $rowclass = 'odd';
                                $tracks = 0;
                                $btn = new GUI_Button('', '');
                                // create button object
                                ?>
<p/>
<table class='dialog'>
<?php 
                                while ($row = mysql_fetch_row($result)) {
                                    $p++;
                                    // increment position counter
                                    /*
                                     *  Heat headerline
                                     */
                                    if ($h != $row[3]) {
                                        $tracks = $row[0];
                                        // keep nbr of planned tracks
                                        // fill previous heat with empty tracks
                                        if ($p > 1) {
                                            printEmptyTracks($p, $tracks, 5 + $c);
                                        }
                                        $h = $row[3];
                                        // keep heat ID
                                        $p = 1;
                                        // start with track one
                                        if (is_null($row[1])) {
                                            // only one round
                                            $title = "{$strFinalround}";
                                        } else {
                                            // more than one round
                                            $title = "{$row['1']}";
                                        }
                                        // increment colspan to include ranking and qualification
                                        $c = 0;
                                        if ($status == $cfgRoundStatus['results_done']) {
                                            $c++;
                                            if ($nextRound > 0) {
                                                $c++;
                                            }
                                        }
                                        ?>
	<tr>
		<form action='event_results.php#heat_<?php 
                                        echo $row[4];
                                        ?>
' method='post'
			name='heat_id_<?php 
                                        echo $h;
                                        ?>
'>

		<th class='dialog' colspan='3'>
			<?php 
                                        echo $title;
                                        ?>
			<input type='hidden' name='arg' value='change_heat_name' />
			<input type='hidden' name='round' value='<?php 
                                        echo $round;
                                        ?>
' />
			<input type='hidden' name='item' value='<?php 
                                        echo $row[3];
                                        ?>
' />
			<input class='nbr' type='text' name='id' maxlength='2'
				value='<?php 
                                        echo $row[4];
                                        ?>
'
				onChange='document.heat_id_<?php 
                                        echo $h;
                                        ?>
.submit()' />
				<a name='heat_<?php 
                                        echo $row[4];
                                        ?>
' />
		</th>
		</form>
<?php 
                                        if ($status != $cfgRoundStatus['results_done']) {
                                            ?>
		<form action='controller.php' method='post'
			name='filmheat_<?php 
                                            echo $row[4];
                                            ?>
' target='controller'>
		<th class='dialog' colspan='2'>
			<?php 
                                            echo $strFilm;
                                            ?>
			<input type='hidden' name='act' value='saveFilm' />
			<input type='hidden' name='round' value='<?php 
                                            echo $round;
                                            ?>
' />
			<input type='hidden' name='item' value='<?php 
                                            echo $row[3];
                                            ?>
' />
			<input class='nbr' type='text' name='film' id='in_<?php 
                                            echo $i;
                                            ?>
'
				maxlength='3' value='<?php 
                                            echo $row[6];
                                            ?>
'
				onChange="submitForm(document.filmheat_<?php 
                                            echo $row[4];
                                            ?>
, 'in_<?php 
                                            echo $i + 1;
                                            ?>
')" />
		</th>
		</form>
<?php 
                                            $i++;
                                            // next element
                                        } else {
                                            // results done
                                            ?>
		<th class='dialog' colspan='2'>
			<?php 
                                            echo $strFilm . " " . $row[6];
                                            ?>
		</th>
<?php 
                                        }
                                        // track discipline with wind
                                        if ($layout == $cfgDisciplineType[$strDiscTypeTrack]) {
                                            if ($status != $cfgRoundStatus['results_done']) {
                                                ?>
		<form action='controller.php' method='post'
			name='windheat_<?php 
                                                echo $row[4];
                                                ?>
' target='controller'>
		<th class='dialog' colspan='<?php 
                                                echo 1 + $c;
                                                ?>
'>
			<?php 
                                                echo $strWind;
                                                ?>
			<input type='hidden' name='act' value='saveWind' />
			<input type='hidden' name='obj' value='windheat_<?php 
                                                echo $row[4];
                                                ?>
' />
			<input type='hidden' name='round' value='<?php 
                                                echo $round;
                                                ?>
' />
			<input type='hidden' name='item' value='<?php 
                                                echo $row[3];
                                                ?>
' />
			<input class='nbr' type='text' name='wind'  id='in_<?php 
                                                echo $i;
                                                ?>
'
				maxlength='5' value='<?php 
                                                echo $row[5];
                                                ?>
'
				onChange="submitForm(document.windheat_<?php 
                                                echo $row[4];
                                                ?>
, 'in_<?php 
                                                echo $i + 1;
                                                ?>
')" />
		</th>
		</form>
<?php 
                                                $i++;
                                                // next element
                                            } else {
                                                // results done
                                                ?>
		<th class='dialog' colspan='2'>
			<?php 
                                                echo $strWind . " " . $row[5];
                                                ?>
		</th>
<?php 
                                            }
                                        } else {
                                            ?>
		<th class='dialog' colspan='<?php 
                                            echo 1 + $c;
                                            ?>
' />
<?php 
                                        }
                                        // ET track discipline with wind
                                        // can set "hand taken time"
                                        if ($row[18] == 1 && $relay == false) {
                                            $handstopped = "checked";
                                        } elseif ($row[15] == 1 && $relay == true) {
                                            $handstopped = "checked";
                                        } else {
                                            $handstopped = "";
                                        }
                                        if ($status != $cfgRoundStatus['results_done']) {
                                            ?>
		<form action='controller.php' method='post'
			name='handstopped_<?php 
                                            echo $row[4];
                                            ?>
' target='controller'>
		<th class='dialog'><?php 
                                            echo $strHandStopped;
                                            ?>
 
			<input type='hidden' name='act' value='saveHandStopped' />
			<input type='hidden' name='obj' value='handstopped_<?php 
                                            echo $row[4];
                                            ?>
' />
			<input type='hidden' name='round' value='<?php 
                                            echo $round;
                                            ?>
' />
			<input type='hidden' name='item' value='<?php 
                                            echo $row[3];
                                            ?>
' />
			<input type="checkbox" name="handstopped" id='in_<?php 
                                            echo $i;
                                            ?>
'
				onChange="submitForm(document.handstopped_<?php 
                                            echo $row[4];
                                            ?>
, 'in_<?php 
                                            echo $i + 1;
                                            ?>
')"
				<?php 
                                            echo $handstopped;
                                            ?>
 >
		</th>
		</form>
<?php 
                                            $i++;
                                            // next element
                                        } else {
                                            ?>
		<th class='dialog'><?php 
                                            echo $strHandStopped;
                                            ?>
			<input type="checkbox" name="handstopped" <?php 
                                            echo $handstopped;
                                            ?>
 disabled>
		</th>
<?php 
                                        }
                                        ?>
	</tr>
<?php 
                                        /*
                                         *  Column header
                                         */
                                        if ($relay == FALSE) {
                                            // athlete display
                                            ?>
	<tr>
		<th class='dialog'><?php 
                                            echo $strPositionShort;
                                            ?>
</th>
		<th class='dialog' colspan='2'><?php 
                                            echo $strAthlete;
                                            ?>
</th>
		<th class='dialog'><?php 
                                            echo $strYearShort;
                                            ?>
</th>
		<th class='dialog'><?php 
                                            echo $strCountry;
                                            ?>
</th>
		<th class='dialog'><?php 
                                            if ($svm) {
                                                echo $strTeam;
                                            } else {
                                                echo $strClub;
                                            }
                                            ?>
</th>
		<th class='dialog'><?php 
                                            echo $strPerformance;
                                            ?>
</th>
        
<?php 
                                        } else {
                                            // relay display
                                            ?>
	<tr>
		<th class='dialog'><?php 
                                            echo $strPositionShort;
                                            ?>
</th>
		<th class='dialog'><?php 
                                            echo $strRelay;
                                            ?>
</th>
		<th class='dialog'><?php 
                                            if ($svm) {
                                                echo $strTeam;
                                            } else {
                                                echo $strClub;
                                            }
                                            ?>
</th>
		<th class='dialog'><?php 
                                            echo $strPerformance;
                                            ?>
</th>
       
<?php 
                                        }
                                        if ($status == $cfgRoundStatus['results_done']) {
                                            ?>
		<th class='dialog'><?php 
                                            echo $strRank;
                                            ?>
</th>
<?php 
                                            if ($nextRound > 0) {
                                                ?>
		<th class='dialog'><?php 
                                                echo $strQualification;
                                                ?>
</th>
<?php 
                                            }
                                        }
                                        ?>
<th class='dialog'><?php 
                                        echo $strResultRemark;
                                        ?>
</th>     
	</tr>
<?php 
                                    }
                                    // ET new heat
                                    /*
                                     * Empty tracks
                                     */
                                    if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                                        // current track and athlete's position not identical
                                        if ($p < $row[9]) {
                                            $p = printEmptyTracks($p, $row[9] - 1, 5 + $c);
                                        }
                                    }
                                    // ET empty tracks
                                    /*
                                     * Athlete data lines
                                     */
                                    $p = $row[9];
                                    // keep position
                                    if ($p % 2 == 0) {
                                        // even row numer
                                        $rowclass = 'even';
                                    } else {
                                        // odd row number
                                        $rowclass = 'odd';
                                    }
                                    if ($relay == FALSE) {
                                        ?>
	<tr class='<?php 
                                        echo $rowclass;
                                        ?>
'>
		<td class='forms_right'><?php 
                                        echo $row[9];
                                        /* position */
                                        ?>
</td>
		<td class='forms_right'><?php 
                                        echo $row[12];
                                        /* start nbr */
                                        ?>
</td>
		<td><?php 
                                        echo $row[13] . " " . $row[14];
                                        /* name */
                                        ?>
</td>
		<td class='forms_ctr'><?php 
                                        echo AA_formatYearOfBirth($row[15]);
                                        ?>
</td>
		<td><?php 
                                        echo $row[19] != '' && $row[19] != '-' ? $row[19] : '&nbsp;';
                                        ?>
</td>
		<td><?php 
                                        echo $row[16];
                                        /* club */
                                        ?>
</td>
      
<?php 
                                    } else {
                                        // relay
                                        ?>
	<tr class='<?php 
                                        echo $rowclass;
                                        ?>
'>
		<td class='forms_right'><?php 
                                        echo $row[9];
                                        /* position */
                                        ?>
</td>
		<td><?php 
                                        echo $row[12];
                                        /* relay name */
                                        ?>
</td>
		<td><?php 
                                        echo $row[13];
                                        /* club */
                                        ?>
</td>
<?php 
                                    }
                                    $sql = "SELECT rs.xResultat, \r\n\t\t\t\t\t\t\t   rs.Leistung, \r\n\t\t\t\t\t\t\t   rs.Info, \r\n\t\t\t\t\t\t\t   d.Strecke \r\n\t\t\t\t\t\t  FROM resultat AS rs \r\n\t\t\t\t\t LEFT JOIN serienstart AS ss USING(xSerienstart) \r\n\t\t\t\t\t LEFT JOIN serie AS se USING(xSerie) \r\n\t\t\t\t\t LEFT JOIN runde AS ru USING(xRunde) \r\n\t\t\t\t\t LEFT JOIN wettkampf AS w USING(xWettkampf) \r\n\t\t\t\t\t LEFT JOIN disziplin AS d USING(xDisziplin) \r\n\t\t\t\t\t\t WHERE rs.xSerienstart = " . $row[8] . " \r\n\t\t\t\t\t  ORDER BY rs.Leistung ASC;";
                                    $res = mysql_query($sql);
                                    if (mysql_errno() > 0) {
                                        // DB error
                                        AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                    } else {
                                        $perf = '';
                                        $resrow = mysql_fetch_array($res);
                                        if ($resrow != NULL) {
                                            // result found
                                            /*$secflag = false;
                                            		if(substr($resrow[1],0,2) >= 60){
                                            			$secflag = true;
                                            		}*/
                                            $secflag = intval($resrow['Strecke']) <= 400;
                                            $perf = AA_formatResultTime($resrow[1], false, $secflag);
                                        }
                                        if ($status != $cfgRoundStatus['results_done']) {
                                            ?>
		<form action='controller.php' method='post'
			name='perf_<?php 
                                            echo $i;
                                            ?>
' target='controller'>
		<td>
			<input type='hidden' name='act' value='saveResult' />
			<input type='hidden' name='obj' value='perf_<?php 
                                            echo $i;
                                            ?>
' />
			<input type='hidden' name='type' value='<?php 
                                            echo $layout;
                                            ?>
' />
			<input type='hidden' name='round' value='<?php 
                                            echo $round;
                                            ?>
' />
			<input type='hidden' name='start' value='<?php 
                                            echo $row[8];
                                            ?>
' />
			<input type='hidden' name='item' value='<?php 
                                            echo $resrow[0];
                                            ?>
' />
			<input class='perftime' type='text' name='perf' id='in_<?php 
                                            echo $i;
                                            ?>
'
				maxlength='12' value='<?php 
                                            echo $perf;
                                            ?>
'
				onChange="submitForm(document.perf_<?php 
                                            echo $i;
                                            ?>
, 'in_<?php 
                                            echo $i + 1;
                                            ?>
')" />
		</td>
		</form>
        
        <form action='controller.php' method='post'
            name='remark_<?php 
                                            echo $i;
                                            ?>
' target='controller'>
        <td>
            <input type='hidden' name='act' value='saveResult' />
            <input type='hidden' name='obj' value='perf_<?php 
                                            echo $i;
                                            ?>
' />
            <input type='hidden' name='type' value='<?php 
                                            echo $layout;
                                            ?>
' />
            <input type='hidden' name='round' value='<?php 
                                            echo $round;
                                            ?>
' />
            <input type='hidden' name='start' value='<?php 
                                            echo $row[8];
                                            ?>
' />
            <input type='hidden' name='item' value='<?php 
                                            echo $resrow[0];
                                            ?>
' />
            <input type='hidden' name='xAthlete' value='<?php 
                                            echo $row[21];
                                            ?>
' />   
            <input class='textshort' type='text' name='remark' id='in_<?php 
                                            echo $i;
                                            ?>
'
                maxlength='5' value='<?php 
                                            if ($relay) {
                                                echo $row[16];
                                            } else {
                                                echo $row[20];
                                            }
                                            ?>
'
                onChange="submitForm(document.remark_<?php 
                                            echo $i;
                                            ?>
, 'in_<?php 
                                            echo $i + 1;
                                            ?>
')" />
        </td>
        </form>
        
       
<?php 
                                            $i++;
                                            // next element
                                        } else {
                                            // results done
                                            ?>
		<td class='forms_right'><?php 
                                            echo $perf;
                                            ?>
</td>
<?php 
                                        }
                                        mysql_free_result($res);
                                        if ($status == $cfgRoundStatus['results_done']) {
                                            if ($row[10] > 0) {
                                                ?>
		<form action='event_results.php' method='post'
			name='rank_<?php 
                                                echo $i;
                                                ?>
'>
		<td>
			<input type='hidden' name='arg' value='save_rank' />
			<input type='hidden' name='round' value='<?php 
                                                echo $round;
                                                ?>
' />
			<input type='hidden' name='focus' value='rank_<?php 
                                                echo $i;
                                                ?>
' />
			<input type='hidden' name='item' value='<?php 
                                                echo $row[8];
                                                ?>
' />
			<input class='nbr' type='text' name='rank' maxlength='3'
				value='<?php 
                                                echo $row[10];
                                                ?>
'
				onChange='document.rank_<?php 
                                                echo $i;
                                                ?>
.submit()' />
		</td>
		</form>     
        
       
<?php 
                                                $i++;
                                                // next element
                                                if ($nextRound > 0) {
                                                    ?>
		<form action='event_results.php' method='post'
			name='qual_<?php 
                                                    echo $i;
                                                    ?>
'>
		<td>
			<input type='hidden' name='arg' value='change_qual' />
			<input type='hidden' name='round' value='<?php 
                                                    echo $round;
                                                    ?>
' />
			<input type='hidden' name='focus' value='qual_<?php 
                                                    echo $i;
                                                    ?>
' />
			<input type='hidden' name='item' value='<?php 
                                                    echo $row[8];
                                                    ?>
' />
			<input type='hidden' name='oldqual' value='<?php 
                                                    echo $row[11];
                                                    ?>
' />
			<input type='hidden' name='heat' value='<?php 
                                                    echo $row[3];
                                                    ?>
' />
<?php 
                                                    $dropdown = new GUI_Select('qual', 1, "document.qual_{$i}.submit()");
                                                    $dropdown->addOptionNone();
                                                    foreach ($cfgQualificationType as $type) {
                                                        $dropdown->addOption($type['text'], $type['code']);
                                                        if ($type['code'] == $row[11]) {
                                                            $dropdown->selectOption($type['code']);
                                                        }
                                                    }
                                                    $dropdown->printList();
                                                    ?>
		</td>
		</form>
<?php 
                                                    $i++;
                                                    // next element
                                                }
                                                // qualification info
                                            } else {
                                                // no rank
                                                ?>
                        <td /> 
                        
                        
<?php 
                                            }
                                            // ET no rank
                                            ?>
                        
                     <td class='perftime'><?php 
                                            if ($relay) {
                                                echo $row[16];
                                            } else {
                                                echo $row[20];
                                            }
                                            ?>
</td>      
<?php 
                                        }
                                        // ET 'results_done'
                                        ?>
		<td>
<?php 
                                        $btn->set("event_results.php?arg=del_start&item={$row['8']}&round={$round}", $strDelete);
                                        $btn->printButton();
                                        ?>
		</td>
<?php 
                                    }
                                    // ET DB error
                                }
                                // Fill last heat with empty tracks for disciplines run in
                                // individual tracks
                                if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                                    if ($p > 0) {
                                        // heats set up
                                        $p++;
                                        printEmptyTracks($p, $tracks, 5 + $c);
                                    }
                                }
                                // ET track disciplines
                                ?>
</table>
<?php 
                                mysql_free_result($result);
                            }
                            // ET DB error
                        }
                    }
                }
            }
            // ET round selected
            if (!empty($presets['focus'])) {
                ?>

<script type="text/javascript">
<!--
	if(<?php 
                echo $presets['focus'];
                ?>
.rank) {
		<?php 
                echo $presets['focus'];
                ?>
.rank.focus();
		<?php 
                echo $presets['focus'];
                ?>
.rank.select();
		window.scrollBy(0,200);
	}
	else if(<?php 
                echo $presets['focus'];
                ?>
.qual) {
		<?php 
                echo $presets['focus'];
                ?>
.qual.focus();
		window.scrollBy(0,200);
	}
//-->
</script>
<?php 
            }
            ?>
</body>
</html>
<?php 
        } else {
            AA_printErrorMsg($strErrMergedRound);
        }
    }
コード例 #2
0
ファイル: print_contest.php プロジェクト: laiello/athletica
 }
 $result = mysql_query($sql);
 $row = mysql_fetch_row($result);
 // remember staffelläufer
 $maxRunners = $row[11];
 // get attempts for tech disc
 if ($_POST['countattempts'] == "") {
     $_POST['countattempts'] = $cfgCountAttempts[$row[7]];
 }
 if ($row[7] == $cfgDisciplineType[$strDiscTypeJump] || $row[7] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[7] == $cfgDisciplineType[$strDiscTypeThrow]) {
     mysql_query("\r\n\t\t\tUPDATE\r\n\t\t\t\trunde\r\n\t\t\tSET\r\n\t\t\t\tVersuche = " . $_POST['countattempts'] . "\r\n                , nurBestesResultat = '" . $onlyBest . "'  \r\n\t\t\tWHERE xRunde = {$round}\r\n\t\t");
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     }
 }
 $relay = AA_checkRelay($row[4]);
 // check, if this is a relay event
 $layout = $row[7];
 // sheet layout type
 $silent = $row[13] == 0;
 $wind = $row[8];
 switch ($layout) {
     case $cfgDisciplineType[$strDiscTypeNone]:
         $doc = new PRINT_Contest($_COOKIE['meeting']);
     case $cfgDisciplineType[$strDiscTypeTrack]:
         if ($print == 'no') {
             AA_timing_setStartInfo($round, $silent);
             // set timing if new heats, not if print startlist only
         }
         if ($row[8] == 1) {
             $doc = new PRINT_ContestTrack($_COOKIE['meeting']);
コード例 #3
0
ファイル: heats.lib.php プロジェクト: laiello/athletica
    /**
     * 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
    }
コード例 #4
0
ファイル: event_heats.php プロジェクト: laiello/athletica
if (!empty($_GET['round'])) {
    $round = $_GET['round'];
} else {
    if (!empty($_POST['round'])) {
        $round = $_POST['round'];
    }
}
if (!empty($_GET['heat'])) {
    $heat = $_GET['heat'];
}
$teamsm = false;
if (isset($_POST['teamsm'])) {
    $teamsm = $_POST['teamsm'];
}
$presets = AA_results_getPresets($round);
$relay = AA_checkRelay($presets['event']);
// check, if this is a relay event
$disctype = AA_getDisciplineType($round);
// get discipline type
if ($_POST['arg'] == 'seed') {
    // heat seeding
    AA_heats_seedEntries($presets['event']);
} else {
    if ($_POST['arg'] == 'seed_qual') {
        // seed qualified athletes
        AA_heats_seedQualifiedAthletes($presets['event']);
    } else {
        if ($_GET['arg'] == 'heats_done') {
            // heat seeding/qualification done
            AA_utils_changeRoundStatus($round, $cfgRoundStatus['heats_done']);
            if (!empty($GLOBALS['AA_ERROR'])) {
コード例 #5
0
 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] . " &nbsp;" . $GLOBALS['$strQualifyTop'] .", "
                     //			. $row[6] . " &nbsp;" . $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'] . "&nbsp;&nbsp;&nbsp;";
                     }
                     $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 = "&nbsp;";
                                     }
                                     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 = "&nbsp;";
                                     }
                                 }
                             }
                         }
                         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);
 }
コード例 #6
0
} else {
    $present = 1;
}
$mk_group = '';
$tm_group = '';
if (!empty($_GET['group'])) {
    if ($teamsm) {
        $tm_group = $_GET['group'];
    } else {
        $mk_group = $_GET['group'];
    }
}
//
//	Check if relay event
//
$relay = AA_checkRelay($event);
$combined = AA_checkCombined($event, $round);
$svm = AA_checkSVM(0, $round);
// decide whether to show club or team name
//
// Update absent status
//
if ($_GET['arg'] == 'change') {
    mysql_query("LOCK TABLES serienstart READ, staffel as st READ ,  start as s READ,start as s2 READ, verein as v READ, staffelathlet as stat READ, anmeldung as a READ,athlet as at READ,wettkampf as w READ, disziplin_de as d READ, disziplin_fr as d READ , disziplin_it as d READ, wettkampf WRITE, start WRITE");
    if ($comb > 0) {
        // if combined set present for all starts
        /*$res = mysql_query("SELECT * FROM
        			serienstart
        			, start
        			, wettkampf
        		WHERE
コード例 #7
0
 $v = "";
 // current club
 $ck = "";
 // current contest category
 $dd = "";
 // current discipline
 $m = "";
 // current discipline
 $paymentPrint = true;
 $i = 0;
 $disc_print = '';
 // full list, sorted by name or start nbr
 while ($row = mysql_fetch_row($result)) {
     // print previous athlete, if any
     $pl = false;
     $relay = AA_checkRelay($row[21]);
     if ($relay && $row[3] != NULL) {
         continue;
     }
     if ($row[3] == NULL) {
         if ($s != $row[23] && $i > 0) {
             $pl = true;
         }
     } else {
         if ($a != $row[0] && $i > 0) {
             $pl = true;
         }
     }
     if ($pl) {
         $count_td = split('<td>', $disc);
         $len = count($count_td);
コード例 #8
0
 function AA_regie_Track($event, $round, $layout, $cat, $disc)
 {
     require './lib/cl_gui_menulist.lib.php';
     require './lib/cl_gui_resulttable.lib.php';
     require './config.inc.php';
     require './lib/common.lib.php';
     require './lib/results.lib.php';
     $relay = AA_checkRelay($event);
     // check, if this is a relay event
     $status = AA_getRoundStatus($round);
     $combined = AA_checkCombined(0, $round);
     $eval = AA_results_getEvaluationType($round);
     if ($eval == $cfgEvalType[$strEvalTypeAll] || $eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club'])) {
         // eval all heats together
         $heatorder = "";
     } else {
         // default: rank results per heat
         $heatorder = "serie.xSerie, ";
     }
     // show qualification info if another round follows
     $nextRound = AA_getNextRound($event, $round);
     if ($nextRound > 0) {
         $result = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tQualifikationSieger\r\n\t\t\t\t\t, QualifikationLeistung\r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde\r\n\t\t\t\tWHERE xRunde = {$round}\r\n\t\t\t");
         if (mysql_errno() > 0) {
             // DB error
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             if (($row = mysql_fetch_row($result)) == TRUE) {
             }
             echo "{$strQualification}: {$row['0']} {$strQualifyTop}, {$row['1']} {$strQualifyPerformance}";
             echo "<p/>";
         }
         // ET DB error
         mysql_free_result($result);
     }
     // ET next round
     mysql_query("\r\n                LOCK TABLES\r\n                    resultat READ\r\n                    , serie READ\r\n                    , start READ                    \r\n                    , serienstart READ\r\n                     , runde as r READ  \r\n                    , resultat as r READ\r\n                    , serie as s READ\r\n                    , start as st READ                    \r\n                    , serienstart as ss READ\r\n                    , anmeldung as a READ \r\n                    , athlet as at READ \r\n                    , verein as v READ \r\n                    , anlage as an READ \r\n                    , rundentyp as rt READ   \r\n                    , tempTrack WRITE\r\n            ");
     mysql_query("TRUNCATE TABLE tempTrack");
     // if this is a combined event, rank all rounds togheter
     $roundSQL = "";
     if ($combined) {
         $roundSQL = "WHERE serie.xRunde IN (";
         $res_c = mysql_query("SELECT xRunde FROM runde WHERE xWettkampf = {$event}");
         while ($row_c = mysql_fetch_array($res_c)) {
             $roundSQL .= $row_c[0] . ",";
         }
         $roundSQL = substr($roundSQL, 0, -1) . ")";
     } else {
         $roundSQL = "WHERE serie.xRunde = {$round}";
     }
     if (mysql_errno() > 0) {
         // DB error
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $sql = "SELECT DISTINCT \r\n                           resultat.Leistung, \r\n                           serienstart.xSerienstart, \r\n                           serienstart.xSerie, \r\n                           serienstart.xStart, \r\n                           serie.Wind \r\n                     FROM \r\n                           resultat \r\n                           LEFT JOIN serienstart USING(xSerienstart) \r\n                           LEFT JOIN serie USING(xSerie) \r\n                           " . $roundSQL . " \r\n                     ORDER BY " . $heatorder . "\r\n                            resultat.Leistung ASC;";
         $result = mysql_query($sql);
         $heat = 0;
         $perf = 0;
         $perfRounded = 0;
         $i = 0;
         $rank = 0;
         while ($row = mysql_fetch_row($result)) {
             // check on codes < 0
             if ($row[0] < 0) {
                 mysql_query("INSERT INTO tempTrack SET" . " Leistung = " . $row[0] . " , xSerienstart = " . $row[1] . " , xSerie = " . $row[2] . " , rang = 0");
             } else {
                 if (!($eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club']))) {
                     if ($eval != $cfgEvalType[$strEvalTypeAll] && $heat != $row[2]) {
                         $i = 0;
                         // restart ranking   (not SVM with single heat)
                         $perf = 0;
                         $perfRounded = 0;
                     }
                 }
                 $i++;
                 // increment ranking
                 if ($perf < $row[0]) {
                     // compare with previous performance
                     $rank = $i;
                     // next rank (only if not same performance)
                 }
                 mysql_query("INSERT INTO tempTrack SET " . " Leistung = " . $row[0] . " , xSerienstart = " . $row[1] . " , xSerie = " . $row[2] . " , rang = " . $rank);
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
                 $heat = $row[2];
                 // keep current heat ID
                 $perf = $row[0];
                 // keep current performance
             }
             mysql_free_result($temp);
         }
         // display all athletes
         if ($relay == FALSE) {
             // single event
             $query = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tr.Bahnen\r\n\t\t\t\t\t, rt.Name\r\n\t\t\t\t\t, rt.Typ\r\n\t\t\t\t\t, s.xSerie\r\n\t\t\t\t\t, s.Bezeichnung\r\n\t\t\t\t\t, s.Wind\r\n\t\t\t\t\t, s.Film\r\n\t\t\t\t\t, s.Status\r\n\t\t\t\t\t, ss.xSerienstart\r\n\t\t\t\t\t, ss.Position\r\n\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t, ss.Qualifikation\r\n\t\t\t\t\t, a.Startnummer\r\n\t\t\t\t\t, at.Name\r\n\t\t\t\t\t, at.Vorname\r\n\t\t\t\t\t, at.Jahrgang\r\n\t\t\t\t\t, v.Name\r\n\t\t\t\t\t, LPAD(s.Bezeichnung,5,'0') as heatid\r\n\t\t\t\t\t, at.Land\r\n\t\t\t\t\t, st.Bestleistung\r\n\t\t\t\t\t, at.xAthlet\r\n                    , t.rang  \r\n                    , if (ss.Rang = 0, 999999, ss.Rang) as orderRang    \r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde AS r\r\n\t\t\t\t\tLEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n\t\t\t\t\tLEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n\t\t\t\t\tLEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n\t\t\t\t\tLEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n\t\t\t\t\tLEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n\t\t\t\t\tLEFT JOIN verein AS v  ON (v.xVerein = at.xVerein)\r\n                    LEFT JOIN tempTrack AS t ON (t.xSerienstart = ss.xSerienstart)  \r\n\t\t\t\t    LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n\t\t\t\t    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n\t\t\t\tWHERE \r\n                    r.xRunde = {$round}    \t\t\t\t\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\theatid\r\n\t\t\t\t\t, orderRang\r\n\t\t\t";
         } else {
             // relay event
             $query = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tr.Bahnen\r\n\t\t\t\t\t, rt.Name\r\n\t\t\t\t\t, rt.Typ\r\n\t\t\t\t\t, s.xSerie\r\n\t\t\t\t\t, s.Bezeichnung\r\n\t\t\t\t\t, s.Wind\r\n\t\t\t\t\t, s.Film\r\n\t\t\t\t\t, s.Status\r\n\t\t\t\t\t, ss.xSerienstart\r\n\t\t\t\t\t, ss.Position\r\n\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t, ss.Qualifikation\r\n\t\t\t\t\t, sf.Name\r\n\t\t\t\t\t, v.Name\r\n\t\t\t\t\t, LPAD(s.Bezeichnung,5,'0') as heatid\r\n\t\t\t\t\t, r.xRunde\r\n\t\t\t\t\t, st.xStart\r\n                    , t.rang \r\n                    , if (ss.Rang = 0, 999999, ss.Rang) as orderRang    \r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde AS r\r\n\t\t\t\t\tLEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n\t\t\t\t\tLEFT JOIN serienstart AS ss  ON (ss.xSerie = s.xSerie )\r\n\t\t\t\t\tLEFT JOIN start AS st ON (st.xStart = ss.xStart) \r\n\t\t\t\t\tLEFT JOIN staffel AS sf ON (sf.xStaffel = st.xStaffel) \r\n\t\t\t\t\tLEFT JOIN verein AS v ON (v.xVerein = sf.xVerein) \r\n                    LEFT JOIN tempTrack AS t ON (t.xSerienstart = ss.xSerienstart)   \r\n\t\t\t\t    LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n\t\t\t\t    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n\t\t\t\tWHERE \r\n                    r.xRunde = {$round}  \t\t\t\t\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\theatid\r\n\t\t\t\t\t, orderRang\r\n\t\t\t";
         }
         $result = mysql_query($query);
         if (mysql_errno() > 0) {
             // DB error
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             // initialize variables
             $h = 0;
             // heat counter
             $p = 0;
             // position counter (to evaluate empty heats
             $tracks = 0;
             $resTable = new GUI_TrackResultTable($round, $layout, $status, $nextRound);
             $resTable->printHeatTitleRegie($cat, $disc);
             while ($row = mysql_fetch_row($result)) {
                 $p++;
                 // increment position counter
                 /*
                  *  Heat headerline
                  */
                 if ($h != $row[3]) {
                     $tracks = $row[0];
                     // keep nbr of planned tracks
                     // fill previous heat with empty tracks
                     if ($p > 1) {
                         $resTable->printEmptyTracks($p, $tracks, 5 + $c);
                     }
                     $h = $row[3];
                     // keep heat ID
                     $p = 1;
                     // start with track one
                     if (is_null($row[1])) {
                         // only one round
                         $title = "{$strFinalround} {$row['4']}";
                     } else {
                         // more than one round
                         $title = "{$row['1']}: {$row['2']}{$row['4']}";
                     }
                     // increment colspan to include ranking and qualification
                     $c = 0;
                     if ($status == $cfgRoundStatus['results_done']) {
                         $c++;
                         if ($nextRound > 0) {
                             $c++;
                         }
                     }
                     $resTable->printHeatTitle($row[3], $row[4], $title, $row[7], $row[6], $row[5], 'regie', $relay);
                     if ($relay == FALSE) {
                         // athlete display
                         $resTable->printAthleteHeader('regie');
                     } else {
                         // relay display
                         $resTable->printRelayHeader('regie');
                     }
                 }
                 // ET new heat
                 /*
                  * Empty tracks
                  */
                 if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                     // current track and athlete's position not identical
                     if ($p < $row[9]) {
                         $p = $resTable->printEmptyTracks($p, $row[9] - 1, 6 + $c);
                     }
                 }
                 // ET empty tracks
                 /*
                  * Athlete/Relay data lines
                  */
                 // get performance
                 $perf = '';
                 $perfRounded = '';
                 $res = mysql_query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\trs.xResultat\r\n\t\t\t\t\t\t, rs.Leistung\r\n\t\t\t\t\t\t, rs.Info\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tresultat AS rs\r\n\t\t\t\t\tWHERE rs.xSerienstart = {$row['8']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\trs.Leistung ASC\r\n\t\t\t\t");
                 if (mysql_errno() > 0) {
                     // DB error
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 } else {
                     $resrow = mysql_fetch_row($res);
                     if ($resrow != NULL) {
                         // result found
                         $perf = AA_formatResultTime($resrow[1]);
                         $perfRounded = AA_formatResultTime($resrow[1], true);
                     }
                     mysql_free_result($res);
                 }
                 // ET DB error
                 // print lines
                 if ($relay == FALSE) {
                     $resTable->printAthleteLine($row[9], $row[12], "{$row['13']} {$row['14']}", '', '', AA_formatResultTime($row[19], true), $perfRounded, $row[10], $row[11], '', $row[20], 'regie', $row[21]);
                 } else {
                     // relay
                     // get Athletes
                     $arrAthletes = array();
                     $sql = "SELECT at.Vorname, at.Name FROM\r\n\t\t\t\t\t\t\t\tstaffelathlet as sfat\r\n\t\t\t\t\t\t\t\tLEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n\t\t\t\t\t\t\t\tLEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\tLEFT JOIN athlet as at USING(xAthlet)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tsfat.xStaffelstart = {$row['16']}\r\n\t\t\t\t\t\t\tAND\tsfat.xRunde = {$row['15']}\r\n\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\tsfat.Position";
                     $res_at = mysql_query($sql);
                     if (mysql_errno() > 0) {
                         // DB error
                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                     } else {
                         while ($row_at = mysql_fetch_array($res_at)) {
                             $arrAthletes[] = array($row_at[1], $row_at[0]);
                         }
                     }
                     $arrAthletes = count($arrAthletes) > 0 ? $arrAthletes : 0;
                     $resTable->printRelayLine($row[9], $row[12], $row[13], $perfRounded, $row[10], $row[11], $arrAthletes, 'regie', $row[17]);
                 }
             }
             // Fill last heat with empty tracks for disciplines run in
             // individual tracks
             if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                 if ($p > 0) {
                     // heats set up
                     $p++;
                     $resTable->printEmptyTracks($p, $tracks, 6 + $c);
                 }
             }
             // ET track disciplines
             $resTable->endTable();
             mysql_free_result($result);
         }
         // ET DB error
     }
     mysql_query("UNLOCK TABLES");
 }
コード例 #9
0
ファイル: results.lib.php プロジェクト: laiello/athletica
 function AA_results_getTimingOmega($round, $arg = false, $noerror = false)
 {
     require './lib/results_track.lib.php';
     global $cfgInvalidResult, $strErrTimingWrongRegid, $cfgRoundStatus;
     $count_results = 0;
     $number_results = 0;
     $omega = new omega($noerror);
     if ($omega->is_configured() == false) {
         return;
     }
     $results = $omega->get_lstrslt();
     $status = $omega->get_lststatu();
     $infos = $omega->get_lstrrslt();
     //print_r($results);
     if (($results && $status && $infos) == false) {
         return;
     }
     $relay = AA_checkRelay(0, $round);
     if ($arg) {
         $sqladd = "AND ru.Status = " . $cfgRoundStatus['heats_done'];
     } else {
         $sqladd = "";
     }
     mysql_query("\r\n\t\tLOCK TABLES \r\n\t\t\tserie as s WRITE\r\n\t\t\t, resultat as r WRITE\r\n\t\t\t, resultat WRITE\r\n            , resultat as re READ\r\n\t\t\t, runde as ru WRITE\r\n            , runde WRITE\r\n\t\t\t, serienstart as sst READ\r\n            , serienstart as se READ \r\n            , serienstart as ss READ \r\n            , serie as s READ\r\n\t\t\t, start as st READ\r\n\t\t\t, anmeldung as a READ\r\n\t\t\t, disziplin_de READ\r\n            , disziplin_fr READ \r\n            , disziplin_it READ \r\n            , disziplin_de as d READ\r\n            , disziplin_fr as d READ \r\n            , disziplin_it as d READ \r\n\t\t\t, wettkampf READ\r\n            , wettkampf as w READ   \r\n\t\t\t, staffel as sf READ\r\n            , kategorie as k READ");
     $res_film = mysql_query("\r\n\t\tSELECT s.Film, ru.xWettkampf FROM \r\n\t\t\tserie as s\r\n\t\t\tLEFT JOIN runde as ru USING(xRunde)\r\n\t\tWHERE s.xRunde = {$round}\r\n\t\t{$sqladd}");
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         if ($relay) {
             $sql = "SELECT \r\n                        count(*) \r\n                   FROM\r\n                        serie as s\r\n                        LEFT JOIN serienstart as sst USING(xSerie)\r\n                        LEFT JOIN start as st USING(xStart)\r\n                        LEFT JOIN staffel as sf USING(xStaffel)\r\n                        LEFT JOIN resultat as r ON (sst.xSerienstart=r.xSerienstart)\r\n                   WHERE s.xRunde = " . $round;
         } else {
             $sql = "SELECT \r\n                        count(*) \r\n                   FROM\r\n                        serie as s\r\n                        LEFT JOIN serienstart as sst USING(xSerie)\r\n                        LEFT JOIN start as st USING(xStart)                          \r\n                        LEFT JOIN resultat as r ON (sst.xSerienstart=r.xSerienstart)\r\n                   WHERE s.xRunde = " . $round;
         }
         $res = mysql_query($sql);
         $row = mysql_fetch_array($res);
         if (mysql_errno() > 0) {
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             $number_results = $row[0];
         }
         while ($row_film = mysql_fetch_array($res_film)) {
             $nr = $row_film[0];
             $event = $row_film[1];
             // get only the official results (end of judgement)
             if ($infos[$nr][8] == 'Official') {
                 // save infos like wind
                 //$timingInf[$nr] = $infos[$nr];
                 $wind = $infos[$nr][5];
                 if ($wind == 'N/A') {
                     $wind = "";
                 } else {
                     $wind = substr($wind, 0, 5);
                     // Korrektur um auf allen Versionen der OMEGA-Zeitmessung korrekte positive Winde zu übermitteln
                     // Paul Rohrer LC Basel Juni 2014
                     if (substr($wind, 0, 1) == "-") {
                         $wind = "-" . trim(substr($wind, 1, 4));
                     } elseif (substr($wind, 0, 1) == "+") {
                         $wind = trim(substr($wind, 1, 4));
                     } else {
                         // positiver Wind ab der ersten Position zu lesen
                         $wind = trim(substr($wind, 0, 4));
                     }
                     // round fraction hundert up
                     $wind = ceil($wind * 10) / 10;
                     $wind = sprintf("%01.1f", $wind);
                 }
                 mysql_query("UPDATE serie as s SET Wind = '" . $wind . "'\r\n\t\t\t\t\t\tWHERE xRunde = {$round} AND Film = {$nr}");
                 foreach ($results as $val) {
                     $reaction_time = false;
                     if ($val[0] == $nr) {
                         // add results to timingRes (array key is the registration id of the athlete)
                         //$timingRes[$val[4]] = $val;
                         // get status text for id (ok, dns, dnf, dq)
                         //$timingRes[$val[4]][6] = $status[$val[6]][2];
                         switch ($status[$val[6]][2]) {
                             case "DNS":
                                 $perf = $cfgInvalidResult['DNS']['code'];
                                 $points = 0;
                                 break;
                             case "DNF":
                                 $perf = $cfgInvalidResult['DNF']['code'];
                                 $points = 0;
                                 break;
                             case "DQ":
                                 $perf = $cfgInvalidResult['DSQ']['code'];
                                 $points = 0;
                                 break;
                             default:
                                 $perf = ceil($val[7] / 10);
                                 if (floor($val[8]) == 0) {
                                     // perf = 0.  --> reaction time
                                     $reaction_time = true;
                                     break;
                                 }
                                 $sex = 'M';
                                 if (!$relay) {
                                     /*$sql = "SELECT Geschlecht
                                     		  FROM serienstart AS sst
                                     	 LEFT JOIN serie AS s USING ( xSerie )
                                     	 LEFT JOIN start AS st ON sst.xStart = st.xStart
                                     	 LEFT JOIN anmeldung AS a ON st.xAnmeldung = a.xAnmeldung
                                     	 LEFT JOIN athlet USING ( xAthlet )
                                     		 WHERE s.xRunde = ".$round."
                                     		   AND s.Film = ".$nr."
                                     		   AND a.Startnummer = ".$val[4].";";*/
                                     $sql_sex = "SELECT DISTINCT(k.Geschlecht) AS Geschlecht\r\n\t\t\t\t\t\t\t\t\t\t\t  FROM kategorie as k \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN wettkampf USING(xKategorie) \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN start AS st USING(xWettkampf)\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN serienstart AS sst  USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN serie AS s USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\t\t WHERE s.XRunde = " . $round . " \r\n\t\t\t\t\t\t\t\t\t\t\t   AND s.Film = " . $nr . ";";
                                     $query = mysql_query($sql_sex);
                                     if (mysql_errno() > 0) {
                                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                     }
                                     if ($query && mysql_num_rows($query) == 1) {
                                         $sex = mysql_result($query, 0, 'Geschlecht');
                                     }
                                 }
                         }
                         if (!$reaction_time) {
                             if ($relay == false) {
                                 $res = mysql_query("\r\n\t\t\t\t\t\t\t\t    SELECT xResultat, sst.xSerienstart FROM\r\n\t\t\t\t\t\t\t\t\t    resultat as r\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN serienstart as sst USING(xSerienstart)\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN serie as s USING (xSerie)\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN start as st ON sst.xStart = st.xStart\r\n\t\t\t\t\t\t\t\t\t    LEFT JOIN anmeldung as a ON st.xAnmeldung = a.xAnmeldung\r\n\t\t\t\t\t\t\t\t    WHERE s.xRunde = {$round}\r\n\t\t\t\t\t\t\t\t    AND s.Film = {$nr}\r\n\t\t\t\t\t\t\t\t    AND a.Startnummer = " . $val[4]);
                                 if (mysql_num_rows($res) == 0) {
                                     // insert result
                                     $res = mysql_query("\r\n\t\t\t\t\t\t\t\t\t    SELECT sst.xSerienstart FROM\r\n\t\t\t\t\t\t\t\t\t\t    serie as s\r\n\t\t\t\t\t\t\t\t\t\t    LEFT JOIN serienstart as sst USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\t    LEFT JOIN start as st USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\t    LEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\t\t    WHERE\ta.Startnummer = " . $val[4] . "\r\n\t\t\t\t\t\t\t\t\t    AND\ts.Film = {$nr}\r\n\t\t\t\t\t\t\t\t\t    AND\ts.xRunde = {$round}");
                                     if (mysql_num_rows($res) == 0) {
                                         // no athlete with this registration id is started
                                         if ($noerror == false) {
                                             AA_printErrorMsg($strErrTimingWrongRegid);
                                         }
                                     } else {
                                         $row = mysql_fetch_array($res);
                                         $count_results++;
                                         $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[0]);
                                         mysql_query("\r\n\t\t\t\t\t\t\t\t\t\t    INSERT INTO resultat\r\n\t\t\t\t\t\t\t\t\t\t    SET \tLeistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\t, xSerienstart = " . $row[0]);
                                         AA_StatusChanged(mysql_insert_id());
                                     }
                                 } else {
                                     // update
                                     $count_results++;
                                     $row = mysql_fetch_array($res);
                                     $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[1]);
                                     mysql_query("UPDATE resultat as r SET Leistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t    , Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t        WHERE xResultat = " . $row[0]);
                                     AA_StatusChanged($row[0]);
                                 }
                                 //
                             } else {
                                 // relay event
                                 //
                                 // set startnumber - 999 because of this omega trick (nbr = 999XXX)
                                 //$val[4] = substr($val[4],3); <-- changed
                                 /*	$res = mysql_query("
                                 			   	SELECT xResultat FROM
                                 					resultat as r
                                 					LEFT JOIN serienstart as sst USING(xSerienstart)
                                 					LEFT JOIN serie as s USING (xSerie)
                                 					LEFT JOIN start as st ON sst.xStart = st.xStart
                                 					LEFT JOIN staffel as sf ON st.xStaffel = a.xStaffel
                                 				WHERE s.xRunde = $round
                                 				AND s.Film = $nr
                                 				AND sf.Startnummer = ".$val[4]
                                 			); */
                                 $res = mysql_query("\r\n\t\t\t\t\t\t\t   \t\tSELECT \r\n\t\t\t\t\t\t\t   \t\t\tr.xResultat, sst.xSerienstart ,  k.Geschlecht\r\n\t\t\t\t\t\t\t   \t\tFROM\r\n\t\t\t\t\t\t\t\t\t\tserie as s\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN serienstart as sst USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN start as st USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN staffel as sf USING(xStaffel)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN resultat as r ON (sst.xSerienstart=r.xSerienstart)\r\n                                        LEFT JOIN kategorie AS k ON ( k.xKategorie = sf.xKategorie )\r\n\t\t\t\t\t\t\t\t\tWHERE s.xRunde = {$round}\r\n\t\t\t\t\t\t\t\t\tAND s.Film = {$nr}\r\n\t\t\t\t\t\t\t\t\tAND sf.Startnummer = " . $val[4]);
                                 if (mysql_errno() > 0) {
                                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                 }
                                 $row = mysql_fetch_array($res);
                                 if (mysql_num_rows($res) == 0) {
                                     // no athlete with this registration id is started
                                     if ($noerror == false) {
                                         AA_printErrorMsg($strErrTimingWrongRegid);
                                     }
                                 } else {
                                     $sex = $row[2];
                                     $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[1]);
                                     if (empty($row[0])) {
                                         // insert result
                                         $count_results++;
                                         mysql_query("\r\n\t\t\t\t\t\t\t\t\t\t\tINSERT INTO resultat\r\n\t\t\t\t\t\t\t\t\t\t\tSET \tLeistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\t\t, xSerienstart = " . $row[1]);
                                         AA_StatusChanged(mysql_insert_id());
                                     } else {
                                         // update
                                         $count_results++;
                                         mysql_query("UPDATE resultat as r SET Leistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE xResultat = " . $row[0]);
                                         AA_StatusChanged($row[0]);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // end foreach
                 // results updated, now set status for event time table
                 mysql_query("UPDATE runde as ru SET StatusZeitmessung = 1 WHERE xRunde = {$round}");
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
             }
         }
         // end while
     }
     mysql_query("UNLOCK TABLES");
     // all results from omega for this round and automatic ranking is 'y'
     if ($count_results == $number_results && $_SESSION['meeting_infos']['AutoRangieren'] == 'y') {
         $layout = AA_getDisciplineType($round);
         // type determines layout
         $_GET['arg'] = 'results_done';
         $autoRank = true;
         AA_results_Track($round, $layout, $autoRank);
         // ranking
     }
 }
コード例 #10
0
    function AA_results_Track($round, $layout, $content_navi, $cat, $disc, $rtyp, $event)
    {
        require './config.inc.php';
        require './config.inc.end.php';
        require './lib/common.lib.php';
        require './lib/heats.lib.php';
        require './lib/utils.lib.php';
        require_once './lib/timing.lib.php';
        $p = "./tmp";
        $fp = @fopen($p . "/live" . $round . ".html", 'w');
        if (!$fp) {
            AA_printErrorMsg($GLOBALS['strErrFileOpenFailed']);
            return;
        }
        $relay = AA_checkRelay($event);
        // check, if this is a relay event
        $svm = AA_checkSVM(0, $round);
        // decide whether to show club or team name
        global $content;
        $mergedMain = AA_checkMainRound($round);
        if ($mergedMain == 1) {
            $round = AA_getMainRound($round);
        }
        // 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];
        }
        // read round data
        if ($round > 0) {
            $content = $cfgHtmlStart1;
            if (empty($GLOBALS['cfgDir'])) {
                $content .= "<meta http-equiv='refresh' content='" . $GLOBALS['cfgMonitorReload'] . ";  url=http://" . $url . "/live" . $round . ".html'>";
            } else {
                $content .= "<meta http-equiv='refresh' content='" . $GLOBALS['cfgMonitorReload'] . ";  url=http://" . $url . "/" . $GLOBALS['cfgDir'] . "/live" . $round . ".html'>";
            }
            $content .= $cfgHtmlStart2;
            $content .= $content_navi;
            $content .= "</div ><div id='content_pc'><div id='content_pda'>";
            $content .= "<h1>{$strStartlist} " . $_COOKIE['meeting'] . "</h1>";
            // title
            if (!empty($rtyp)) {
                $content .= "<h2>{$cat} {$disc}, {$rtyp}</h2>";
            } else {
                $content .= "<h2>{$cat} {$disc}</h2>";
            }
            $content .= "<table class='dialog'>";
            // check if round is final
            $sql_r = "SELECT \r\n                    rt.Typ\r\n                FROM\r\n                    athletica.runde as r\r\n                    LEFT JOIN athletica.rundentyp_" . $_COOKIE['language'] . " as rt USING (xRundentyp)\r\n                WHERE\r\n                    r.xRunde=" . $round;
            $res_r = mysql_query($sql_r);
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            }
            $order = "ASC";
            if (mysql_num_rows($res_r) == 1) {
                $row_r = mysql_fetch_row($res_r);
                if ($row_r[0] == 'F') {
                    $order = "DESC";
                }
            }
            // display all athletes
            if ($relay == FALSE) {
                // single event
                $query = "SELECT \r\n                                r.Bahnen\r\n                                , rt.Name\r\n                                , rt.Typ\r\n                                , s.xSerie\r\n                                , s.Bezeichnung\r\n                                , s.Wind\r\n                                , s.Film\r\n                                , an.Bezeichnung\r\n                                , ss.xSerienstart\r\n                                , ss.Position\r\n                                , ss.Rang\r\n                                , ss.Qualifikation\r\n                                , a.Startnummer\r\n                                , at.Name\r\n                                , at.Vorname\r\n                                , at.Jahrgang  \r\n                                , if('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo))  \r\n                                , LPAD(s.Bezeichnung,5,'0') as heatid\r\n                                , s.Handgestoppt\r\n                                , at.Land   \r\n                                , ss.Bemerkung  \r\n                                , at.xAthlet                    \r\n                         FROM \r\n                                athletica.runde AS r\r\n                                LEFT JOIN athletica.serie AS s ON (s.xRunde = r.xRunde)\r\n                                LEFT JOIN athletica.serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n                                LEFT JOIN athletica.start AS st ON (st.xStart = ss.xStart)\r\n                                LEFT JOIN athletica.anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n                                LEFT JOIN athletica.athlet AS at ON (at.xAthlet = a.xAthlet)\r\n                                LEFT JOIN athletica.verein AS v ON (v.xVerein = at.xVerein)\r\n                                LEFT JOIN athletica.team AS t ON(a.xTeam = t.xTeam)\r\n                                LEFT JOIN athletica.rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n                                LEFT JOIN athletica.anlage AS an ON an.xAnlage = s.xAnlage\r\n                         WHERE\r\n                                r.xRunde = " . $round . "   \r\n                         ORDER BY heatid " . $order . ", ss.Position";
            } else {
                // relay event
                $query = "SELECT \r\n                            r.Bahnen\r\n                            , rt.Name\r\n                            , rt.Typ\r\n                            , s.xSerie\r\n                            , s.Bezeichnung\r\n                            , s.Wind\r\n                            , s.Film\r\n                            , an.Bezeichnung\r\n                            , ss.xSerienstart\r\n                            , ss.Position\r\n                            , ss.Rang\r\n                            , ss.Qualifikation\r\n                            , sf.Name\r\n                            , if('" . $svm . "', t.Name, v.Name)  \r\n                            , LPAD(s.Bezeichnung,5,'0') as heatid\r\n                            , s.Handgestoppt\r\n                            , ss.Bemerkung   \r\n                     FROM \r\n                            athletica.runde AS r\r\n                            LEFT JOIN athletica.serie AS s ON (s.xRunde = r.xRunde)\r\n                            LEFT JOIN athletica.serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n                            LEFT JOIN athletica.start AS st ON (st.xStart = ss.xStart)\r\n                            LEFT JOIN athletica.staffel AS sf ON (sf.xStaffel = st.xStaffel)\r\n                            LEFT JOIN athletica.verein AS v ON (v.xVerein = sf.xVerein)                    \r\n                            LEFT JOIN athletica.team AS t ON(sf.xTeam = t.xTeam)\r\n                            LEFT JOIN athletica.rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n                            LEFT JOIN athletica.anlage AS an ON an.xAnlage = s.xAnlage\r\n                     WHERE \r\n                            r.xRunde = " . $round . "                          \r\n                    ORDER BY heatid " . $order . ", ss.Position";
            }
            $result = mysql_query($query);
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            } else {
                // initialize variables
                $h = 0;
                // heat counter
                $p = 0;
                // position counter (to evaluate empty heats
                $i = 0;
                // input counter (an individual id is assigned to each
                // input field, focus is then moved to the next input
                // field by calling $i+1)
                $rowclass = 'odd';
                $tracks = 0;
                while ($row = mysql_fetch_row($result)) {
                    $p++;
                    // increment position counter
                    /*
                     *  Heat headerline
                     */
                    if ($h != $row[3]) {
                        $tracks = $row[0];
                        // keep nbr of planned tracks
                        // fill previous heat with empty tracks
                        if ($p > 1) {
                            printEmptyTracks($p, $tracks, 5 + $c);
                        }
                        $h = $row[3];
                        // keep heat ID
                        $p = 1;
                        // start with track one
                        if (is_null($row[1])) {
                            // only one round
                            $title = "{$strFinalround}";
                        } else {
                            // more than one round
                            $title = "{$row['1']}";
                        }
                        // increment colspan to include ranking and qualification
                        $c = 0;
                        if ($status == $cfgRoundStatus['results_done']) {
                            $c++;
                            if ($nextRound > 0) {
                                $c++;
                            }
                        }
                        $content .= "</table><table class='dialog'>";
                        $content .= "<tr>";
                        $content .= "<th class='dialog' colspan='2'>" . $title . " " . $row[4] . "</th>";
                        if ($relay == FALSE) {
                            $content .= "<th class='dialog' colspan='4'>" . $strFilm . " " . $row[6] . "</th>";
                        } else {
                            $content .= "<th class='dialog' colspan='2'>" . $strFilm . " " . $row[6] . "</th>";
                        }
                        $i++;
                        // next element
                        $content .= "<tr>";
                        /*
                         *  Column header
                         */
                        if ($relay == FALSE) {
                            // athlete display
                            $content .= "<tr>";
                            $content .= "<th class='dialog'>" . $strPositionShort . "</th>";
                            $content .= "<th class='dialog'>" . $strStartnumber . "</th>";
                            $content .= "<th class='dialog' >" . $strAthlete . "</th>";
                            $content .= "<th class='dialog_pc'>" . $strYearShort . "</th>";
                            $content .= "<th class='dialog_pc'>" . $strCountry . "</th>";
                            $content .= "<th class='dialog_pc'>";
                            if ($svm) {
                                $content .= $strTeam;
                            } else {
                                $content .= $strClub;
                            }
                            $content .= "</th>";
                        } else {
                            // relay display
                            $content .= "<tr>";
                            $content .= "<th class='dialog'>" . $strPositionShort . "</th>";
                            $content .= "<th class='dialog'>" . $strRelay . "</th>";
                            $content .= "<th class='dialog_pc'>";
                            if ($svm) {
                                $content .= $strTeam;
                            } else {
                                $content .= $strClub;
                            }
                            $content .= "</th>";
                        }
                        $content .= "</tr>";
                    }
                    // ET new heat
                    /*
                     * Empty tracks
                     */
                    if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                        // current track and athlete's position not identical
                        if ($p < $row[9]) {
                            $p = printEmptyTracks($p, $row[9] - 1, 5 + $c);
                        }
                    }
                    // ET empty tracks
                    /*
                     * Athlete data lines
                     */
                    $p = $row[9];
                    // keep position
                    if ($p % 2 == 0) {
                        // even row numer
                        $rowclass = 'even';
                    } else {
                        // odd row number
                        $rowclass = 'odd';
                    }
                    if ($relay == FALSE) {
                        $content .= "<tr class='" . $rowclass . "'>";
                        $content .= "<td class='forms_right'>" . $row[9] . "</td>";
                        /* position */
                        $content .= "<td class='forms_right'>" . $row[12] . "</td>";
                        /* start nbr */
                        $content .= "<td>" . $row[13] . " " . $row[14] . "</td>";
                        /* name */
                        $content .= "<td class='forms_ctr_pc'>" . AA_formatYearOfBirth($row[15]) . "</td>";
                        $content .= "<td class='forms_pc'>";
                        if ($row[19] != '' && $row[19] != '-') {
                            $content .= $row[19];
                        } else {
                            $content .= " ";
                        }
                        $content .= "</td>";
                        $content .= "<td class='forms_pc' nowrap>" . $row[16] . "</td>";
                        /* club */
                    } else {
                        // relay
                        $content .= "<tr class='" . $rowclass . "'>";
                        $content .= "<td class='forms_right'>" . $row[9] . "</td>";
                        /* position */
                        $content .= "<td>" . $row[12] . "</td>";
                        /* relay name */
                        $content .= "<td>" . $row[13] . "</td>";
                        /* club */
                    }
                }
                // Fill last heat with empty tracks for disciplines run in
                // individual tracks
                if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                    if ($p > 0) {
                        // heats set up
                        $p++;
                        printEmptyTracks($p, $tracks, 5 + $c);
                    }
                }
                // ET track disciplines
                mysql_free_result($result);
                // $list->endPage();    // end HTML page for printing
                $content .= "</table>";
                $content .= $cfgHtmlFooter;
                $content .= "</div ></div>";
                $content .= $cfgHtmlEnd;
                if (!fwrite($fp, $content)) {
                    AA_printErrorMsg($GLOBALS['strErrFileWriteFailed']);
                    return;
                }
                fclose($fp);
            }
            // ET DB error
        }
        // ET round selected
        AA_UpdateStatusChanged($round);
        ?>
</body>
</html>
<?php 
    }
コード例 #11
0
 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'] . "&nbsp;&nbsp;&nbsp;";
                     }
                     $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 = "&nbsp;";
                                     }
                                     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 = "&nbsp;";
                                     }
                                 }
                             }
                         }
                         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'] . "&nbsp;&nbsp;&nbsp;";
                             }
                             $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 = "&nbsp;";
                                             }
                                             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 = "&nbsp;";
                                             }
                                         }
                                     }
                                 }
                                 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
 }
コード例 #12
0
ファイル: cl_alge.lib.php プロジェクト: laiello/athletica
 /**
  * export a round to alge
  * 
  * exportet are 2 files, .txt (competitiors) and .rac (race information)
  * - param round
  */
 function export_round($round)
 {
     $relay = AA_checkRelay(0, $round);
     mysql_query("LOCK TABLES wettkampf as w READ, runde as r READ\r\n\t\t\t\t\t, serie as s READ, disziplin_de as d READ , disziplin_fr as d READ  , disziplin_it as d READ  \r\n\t\t\t\t\t, rundentyp_de as rt READ, rundentyp_fr as rt READ, rundentyp_it as rt READ\r\n                    , kategorie as k READ\r\n\t\t\t\t\t, anmeldung as a READ, athlet as at READ\r\n\t\t\t\t\t, start as st READ, serienstart as ss READ\r\n\t\t\t\t\t, verein as v READ, meeting as m READ\r\n\t\t\t\t\t, stadion as sta, staffel as sf READ");
     $file = $this->make_filename($round);
     // get each heat with race informations
     /*$sql = "SELECT 
     			s.xSerie
     			, m.Name
     			, m.Ort
     			, d.Kurzname
     			, k.Name
     			, rt.Name
     			, w.xWettkampf
     			, d.Strecke
     			, s.Film
     			, s.Bezeichnung
     			, sta.Name
     		FROM
     			meeting as m
     			, wettkampf as w
     			, disziplin as d
     			, kategorie as k
     			, runde as r
     			, serie as s
     			, rundentyp as rt
     			, stadion as sta
     		WHERE	r.xRunde = $round
     		AND	w.xWettkampf = r.xWettkampf
     		AND	m.xMeeting = w.xMeeting
     		AND	sta.xStadion = m.xStadion
     		AND	d.xDisziplin = w.xDisziplin
     		AND	k.xKategorie = w.xKategorie
     		AND	s.xRunde = r.xRunde
     		AND	rt.xRundentyp = r.xRundentyp
     		AND	w.Zeitmessung = 1
     		";*/
     $sql = "SELECT s.xSerie, \r\n\t\t\t\t\t\t   m.Name, \r\n\t\t\t\t\t\t   m.Ort, \r\n\t\t\t\t\t\t   d.Kurzname, \r\n\t\t\t\t\t\t   k.Name, \r\n\t\t\t\t\t\t   rt.Name, \r\n\t\t\t\t\t\t   w.xWettkampf, \r\n\t\t\t\t\t\t   d.Strecke, \r\n\t\t\t\t\t\t   s.Film, \r\n\t\t\t\t\t\t   s.Bezeichnung, \r\n\t\t\t\t\t\t   sta.Name,\r\n                           d.Code \r\n\t\t\t\t\t  FROM meeting AS m \r\n\t\t\t\t LEFT JOIN wettkampf AS w USING(xMeeting) \r\n\t\t\t\t LEFT JOIN disziplin_" . $_COOKIE['language'] . " AS d USING(xDisziplin) \r\n\t\t\t\t LEFT JOIN kategorie AS k ON(w.xKategorie = k.xKategorie) \r\n\t\t\t\t LEFT JOIN runde AS r ON(w.xWettkampf = r.xWettkampf) \r\n\t\t\t\t LEFT JOIN serie AS s USING(xRunde) \r\n\t\t\t\t LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON(r.xRundentyp = rt.xRundentyp) \r\n\t\t\t\t LEFT JOIN stadion AS sta ON(m.xStadion = sta.xStadion) \r\n\t\t\t\t\t WHERE r.xRunde = " . $round . " \r\n\t\t\t\t\t   AND w.Zeitmessung = 1;";
     $resHeat = mysql_query($sql);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         while ($rowHeat = mysql_fetch_array($resHeat)) {
             $fileHeat = sprintf("%03d", $rowHeat[8]) . $file . $rowHeat[9];
             // race information (*.rac file)
             // "RaceNo" = Heat Number, no identification
             $windmode = 7;
             // no measurement
             if ($rowHeat[11] == 10 || $rowHeat[11] == 30 || $rowHeat[11] >= 252 & $rowHeat[11] <= 256) {
                 $windmode = 6;
             } elseif ($rowHeat[11] == 35 || $rowHeat[11] == 258 || $rowHeat[11] == 40) {
                 $windmode = 5;
             } elseif ($rowHeat[11] >= 259 & $rowHeat[11] <= 271) {
                 $windmode = 4;
             } elseif ($rowHeat[11] == 50) {
                 $windmode = 3;
             } else {
                 $windmode = 7;
             }
             $tmp = "[RaceInfo]\r\nMeeting={$rowHeat['1']}, {$rowHeat['2']}\r\nPlace={$rowHeat['10']}\r\nCompType={$rowHeat['3']} {$rowHeat['4']} - {$rowHeat['5']}\r\nCompNo={$rowHeat['6']}\r\nDistance={$rowHeat['7']}m\r\nRaceNo={$rowHeat['9']}\r\nPrepared=1\r\nWindmode={$windmode}\r\n[Files]\r\nName={$fileHeat}\r\n";
             $this->send_file($tmp, "{$fileHeat}.rac");
             if ($relay == false) {
                 // starts for each race (*.txt file)
                 $tmp = "";
                 /*$sql = "SELECT
                 			a.Startnummer
                 			, ss.Bahn
                 			, at.Name
                 			, at.Vorname
                 			, v.Name
                 			, at.Jahrgang
                 		FROM 
                 			runde as r
                 			, wettkampf as w
                 			, serie as s
                 			, serienstart as ss
                 			, start as st
                 			, anmeldung as a
                 			, athlet as at
                 			, verein as v
                 		WHERE	s.xSerie = $rowHeat[0]
                 		AND	r.xWettkampf = w.xWettkampf
                 		AND	s.xRunde = r.xRunde
                 		AND	ss.xSerie = s.xSerie
                 		AND	st.xStart = ss.xStart
                 		AND	a.xAnmeldung = st.xAnmeldung
                 		AND	at.xAthlet = a.xAthlet
                 		AND	v.xVerein = at.xVerein";*/
                 $sql = "SELECT a.Startnummer, \r\n\t\t\t\t\t\t\t\t   ss.Bahn, \r\n\t\t\t\t\t\t\t\t   at.Name, \r\n\t\t\t\t\t\t\t\t   at.Vorname, \r\n\t\t\t\t\t\t\t\t   v.Name, \r\n\t\t\t\t\t\t\t\t   at.Jahrgang \r\n\t\t\t\t\t\t\t  FROM runde AS r \r\n\t\t\t\t\t\t LEFT JOIN wettkampf AS w USING(xWettkampf) \r\n\t\t\t\t\t\t LEFT JOIN serie AS s ON(r.xRunde = s.xRunde) \r\n\t\t\t\t\t\t LEFT JOIN serienstart AS ss USING(xSerie) \r\n\t\t\t\t\t\t LEFT JOIN start AS st USING(xStart) \r\n\t\t\t\t\t\t LEFT JOIN anmeldung AS a USING(xAnmeldung) \r\n\t\t\t\t\t\t LEFT JOIN athlet AS at USING(xAthlet) \r\n\t\t\t\t\t\t LEFT JOIN verein AS v USING(xVerein) \r\n\t\t\t\t\t\t\t WHERE s.xSerie = " . $rowHeat[0] . "\r\n                               ORDER BY ss.Position";
                 $res = mysql_query($sql);
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 } else {
                     if (mysql_num_rows($res) == 0) {
                     } else {
                         while ($row = mysql_fetch_array($res)) {
                             $tmp .= "\t{$row['0']}\t{$row['1']}\t" . trim($row[2]) . "\t" . trim($row[3]) . "\t" . trim($row[4]) . "\t{$row['5']}";
                             $tmp .= "\t\t\t999999999\t1\t3";
                             $tmp .= "\t\t\t\t\t999999999\t\t\t\t\r\n";
                         }
                         $this->send_file($tmp, "{$fileHeat}.txt");
                     }
                 }
                 mysql_Free_result($res);
             } else {
                 // relay event
                 // starts for each race (*.txt file)
                 $tmp = "";
                 /*$sql = "SELECT
                 			sf.Startnummer
                 			, ss.Bahn
                 			, sf.Name
                 			, '-'
                 			, v.Name
                 			, '-'
                 		FROM 
                 			runde as r
                 			, wettkampf as w
                 			, serie as s
                 			, serienstart as ss
                 			, start as st
                 			, staffel as sf
                 			, verein as v
                 		WHERE	s.xSerie = $rowHeat[0]
                 		AND	r.xWettkampf = w.xWettkampf
                 		AND	s.xRunde = r.xRunde
                 		AND	ss.xSerie = s.xSerie
                 		AND	st.xStart = ss.xStart
                 		AND	sf.xStaffel = st.xStaffel
                 		AND	v.xVerein = sf.xVerein";*/
                 $sql = "SELECT sf.Startnummer, \r\n\t\t\t\t\t\t\t\t   ss.Bahn, \r\n\t\t\t\t\t\t\t\t   sf.Name, \r\n\t\t\t\t\t\t\t\t   '-', \r\n\t\t\t\t\t\t\t\t   v.Name, \r\n\t\t\t\t\t\t\t\t   '-' \r\n\t\t\t\t\t\t\t  FROM runde AS r \r\n\t\t\t\t\t\t LEFT JOIN wettkampf AS w USING(xWettkampf) \r\n\t\t\t\t\t\t LEFT JOIN serie AS s ON(r.xRunde = s.xRunde) \r\n\t\t\t\t\t\t LEFT JOIN serienstart AS ss USING(xSerie) \r\n\t\t\t\t\t\t LEFT JOIN start AS st USING(xStart) \r\n\t\t\t\t\t\t LEFT JOIN staffel AS sf USING(xStaffel) \r\n\t\t\t\t\t\t LEFT JOIN verein AS v USING(xVerein) \r\n\t\t\t\t\t\t\t WHERE s.xSerie = " . $rowHeat[0] . "\r\n                             ORDER BY ss.Position";
                 $res = mysql_query($sql);
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 } else {
                     if (mysql_num_rows($res) == 0) {
                     } else {
                         while ($row = mysql_fetch_array($res)) {
                             $tmp .= "\t{$row['0']}\t{$row['1']}\t" . trim($row[2]) . "\t" . trim($row[3]) . "\t" . trim($row[4]) . "\t{$row['5']}";
                             $tmp .= "\t\t\t999999999\t1\t3";
                             $tmp .= "\t\t\t\t\t999999999\t\t\t\t\r\n";
                         }
                         $this->send_file($tmp, "{$fileHeat}.txt");
                     }
                 }
                 mysql_Free_result($res);
             }
         }
     }
     mysql_query("UNLOCK TABLES");
 }
コード例 #13
0
 function AA_speaker_Track($event, $round, $layout)
 {
     require './lib/cl_gui_menulist.lib.php';
     require './lib/cl_gui_resulttable.lib.php';
     require './lib/cl_performance.lib.php';
     require './config.inc.php';
     require './lib/common.lib.php';
     $mergedMain = AA_checkMainRound($round);
     if ($mergedMain != 1) {
         $relay = AA_checkRelay($event);
         // check, if this is a relay event
         $status = AA_getRoundStatus($round);
         $svm = AA_checkSVM(0, $round);
         // decide whether to show club or team name
         // No action yet
         if ($status == $cfgRoundStatus['open'] || $status == $cfgRoundStatus['enrolement_done'] || $status == $cfgRoundStatus['heats_in_progress']) {
             AA_printWarningMsg($strHeatsNotDone);
         } else {
             if ($status == $cfgRoundStatus['enrolement_pending']) {
                 AA_printWarningMsg($strEnrolementNotDone);
             } else {
                 if ($status >= $cfgRoundStatus['heats_done']) {
                     // show link to rankinglist if results done
                     if ($status == $cfgRoundStatus['results_done']) {
                         $menu = new GUI_Menulist();
                         $menu->addButton("print_rankinglist.php?event={$event}&round={$round}&type=single&formaction=speaker&show_efforts=none", $GLOBALS['strRankingList']);
                         $menu->addButton("print_rankinglist.php?event={$event}&round={$round}&type=single&formaction=speaker&show_efforts=sb_pb", $GLOBALS['strRankingListEfforts']);
                         $menu->printMenu();
                         echo "<p/>";
                     }
                     // show qualification info if another round follows
                     $nextRound = AA_getNextRound($event, $round);
                     if ($nextRound > 0) {
                         $result = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tQualifikationSieger\r\n\t\t\t\t\t, QualifikationLeistung\r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde\r\n\t\t\t\tWHERE xRunde = {$round}\r\n\t\t\t");
                         if (mysql_errno() > 0) {
                             // DB error
                             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                         } else {
                             if (($row = mysql_fetch_row($result)) == TRUE) {
                             }
                             echo "{$strQualification}: {$row['0']} {$strQualifyTop}, {$row['1']} {$strQualifyPerformance}";
                             echo "<p/>";
                         }
                         // ET DB error
                         mysql_free_result($result);
                     }
                     // ET next round
                     // display all athletes
                     if ($relay == FALSE) {
                         // single event
                         $query = "\r\n                SELECT\r\n                    r.Bahnen\r\n                    , rt.Name\r\n                    , rt.Typ\r\n                    , s.xSerie\r\n                    , s.Bezeichnung\r\n                    , s.Wind\r\n                    , s.Film\r\n                    , s.Status\r\n                    , ss.xSerienstart\r\n                    , ss.Position\r\n                    , ss.Rang\r\n                    , ss.Qualifikation\r\n                    , a.Startnummer\r\n                    , at.Name\r\n                    , at.Vorname\r\n                    , at.Jahrgang\r\n                    , if('" . $svm . "', te.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo))  \r\n                    , LPAD(s.Bezeichnung,5,'0') as heatid\r\n                    , at.Land\r\n                    , st.Bestleistung\r\n                    , at.xAthlet\r\n                FROM\r\n                    runde AS r\r\n                    LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n                    LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie   )\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 team AS te ON(a.xTeam = te.xTeam)\r\n                    LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n                    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n                WHERE \r\n                    r.xRunde = {$round} \r\n                ORDER BY\r\n                    heatid\r\n                    , ss.Position\r\n            ";
                     } else {
                         // relay event
                         $query = "\r\n                SELECT\r\n                    r.Bahnen\r\n                    , rt.Name\r\n                    , rt.Typ\r\n                    , s.xSerie\r\n                    , s.Bezeichnung\r\n                    , s.Wind\r\n                    , s.Film\r\n                    , s.Status\r\n                    , ss.xSerienstart\r\n                    , ss.Position\r\n                    , ss.Rang\r\n                    , ss.Qualifikation\r\n                    , sf.Name\r\n                    , if('" . $svm . "', te.Name, v.Name)  \r\n                    , LPAD(s.Bezeichnung,5,'0') as heatid\r\n                    , r.xRunde\r\n                    , st.xStart\r\n                FROM\r\n                    runde AS r\r\n                    LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n                    LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n                    LEFT JOIN start AS st ON (st.xStart = ss.xStart )\r\n                    LEFT JOIN staffel AS sf ON (sf.xStaffel = st.xStaffel  )\r\n                    LEFT JOIN verein AS v ON (v.xVerein = sf.xVerein)\r\n                    LEFT JOIN team AS te ON(sf.xTeam = te.xTeam)\r\n                    LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n                    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n                WHERE \r\n                    r.xRunde = {$round}  \r\n                ORDER BY\r\n                    heatid\r\n                    , ss.Position";
                     }
                     $result = mysql_query($query);
                     if (mysql_errno() > 0) {
                         // DB error
                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                     } else {
                         // initialize variables
                         $h = 0;
                         // heat counter
                         $p = 0;
                         // position counter (to evaluate empty heats
                         $tracks = 0;
                         $resTable = new GUI_TrackResultTable($round, $layout, $status, $nextRound);
                         while ($row = mysql_fetch_row($result)) {
                             $p++;
                             // increment position counter
                             /*
                              *  Heat headerline
                              */
                             if ($h != $row[3]) {
                                 $tracks = $row[0];
                                 // keep nbr of planned tracks
                                 // fill previous heat with empty tracks
                                 if ($p > 1) {
                                     $resTable->printEmptyTracks($p, $tracks, 5 + $c);
                                 }
                                 $h = $row[3];
                                 // keep heat ID
                                 $p = 1;
                                 // start with track one
                                 if (is_null($row[1])) {
                                     // only one round
                                     $title = "{$strFinalround} {$row['4']}";
                                 } else {
                                     // more than one round
                                     $title = "{$row['1']}: {$row['2']}{$row['4']}";
                                 }
                                 // increment colspan to include ranking and qualification
                                 $c = 0;
                                 if ($status == $cfgRoundStatus['results_done']) {
                                     $c++;
                                     if ($nextRound > 0) {
                                         $c++;
                                     }
                                 }
                                 $resTable->printHeatTitle($row[3], $row[4], $title, $row[7], $row[6], $row[5]);
                                 if ($relay == FALSE) {
                                     // athlete display
                                     $resTable->printAthleteHeader('', $round);
                                 } else {
                                     // relay display
                                     $resTable->printRelayHeader('', $round);
                                 }
                             }
                             // ET new heat
                             /*
                              * Empty tracks
                              */
                             if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                                 // current track and athlete's position not identical
                                 if ($p < $row[9]) {
                                     $p = $resTable->printEmptyTracks($p, $row[9] - 1, 6 + $c);
                                 }
                             }
                             // ET empty tracks
                             /*
                              * Athlete/Relay data lines
                              */
                             // get performance
                             $perf = '';
                             $perfRounded = '';
                             $res = mysql_query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\trs.xResultat\r\n\t\t\t\t\t\t, rs.Leistung\r\n\t\t\t\t\t\t, rs.Info\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tresultat AS rs\r\n\t\t\t\t\tWHERE rs.xSerienstart = {$row['8']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\trs.Leistung ASC\r\n\t\t\t\t");
                             if (mysql_errno() > 0) {
                                 // DB error
                                 AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                             } else {
                                 $resrow = mysql_fetch_row($res);
                                 if ($resrow != NULL) {
                                     // result found
                                     $perf = AA_formatResultTime($resrow[1]);
                                     $perfRounded = AA_formatResultTime($resrow[1], true);
                                 }
                                 mysql_free_result($res);
                             }
                             // ET DB error
                             // print lines
                             if ($relay == FALSE) {
                                 $resTable->printAthleteLine($row[9], $row[12], "{$row['13']} {$row['14']}", AA_formatYearOfBirth($row[15]), $row[16], AA_formatResultTime($row[19], true), $perfRounded, $row[10], $row[11], $row[18], $row[20]);
                             } else {
                                 // relay
                                 // get Athletes
                                 $arrAthletes = array();
                                 $sql = "SELECT at.Vorname, at.Name, at.Jahrgang, a.Startnummer FROM\r\n\t\t\t\t\t\t\t\tstaffelathlet as sfat\r\n\t\t\t\t\t\t\t\tLEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n\t\t\t\t\t\t\t\tLEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\tLEFT JOIN athlet as at USING(xAthlet)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tsfat.xStaffelstart = {$row['16']}\r\n\t\t\t\t\t\t\tAND\tsfat.xRunde = {$row['15']}\r\n\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\tsfat.Position";
                                 $res_at = mysql_query($sql);
                                 if (mysql_errno() > 0) {
                                     // DB error
                                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                 } else {
                                     while ($row_at = mysql_fetch_array($res_at)) {
                                         $arrAthletes[] = array($row_at[1], $row_at[0], AA_formatYearOfBirth($row_at[2]), $row_at[3]);
                                     }
                                 }
                                 $arrAthletes = count($arrAthletes) > 0 ? $arrAthletes : 0;
                                 $resTable->printRelayLine($row[9], $row[12], $row[13], $perfRounded, $row[10], $row[11], $arrAthletes);
                             }
                         }
                         // Fill last heat with empty tracks for disciplines run in
                         // individual tracks
                         if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                             if ($p > 0) {
                                 // heats set up
                                 $p++;
                                 $resTable->printEmptyTracks($p, $tracks, 6 + $c);
                             }
                         }
                         // ET track disciplines
                         $resTable->endTable();
                         mysql_free_result($result);
                     }
                     // ET DB error
                 }
             }
         }
         // ET heat seeding done
     } else {
         AA_printErrorMsg($strErrMergedRoundSpeaker);
     }
 }
コード例 #14
0
ファイル: cl_xml_data.lib.php プロジェクト: laiello/athletica
 function gen_result_xml($file)
 {
     //function returns containing number of results in xml-file
     $nbr_effort = 0;
     $notStartedMK = array();
     //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 = "";
     $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);
         $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') {
             $indoor = "1";
         }
         // 1 = inddor , 0 = outdoor
     }
     //
     // output all athletica generated teams (relays, svm)
     //
     $this->write_xml_open("accounts");
     $query = "\r\n            SELECT \r\n                s.xStaffel\r\n                , s.Name\r\n                , v.xCode as Verein\r\n                , k.Code as Kat\r\n                , d.Code as Dis\r\n            FROM\r\n                staffel as s\r\n                LEFT JOIN verein as v ON (s.xVerein = v.xVerein)\r\n                LEFT JOIN kategorie as k ON (k.xKategorie = s.xKategorie  )\r\n                LEFT JOIN start as st ON (st.xStaffel = s.xStaffel)\r\n                LEFT JOIN wettkampf as w ON (w.xWettkampf = st.xWettkampf )\r\n                LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d  ON (d.xDisziplin = w.xDisziplin)\r\n            WHERE \r\n                Athleticagen = 'y'    \r\n                AND w.Mehrkampfcode != 408         \r\n                AND s.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n            ORDER BY \r\n                v.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            SELECT \r\n                t.xTeam\r\n                , t.Name\r\n                , v.xCode as Verein\r\n                , k.Code as Kat\r\n            FROM\r\n                team as t\r\n                LEFT JOIN verein as v ON (t.xVerein = v.xVerein) \r\n                LEFT JOIN wettkampf as w ON (t.xKategorie = w.xKategorie)\r\n                LEFT JOIN kategorie_svm as k ON (w.xKategorie_svm = k.xKategorie_svm)   \r\n            WHERE \r\n                Athleticagen = 'y'   \r\n                AND w.Mehrkampfcode != 408                 \r\n                AND w.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n            GROUP BY\r\n                t.xTeam\r\n            ORDER BY \r\n                v.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");
     $sql = "SELECT\r\n                    w.Typ,\r\n                    w.Windmessung,\r\n                    d.Typ,\r\n                    d.Code AS dCode,\r\n                    k.Code,\r\n                    w.xWettkampf,\r\n                    d.Kurzname,\r\n                    w.Mehrkampfcode,\r\n                    w.xKategorie,\r\n                    d.Staffellaeufer, \r\n                    r.xRunde\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 r.xRunde > 0 \r\n                      AND w.Mehrkampfcode != 408         \r\n                      AND w.xMeeting = " . $_COOKIE['meeting_id'] . "                  \r\n                ORDER BY\r\n                    k.Code\r\n                    , w.xKategorie\r\n                    , dCode\r\n                    , w.Mehrkampfcode\r\n                    , w.Mehrkampfreihenfolge\r\n                    , d.Staffellaeufer";
     // 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;
         $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] = "";
             }
             $relay = AA_checkRelay($row[5]);
             // check, if this is a relay event
             if ($relay != False) {
                 if ($keep_dCode == $row[3] && ($keep_kCode = $row[4] && ($keep_Event = $row[5] && ($keep_wCat = $row[8])))) {
                     // skip hier relays with more than one round (to prevent them double)
                     continue;
                 }
             }
             //
             // 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
                 //if(!empty($combined) && $combined_dis < 796){ // combined codes 9000 and above are self made disciplines
                 if (!empty($combined) && $combined_dis < 9000 && $combined_dis != 796 && $combined_dis != 797 && $combined_dis != 798 && $combined_dis != 799) {
                     $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;
                         }
                         if (!$notStartedMK[$tmp['xAthlet']]) {
                             // Athlet is not started for one disziplin --> not send the combined event points to AES
                             $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", " ");
                             }
                             $nbr_effort++;
                             $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("indoor", $tmp['indoor']);
                             $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)
             //
             $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) {
                 // check if merged rounds
                 $sqlEvents = AA_getMergedEventsFromEvent($row[5]);
                 if (empty($sqlEvents)) {
                     $sqlSeparate = "ru.xRunde = " . $row[10];
                 } else {
                     $sqlSeparate = "ss.RundeZusammen = " . $row[10];
                 }
                 // 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                            , ba.license_paid \r\n                            , if (ss.RundeZusammen > 0,ss.RundeZusammen,ru.xRunde) as spezRound     \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 base_athlete AS ba ON (ba.license = at.Lizenznummer)\r\n                        WHERE {$sqlSeparate}\r\n                        AND ru.Status = " . $cfgRoundStatus['results_done'] . "\r\n                        AND ru.StatusUpload = 0\r\n                        AND r.Leistung >= " . $GLOBALS['cfgInvalidResult']['DNS']['code'] . "\r\n                        \r\n                        {$valid_result}\r\n                        ORDER BY \r\n                            at.xAthlet\r\n                            , ru.xRunde\r\n                            , r.Leistung " . $order_perf;
             } else {
                 // relay event
                 $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                            , sf.Name\r\n                            , sf.xStaffel\r\n                            , ru.Datum\r\n                            , rt.Code as Typ\r\n                            , st.xStart\r\n                            , ru.xRunde\r\n                            , s.Handgestoppt\r\n                            , ss.rundeZusammen\r\n                            , k.Name\r\n                            , k.Code  \r\n                        FROM\r\n                            runde as ru\r\n                            LEFT JOIN serie AS s ON (s.xRunde = ru.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 staffel AS sf ON (sf.xStaffel = st.xStaffel)\r\n                            LEFT JOIN verein AS v ON (v.xVerein = sf.xVerein)\r\n                            LEFT JOIN rundentyp_" . $_COOKIE['language'] . " as rt ON (ru.xRundentyp = rt.xRundentyp )\r\n                            LEFT JOIN kategorie AS k ON (k.xKategorie = sf.xKategorie)\r\n                        WHERE \r\n                            ru.xWettkampf = {$row['5']}                                 \r\n                            AND ru.Status = " . $cfgRoundStatus['results_done'] . "\r\n                            AND ru.StatusUpload = 0\r\n                            AND r.Leistung > 0\r\n                            AND v.xCode != ''\r\n                            AND v.xCode != '999999'\r\n                            {$valid_result}\r\n                        GROUP BY\r\n                            r.xSerienstart\r\n                        ORDER BY\r\n                            k.Name\r\n                            , st.xStaffel\r\n                            , ss.Rang\r\n                             " . $order_perf;
                 $res_teams = mysql_query($query);
             }
             $res_results = mysql_query($query);
             if (mysql_errno() > 0) {
                 echo mysql_Error();
             } else {
                 if (mysql_num_rows($res_results) > 0) {
                     if ($row[3] != 796 && $row[3] != 797 && $row[3] != 798) {
                         // ...lauf / ...sprung  / ...wurf       --> not send to AES
                         if (!$relay) {
                             $this->write_xml_open("discipline", array('sportDiscipline' => $row[3], 'licenseCategory' => $row[4]));
                             $this->write_xml_open("athletes");
                         }
                     }
                 }
                 $id = 0;
                 // athletes id
                 $ru = 0;
                 // round id
                 $c = 0;
                 while ($row_results = mysql_fetch_assoc($res_results)) {
                     if ($row['Mehrkampfcode'] >= 796 && $row['Mehrkampfcode'] <= 798) {
                         // ...sprung / ...lauf / ...wurf     --> not send to AES
                         continue;
                     }
                     if ($row['dCode'] >= 796 && $row['dCode'] <= 798) {
                         // ...sprung / ...lauf / ...wurf     --> not send to AES
                         continue;
                     }
                     if ($row_results['Leistung'] == -1) {
                         $notStartedMK[$row_results['xAthlet']] = true;
                         continue;
                     }
                     // 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'];
                             if ($row_results[rundeZusammen] > 0) {
                                 if ($c == 0) {
                                     $this->write_xml_open("discipline", array('sportDiscipline' => $row[3], 'licenseCategory' => $row_results['Code']));
                                     $this->write_xml_open("teams");
                                     $lic_catName = $row_results['Name'];
                                     $this->write_xml_open("team", array('teamCode' => 'S'));
                                     $this->write_xml_finished("relayId", $id);
                                     $this->write_xml_open("efforts");
                                 } else {
                                     if ($lic_catName != $row_results['Name']) {
                                         $lic_catName = $row_results['Name'];
                                         $this->write_xml_close("efforts");
                                         $this->write_xml_close("team");
                                         $this->write_xml_close("teams");
                                         $this->write_xml_close("discipline");
                                         $this->write_xml_open("discipline", array('sportDiscipline' => $row[dCode], 'licenseCategory' => $row_results['Code']));
                                         $this->write_xml_open("teams");
                                         $this->write_xml_open("team", array('teamCode' => 'S'));
                                         $this->write_xml_finished("relayId", $id);
                                         $this->write_xml_open("efforts");
                                     } else {
                                         $this->write_xml_close("efforts");
                                         $this->write_xml_close("team");
                                         $this->write_xml_open("team", array('teamCode' => 'S'));
                                         $this->write_xml_finished("relayId", $id);
                                         $this->write_xml_open("efforts");
                                     }
                                 }
                             } else {
                                 if ($c == 0) {
                                     $this->write_xml_open("discipline", array('sportDiscipline' => $row[3], 'licenseCategory' => $row[4]));
                                     $this->write_xml_open("teams");
                                 }
                                 $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");
                             }
                         }
                         $nbr_effort++;
                         $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[2] == $cfgDisciplineType[$strDiscTypeJump] || $row[2] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeThrow] || $row[2] == $cfgDisciplineType[$strDiscTypeHigh]) {
                             if ($row_results['Typ'] == 'F') {
                                 // tech. discipline Final (no serie)
                                 if (is_numeric($row_results['Bezeichnung'])) {
                                     $row_results['Bezeichnung'] = '';
                                 }
                             }
                         }
                         if ($row_results['Typ'] == '0') {
                             // (ohne)
                             $row_results['Bezeichnung'] = '';
                         }
                         if ($row_results['Typ'] == 'F') {
                             // (ohne)
                             $row_results['Typ'] = '';
                         }
                         //$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("indoor", $indoor);
                         $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                                SELECT \r\n                                    at.Name, \r\n                                    at.Vorname, \r\n                                    st.Position \r\n                                FROM\r\n                                    staffelathlet as st\r\n                                    LEFT JOIN start as s  ON (st.xAthletenstart = s.xStart)\r\n                                    LEFT JOIN anmeldung as a ON (s.xAnmeldung = a.xAnmeldung)\r\n                                    LEFT JOIN athlet as at ON (a.xAthlet = at.xAthlet)\r\n                                WHERE \r\n                                    st.xStaffelstart = " . $row_results['xStart'] . "\r\n                                    AND (st.xRunde = " . $row_results['xRunde'] . "  OR st.xRunde = " . $row_results['rundeZusammen'] . ")                                \r\n                                ORDER BY\r\n                                    st.Position ASC\r\n                                LIMIT {$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, 'indoor' => $indoor, 'points' => $row_results['Punkte'], 'discipline' => $row[6], 'license' => $row_results['Lizenznummer'], 'xAthlet' => $row_results['xAthlet'], '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
                         $nbr_effort++;
                         $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, 'indoor' => $indoor, 'points' => $row_results['Punkte'], 'effort' => $perfRounded, 'discipline' => $row[6], 'license' => $row_results['Lizenznummer'], 'xAthlet' => $row_results['xAthlet'], '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[2] == $cfgDisciplineType[$strDiscTypeJump] || $row[2] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $row[2] == $cfgDisciplineType[$strDiscTypeThrow] || $row[2] == $cfgDisciplineType[$strDiscTypeHigh]) {
                             if ($row_results['Typ'] == 'F') {
                                 // tech. discipline Final (no serie)
                                 if (is_numeric($row_results['Bezeichnung'])) {
                                     $row_results['Bezeichnung'] = '';
                                 }
                             }
                         }
                         if ($row_results['Typ'] == '0') {
                             // (ohne)
                             $row_results['Bezeichnung'] = '';
                         }
                         if ($row_results['Typ'] == 'F') {
                             // (ohne)
                             $row_results['Typ'] = '';
                         }
                         // output result data
                         // temp. solution (wind only with 4 characters)
                         $windEnd = substr($wind, -1);
                         if ($windEnd == 'm') {
                             $wind = substr($wind, 0, -1);
                         }
                         $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("indoor", $indoor);
                         $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                                        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++;
                                         $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("indoor", $indoor);
                                         $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
                     $c++;
                 }
                 // end while res_results
             }
             $this->close_open_tags("disciplines");
             $keep_dCode = $row[3];
             $keep_kCode = $row[4];
             $keep_Event = $row[5];
             $keep_wCat = $row[8];
         }
         // check on last combined event
         // if(!empty($combined) && $combined_dis < 9000){ // combined codes 9000 and above are self made disciplines
         if (!empty($combined) && $combined_dis < 9000 && $combined_dis != 796 && $combined_dis != 797 && $combined_dis != 798 && $combined_dis != 799) {
             $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;
                 }
                 if (!$notStartedMK[$tmp['xAthlet']]) {
                     // Athlet is not started for one disziplin --> not send the combined event points
                     $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");
                     $nbr_effort;
                     $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("indoor", $tmp['indoor']);
                     $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                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);
                     $this->close_open_tags("disciplines");
                 }
             }
         }
         // close last tags
         $this->close_open_tags();
     }
     $this->gzip_close();
     return $nbr_effort;
 }
コード例 #15
0
ファイル: utils.lib.php プロジェクト: laiello/athletica
 /**
  * Calculate ranking points for a given round
  *
  * @param	round			ID table 'runde'
  */
 function AA_utils_calcRankingPoints($round)
 {
     global $strConvtableRankingPoints, $strConvtableRankingPointsU20, $cfgEventType;
     global $strEventTypeSVMNL, $strEventTypeSingleCombined, $strEventTypeClubAdvanced, $strEventTypeClubBasic, $strEventTypeClubTeam, $strEventTypeClubMixedTeam;
     $valid = false;
     $minus = true;
     //
     // initialize parameters
     //
     $pStart = 0;
     $pStep = 0;
     $bSVM = false;
     // set if contest type has a result limitation for only best athletes
     // e.g.: for svm NL only the 2 best athletes of a team are counting -> distribute points on these athletes
     $countMaxRes = 0;
     // set to the maximum of countet results in case of an svm contest
     $relay = AA_checkRelay('', $round);
     $sql = "\r\n            SELECT\r\n                w.Punktetabelle\r\n                , w.Punkteformel\r\n                , w.Typ\r\n            FROM\r\n                athletica.runde as r\r\n                LEFT JOIN athletica.wettkampf as w  ON (r.xWettkampf = w.xWettkampf )\r\n            WHERE                 \r\n                r.xRunde = {$round}";
     $res = mysql_query($sql);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $row = mysql_fetch_array($res);
         mysql_free_result($res);
         if ($row[0] == $GLOBALS['cvtTable'][$strConvtableRankingPoints]) {
             $rpt = $GLOBALS['cvtTable'][$strConvtableRankingPoints];
         } elseif ($row[0] == $GLOBALS['cvtTable'][$strConvtableRankingPointsU20]) {
             $rpt = $GLOBALS['cvtTable'][$strConvtableRankingPointsU20];
         }
         if ($row[0] == $rpt) {
             // if mode is team
             if ($row[2] > $cfgEventType[$strEventTypeSingleCombined]) {
                 $bSVM = true;
                 switch ($row[2]) {
                     case $cfgEventType[$strEventTypeSVMNL]:
                         if ($relay) {
                             $countMaxRes = 1;
                         } else {
                             $countMaxRes = 2;
                         }
                         break;
                     case $cfgEventType[$strEventTypeClubBasic]:
                         $countMaxRes = 1;
                         break;
                     case $cfgEventType[$strEventTypeClubAdvanced]:
                         $countMaxRes = 2;
                         break;
                     case $cfgEventType[$strEventTypeClubTeam]:
                         $countMaxRes = 5;
                         break;
                     case $cfgEventType[$strEventTypeClubMixedTeam]:
                         $countMaxRes = 6;
                         break;
                     default:
                         $countMaxRes = 1;
                 }
             }
             //list($pStart, $pStep) = explode(" ", $GLOBALS['cvtFormulas'][$rpt][$row[1]]);
             list($pStart, $pStep) = explode(" ", $row[1]);
             if (strpos($row[1], '-')) {
                 $pStep = str_replace('-', '', $pStep);
                 $minus = true;
             } else {
                 $pStep = str_replace('+', '', $pStep);
                 $minus = false;
             }
             $valid = true;
         }
     }
     //
     // calculate points
     //
     if ($valid) {
         // if svm, the ranking points have only to be distributed on the results that count afterwards for team
         // so: only the best 2 athletes of the same team will get points
         if (!$bSVM) {
             $sql = "\r\n                    SELECT\r\n                        ss.xSerienstart\r\n                        , ss.Rang\r\n                    FROM\r\n                        athletica.serienstart AS ss\r\n                        LEFT JOIN athletica.serie AS s ON (ss.xSerie = s.xSerie )\r\n                    WHERE \r\n                         s.xRunde = {$round}\r\n                         AND ss.Rang > 0\r\n                    ORDER BY ss.Rang ASC\r\n                ";
             $res = mysql_query($sql);
         } else {
             $res = mysql_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, IF(a.xTeam > 0, a.xTeam, staf.xTeam)\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\tathletica.serienstart AS ss\r\n\t\t\t\t\t\t\tLEFT JOIN athletica.serie AS s ON (ss.xSerie = s.xSerie  )\r\n\t\t\t\t\t\t\tLEFT JOIN athletica.start AS st ON (ss.xStart = st.xStart)\r\n\t\t\t\t\t\t\tLEFT JOIN athletica.staffel AS staf ON (st.xStaffel = staf.xStaffel)\r\n\t\t\t\t\t\t\tLEFT JOIN athletica.anmeldung AS a ON (st.xAnmeldung = a.xAnmeldung)\r\n\t\t\t\t\t\tWHERE  \t\t\t\t\t\t \r\n\t\t\t\t\t\t    s.xRunde = {$round}\r\n\t\t\t\t\t\t    AND ss.Rang > 0\r\n\t\t\t\t\t\tORDER BY ss.Rang ASC\r\n\t\t\t\t\t\t");
         }
         if (mysql_errno() > 0) {
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             $pts = 0;
             // points to share
             $rank = 1;
             // current rank
             $update = array();
             // holding serienstart[key] with points
             $tmp = array();
             // holding temporary serienstarts
             $point = $pStart;
             // current points to set
             $i = 0;
             // share counter
             $cClubs = array();
             // count athlete teams for svm mode
             while ($row = mysql_fetch_array($res)) {
                 if ($bSVM) {
                     // count athletes per club
                     if (isset($cClubs[$row[2]])) {
                         $cClubs[$row[2]]++;
                     } else {
                         $cClubs[$row[2]] = 1;
                     }
                     // skip result if more than MaxRes athletes of a team are on top
                     if (isset($cClubs[$row[2]]) && $cClubs[$row[2]] > $countMaxRes) {
                         mysql_query("UPDATE athletica.resultat SET\r\n\t\t\t\t\t\t\t\t\tPunkte = 0\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\txSerienstart = {$row['0']}");
                         if (mysql_errno() > 0) {
                             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                         }
                         continue;
                         // skip
                     }
                 }
                 if ($rank != $row[1] && $i > 0) {
                     $p = $pts / $i;
                     // divide points for athletes with the same rank
                     $p = round($p, 1);
                     foreach ($tmp as $x) {
                         $update[$x] = $p;
                     }
                     $i = 1;
                     $pts = $point;
                     $rank = $row[1];
                     $tmp = array();
                 } else {
                     $i++;
                     $pts += $point;
                 }
                 $tmp[] = $row[0];
                 if ($minus) {
                     $point -= $pStep;
                 } else {
                     $point += $pStep;
                 }
             }
             // check on last entries
             if ($i > 0) {
                 $p = $pts / $i;
                 // divide points for athletes with the same rank
                 $p = round($p, 1);
                 foreach ($tmp as $x) {
                     $update[$x] = $p;
                 }
             }
             // update points
             foreach ($update as $key => $p) {
                 mysql_query("UPDATE athletica.resultat SET\r\n\t\t\t\t\t\t\tPunkte = {$p}\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\txSerienstart = {$key}");
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
             }
         }
     }
     // endif $valid
 }