コード例 #1
0
ファイル: cl_ftp_data.lib.php プロジェクト: laiello/athletica
 function get_file($local, $remote)
 {
     global $strErrFtpNoGet;
     @ftp_pasv($this->ftpc, true);
     $download = @ftp_get($this->ftpc, $local, $remote, FTP_BINARY);
     if (!$download) {
         AA_printErrorMsg($strErrFtpNoGet);
         return false;
     } else {
         return true;
     }
 }
コード例 #2
0
ファイル: cl_film.lib.php プロジェクト: laiello/athletica
 function save($film = '')
 {
     global $strErrFilmExists;
     $GLOBALS['AA_ERROR'] = '';
     $this->film = $film;
     /*mysql_query("
     			LOCK TABLES
     				serie WRITE
     		");
     
     		mysql_query("
     			UPDATE serie SET
     				Film = '" . $this->film . "'
     			WHERE xSerie = " . $this->heatID
     		);*/
     mysql_query("LOCK TABLES runde READ, wettkampf READ, meeting READ, serie WRITE");
     // check if filmnummer already exists in context of current meeting
     $res = mysql_query("\r\n\t\t\t\tSELECT * FROM \r\n\t\t\t\t\tserie\r\n\t\t\t\t\tLEFT JOIN runde  USING(xRunde) \r\n\t\t\t\t\tLEFT JOIN wettkampf USING(xWettkampf) \r\n\t\t\t\t\tLEFT JOIN meeting USING(xMeeting)\r\n\t\t\t\tWHERE meeting.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n\t\t\t\tAND serie.Film = " . $_POST['film']);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         if (mysql_num_rows($res) == 0) {
             // no results --> update film nummer
             mysql_query("update \r\n\t\t\t\t\t\tserie\r\n\t\t\t\t\tset Film = " . $_POST['film'] . "\r\n\t\t\t\t\twhere xSerie = " . $_POST['item']);
             if (mysql_errno() > 0) {
                 $GLOBALS['AA_ERROR'] = mysql_errno() . ": " . mysql_error();
             }
         } else {
             // film already exists
             $GLOBALS['AA_ERROR'] = $strErrFilmExists;
         }
     }
     //mysql_query("UNLOCK TABLES");
     if (mysql_affected_rows() == 0) {
         $GLOBALS['AA_ERROR'] = $GLOBALS['strFilm'] . $GLOBALS['strErrNotValid'];
     }
     if (mysql_errno() > 0) {
         $GLOBALS['AA_ERROR'] = mysql_errno() . ": " . mysql_error();
     }
     mysql_query("UNLOCK TABLES");
 }
コード例 #3
0
    function AA_results_High($round, $layout, $singleRound, $content_navi, $cat, $disc, $rtyp)
    {
        require './config.inc.php';
        require './config.inc.end.php';
        require './lib/common.lib.php';
        require './lib/heats.lib.php';
        require './lib/utils.lib.php';
        $p = "./tmp";
        $fp = @fopen($p . "/live" . $round . ".html", 'w');
        if (!$fp) {
            AA_printErrorMsg($GLOBALS['strErrFileOpenFailed']);
            return;
        }
        $svm = AA_checkSVM(0, $round);
        // decide whether to show club or team name
        if ($singleRound > 0) {
            $single_svm = AA_checkSVM(0, $singleRound);
            // decide whether to show club or team name
        }
        $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) {
            $status = AA_getRoundStatus($round);
            $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'>";
            // display all athletes
            $result = mysql_query("\r\n\t\t\tSELECT rt.Name\r\n\t\t\t\t, rt.Typ\r\n\t\t\t\t, s.xSerie\r\n\t\t\t\t, s.Bezeichnung\r\n\t\t\t\t, ss.xSerienstart\r\n\t\t\t\t, ss.Position\r\n\t\t\t\t, ss.Rang\r\n\t\t\t\t, a.Startnummer\r\n\t\t\t\t, at.Name\r\n\t\t\t\t, at.Vorname\r\n\t\t\t\t, at.Jahrgang\r\n\t\t\t\t, if('" . $svm . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo))   \r\n\t\t\t\t, LPAD(s.Bezeichnung,5,'0') as heatid\r\n\t\t\t\t, rs.xResultat\r\n\t\t\t\t, rs.Leistung\r\n\t\t\t\t, rs.Info\r\n\t\t\t\t, at.Land\r\n                , ss.Bemerkung\r\n                , at.xAthlet\r\n                , r.xRunde \r\n                , ss.RundeZusammen  \r\n\t\t\tFROM\r\n\t\t\t\tathletica.runde AS r\r\n\t\t\t\tLEFT JOIN athletica.serie AS s ON (s.xRunde = r.xRunde )\r\n\t\t\t\tLEFT JOIN athletica.serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n\t\t\t\tLEFT JOIN athletica.start AS st ON (st.xStart = ss.xStart)\r\n\t\t\t\tLEFT JOIN athletica.anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n\t\t\t\tLEFT JOIN athletica.athlet AS at ON (at.xAthlet = a.xAthlet)\r\n\t\t\t\tLEFT 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\t\t\tLEFT JOIN athletica.rundentyp_" . $_COOKIE['language'] . " AS rt\r\n\t\t\t\tON rt.xRundentyp = r.xRundentyp\r\n\t\t\tLEFT JOIN athletica.resultat AS rs\r\n\t\t\t\tON rs.xSerienstart = ss.xSerienstart\r\n\t\t\tWHERE r.xRunde = {$round}  \r\n\t\t\tORDER BY\r\n\t\t\t\theatid\r\n\t\t\t\t, ss.Position\r\n\t\t\t\t, rs.xResultat DESC\r\n\t\t");
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            } else {
                // initialize variables
                $a = 0;
                $h = 0;
                $c_results = 0;
                $rowclass = 'odd';
                while ($row = mysql_fetch_row($result)) {
                    if ($row[20] > 0) {
                        $singleRound = $row[20];
                    } else {
                        $singleRound = $row[19];
                    }
                    /*
                     *  Heat headerline
                     */
                    if ($h != $row[2]) {
                        $h = $row[2];
                        // keep heat ID
                        if (is_null($row[0])) {
                            // only one round
                            $title = "{$strFinalround}";
                        } else {
                            // more than one round
                            if ($row[1] == '0') {
                                $title = "";
                            } else {
                                $title = "{$row['0']}";
                            }
                        }
                        $content .= "</table><table class='dialog'>";
                        if ($title != '') {
                            $content .= "<tr>";
                            $content .= "<th class='dialog' colspan='6' />" . $title . " " . $row[3] . "</th> ";
                            $content .= "</tr>";
                        }
                        $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>";
                        $content .= "<th class='dialog'>" . $strPerformance . "</th>";
                        $content .= "</tr>";
                    }
                    // ET new heat
                    /*
                     * Athlete data lines
                     */
                    if ($a != $row[4]) {
                        $c_results = 0;
                        $a = $row[4];
                        // keep athlete ID
                        $l = 0;
                        // reset result counter
                        if ($row[5] % 2 == 0) {
                            // even row numer
                            $rowclass = 'even';
                        } else {
                            // odd row number
                            $rowclass = 'odd';
                        }
                        $content .= "<tr class='" . $rowclass . "' >";
                        $content .= "<td class='forms_right'>" . $row[5] . "</td>";
                        $content .= "<td class='forms_right'>" . $row[7] . "</td>";
                        /* start nbr */
                        $content .= "<td nowrap>" . $row[8] . " " . $row[9] . "</td>";
                        /* name */
                        $content .= "<td class='forms_ctr_pc'>" . AA_formatYearOfBirth($row[10]) . "</td>";
                        $content .= "<td class='forms_pc'>";
                        if ($row[16] != '' && $row[16] != '-') {
                            $content .= $row[16];
                        } else {
                            $content .= " ";
                        }
                        $content .= "</td>";
                        $content .= "<td class='forms_pc' nowrap>" . $row[11] . "</td>";
                        /* club */
                    }
                    // ET new athlete
                    $perf = '';
                    if (is_null($row[14]) == false) {
                        $c_results++;
                        if ($c_results > 4) {
                            $content .= "<tr><td colspan='6'></td>";
                            $c_results = 0;
                        }
                        $perf = $row[14];
                        if ($perf == $cfgMissedAttempt['dbx']) {
                            $perf = $cfgMissedAttempt['codeX'];
                        }
                        $content .= "<td colspan='2' nowrap>" . AA_formatResultMeter($perf) . "({$row['15']})</td>";
                    }
                }
                mysql_free_result($result);
                $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 
    }
コード例 #4
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
 }
コード例 #5
0
        function printHeader($team, $category, $competitors)
        {
            $this->linecnt = $this->linecnt + 7;
            ?>
<table class='sheet'>
	<tr>
		<td class='sheet_title' colspan='6'><?php 
            echo $GLOBALS['strTeamRankingTitle'];
            ?>
</td>
	</tr>
<?php 
            $result = mysql_query("\r\n\t\t\tSELECT m.Ort\r\n\t\t\t\t, s.Name\r\n\t\t\t\t, DATE_FORMAT(m.DatumBis, '" . $GLOBALS['cfgDBdateFormat'] . "')\r\n\t\t\tFROM\r\n\t\t\t\tmeeting AS m\r\n\t\t\t\tLEFT JOIN stadion AS s ON (m.xStadion = s.xStadion)\r\n\t\t\tWHERE \r\n                m.xMeeting = " . $_COOKIE['meeting_id']);
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            } else {
                $row = mysql_fetch_row($result);
                $place = $row[0];
                $stadium = $row[1];
                $date = $row[2];
                mysql_free_result($result);
            }
            ?>
	<tr>
		<td class='sheet_col1'><?php 
            echo $GLOBALS['strPlace'] . ", " . $GLOBALS['strStadium'];
            ?>
</td>
		<td class='sheet_col2'><?php 
            echo $place . ", " . $stadium;
            ?>
</td>
		<td class='sheet_col3'><?php 
            echo $GLOBALS['strDate'];
            ?>
</td>
		<td class='sheet_col4' colspan='4'><?php 
            echo $date;
            ?>
</td>
	</tr>
	<tr>
		<td class='sheet_col1'><?php 
            echo $GLOBALS['strClub'];
            ?>
</td>
		<td class='sheet_team'><?php 
            echo $team;
            ?>
</td>
		<td class='sheet_col3'><?php 
            echo $GLOBALS['strCategory'];
            ?>
</td>
		<td class='sheet_cat' colspan='4'><?php 
            echo $category;
            ?>
</td>
	</tr>
	<tr>
		<td class='sheet_col1'><?php 
            echo $GLOBALS['strCompetition'];
            ?>
</td>
		<td class='sheet_col2' colspan='6'><?php 
            echo $competitors;
            ?>
</td>
	</tr>
	<tr>
		<td colspan='7'><hr class='sep'/></td>
	</tr>
