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] : ' '; ?> </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); } }
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 }