<?php 
            $this->linecnt = $this->linecnt + 3;
            // increment line count
        }
コード例 #6
0
ファイル: results.lib.php プロジェクト: laiello/athletica
 function AA_checkHeight($round, $heat)
 {
     $sql = "SELECT \r\n                    h.xHoehe \r\n              FROM \r\n                    hoehe AS h\r\n                    LEFT JOIN runde AS r ON (r.xRunde = h.xRunde)\r\n                    LEFT JOIN wettkampf AS w ON (w.xWettkampf = r.xWettkampf) \r\n              WHERE h.xRunde = " . $round . " \r\n                    AND h.xSerie = " . $heat . "\r\n                    AND w.xMeeting = " . $_COOKIE['meeting_id'];
     $res = mysql_query($sql);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         return mysql_num_rows($res);
     }
 }
コード例 #7
0
 function check_samePoints($xCategory)
 {
     $sql = "SELECT \r\n                Punkte,\r\n                xDisziplin,\r\n                xTeam\r\n            FROM tmp_team \r\n            WHERE xKategorie = " . $xCategory . "\r\n            ORDER BY xDisziplin, Punkte";
     $res = mysql_query($sql);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $disc = 0;
         $arr_team = array();
         while ($row = mysql_fetch_row($res)) {
             if ($disc != $row[1]) {
                 $arr_team[$row[2]]++;
             }
             $disc = $row[1];
         }
     }
     return $arr_team;
 }
コード例 #8
0
ファイル: heats.lib.php プロジェクト: laiello/athletica
 /**
  * get remark if combined heats exist
  * -----------------------------------
  *
  * returns remark
  */
 function AA_getResultRemark($xAthlete)
 {
     $remark = '';
     // check for combined event
     $query_mk = "SELECT \r\n                    ss.xSerienstart , ss.Bemerkung   \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 wettkampf as w ON (w.xWettkampf = st.xWettkampf)\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 AS rt ON rt.xRundentyp = r.xRundentyp                              \r\n                WHERE w.mehrkampfcode > 0\r\n                    AND at.xAthlet = " . $xAthlete;
     $result = mysql_query($query_mk);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         if (mysql_num_rows($result) > 0) {
             $row = mysql_fetch_row($result);
             $remark = $row[1];
         }
     }
     return $remark;
 }
コード例 #9
0
ファイル: cl_omega.lib.php プロジェクト: laiello/athletica
 function get_file($filename)
 {
     global $strErrFileOpenFailed;
     // get file
     // skip if the file is allredy read on script-runtime
     if (isset($GLOBALS['omega_lstfiles'][$filename])) {
         return $GLOBALS['omega_lstfiles'][$filename];
     }
     $GLOBALS['omega_lstfiles'][$filename] = false;
     if ($this->connection == "local") {
         if (!file_exists($this->path . "/" . $filename)) {
             return false;
         }
         $fp = @fopen($this->path . "/" . $filename, 'r');
     } elseif ($this->connection == "ftp") {
         $this->ftp->open_connection($this->host, $this->user, $this->pass);
         $this->ftp->get_file("./tmp/" . $filename, $this->ftppath . "/" . $filename);
         $fp = @fopen("./tmp/" . $filename, 'r');
     }
     if (!$fp) {
         return false;
         AA_printErrorMsg($strErrFileOpenFailed);
     } else {
         $content = array();
         while (!feof($fp)) {
             $buffer = fgets($fp, 4096);
             $t = false;
             $field = 0;
             $tmp = array();
             for ($i = 0; $i < strlen($buffer); $i++) {
                 if ($buffer[$i] == '"') {
                     if ($buffer[$i + 1] == '"' && $t) {
                         $tmp[$field] .= $buffer[$i];
                         continue 2;
                     } elseif ($t) {
                         $t = false;
                     } elseif (!$t) {
                         $t = true;
                     }
                 } elseif ($buffer[$i] == ';' && !$t) {
                     $tmp[$field] = trim($tmp[$field]);
                     $field++;
                 } else {
                     $tmp[$field] .= $buffer[$i];
                 }
             }
             $tmp[$field] = trim($tmp[$field]);
             $content[] = $tmp;
         }
     }
     $GLOBALS['omega_lstfiles'][$filename] = $content;
     return $content;
 }
コード例 #10
0
 function AA_rankinglist_Combined($category, $formaction, $break, $cover, $sepu23, $cover_timing = false, $date = '%', $disc_nr, $catFrom, $catTo, $ukc)
 {
     require './lib/cl_gui_page.lib.php';
     require './lib/cl_print_page.lib.php';
     require './lib/cl_export_page.lib.php';
     require './lib/common.lib.php';
     require './lib/results.lib.php';
     require './config.inc.php';
     if (AA_connectToDB() == FALSE) {
         // invalid DB connection
         return;
         // abort
     }
     if (AA_checkMeetingID() == FALSE) {
         // no meeting selected
         return;
         // abort
     }
     $contestcat = " ";
     if (!empty($category)) {
         // show every category
         $contestcat = " AND w.xKategorie = {$category}";
     }
     if ($catFrom > 0) {
         $getSortCat = AA_getSortCat($catFrom, $catTo);
         if ($getSortCat[0]) {
             if ($catTo > 0) {
                 $contestcat = " AND k.Anzeige >=" . $getSortCat[$catFrom] . " AND k.Anzeige <=" . $getSortCat[$catTo] . " ";
             } else {
                 $contestcat = " AND k.Anzeige =" . $getSortCat[$catFrom] . " ";
             }
         }
     }
     $GroupByUkc = "";
     if ($ukc) {
         $checkyear = date('Y') - 16;
         $min_age = date('Y') - 7;
         $selection = " AND at.Jahrgang > {$checkyear} AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") ";
         $sql_leftjoin = " LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (w.xDisziplin = d.xDisziplin) ";
         $order = " at.Geschlecht, at.Jahrgang,  at.Name, at.Vorname,  d.Anzeige";
         $disc_nr = 3;
     } else {
         $selection = " AND w.Mehrkampfcode > 0 ";
         $sql_leftjoin = " LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d ON (w.Mehrkampfcode = d.Code)";
         $order = " k.Anzeige , w.Mehrkampfcode , ka.Alterslimite DESC";
     }
     $dCode = 0;
     if ($ukc) {
         $mk = ",0";
     } else {
         $mk = ",w.Mehrkampfcode";
     }
     // get athlete info per contest category
     $sql1 = "SELECT DISTINCT \r\n        a.xAnmeldung\r\n        , at.Name\r\n        , at.Vorname\r\n        , at.Jahrgang\r\n        , k.Name\r\n        , IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)\r\n        , IF(at.xRegion = 0, at.Land, re.Anzeige)";
     $sql2 = ", d.Name\r\n        , w.xKategorie\r\n        , ka.Code\r\n        , ka.Name\r\n        , ka.Alterslimite \r\n        , d.Code \r\n        , at.xAthlet\r\n        , at.Geschlecht               \r\n    FROM\r\n        anmeldung AS a\r\n        LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet )\r\n        LEFT JOIN verein AS v  ON (v.xVerein = at.xVerein  )\r\n        LEFT JOIN start as st ON (st.xAnmeldung = a.xAnmeldung ) \r\n        LEFT JOIN wettkampf as w  ON (w.xWettkampf = st.xWettkampf) " . $sql_leftjoin . "\r\n        LEFT JOIN kategorie AS k ON (k.xKategorie = w.xKategorie)\r\n        LEFT JOIN kategorie AS ka ON (ka.xKategorie = a.xKategorie)     \r\n        LEFT JOIN region as re ON (at.xRegion = re.xRegion) \r\n    WHERE a.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n    " . $contestcat . " \r\n     " . $selection . " \r\n    AND st.anwesend = 0 ";
     $sqlOrder = " ORDER BY " . $order;
     $sql = $sql1 . $mk . $sql2 . $sqlOrder;
     $results = mysql_query($sql);
     if (mysql_errno() > 0) {
         // DB error
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $cat = '';
         $catEntry = '';
         $catEntryLimit = "";
         $u23name = "";
         $comb = 0;
         // hold combined type
         $combName = "";
         $lastTime = "";
         // hold start time of last event for print list
         $a = 0;
         $info = '';
         $points = 0;
         $sep = '';
         $rFrom = 0;
         $rTo = 0;
         $limitRank = false;
         if ($_GET['limitRank'] == "yes" && substr($formaction, 0, 6) == "export") {
             // check if ranks are limited
             if (!empty($_GET['limitRankFrom']) && !empty($_GET['limitRankTo'])) {
                 $limitRank = true;
                 $rFrom = $_GET['limitRankFrom'];
                 $rTo = $_GET['limitRankTo'];
             }
         }
         // start a new HTML display page
         if ($formaction == 'view') {
             // display page for speaker
             $list = new GUI_CombinedRankingList($_COOKIE['meeting']);
             $list->printPageTitle("{$strRankingLists} " . $_COOKIE['meeting']);
         } elseif ($formaction == "print") {
             $list = new PRINT_CombinedRankingList($_COOKIE['meeting']);
             if ($cover == true) {
                 // print cover page
                 $list->printCover($GLOBALS['strResults'], $cover_timing);
             }
         } elseif ($formaction == "exportpress") {
             $list = new EXPORT_CombinedRankingListPress($_COOKIE['meeting'], 'txt');
         } elseif ($formaction == "exportdiplom") {
             $list = new EXPORT_CombinedRankingListDiplom($_COOKIE['meeting'], 'csv');
         }
         if ($ukc) {
             while ($row = mysql_fetch_row($results)) {
                 if ($roundsUkc[$row[4]][$row[14]] == "") {
                     $roundsUkc[$row[4]][$row[14]] = 0;
                 }
                 $roundsUkc[$row[4]][$row[14]]++;
             }
             $GroupByUkc = " GROUP BY at.xAthlet ";
             $mk = ",w.Mehrkampfcode";
             $sql = $sql1 . $mk . $sql2 . $GroupByUkc . $sqlOrder;
             $results = mysql_query($sql);
         }
         while ($row = mysql_fetch_row($results)) {
             $dCode = $row[13];
             $row3_tmp = $row[3];
             if ($row3_tmp > $min_age) {
                 $row3_tmp = $min_age;
             }
             if ($ukc) {
                 if ($roundsUkc[$row[4]][$row[14]] != 3) {
                     continue;
                 }
             }
             // store previous before processing new athlete
             if ($a != $row[0] && $a > 0) {
                 $points_arr[] = $points;
                 if ($ukc) {
                     $xKatUKC = AA_getCatUkc($birthDate, $sex, true);
                     $points_arr_more_disc_all[$xKatUKC][] = $points_disc;
                 } else {
                     $points_arr_more_disc_all[$row[9]][] = $points_disc;
                 }
                 $name_arr[] = $name;
                 $year_arr[] = $year;
                 $club_arr[] = $club;
                 $info_arr[] = $info;
                 $ioc_arr[] = $ioc;
                 $x_arr[] = $a;
                 if (isset($points_disc_keep) && sizeof($points_disc_keep) < 3 && $ukc) {
                     $rank_arr[] = 0;
                 } else {
                     $rank_arr[] = $rank;
                 }
                 $info = '';
                 $points = 0;
                 $sep = '';
             }
             // print previous before processing new category
             if (!empty($cat) && (($row[4] != $cat || $row[7] != $comb) && $ukc == false || $ukc == true && $row3_tmp != $age || ($comb == 410 || $comb == 400) && $catEntry != $row[10] && $row[12] < 23 && !$bU23 && $sepu23)) {
                 $bU23 = false;
                 // set the separate flag! else it will be separated by each category
                 if (($comb == 410 || $comb == 400) && $catEntry != $row[10] && $row[12] < 23) {
                     $bU23 = true;
                 }
                 $u23name = '';
                 // set the addition for the title if this is the separated cat
                 if (($comb == 410 || $comb == 400) && $catEntryLimit < 23 && $sepu23) {
                     $u23name = " (U 23)";
                 }
                 $list->endList();
                 if ($ukc) {
                     $list->printSubTitle($catUKC . ", " . $cfgUKC_Name);
                 } else {
                     $list->printSubTitle($cat . "{$u23name}, " . $combName, "", "");
                 }
                 $list->startList();
                 $list->printHeaderLine($lastTime);
                 arsort($points_arr, SORT_NUMERIC);
                 // sort descending by points
                 $rank = 1;
                 // initialize rank
                 $r = 0;
                 // start value for ranking
                 $p = 0;
                 $no_rank = 999999;
                 $max_rank = $no_rank;
                 foreach ($points_arr as $key => $val) {
                     $r++;
                     if ($limitRank && ($r < $rFrom || $r > $rTo)) {
                         // limit ranks if set (export)
                         continue;
                     }
                     if ($p != $val) {
                         // not same points as previous team
                         $rank = $r;
                         // next rank
                     }
                     // not set rank for invalid results
                     if (preg_match("@\\(-[1]{1}@", $info_arr[$key])) {
                         $rank = $max_rank;
                         $max_rank += 1;
                         $r--;
                     }
                     $rank_arr[$key] = $rank;
                     $p = $val;
                     // keep current points
                 }
                 asort($rank_arr, SORT_NUMERIC);
                 // sort descending by rank
                 $rank_keep = 0;
                 $key_keep = '';
                 foreach ($rank_arr as $key => $v) {
                     $val = $points_arr[$key];
                     $rank = $v;
                     if ($rank == $rank_keep) {
                         $c = 0;
                         $keep_c = 0;
                         // first rule
                         for ($i = 1; $i <= sizeof($points_disc); $i++) {
                             if ($points_arr_more_disc_all[$xKat][$key_keep][$i] > $points_arr_more_disc_all[$xKat][$key][$i]) {
                                 $keep_c++;
                             } else {
                                 $c++;
                             }
                         }
                         $more = ceil(sizeof($points_disc) / 2);
                         if (sizeof($points_disc) % 2 == 0) {
                             // combined with even number discs
                             $more++;
                         }
                         if ($keep_c >= $more && $keep_c > $c) {
                             $rank_arr[$key]++;
                         } else {
                             if ($c >= $more && $c > $keep_c) {
                                 $rank_arr[$key_keep]++;
                             } else {
                                 // second rule
                                 // check the best points of the highest points of discipline
                                 $k = AA_get_AthletBestPointDisc($points_arr_more_disc_all[$xKat][$key_keep], $points_arr_more_disc_all[$xKat][$key], $key_keep, $key);
                                 if ($k != 0) {
                                     $rank_arr[$k]++;
                                 }
                                 // if $k is 0, all points of diszipline are the same -->   athletes with same rank
                             }
                         }
                     }
                     $rank_keep = $rank;
                     $key_keep = $key;
                 }
                 asort($rank_arr, SORT_NUMERIC);
                 // sort descending by rank
                 foreach ($rank_arr as $key => $v) {
                     $val = $points_arr[$key];
                     $rank = $v;
                     if ($rank >= $no_rank) {
                         $rank = '';
                     }
                     $list->printLine($rank, $name_arr[$key], $year_arr[$key], $club_arr[$key], $val, $ioc_arr[$key]);
                     $list->printInfo($info_arr[$key]);
                     // insert points into combined top performance of entry
                     mysql_query("UPDATE anmeldung SET BestleistungMK = {$val} WHERE xAnmeldung = " . $x_arr[$key]);
                 }
                 unset($points_arr);
                 unset($name_arr);
                 unset($year_arr);
                 unset($club_arr);
                 unset($info_arr);
                 unset($ioc_arr);
                 unset($x_arr);
                 unset($rank_arr);
                 if (is_a($list, "PRINT_CombinedRankingList") && $break == 'category') {
                     // page break after category
                     $list->insertPageBreak();
                 }
             }
             $cat = $row[4];
             // keep current category
             $age = $row3_tmp;
             if ($ukc) {
                 $catUKC = AA_getCatUkc($row[3], $row[15], false);
                 $xKat = AA_getCatUkc($row[3], $row[15], true);
             } else {
                 $xKat = $row[9];
             }
             $catEntry = $row[10];
             $catEntryLimit = $row[12];
             $comb = $row[7];
             $combName = $row[8];
             if ($ukc) {
                 $order = " d.Anzeige, ru.Datum, ru.Startzeit";
                 $selectionDisc = " AND (d.Code = " . $cfgUKC_disc[0] . " || d.Code = " . $cfgUKC_disc[1] . " || d.Code = " . $cfgUKC_disc[2] . ") ";
                 $selectionMk = '';
             } else {
                 $order = " w.Mehrkampfreihenfolge ASC, ru.Datum, ru.Startzeit";
                 $selectionMk = " AND w.Mehrkampfcode = " . $row[7];
                 $selectionDisc = '';
             }
             // events
             $query = "SELECT\r\n                d.Kurzname\r\n                , d.Typ\r\n                , MAX(IF ((r.Info='-') && (d.Typ = 6) ,0,r.Leistung)) \r\n                , r.Info\r\n                , MAX(IF ((r.Info='-') && (d.Typ = 6),0,r.Punkte)) AS pts    \r\n                , s.Wind\r\n                , w.Windmessung\r\n                , st.xStart\r\n                , CONCAT(DATE_FORMAT(ru.Datum,'{$cfgDBdateFormat}'), ' ', TIME_FORMAT(ru.Startzeit, '{$cfgDBtimeFormat}'))\r\n                , w.Mehrkampfreihenfolge \r\n                , ss.Bemerkung\r\n                , w.info\r\n                , ss.xSerienstart \r\n                , d.Code\r\n            FROM\r\n                start AS st USE INDEX (Anmeldung)\r\n                LEFT JOIN serienstart AS ss ON (ss.xStart = st.xStart )\r\n                LEFT JOIN resultat AS r ON (r.xSerienstart = ss.xSerienstart) \r\n                LEFT JOIN serie AS s ON (s.xSerie = ss.xSerie)\r\n                LEFT JOIN runde AS ru ON (ru.xRunde = s.xRunde)\r\n                LEFT JOIN wettkampf AS w ON (w.xWettkampf = st.xWettkampf)\r\n                LEFT JOIN disziplin_" . $_COOKIE['language'] . " AS d ON (d.xDisziplin = w.xDisziplin)\r\n            WHERE st.xAnmeldung = {$row['0']}  \r\n                {$selectionDisc} \r\n                AND ( (r.Info = '" . $cfgResultsHighOut . "' && d.Typ = 6 && r.Leistung < 0)  OR  (d.Typ = 6 && (r.Info !=  '" . $cfgResultsHighOut . "' && r.Info !=  '" . $cfgResultsHighOut1 . "' \r\n                                                 && r.Info !=  '" . $cfgResultsHighOut2 . "'  && r.Info !=  '" . $cfgResultsHighOut3 . "'  && r.Info !=  '" . $cfgResultsHighOut4 . "'\r\n                                                 && r.Info !=  '" . $cfgResultsHighOut5 . "' && r.Info !=  '" . $cfgResultsHighOut6 . "' && r.Info !=  '" . $cfgResultsHighOut7 . "' && r.Info !=  '" . $cfgResultsHighOut7 . "'))\r\n                      OR (d.Typ != 6 ) )   \r\n                \r\n               AND w.xKategorie = {$row['9']}\r\n                {$selectionMk}   \r\n                AND ru.Status = " . $cfgRoundStatus['results_done'] . "   \r\n            GROUP BY\r\n                st.xStart\r\n            ORDER BY\r\n                {$order}";
             $res = mysql_query($query);
             if (mysql_errno() > 0) {
                 // DB error
                 AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
             } else {
                 $count_disc = 0;
                 $remark = '';
                 $points_disc = array();
                 while ($pt_row = mysql_fetch_row($res)) {
                     $remark = $pt_row[10];
                     $lastTime = $pt_row[8];
                     if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeJump]) {
                         $res2 = mysql_query("SELECT r.Info FROM \r\n\t\t\t\t\t\t\t\tresultat as r\r\n\t\t\t\t\t\t\t\tLEFT JOIN serienstart as ss USING(xSerienstart)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tss.xStart = {$pt_row['7']}\r\n\t\t\t\t\t\t\tAND\tr.Punkte = {$pt_row['4']}");
                         $row2 = mysql_fetch_array($res2);
                         $pt_row[3] = $row2[0];
                     }
                     // set wind, if required
                     if ($pt_row[6] == 1) {
                         if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeTrack]) {
                             $wind = " / " . $pt_row[5];
                         } else {
                             if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeJump]) {
                                 $wind = " / " . $pt_row[3];
                             }
                         }
                     } else {
                         $wind = '';
                     }
                     // format output
                     if ($pt_row[1] == $cfgDisciplineType[$strDiscTypeJump] || $pt_row[1] == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $pt_row[1] == $cfgDisciplineType[$strDiscTypeThrow] || $pt_row[1] == $cfgDisciplineType[$strDiscTypeHigh]) {
                         $perf = AA_formatResultMeter($pt_row[2]);
                     } else {
                         $perf = AA_formatResultTime($pt_row[2], true);
                     }
                     // show only points for number of choosed disciplines if the diszipline is done
                     $count_disc++;
                     if ($count_disc <= $disc_nr) {
                         if ($pt_row[4] > 0 || $ukc) {
                             // any points for this event
                             if ($ukc) {
                                 $pointsUKC = AA_utils_calcPointsUKC(0, $pt_row[2], 0, $row[16], $pt_row[12], $row[14], $row[0], $pt_row[13]);
                                 $points = $points + $pointsUKC;
                                 // calculate points
                                 mysql_query("UPDATE resultat SET\r\n                                                    Punkte = {$pointsUKC}\r\n                                              WHERE\r\n                                                    xSerienstart = {$pt_row['12']}");
                                 if (mysql_errno() > 0) {
                                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                 }
                                 AA_StatusChanged(0, 0, $pt_row[12]);
                             } else {
                                 $points = $points + $pt_row[4];
                                 // calculate points
                             }
                             if ($dCode == 408) {
                                 // UBS Kids Cup
                                 switch ($pt_row[1]) {
                                     case 1:
                                     case 2:
                                         $c = 1;
                                         // track
                                         break;
                                     case 4:
                                     case 5:
                                     case 6:
                                         $c = 2;
                                         // jump and high
                                         break;
                                     case 8:
                                         $c = 3;
                                         // throw
                                         break;
                                     default:
                                         $c = 0;
                                         break;
                                 }
                                 $points_disc[$c] = $pt_row[4];
                             } else {
                                 if ($ukc) {
                                     switch ($pt_row[1]) {
                                         case 1:
                                         case 2:
                                             $c = 1;
                                             // track
                                             break;
                                         case 4:
                                         case 5:
                                         case 6:
                                             $c = 2;
                                             // jump and high
                                             break;
                                         case 8:
                                             $c = 3;
                                             // throw
                                             break;
                                         default:
                                             $c = 0;
                                             break;
                                     }
                                     $points_disc[$c] = $pointsUKC;
                                 } else {
                                     $points_disc[$row[9]] = $pt_row[4];
                                 }
                             }
                             if ($ukc) {
                                 $info = $info . $sep . $pt_row[0] . " " . "&nbsp;(" . $perf . $wind . ", {$pointsUKC})";
                             } else {
                                 $info = $info . $sep . $pt_row[0] . " " . "&nbsp;(" . $perf . $wind . ", {$pt_row['4']})";
                             }
                             $sep = ", ";
                         } elseif ($pt_row[4] == 0 && $pt_row[2] >= 0) {
                             //  athlete with 0 points
                             $info = $info . $sep . $pt_row[0] . " " . "&nbsp;(" . $perf . $wind . ", {$pt_row['4']})";
                             $sep = ", ";
                         } else {
                             $count_disc--;
                             $pointTxt = "";
                             foreach ($cfgInvalidResult as $value) {
                                 if ($value['code'] == $perf) {
                                     $pointTxt = $value['short'];
                                 }
                             }
                             $info = $info . $sep . $pt_row[0] . $pt_row[11] . "&nbsp;(" . $perf . $wind . ", {$pointTxt})";
                             $sep = ", ";
                         }
                     }
                 }
                 // END WHILE combined events
                 mysql_free_result($res);
             }
             $a = $row[0];
             $name = $row[1] . " " . $row[2];
             $year = AA_formatYearOfBirth($row[3]);
             $birthDate = $row[3];
             $sex = $row[15];
             $club = $row[5];
             $ioc = $row[6];
             $remark_arr[] = $remark;
             if ($ukc) {
                 $xKat = AA_getCatUkc($row[3], $row[15], true);
             } else {
                 $xKat = $row[9];
             }
             $points_disc_keep = $points_disc;
             $dCode_keep = $dCode;
         }
         // END WHILE athlete per category
         if (!empty($a)) {
             $points_arr[] = $points;
             $points_arr_more_disc_all[$xKat][] = $points_disc;
             $name_arr[] = $name;
             $year_arr[] = $year;
             $club_arr[] = $club;
             $info_arr[] = $info;
             $ioc_arr[] = $ioc;
             $x_arr[] = $a;
             $remark_arr[] = $remark;
             $rank_arr[] = $rank;
         }
         if (!empty($cat)) {
             $u23name = '';
             if (($comb == 410 || $comb == 400) && $catEntryLimit < 23 && $sepu23) {
                 $u23name = " (U 23)";
             }
             $list->endList();
             if ($ukc) {
                 $list->printSubTitle($catUKC . ", " . $cfgUKC_Name);
             } else {
                 $list->printSubTitle($cat . "{$u23name}, " . $combName, "", "");
             }
             $list->startList();
             $list->printHeaderLine($lastTime);
             arsort($points_arr, SORT_NUMERIC);
             // sort descending by points
             $rank = 1;
             // initialize rank
             $r = 0;
             // start value for ranking
             $p = 0;
             $k = 0;
             $no_rank = 999999;
             $max_rank = $no_rank;
             foreach ($points_arr as $key => $val) {
                 $r++;
                 if ($limitRank && ($r < $rFrom || $r > $rTo)) {
                     // limit ranks if set (export)
                     continue;
                 }
                 if ($p != $val) {
                     // not same points as previous athlete
                     $rank = $r;
                     // next rank
                 }
                 // not set rank for invalid results
                 if (preg_match("@\\(-[1]{1}@", $info_arr[$key])) {
                     $rank = $max_rank;
                     $max_rank += 1;
                     $r--;
                 }
                 $p = $val;
                 // keep current points
                 $k = $key;
                 // keep current key
                 $rank_arr[$key] = $rank;
             }
             asort($rank_arr, SORT_NUMERIC);
             // sort descending by rank
             $rank_keep = 0;
             foreach ($rank_arr as $key => $v) {
                 $val = $points_arr[$key];
                 $rank = $v;
                 if ($rank == $rank_keep) {
                     $c = 0;
                     $keep_c = 0;
                     // first rule
                     for ($i = 1; $i <= sizeof($points_disc); $i++) {
                         if ($points_arr_more_disc_all[$xKat][$key_keep][$i] > $points_arr_more_disc_all[$xKat][$key][$i]) {
                             $keep_c++;
                         } else {
                             $c++;
                         }
                     }
                     $more = ceil(sizeof($points_disc) / 2);
                     if (sizeof($points_disc) % 2 == 0) {
                         // combined with even number discs
                         $more++;
                     }
                     if ($keep_c >= $more && $keep_c > $c) {
                         $rank_arr[$key]++;
                     } else {
                         if ($c >= $more && $c > $keep_c) {
                             $rank_arr[$key_keep]++;
                         } else {
                             // second rule
                             // check the best points of the highest points of discipline
                             $k = AA_get_AthletBestPointDisc($points_arr_more_disc_all[$xKat][$key_keep], $points_arr_more_disc_all[$xKat][$key], $key_keep, $key);
                             if ($k != 0) {
                                 $rank_arr[$k]++;
                             }
                             // if $k is 0, all points of diszipline are the same -->   athletes with same rank
                         }
                     }
                 }
                 $rank_keep = $rank;
                 $key_keep = $key;
             }
             asort($rank_arr, SORT_NUMERIC);
             // sort descending by rank
             foreach ($rank_arr as $key => $v) {
                 $val = $points_arr[$key];
                 $rank = $v;
                 if ($rank >= $no_rank) {
                     $rank = '';
                 }
                 $list->printLine($rank, $name_arr[$key], $year_arr[$key], $club_arr[$key], $val, $ioc_arr[$key]);
                 $list->printInfo($info_arr[$key]);
                 // insert points into combined top performance of entry
                 mysql_query("UPDATE anmeldung SET BestleistungMK = {$val} WHERE xAnmeldung = " . $x_arr[$key]);
             }
         }
         mysql_free_result($results);
         $list->endList();
         $list->endPage();
         // end HTML page for printing
     }
     // ET DB error all teams
 }
コード例 #11
0
//
if (isset($_POST['ukc_meeting'])) {
    $ukc_meeting = $_POST['ukc_meeting'];
}
$page = new GUI_Page('admin_onlineRegUKC.php');
$page->startPage();
$page->printPageTitle($strImportUKC_Title);
$menu = new GUI_Menulist();
$menu->addButton($cfgURLDocumentation . 'help/administration/base.html', $strHelp, '_blank');
$menu->printMenu();
// get xml file for registrations from athletes
// get uploaded XML file and read its content
$fd = fopen($_FILES['xmlfile']['tmp_name'], 'rb');
$content = fread($fd, filesize($_FILES['xmlfile']['tmp_name']));
if (!$fd) {
    AA_printErrorMsg($strErrFtpNoGet);
} else {
    $xml = new XML_simple_data();
    $arr_noCat = $xml->load_xml_simple($_FILES['xmlfile']['tmp_name'], 'regUKC', '', $ukc_meeting);
    if ($arr_noCat['cat'][0] != '') {
        foreach ($arr_noCat['cat'] as $key => $val) {
            $mess = str_replace('%NAME%', $val, $strXmlNoCatAge);
            echo $mess;
        }
    }
    if ($arr_noCat['club'][0] != '') {
        foreach ($arr_noCat['club'] as $key => $val) {
            $mess = str_replace('%NAME%', $val, $strXmlNoClub);
            echo $mess;
        }
    }
コード例 #12
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 
    }
コード例 #13
0
 function printList($key = 0)
 {
     require './config.inc.php';
     $this->select->options[1] = 1;
     $this->select->options[2] = 2;
     if (!empty($GLOBALS['AA_ERROR'])) {
         AA_printErrorMsg($GLOBALS['AA_ERROR']);
     }
     if ($key == 0) {
         $key = '-';
     }
     $this->select->selectOption($key);
     $this->select->printList();
 }
コード例 #14
0
 function getNextHeight($heat, $curr_perf)
 {
     require './lib/common.lib.php';
     $result = mysql_query("\r\n        SELECT DISTINCT\r\n            r.Leistung\r\n        FROM\r\n            resultat AS r\r\n            , serienstart AS ss\r\n        WHERE r.xSerienstart = ss.xSerienstart\r\n        AND ss.xSerie = {$heat}\r\n        AND r.Leistung > {$curr_perf}\r\n        ORDER BY\r\n            r.Leistung ASC\r\n    ");
     if (mysql_errno() > 0) {
         // DB error
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $row = mysql_fetch_row($result);
         $new_perf = AA_formatResultMeter($row[0]);
         mysql_free_result($result);
     }
     return $new_perf;
 }
コード例 #15
0
ファイル: timing.lib.php プロジェクト: laiello/athletica
function AA_timing_getAutoRank()
{
    $autorank = '';
    $res = mysql_query("SELECT AutoRangieren FROM meeting WHERE xMeeting = " . $_COOKIE['meeting_id']);
    if (mysql_errno() > 0) {
        AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
    } else {
        $row = mysql_fetch_row($res);
        $autorank = $row[0];
    }
    return $autorank;
}
コード例 #16
0
ファイル: event_results.php プロジェクト: laiello/athletica
                        AA_printErrorMsg($GLOBALS['AA_ERROR']);
                    }
                } else {
                    if ($_POST['arg'] == 'add_start') {
                        // add new athlete/relay
                        AA_heats_addStart($round);
                        if (!empty($GLOBALS['AA_ERROR'])) {
                            AA_printErrorMsg($GLOBALS['AA_ERROR']);
                        }
                        AA_timing_setStartInfo($round, false);
                    } else {
                        if ($_GET['arg'] == 'del_start') {
                            // delete athlete/relay
                            AA_heats_deleteStart();
                            if (!empty($GLOBALS['AA_ERROR'])) {
                                AA_printErrorMsg($GLOBALS['AA_ERROR']);
                            }
                            AA_timing_setStartInfo($round, false);
                        } elseif ($_GET['arg'] == "del_results") {
                            // delete all results
                            AA_results_deleteResults($round);
                        } elseif ($_GET['arg'] == "live_results") {
                            // reset status live
                            AA_utils_changeRoundStatus($round, $GLOBALS['cfgRoundStatus']['results_in_progress']);
                        }
                    }
                }
            }
        }
    }
}
コード例 #17
0
    function AA_speaker_High($event, $round, $layout)
    {
        require './lib/cl_gui_resulttable.lib.php';
        require './config.inc.php';
        require './lib/common.lib.php';
        require './lib/results.lib.php';
        $status = AA_getRoundStatus($round);
        $svm = AA_checkSVM(0, $round);
        // decide whether to show club or team name
        $mergedMain = AA_checkMainRound($round);
        if ($mergedMain != 1) {
            // 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", $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/>";
                        }
                        $prog_mode = AA_results_getProgramMode();
                        // display all athletes
                        $sql = "\r\n            SELECT\r\n                rt.Name\r\n                , rt.Typ\r\n                , s.xSerie\r\n                , s.Bezeichnung\r\n                , s.Status\r\n                , ss.xSerienstart\r\n                , ss.Position\r\n                , ss.Rang\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                , st.Bestleistung\r\n                , at.xAthlet\r\n                , at.Land\r\n                , r.Status\r\n                , ss.Starthoehe\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 team AS te ON(a.xTeam = te.xTeam) \r\n                LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n                LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n            WHERE \r\n                r.xRunde = {$round}   \r\n            ORDER BY\r\n                heatid\r\n                , ss.Position";
                        $result = mysql_query($sql);
                        if (mysql_errno() > 0) {
                            // DB error
                            AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                        } else {
                            // initialize variables
                            $h = 0;
                            $i = 0;
                            $current_athlete = false;
                            $curr_class = '';
                            $resTable = new GUI_HighResultTable($round, $layout, $status);
                            while ($row = mysql_fetch_row($result)) {
                                /*
                                 *  Heat headerline
                                 */
                                if ($h != $row[2]) {
                                    $h = $row[2];
                                    // keep heat ID
                                    if (is_null($row[0])) {
                                        // only one round
                                        $title = "{$strFinalround}  {$row['3']}";
                                    } else {
                                        // more than one round
                                        $title = "{$row['0']}: {$row['1']}{$row['3']}";
                                    }
                                    $c = 0;
                                    if ($status == $cfgRoundStatus['results_done']) {
                                        $c = 1;
                                        // increment colspan to include ranking
                                    }
                                    $resTable->printHeatTitle($row[2], $row[3], $title, $row[4]);
                                    $resTable->printAthleteHeader('', $round, $row[17]);
                                }
                                // ET new heat
                                /*
                                 * Athlete data lines
                                 */
                                $rank = '';
                                $perfs = array();
                                $res = mysql_query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\tr.Leistung\r\n\t\t\t\t\t\t, r.Info\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tresultat as r\r\n\t\t\t\t\tWHERE r.xSerienstart = {$row['5']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\tr.xResultat DESC\r\n\t\t\t\t");
                                if (mysql_errno() > 0) {
                                    // DB error
                                    AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                } else {
                                    if ($status == $cfgRoundStatus['results_done']) {
                                        $rank = $row[7];
                                    }
                                    while ($resrow = mysql_fetch_row($res)) {
                                        $perf = AA_formatResultMeter($resrow[0]);
                                        $info = $resrow[1];
                                        $perfs[] = "{$perf} ( {$info} )";
                                    }
                                    // end loop every tech result acc. programm mode
                                    mysql_free_result($res);
                                }
                                $heatStart = AA_getCurrAthlete($row[2]);
                                if ($heatStart > 0) {
                                    if ($row[5] == $heatStart) {
                                        $curr_class = "active";
                                    }
                                } else {
                                    if (empty($perfs) && !$current_athlete) {
                                        $current_athlete = true;
                                        $curr_class = "active";
                                    }
                                }
                                $resTable->printAthleteLine($row[6], $row[8], "{$row['9']} {$row['10']}", AA_formatYearOfBirth($row[11]), $row[12], AA_formatResultMeter($row[14]), $perfs, $fett, $rank, $row[16], $row[15], $curr_class, '', $row[17], $row[18]);
                                $curr_class = "";
                            }
                            $resTable->endTable();
                            mysql_free_result($result);
                        }
                        // ET DB error
                    }
                }
            }
            // ET heat seeding done
        } else {
            AA_printErrorMsg($strErrMergedRoundSpeaker);
        }
        ?>
 
    
   <script type="text/javascript">
<!--
    window.setTimeout("updatePage()", <?php 
        echo $cfgMonitorReload * 1000;
        ?>
);

   

    function updatePage()
    {
        window.open("speaker_results.php?round=<?php 
        echo $round;
        ?>
", "main");
    }

    
</script> 
    
    
    <?php 
    }
コード例 #18
0
 function printList($scoretable, $key)
 {
     require './config.inc.php';
     // get items from DB
     /*$this->select->addOptionsFromDB("
     			SELECT
     				DISTINCT(wertungstabelle_punkte.xDisziplin) 
     				, Name
     			FROM
     				wertungstabelle_punkte 
     			LEFT JOIN
     				disziplin 
     			USING(xDisziplin) 
     			WHERE
     				xWertungstabelle = ".$scoretable." 
     			ORDER BY
     				Name
     		");*/
     $this->select->addOptionsFromDB("\r\n\t\t\tSELECT\r\n\t\t\t\tDISTINCT(xDisziplin) \r\n\t\t\t\t, Name\r\n\t\t\tFROM\r\n\t\t\t\tdisziplin \r\n\t\t\tORDER BY\r\n\t\t\t\tAnzeige\r\n\t\t");
     if (!empty($GLOBALS['AA_ERROR'])) {
         AA_printErrorMsg($GLOBALS['AA_ERROR']);
     }
     if ($key == 0) {
         $key = '-';
     }
     $this->select->selectOption($key);
     $this->select->printList();
 }
コード例 #19
0
                    <form action='meeting_entries_receipt.php' method='post' name='athleteSearch'>   
                    <input name='arg' type='hidden' value='change_athlete' /> 
                    <input name='club' type='hidden' value='<?php 
echo $club;
?>
' />  
                    <input name='athleteSearch' type='hidden' value='<?php 
echo $athleteSearch;
?>
' />                 
                    <?php 
$dropdown = new GUI_Select('athleteSearch', 1, "document.athleteSearch.submit()");
$sql_athlets = "SELECT    \r\n                                at.Vorname, \r\n                                at.Name, \r\n                                a.xAnmeldung \r\n                         FROM \r\n                                anmeldung AS a\r\n                                LEFT JOIN athlet AS at USING (xAthlet)\r\n                                \r\n                         WHERE \r\n                                a.xMeeting = " . $_COOKIE['meeting_id'] . " \r\n                                " . $club_clause . "\r\n                         ORDER BY at.Name, at.Vorname";
$result_a = mysql_query($sql_athlets);
if (mysql_errno() > 0) {
    AA_printErrorMsg("Line " . __LINE__ . ": " . mysql_errno() . ": " . mysql_error());
} else {
    if (mysql_num_rows($result_a) > 0) {
        while ($row_athlets = mysql_fetch_row($result_a)) {
            $name_athlete = $row_athlets[1] . " " . $row_athlets[0];
            $dropdown->addOption($name_athlete, $row_athlets[2]);
        }
        $dropdown->selectOption($athleteSearch);
        $dropdown->addOptionNone();
        $dropdown->printList();
    } else {
        $search_occurred = true;
        $search_match;
    }
}
?>
コード例 #20
0
ファイル: event_heats.php プロジェクト: laiello/athletica
	</tr>
<?php 
                        // set a new heat name
                        $newhn = chr(ord($hn) + 1);
                        AA_heats_printEmptyTracks(1, 1, 0, $newhn);
                        printf("</table>");
                        mysql_free_result($result);
                    }
                    // ET DB error
                } else {
                    if ($status == $cfgRoundStatus['results_in_progress']) {
                        AA_printWarningMsg($strResultsInWork);
                    } else {
                        if ($status == $cfgRoundStatus['results_done']) {
                            AA_printWarningMsg($strErrResultsEntered);
                        }
                    }
                    ?>
	<br/>
<?php 
                    $btn = new GUI_Button("event_results.php?round={$round}", $strOpenResultView);
                    $btn->printButton();
                }
            }
        }
    }
    // ET round selected
} else {
    AA_printErrorMsg($strErrMergedRound);
}
$page->endPage();
コード例 #21
0
ファイル: entries.lib.php プロジェクト: laiello/athletica
 /**
  *	assign startnumbers
  *	-------------------
  */
 function AA_entries_assignStartnumbers()
 {
     require './lib/common.lib.php';
     //
     // Content
     // -------
     if (empty($_COOKIE['meeting_id'])) {
         AA_printErrorMsg($GLOBALS['strNoMeetingSelected']);
     }
     if ($_GET['sort'] != "del") {
         // sort argument
         if ($_GET['sort'] == "name") {
             $argument = "athlet.Name, athlet.Vorname";
         } else {
             if ($_GET['sort'] == "nbr") {
                 $argument = "anmeldung.Startnummer";
             } else {
                 if ($_GET['sort'] == "cat") {
                     $argument = "kategorie.Anzeige, athlet.Name, athlet.Vorname";
                 } else {
                     if ($_GET['sort'] == "club") {
                         $argument = "verein.Sortierwert, athlet.Name, athlet.Vorname";
                     } else {
                         if ($_GET['sort'] == "club_cat") {
                             $argument = "verein.Sortierwert, kategorie.Anzeige, athlet.Name, athlet.Vorname";
                         } else {
                             $argument = "athlet.Name, athlet.Vorname";
                         }
                     }
                 }
             }
         }
         // assignment rules
         if (!empty($_GET['start'])) {
             $nbr = $_GET['start'] - 1;
             // first number
         } else {
             $nbr = $cfgNbrStartWith - 1;
             // default
         }
         if (!empty($_GET['catgap']) || $_GET['catgap'] == '0') {
             $catgap = $_GET['catgap'];
             // nbr gap between each category
         } else {
             $catgap = $cfgNbrCategoryGap;
             // default
         }
         if (!empty($_GET['clubgap']) || $_GET['clubgap'] == '0') {
             $clubgap = $_GET['clubgap'];
             // nbr gap between each club
         } else {
             $clubgap = $cfgNbrClubyGap;
             // default
         }
         //
         // Read athletes
         //
         mysql_query("LOCK TABLES athlet READ, kategorie READ, verein READ" . ", anmeldung wRITE");
         $result = mysql_query("SELECT anmeldung.xAnmeldung" . ", anmeldung.xKategorie" . ", athlet.xVerein" . " FROM anmeldung" . ", athlet" . ", kategorie" . ", verein" . " WHERE anmeldung.xMeeting = " . $_COOKIE['meeting_id'] . " AND anmeldung.xAthlet = athlet.xAthlet" . " AND anmeldung.xKategorie = kategorie.xKategorie" . " AND athlet.xVerein = verein.xVerein" . " ORDER BY " . $argument);
         if (mysql_errno() > 0) {
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             if (mysql_num_rows($result) > 0) {
                 $k = 0;
                 // initialize current category
                 $v = 0;
                 // initialize current club
                 // Assign startnumbers
                 while ($row = mysql_fetch_row($result)) {
                     if ($v != $row[2] && $clubgap > 0 && $v > 0 && ($_GET['sort'] == "club_cat" || $_GET['sort'] == "club")) {
                         $nbr = $nbr + $clubgap;
                         // calculate next number
                     } else {
                         if ($k != $row[1] && $catgap > 0 && $k > 0 && ($_GET['sort'] == "club_cat" || $_GET['sort'] == "cat")) {
                             $nbr = $nbr + $catgap;
                             // calculate next number
                         } else {
                             $nbr++;
                         }
                     }
                     mysql_query("UPDATE anmeldung SET" . " Startnummer='" . $nbr . "' WHERE xAnmeldung='" . $row[0] . "'");
                     if (mysql_errno() > 0) {
                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                     }
                     $k = $row[1];
                     // keep current category
                     $v = $row[2];
                     // keep current club
                 }
                 mysql_free_result($result);
             }
         }
         // ET DB error
         mysql_query("UNLOCK TABLES");
     } else {
         mysql_query("LOCK TABLE anmeldung WRITE");
         mysql_query("UPDATE anmeldung SET" . " Startnummer='0'" . " WHERE xMeeting='" . $_COOKIE['meeting_id'] . "'");
         if (mysql_errno() > 0) {
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         }
         mysql_query("UNLOCK TABLES");
     }
 }
コード例 #22
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);
        }
    }
コード例 #23
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");
 }
コード例 #24
0
 function processDiscipline($event, $disctype, $catname, $discname, $windmeas, $list)
 {
     global $rFrom, $rTo, $limitRank, $date;
     require 'config.inc.php';
     $teams = array();
     // team array
     $countRes = 3;
     // results per team counting
     $order_perf = "";
     $valid_result = "";
     if ($disctype == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $disctype == $cfgDisciplineType[$strDiscTypeThrow]) {
         $order_perf = "DESC";
     } else {
         if ($disctype == $cfgDisciplineType[$strDiscTypeJump]) {
             if ($windmeas == 1) {
                 // with wind
                 $order_perf = "DESC, r.Info ASC";
             } else {
                 // without wind
                 $order_perf = "DESC";
             }
         } else {
             if ($disctype == $cfgDisciplineType[$strDiscTypeHigh]) {
                 $order_perf = "DESC";
                 $valid_result = " AND (r.Info LIKE '%O%' OR r.Leistung < 0)";
             } else {
                 $order_perf = "ASC";
             }
         }
     }
     $sql_leistung = $order_perf == 'ASC' ? "r.Leistung" : "IF(r.Leistung<0, (If(r.Leistung = -99, -9, r.Leistung) * -1), r.Leistung)";
     $res = mysql_query("\r\n\t\tSELECT\r\n\t\t\tts.xTeamsm\r\n\t\t\t, ts.Name\r\n\t\t\t, v.Name\r\n\t\t\t, at.Name\r\n\t\t\t, at.Vorname\r\n\t\t\t, a.Startnummer\r\n\t\t\t, " . $sql_leistung . " AS leistung_neu\r\n\t\t\t, at.xAthlet\r\n\t\tFROM\r\n\t\t\tteamsm AS ts\r\n\t\t\t, verein AS v\r\n\t\t\t, teamsmathlet AS tsa\r\n\t\t\t, anmeldung AS a\r\n\t\t\t, athlet AS at\r\n\t\t\t, start AS st\r\n\t\t\t, serienstart AS ss\r\n\t\t\t, resultat AS r \r\n\t\t\t, serie AS se\r\n\t\t\t, runde as ru\r\n\t\tWHERE\r\n\t\t\tts.xWettkampf = {$event}\r\n\t\tAND\ttsa.xTeamsm = ts.xTeamsm\r\n\t\tAND\tv.xVerein = ts.xVerein\r\n\t\tAND\ta.xAnmeldung = tsa.xAnmeldung\r\n\t\tAND\tat.xAthlet = a.xAthlet\r\n\t\tAND\tst.xAnmeldung = tsa.xAnmeldung\r\n\t\tAND\tst.xWettkampf = {$event}\r\n\t\tAND\tss.xStart = st.xStart\r\n\t\tAND ss.xSerie = se.xSerie\r\n\t\tAND se.xRunde = ru.xRunde\r\n\t\tAND ru.Datum LIKE '" . $date . "'\r\n\t\t\r\n\t\tAND\tr.xSerienstart = ss.xSerienstart\r\n\t\t{$valid_result}\r\n\t\t\r\n\t\tORDER BY\r\n\t\t\tts.xTeamsm\r\n\t\t\t, leistung_neu {$order_perf}\r\n\t");
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $team = 0;
         // current team
         $c = 0;
         // count results
         $athletes = array();
         $teams_notValid = array();
         // team array
         while ($row = mysql_fetch_array($res)) {
             $row_res[6] = $row_res[6] == 1 || $row_res[6] == 2 || $row_res[6] == 3 || $row_res[6] == 4 ? $row_res[6] * -1 : ($row_res[6] == 9 ? -99 : $row_res[6]);
             if (isset($athletes[$row[7]])) {
                 continue;
             } else {
                 $athletes[$row[7]] = 1;
             }
             if ($team != $row[0]) {
                 if ($team > 0) {
                     $countAthl = count($teams[$team]['athletes']);
                     if ($countAthl < $countRes) {
                         $teams[$team]['perf'] = 0;
                         $teams_notValid[$team]['club'] = $teams[$team]['club'];
                         $teams_notValid[$team]['name'] = $teams[$team]['name'];
                         $teams_notValid[$team]['perf'] = 0;
                         $teams_notValid[$team]['athletes'] = $teams[$team]['athletes'];
                     } else {
                         $teams[$team]['perf'] /= $countRes;
                     }
                 }
                 $team = $row[0];
                 $teams[$team]['club'] = $row[2];
                 $teams[$team]['name'] = $row[1];
                 $c = 0;
             }
             $perf = 0;
             $perf_print = 0;
             if ($disctype == $cfgDisciplineType[$strDiscTypeJump] || $disctype == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $disctype == $cfgDisciplineType[$strDiscTypeThrow] || $disctype == $cfgDisciplineType[$strDiscTypeHigh]) {
                 $perf = $row[6];
                 $perf_print = AA_formatResultMeter($row[6]);
             } else {
                 $perf = ceil($row[6] / 10) * 10;
                 // round up 1000
                 if ($disctype == $cfgDisciplineType[$strDiscTypeTrack] || $disctype == $cfgDisciplineType[$strDiscTypeTrackNoWind]) {
                     $perf_print = AA_formatResultTime($row[6], true, true);
                 } else {
                     $perf_print = AA_formatResultTime($row[6], true);
                 }
             }
             if ($c < $countRes) {
                 $teams[$team]['perf'] += $perf;
                 $teams[$team]['athletes'][] = "{$row['3']} {$row['4']}, {$perf_print}";
             } else {
                 $teams[$team]['athletes'][] = "[{$row['3']} {$row['4']}, {$perf_print}]";
             }
             $c++;
         }
         if ($team > 0) {
             // calc last team
             $countAthl = count($teams[$team]['athletes']);
             if ($countAthl < $countRes) {
                 $teams[$team]['perf'] = 0;
                 $teams_notValid[$team]['club'] = $teams[$team]['club'];
                 $teams_notValid[$team]['name'] = $teams[$team]['name'];
                 $teams_notValid[$team]['perf'] = 0;
                 $teams_notValid[$team]['athletes'] = $teams[$team]['athletes'];
             } else {
                 $teams[$team]['perf'] /= $countRes;
             }
         }
         $teams_valid = array();
         foreach ($teams as $k => $arr_team) {
             if (!isset($teams_notValid[$k]['name'])) {
                 $teams_valid[$k]['name'] = $teams[$k]['name'];
                 $teams_valid[$k]['club'] = $teams[$k]['club'];
                 $teams_valid[$k]['perf'] = $teams[$k]['perf'];
                 $teams_valid[$k]['athletes'] = $teams[$k]['athletes'];
             }
         }
         $teams = $teams_valid;
         //
         // print team ranking
         //
         if (count($teams) > 0) {
             $list->printSubTitle($catname, $discname, "");
             $list->startList();
             $list->printHeaderLine();
             usort($teams, "cmp_{$order_perf}");
             // sort by performance
             $teams = array_merge($teams, $teams_notValid);
             $rank = 1;
             // initialize rank
             $r = 0;
             // start value for ranking
             $p = 0;
             foreach ($teams as $team) {
                 $r++;
                 if ($limitRank && ($r < $rFrom || $r > $rTo)) {
                     // limit ranks if set (export)
                     continue;
                 }
                 if ($p != $team['perf']) {
                     // not the same performance
                     $rank = $r;
                     // next rank
                 } else {
                     $rank = '';
                 }
                 $perf = 0;
                 if ($disctype == $cfgDisciplineType[$strDiscTypeJump] || $disctype == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $disctype == $cfgDisciplineType[$strDiscTypeThrow] || $disctype == $cfgDisciplineType[$strDiscTypeHigh]) {
                     $perf = AA_formatResultMeter($team['perf']);
                 } else {
                     if ($disctype == $cfgDisciplineType[$strDiscTypeTrack] || $disctype == $cfgDisciplineType[$strDiscTypeTrackNoWind]) {
                         $perf = AA_formatResultTime($team['perf'], true, true);
                     } else {
                         $perf = AA_formatResultTime($team['perf'], true);
                     }
                 }
                 if ($perf == 0) {
                     $rank = '';
                 }
                 $list->printLine($rank, $team['name'], $team['club'], $perf);
                 // print each athlete with result for team
                 $tmp = "";
                 foreach ($team['athletes'] as $athlete) {
                     //$list->printInfo($athlete);
                     $tmp .= $athlete . " / ";
                 }
                 $list->printInfo(substr($tmp, 0, -2));
                 $p = $team['perf'];
                 // keep current performance
             }
             $list->endList();
         }
     }
 }
コード例 #25
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);
 }
コード例 #26
0
ファイル: common.lib.php プロジェクト: laiello/athletica
 /**    
  * check event for tech discipline
  * -------------------------------
  */
 function AA_checkEventDisc($event)
 {
     global $cfgDisciplineType, $strDiscTypeJump, $strDiscTypeJumpNoWind, $strDiscTypeHigh, $strDiscTypeThrow;
     $techDisc = false;
     $sql = "SELECT \r\n                d.Typ\r\n            FROM \r\n                wettkampf as w\r\n                LEFT JOIN disziplin_" . $_COOKIE['language'] . " AS d ON (w.xDisziplin = d.xDisziplin)     \r\n            WHERE \r\n                (d.Typ = " . $cfgDisciplineType[$strDiscTypeJump] . " || d.Typ = " . $cfgDisciplineType[$strDiscTypeJumpNoWind] . " || d.Typ = " . $cfgDisciplineType[$strDiscTypeHigh] . " || d.Typ = " . $cfgDisciplineType[$strDiscTypeThrow] . ") \r\n                AND w.xWettkampf = " . $event;
     $res = mysql_query($sql);
     if (mysql_errno() > 0) {
         // DB error
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     }
     if (mysql_num_rows($res) > 0) {
         $techDisc = true;
     }
     return $techDisc;
 }
コード例 #27
0
function meeting_get_disciplines()
{
    global $athlete_id, $cfgDisciplineType, $cfgEventType, $strEventTypeSingleCombined, $strEventTypeClubCombined, $strDiscTypeTrack, $strDiscTypeTrackNoWind, $strDiscTypeRelay, $strDiscTypeDistance, $discs_def, $combs_def, $first, $catcode, $birth_date, $athletesex;
    $combs_def = array();
    // delete the selected disziplines from previous enrolement
    $order = "ASC";
    if ($athletesex == 'w') {
        $order = "DESC";
    }
    $sql = "SELECT\r\n            d.Kurzname as DiszKurzname\r\n            , d.Typ as DiszTyp\r\n            , w.xWettkampf\r\n            , w.Typ\r\n            , k.Kurzname as KatKurzname\r\n            , k.Name\r\n            , d.Code as DiszCode\r\n            , k.Code as KatCode\r\n            , k.xKategorie\r\n            , w.Info\r\n            , w.Mehrkampfcode\r\n            , k.Geschlecht\r\n            , k.Alterslimite\r\n        FROM\r\n            disziplin_" . $_COOKIE['language'] . " AS d\r\n            LEFT JOIN wettkampf as w ON (w.xDisziplin = d.xDisziplin)\r\n            LEFT JOIN kategorie as k ON (w.xKategorie = k.xKategorie)\r\n        WHERE \r\n            w.xMeeting = " . $_COOKIE['meeting_id'] . "         \r\n        ORDER BY\r\n             k.Geschlecht {$order}, k.Alterslimite, k.Kurzname, w.Mehrkampfcode, d.Anzeige";
    $result = mysql_query($sql);
    if (mysql_errno() > 0) {
        AA_printErrorMsg("Line " . __LINE__ . ": " . mysql_errno() . ": " . mysql_error());
    }
    $i = 0;
    $d = 0;
    $k = 0;
    $last_cat = "";
    $comb = 0;
    $combCat = 0;
    $combDiv = "";
    // fetch all rows and put the disciplines of the entry category on top
    $event_rows = array();
    $temp_rows = array();
    // get age of athlete
    $age = 0;
    $currYear = date('Y');
    $age = $currYear - substr($birth_date, 0, 4);
    $first = true;
    while ($event_row = mysql_fetch_row($result)) {
        $first = false;
        if ($catcode != '' && $event_row[8] == $catcode || $event_row[12] == $age && $event_row[11] == $athletesex) {
            $event_rows[] = $event_row;
        } elseif ($event_row[12] > $age && $event_row[11] == $athletesex) {
            if (sizeof($event_rows) == 0) {
                $event_rows[] = $event_row;
            } else {
                if (in_array($event_row[7], $event_rows[0])) {
                    $event_rows[] = $event_row;
                }
            }
        }
    }
    $kName = $event_rows[0][4];
    $sql = "SELECT  DISTINCT\r\n            d.Kurzname as DiszKurzname\r\n            , d.Typ as DiszTyp\r\n            , w.xWettkampf\r\n            , w.Typ\r\n            , k.Kurzname as KatKurzname\r\n            , k.Name\r\n            , d.Code as DiszCode\r\n            , k.Code as KatCode\r\n            , k.xKategorie\r\n            , w.Info\r\n            , w.Mehrkampfcode\r\n            , k.Geschlecht\r\n            , k.Alterslimite   \r\n        FROM\r\n            disziplin_" . $_COOKIE['language'] . " AS d \r\n            LEFT JOIN wettkampf as w  ON (w.xDisziplin = d.xDisziplin)    \r\n            LEFT JOIN kategorie as k ON (w.xKategorie = k.xKategorie)\r\n        WHERE \r\n            w.xMeeting = " . $_COOKIE['meeting_id'] . "  \r\n        ORDER BY\r\n            k.Geschlecht " . $order . ", k.Alterslimite DESC,  k.Kurzname, w.Mehrkampfcode, d.Anzeige";
    $result = mysql_query($sql);
    if (mysql_errno() > 0) {
        AA_printErrorMsg("Line " . __LINE__ . ": " . mysql_errno() . ": " . mysql_error());
    }
    while ($event_row = mysql_fetch_row($result)) {
        if ($event_row[4] != $kName) {
            $event_rows[] = $event_row;
        }
    }
    // display list of events
    // while ($event_row = mysql_fetch_row($result))
    foreach ($event_rows as $event_row) {
        if ($last_cat != $event_row[4]) {
            // new row with title for separating categories
            $k++;
            // cat counter
            if ($comb > 0) {
                echo "</table></div></td>";
                $comb = 0;
            }
            if ($last_cat != "") {
                printf("</tr>");
                echo "</table></div>\n";
            }
            echo "<div id='place{$k}'><table id='cat{$event_row['8']}'>\n";
            printf("<tr><td colspan=6 class='cat'>{$event_row['5']}</td></tr><tr>");
            $last_cat = $event_row[4];
            $d = 0;
        } else {
            if ($d % 3 == 0) {
                // new row after three events
                if ($i != 0) {
                    printf("</tr>");
                    // terminate previous row
                }
                $i++;
                printf("<tr>\n");
            }
        }
        $class = 'meter';
        if ($event_row[1] == $cfgDisciplineType[$strDiscTypeTrack] || $event_row[1] == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $event_row[1] == $cfgDisciplineType[$strDiscTypeRelay] || $event_row[1] == $cfgDisciplineType[$strDiscTypeDistance]) {
            $class = 'time';
        }
        //
        // get performance from base data if searched for an athlete
        //
        $effort = 0;
        if ($athlete_id > 0) {
            $saison = $_SESSION['meeting_infos']['Saison'];
            if ($saison == '') {
                $saison = "O";
                //if no saison is set take outdoor
            }
            $sql = "\r\n\t\t\t\tSELECT \r\n\t\t\t\t\tseason_effort, notification_effort \r\n\t\t\t\tFROM\r\n\t\t\t\t\tbase_performance\r\n\t\t\t\tWHERE\tid_athlete = {$athlete_id}\r\n\t\t\t\tAND\tdiscipline = " . $event_row[6] . "\r\n\t\t\t\tAND season = '{$saison}'";
            $res = mysql_query($sql);
            if (mysql_errno() > 0) {
                AA_printErrorMsg("Line " . __LINE__ . ": " . mysql_errno() . ": " . mysql_error());
                echo $sql;
            } else {
                $rowPerf = mysql_fetch_array($res);
                $effort = $rowPerf['notification_effort'];
                // best effort current or previous year (Indoor: best of both / Outdoor: best of outdoor)
            }
        }
        $effort = ltrim($effort, "0:");
        //
        // merge the disciplines for a combined event
        //
        if ($event_row[3] == $cfgEventType[$strEventTypeSingleCombined]) {
            $d = 1;
            if ($comb != $event_row[10]) {
                if ($comb > 0) {
                    echo "</table></div>";
                    echo "</td></tr><tr>";
                }
                $comb = $event_row[10];
                $combCat = $event_row[8];
                $comb_res = mysql_query("SELECT Name FROM disziplin_" . $_COOKIE['language'] . " WHERE Code = {$comb}");
                $comb_row = mysql_Fetch_array($comb_res);
                global $AthReg;
                global $arr_checkedCombs;
                if ($AthReg) {
                    if (in_array($event_row[2], $arr_checkedCombs)) {
                        $checked = ' checked="checked"';
                    } else {
                        $checked = ' ';
                    }
                } else {
                    $checked = isset($combs_def[$event_row[8] . "_" . $comb]) ? ' checked="checked"' : '';
                }
                $val = isset($combs_def[$event_row[8] . "_" . $comb]) ? $combs_def[$event_row[8] . "_" . $comb] : '';
                //get performance from base -----------------------------------------------------------------------
                if ($val == '') {
                    //dont overwrite value ... no guess what can be stored in $val before.. ***SBA***
                    $sql = "\r\n\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\tseason_effort, notification_effort \r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\tbase_performance\r\n\t\t\t\t\t\tWHERE\tid_athlete = {$athlete_id}\r\n\t\t\t\t\t\tAND\tdiscipline = " . $comb . "\r\n\t\t\t\t\t\tAND season = '{$saison}'";
                    $res_perf_comb = mysql_query($sql);
                    if (mysql_errno() > 0) {
                        AA_printErrorMsg("Line " . __LINE__ . ": " . mysql_errno() . ": " . mysql_error());
                        echo $sql;
                    } else {
                        $row_perf_comb = mysql_fetch_array($res_perf_comb);
                        $val = $row_perf_comb['notification_effort'];
                        // best effort current or previous year (Indoor: best of both / Outdoor: best of outdoor)
                        //  $seasonval = $row_perf_comb['season_effort'];     // base_performance feld wird von alabus noch defniniert im 2012
                        $seasonval = 0;
                        $val = ltrim($val, "0:");
                        $val = substr($val, -2) == ".0" ? substr($val, 0, -2) : $val;
                        $seasonval = ltrim($seasonval, "0:");
                        $seasonval = substr($seasonval, -2) == ".0" ? substr($seasonval, 0, -2) : $seasonval;
                    }
                }
                //--------------------------------------------------------------------------------------------------
                ?>
				<td class='dialog-top' nowrap="nowrap" id="topperftd<?php 
                echo $combCat . $comb;
                ?>
">
					<input type="checkbox" value="<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
" name="combined[]" id="combinedCheck<?php 
                echo $event_row[8];
                ?>
_<?php 
                echo $comb;
                ?>
" 
						onclick="check_combined('<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
', this);
							validate_discipline(<?php 
                echo "'" . $combCat . $comb . "', '" . $event_row[11] . "', " . $event_row[12];
                ?>
,this.checked);"<?php 
                echo $checked;
                ?>
>
					<?php 
                echo $comb_row['Name'];
                ?>
				</td>
				<td class='dialog-top' nowrap="nowrap">
					<input type="text" name="topcomb_<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
" id="topcomb<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
" size="5" value="<?php 
                echo $val;
                ?>
">
                    <input type="hidden" name="hidden_topcomb_<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
" id="hidden_topcomb<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
"  value="<?php 
                echo $seasonval;
                ?>
">
				</td>
				<td class='dialog' nowrap="nowrap" colspan="4" id='td_<?php 
                echo $event_row[8] . "_" . $comb;
                ?>
'>
					<div id="div_<?php 
                echo $event_row[8];
                ?>
_<?php 
                echo $comb;
                ?>
" style="position: relative; display: none;">
						<?php 
                if ($checked == ' checked="checked"') {
                    ?>
							<script type="text/javascript">
								check_combined('<?php 
                    echo $event_row[8];
                    ?>
_<?php 
                    echo $comb;
                    ?>
', document.getElementById('combinedCheck<?php 
                    echo $event_row[8];
                    ?>
_<?php 
                    echo $comb;
                    ?>
'));
								validate_discipline('<?php 
                    echo $combCat;
                    echo $comb;
                    ?>
', '<?php 
                    echo $event_row[11];
                    ?>
', <?php 
                    echo $event_row[12];
                    ?>
,this.checked);
							</script>
							<?php 
                }
                ?>
						<table>
						<?php 
            }
            $effort = isset($discs_def[$event_row[2]]) && $effort == '' ? $discs_def[$event_row[2]] : $effort;
            // create text nodes for adding with javascript
            echo "<tr><td class='dialog'>\r\n\t\t\t\t\t<input name='start_{$event_row['2']}' type='checkbox' id='start{$event_row['2']}'\r\n\t\t\t\t\t\t\t\tvalue='start_{$event_row['0']}' checked/>\r\n\t\t\t\t\t\t\t\t{$event_row['0']}\r\n\t\t\t\t</td>\r\n\t\t\t\t<td class='forms'  nowrap=\"nowrap\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"eventscombtemp[]\" value=\"{$event_row['2']}\">\r\n\t\t\t\t\t<input class='perf{$class}' type=\"text\" name=\"topperf_{$event_row['2']}\" value='{$effort}'\r\n\t\t\t\t\t\tid='topperf{$event_row['2']}' >\r\n\t\t\t\t\t<input name='type_{$event_row['2']}' type='hidden' value='{$class}' />\r\n\t\t\t\t</td></tr>\n";
        } else {
            if ($comb > 0) {
                echo "</table></div>";
                $comb = 0;
            }
            global $AthReg;
            global $arr_checkedDisc;
            if ($AthReg) {
                if (in_array($event_row[2], $arr_checkedDisc)) {
                    $checked = ' checked="checked"';
                } else {
                    $checked = ' ';
                }
            } else {
                $checked = isset($discs_def[$event_row[2]]) && $first != '' ? ' checked="checked"' : '';
            }
            $info = strlen($event_row[9]) == 0 ? "" : "(" . $event_row[9] . ")";
            ?>
            <td class="dialog-top" nowrap="nowrap" id='topperftd<?php 
            echo $event_row[2];
            ?>
'>
                <input name='start_<?php 
            echo $event_row[2];
            ?>
' type='hidden' id='start<?php 
            echo $event_row[2];
            ?>
'
                                value='start_<?php 
            echo $event_row[0];
            ?>
'/>
                <input name='events[]' type='checkbox' value='<?php 
            echo $event_row['2'];
            ?>
'
                 onclick="validate_discipline(<?php 
            echo $event_row[2] . ',\'' . $event_row[11] . '\',' . $event_row[12] . ',';
            ?>
this.checked)" <?php 
            echo $checked;
            ?>
/><?php 
            echo $event_row[0] . $info;
            ?>
</td>
            <?php 
            $effort = isset($discs_def[$event_row[2]]) && $effort == '' && $first != '' ? $discs_def[$event_row[2]] : $effort;
            printf("<td class=\"dialog-top\" nowrap=\"nowrap\">\r\n\t\t\t\t<input name='type_{$event_row['2']}' type='hidden' value='{$class}' />\r\n\t\t\t\t<input class='perf{$class}' name='topperf_{$event_row['2']}' type='text'\r\n\t\t\t\tvalue='{$effort}' maxlength='12' id='topperf{$event_row['2']}' /></td>");
            $d++;
        }
        // end if not combiend
    }
    // end loop
    if ($comb > 0) {
        echo "</table></div></td>";
    }
    echo "</tr></table></div>\n";
    echo $combDiv;
    mysql_free_result($result);
}
コード例 #28
0
ファイル: cl_gui_page.lib.php プロジェクト: laiello/athletica
        /**
         * printCover 
         * ----------
         * Sets up a cover page with basic meeting data.
         */
        function printCover($type, $timing = true)
        {
            $result = mysql_query("\r\n\t\t\tSELECT m.Name\r\n\t\t\t\t, m.Ort\r\n\t\t\t\t, m.DatumVon\r\n\t\t\t\t, m.DatumBis\r\n\t\t\t\t, s.Name\r\n\t\t\t\t, DATE_FORMAT(m.DatumVon, '" . $GLOBALS['cfgDBdateFormat'] . "')\r\n\t\t\t\t, DATE_FORMAT(m.DatumBis, '" . $GLOBALS['cfgDBdateFormat'] . "')\r\n\t\t\tFROM\r\n\t\t\t\tmeeting AS m\r\n\t\t\t\tLEFT JOIN stadion AS s ON (m.xStadion = s.xStadion)\r\n\t\t\tWHERE m.xMeeting = " . $_COOKIE['meeting_id']);
            if (mysql_errno() > 0) {
                // DB error
                AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
            } else {
                $row = mysql_fetch_row($result);
                $date = $row[5];
                if ($row[2] != $row[3]) {
                    // more than one day
                    $date = $date . " " . $GLOBALS['strDateTo'] . " " . $row[6];
                }
                $this->printSubtitle($type . " " . $row[0]);
                ?>
	<table class='dialog'>
		<tr>
			<th class='dialog'><?php 
                echo $GLOBALS['strStadium'];
                ?>
</th>
			<td class='dialog'><?php 
                echo $row[4] . ", " . $row[1];
                ?>
</td>
		</tr>
		<tr>
			<th class='dialog'><?php 
                echo $GLOBALS['strOrganizer'];
                ?>
</th>
			<td class='dialog'><?php 
                echo $GLOBALS['cfgRankingOrganizer'];
                ?>
</td>
		</tr>
		<tr>
			<th class='dialog'><?php 
                echo $GLOBALS['strDate'];
                ?>
</th>
			<td class='dialog'><?php 
                echo $date;
                ?>
</td>
		</tr>
		<?php 
                if ($timing) {
                    ?>
			<tr>
				<th class='dialog'><?php 
                    echo $GLOBALS['strTiming'];
                    ?>
</th>
				<td class='dialog'><?php 
                    echo $GLOBALS['cfgRankingTiming'];
                    ?>
</td>
			</tr>
			<?php 
                }
                ?>
	</table>
<?php 
                mysql_free_result($result);
            }
        }
コード例 #29
0
ファイル: print_contest.php プロジェクト: laiello/athletica
         $b++;
     }
     if ($relay == FALSE) {
         $doc->printHeatLine($row[4], $row[6], "{$row['7']} {$row['8']}", AA_formatYearOfBirth($row[9]), $row[10], $row[12], $row[14]);
     } else {
         $team = $row[7];
         // relay name
         if ($row[13] > 0) {
             $sqlRound = $row[13];
         } else {
             $sqlRound = $row[10];
         }
         // get the relay athletes
         $res = mysql_query("SELECT at.Name" . ", at.Vorname" . ", sta.Position" . ", IF(at.xRegion = 0, at.Land, re.Anzeige) AS Land" . " FROM athlet AS at" . ", anmeldung AS a" . ", start AS ss" . ", staffelathlet AS sta" . ", start AS st" . " LEFT JOIN region AS re On (at.xRegion = re.xRegion) " . " WHERE ss.xStaffel = " . $row[6] . " AND sta.xStaffelstart = ss.xStart" . " AND sta.xAthletenstart = st.xStart" . " AND st.xAnmeldung = a.xAnmeldung" . " AND a.xAthlet = at.xAthlet" . " AND sta.xRunde = " . $sqlRound . " ORDER BY sta.Position\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT {$maxRunners}");
         if (mysql_errno() > 0) {
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             while ($athl_row = mysql_fetch_row($res)) {
                 $team = $team . "<br />&nbsp;&nbsp;&nbsp;" . $athl_row[2] . ". " . $athl_row[0] . " " . $athl_row[1] . ($athl_row[3] != '' && $athl_row[3] != '-' ? ', ' . $athl_row[3] : '');
             }
             mysql_free_result($res);
         }
         $doc->printHeatLine($row[4], $row[12] . ". " . $team, $row[8]);
     }
 }
 // fill last heat with empty tracks
 $b++;
 while ($b > 1 && $b <= $tracks) {
     $doc->printHeatLine($b, $strEmpty);
     $b++;
 }
コード例 #30
0
ファイル: cl_alge.lib.php プロジェクト: laiello/athletica
 /**
  * get file function
  *
  * - race information in alge timing are stored in a ini format
  */
 function get_file($filename, $ini = false)
 {
     global $strErrFileOpenFailed;
     $tpath = "";
     // get file
     if ($this->connection == "local") {
         $fp = @fopen($this->path . "/" . $filename, 'r');
         $tpath = $this->path . "/";
     } elseif ($this->connection == "ftp") {
         $this->ftp->open_connection($this->host, $this->user, $this->pass);
         $this->ftp->get_file("./tmp/" . $filename, $this->ftppath . "/" . $filename);
         $fp = @fopen("./tmp/" . $filename, 'r');
         $tpath = "./tmp/";
     }
     if (!$fp) {
         if ($this->si == false) {
             AA_printErrorMsg($strErrFileOpenFailed);
         }
         return false;
     } else {
         if ($ini) {
             // parse ini
             @fclose($fp);
             return parse_ini_file($tpath . $filename, true);
         }
         $content = array();
         while (!feof($fp)) {
             $buffer = fgets($fp, 4096);
             if (!empty($buffer)) {
                 $content[] = explode("\t", $buffer);
             }
         }
     }
     return $content;
 }