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_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 }
// event selected printf("<td class='forms'>\n"); AA_printRoundSelection("event_heats.php", $presets['category'], $presets['event'], $round); printf("</td>\n"); } if ($round > 0) { // round selected printf("<td class='forms'>\n"); AA_printHeatSelection($round); printf("</td>\n"); } ?> </tr></table> <?php $mergedMain = AA_checkMainRound($round); if ($mergedMain != 1) { // main round or not merged round // read round data if ($round > 0) { $mergedRounds = AA_getMergedRounds($round); // get merged rounds if ($mergedRounds != '') { $SqlRound = " IN " . $mergedRounds; } else { $SqlRound = " = " . $round; } $status = AA_getRoundStatus($round); $combined = AA_checkCombined(0, $round); $svm = AA_checkSVM(0, $round); // decide whether to show club or team name
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 }
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 }
function AA_results_High($round, $layout, $singleRound) { $zaehler = 0; $max = 0; foreach ($_POST as $key => $val) { $arr_key = explode('_', $key); if ($arr_key[0] == 'hight') { $max = $arr_key[1]; } } if ($max > 0) { $max++; } else { $max = $GLOBALS['cfgCountHeight']; } require './lib/cl_gui_button.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/cl_performance.lib.php'; $presets = AA_results_getPresets($round); // read GET/POST variables $performance = 0; // initialize $svm = AA_checkSVM(0, $round); // decide whether to show club or team name $prog_mode = AA_results_getProgramMode(); if ($singleRound > 0) { $single_svm = AA_checkSVM(0, $singleRound); // decide whether to show club or team name } $click = true; // true = User clicks at this athlete false = user save athlete before // // update result(s) // if ($_POST['arg'] == 'save_res') { $click = false; // check if athlet valid if (AA_checkReference("serienstart", "xSerienstart", $_POST['start']) == 0) { AA_printErrorMsg($strErrAthleteNotInHeat); } else { AA_utils_changeRoundStatus($round, $cfgRoundStatus['results_in_progress']); if (!empty($GLOBALS['AA_ERROR'])) { AA_printErrorMsg($GLOBALS['AA_ERROR']); } mysql_query("\r\n LOCK TABLES\r\n disziplin READ\r\n , runde READ\r\n , runde AS r READ \r\n , serienstart WRITE\r\n , wettkampf READ\r\n , wettkampf AS w READ \r\n , resultat WRITE\r\n , wertungstabelle READ\r\n , wertungstabelle_punkte READ\r\n , meeting READ\r\n "); // validate result if ($_POST['attempts'] < 0) { $perf = new PerformanceAttempt($_POST['attempts']); $performance = $perf->getPerformance(); } else { $perf = new PerformanceAttempt($_POST['perf']); $performance = $perf->getPerformance(); } // validate attempts if ($performance > 0) { $info = strtoupper($_POST['attempts']); $info = strtr($info, '0', 'O'); $info = str_replace("OOO", "O", $info); $info = str_replace("OO", "O", $info); if (in_array($info, $cfgResultsHigh) == false) { $info = NULL; } } else { // negative or zero result $info = $cfgResultsHighOut; } // check on failed attempts (not more than 3 X in a row, it doesent matter on which hights) $res = mysql_query("SELECT Leistung, Info FROM \r\n resultat\r\n WHERE\r\n xSerienstart = " . $_POST['start'] . "\r\n ORDER BY\r\n Leistung ASC"); $Xcount = 0; while ($row = mysql_fetch_array($res)) { if (strpos($row[1], strtoupper("o")) === false) { preg_match_all("[X]", $row[1], $m); $Xcount += count($m[0]); } else { $Xcount = 0; } } if (strpos($info, strtoupper("o")) === false) { // count X for last entered attempt preg_match_all("[X]", $info, $m); $Xcount += count($m[0]); } else { $Xcount = 0; } if ($info == $cfgResultsHighOut || $Xcount >= 3) { // last attempt if ($cfgProgramMode[$prog_mode]['name'] == $strProgramModeBackoffice) { $_POST['athlete'] = $_POST['athlete'] + 1; // next athlete } $points = 0; } else { /*$sql_sex = "SELECT Geschlecht FROM athlet LEFT JOIN anmeldung USING(xAthlet) LEFT JOIN start USING(xAnmeldung) LEFT JOIN serienstart USING(xStart) WHERE xSerienstart = ".$_POST['start'].";";*/ $sql_sex = "SELECT Geschlecht \r\n FROM kategorie \r\n LEFT JOIN wettkampf USING(xKategorie) \r\n LEFT JOIN start USING(xWettkampf) \r\n LEFT JOIN serienstart USING(xStart) \r\n WHERE xSerienstart = " . $_POST['start'] . ";"; $query_sex = mysql_query($sql_sex); if ($_POST['attempts'] == '-') { $points = 0; } else { if ($single_svm) { $single_presets = AA_results_getPresets($singleRound); // read GET/POST variables $points = AA_utils_calcPoints($single_presets['event'], $performance, 0, mysql_result($query_sex, 0, 'Geschlecht')); } else { $points = AA_utils_calcPoints($presets['event'], $performance, 0, mysql_result($query_sex, 0, 'Geschlecht')); } } } if (!empty($info)) { AA_results_update($performance, $info, $points); } else { $_POST['athlete']--; } } // ET Athlete valid mysql_query("UNLOCK TABLES"); // set ranks after every new result in mode = decentral with ranking // ****************************************************************** if ($prog_mode == 2) { $eval = AA_results_getEvaluationType($round); $combined = AA_checkCombined(0, $round); mysql_query("DROP TABLE IF EXISTS tempresult"); // temporary table if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { mysql_query("\r\n LOCK TABLES\r\n serie READ\r\n , wettkampf READ\r\n , resultat WRITE\r\n , serienstart WRITE\r\n , tempresult WRITE\r\n "); // clean ranks, set all to 0 mysql_query("UPDATE \r\n serienstart\r\n , serie\r\n SET\r\n serienstart.Rang = 0\r\n WHERE\r\n serienstart.xSerie = serie.xSerie\r\n AND serie.xRunde = {$round}"); // Set up a temporary table to hold all results for ranking. mysql_query("\r\n CREATE TABLE tempresult (\r\n xSerienstart int(11)\r\n , xSerie int(11)\r\n , Leistung int(9)\r\n , TopX int(1)\r\n , TotalX int(2)\r\n )\r\n TYPE=HEAP \r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // if this is a combined event, rank all rounds togheter $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}"; } // read all valid results (per athlet) $result = mysql_query("\r\n SELECT\r\n resultat.Leistung\r\n , resultat.Info\r\n , serienstart.xSerienstart\r\n , serienstart.xSerie\r\n FROM\r\n resultat\r\n , serienstart\r\n , serie\r\n WHERE resultat.xSerienstart = serienstart.xSerienstart\r\n AND serienstart.xSerie = serie.xSerie\r\n {$roundSQL}\r\n AND resultat.Leistung != 0\r\n ORDER BY\r\n serienstart.xSerienstart\r\n ,resultat.Leistung DESC\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $leistung = 0; $serienstart = 0; $serie = 0; $topX = 0; $totX = 0; $ss = 0; // athlete's ID $tt = FALSE; // top result check // process every result while ($row = mysql_fetch_row($result)) { // new athlete: save last athlete's data if ($ss != $row[2] && $ss != 0) { if ($leistung != 0) { // add one row per athlete to temp table mysql_query("\r\n INSERT INTO tempresult\r\n VALUES(\r\n {$serienstart}\r\n , {$serie}\r\n , {$leistung}\r\n , {$topX}\r\n , {$totX})\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } // initialize variables $leistung = 0; $serienstart = 0; $serie = 0; $totX = 0; $topX = 0; $tt = FALSE; } // save data of current athlete's top result if ($tt == FALSE && strstr($row[1], 'O')) { $leistung = $row[0]; $serienstart = $row[2]; $serie = $row[3]; $topX = substr_count($row[1], 'X'); $tt = TRUE; } // count total invalid attempts $totX = $totX + substr_count($row[1], 'X'); $ss = $row[2]; // keep athlete's ID } mysql_free_result($result); // insert last pending data in temp table if ($ss != 0 && $leistung != 0) { mysql_query("\r\n INSERT INTO tempresult\r\n VALUES(\r\n {$serienstart}\r\n , {$serie}\r\n , {$leistung}\r\n , {$topX}\r\n , {$totX})\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } } if ($eval == $cfgEvalType[$strEvalTypeHeat]) { // eval per heat $order = "xSerie ,"; } else { // default: rank results from all heats together $order = ""; } // Read rows from temporary table ordered by performance, // nbr of invalid attempts for top performance and // total nbr of invalid attempts to determine ranking. $result = mysql_query("\r\n SELECT\r\n xSerienstart\r\n , xSerie\r\n , Leistung\r\n , TopX\r\n , TotalX\r\n FROM\r\n tempresult\r\n ORDER BY\r\n {$order}\r\n Leistung DESC\r\n ,TopX ASC\r\n ,TotalX ASC\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $heat = 0; $perf = 0; $topX = 0; $totalX = 0; $i = 0; $rank = 0; // set rank for every athlete while ($row = mysql_fetch_row($result)) { if ($eval == $cfgEvalType[$strEvalTypeHeat] && $heat != $row[1]) { $i = 0; // restart ranking $perf = 0; $topX = 0; $totalX = 0; } $j++; // increment ranking if ($perf != $row[2] || $topX != $row[3] || $totalX != $row[4]) { $rank = $j; // next rank (only if not same performance) } mysql_query("\r\n UPDATE serienstart SET\r\n Rang = {$rank}\r\n WHERE xSerienstart = {$row['0']}\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } $heat = $row[1]; // keep current heat ID $perf = $row[2]; $topX = $row[3]; $totalX = $row[4]; } mysql_free_result($result); } mysql_query("DROP TABLE IF EXISTS tempresult"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } // ET DB error (create temp table) mysql_query("UNLOCK TABLES"); } // ET DB error (drop temp table) AA_results_setNotStarted($round); // update athletes with no result if (!empty($GLOBALS['AA_ERROR'])) { AA_printErrorMsg($GLOBALS['AA_ERROR']); } } // end prog mode = 2 (decentral with ranking) } elseif ($_POST['arg'] == 'save_height') { $max = $_POST['max']; $arr_prev = array(); $arr_new = array(); for ($g = 0; $g < $max; $g++) { $name = "hight_" . $g; $hiddenName = "hiddenHeight_" . $g; $previous_height = $_POST[$hiddenName]; $previous_height = new PerformanceAttempt($previous_height); $previous_height = $previous_height->getPerformance(); if (isset($_POST[$name])) { $new_height = $_POST[$name]; $new_height = new PerformanceAttempt($new_height); $new_height = $new_height->getPerformance(); } else { $new_height = $previous_height; } $arr_prev[$g] = $previous_height; $arr_new[$g] = $new_height; } $diff = 0; $first_change = false; foreach ($arr_prev as $key => $val) { if ($first_change) { $arr_new[$key] = $arr_new[$key - 1] + $diff; } else { if ($val == $arr_new[$key]) { if ($diff > 0) { $arr_new[$key] = $arr_new[$key - 1] + $diff; } } else { if ($diff == 0) { if ($key == 0) { $first_change = true; if ($_POST['disCode'] == '310') { // jump $diff = $cfgHeightDiffJump * 100; } elseif ($_POST['disCode'] == '320') { $diff = $cfgHeightDiffPole * 100; // pole } else { $diff = $cfgHeightDiffJump * 100; } } else { $diff = $arr_new[$key] - $keep_val; } } else { $arr_new[$key] = $arr_prev[$key] + $diff; } } } $keep_val = $val; } AA_delHeight($_POST['round'], $_POST['heat']); AA_setHeight($arr_new, $_POST['round'], $_POST['heat']); $name = "hight_" . $max; if (isset($_POST[$name]) && !empty($_POST[$name])) { $new_height = $_POST[$name]; $new_height = new PerformanceAttempt($new_height); $new_height = $new_height->getPerformance(); // insert new hight $sql = "INSERT INTO hoehe SET \r\n hoehe = " . $new_height . ",\r\n xRunde = " . $_POST['round'] . ", \r\n xSerie = " . $_POST['heat']; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } } else { if ($_GET['arg'] == 'delete') { AA_results_delete($round, $_GET['item']); } } // // terminate result processing // if ($_GET['arg'] == 'results_done') { $eval = AA_results_getEvaluationType($round); $combined = AA_checkCombined(0, $round); mysql_query("DROP TABLE IF EXISTS tempresult"); // temporary table if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { mysql_query("\r\n LOCK TABLES\r\n serie READ\r\n , wettkampf READ\r\n , resultat WRITE\r\n , serienstart WRITE\r\n , tempresult WRITE\r\n "); // clean ranks, set all to 0 mysql_query("UPDATE \r\n serienstart\r\n , serie\r\n SET\r\n serienstart.Rang = 0\r\n WHERE\r\n serienstart.xSerie = serie.xSerie\r\n AND serie.xRunde = {$round}"); // Set up a temporary table to hold all results for ranking. mysql_query("\r\n CREATE TABLE tempresult (\r\n xSerienstart int(11)\r\n , xSerie int(11)\r\n , Leistung int(9)\r\n , TopX int(1)\r\n , TotalX int(2)\r\n )\r\n TYPE=HEAP\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // if this is a combined event, rank all rounds togheter $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}"; } // read all valid results (per athlet) $result = mysql_query("\r\n SELECT\r\n resultat.Leistung\r\n , resultat.Info\r\n , serienstart.xSerienstart\r\n , serienstart.xSerie\r\n FROM\r\n resultat\r\n , serienstart\r\n , serie\r\n WHERE resultat.xSerienstart = serienstart.xSerienstart\r\n AND serienstart.xSerie = serie.xSerie\r\n {$roundSQL}\r\n AND resultat.Leistung != 0\r\n ORDER BY\r\n serienstart.xSerienstart\r\n ,resultat.Leistung DESC\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $leistung = 0; $serienstart = 0; $serie = 0; $topX = 0; $totX = 0; $ss = 0; // athlete's ID $tt = FALSE; // top result check // process every result while ($row = mysql_fetch_row($result)) { // new athlete: save last athlete's data if ($ss != $row[2] && $ss != 0) { if ($leistung != 0) { // add one row per athlete to temp table mysql_query("\r\n INSERT INTO tempresult\r\n VALUES(\r\n {$serienstart}\r\n , {$serie}\r\n , {$leistung}\r\n , {$topX}\r\n , {$totX})\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } // initialize variables $leistung = 0; $serienstart = 0; $serie = 0; $totX = 0; $topX = 0; $tt = FALSE; } // save data of current athlete's top result if ($tt == FALSE && strstr($row[1], 'O')) { $leistung = $row[0]; $serienstart = $row[2]; $serie = $row[3]; $topX = substr_count($row[1], 'X'); $tt = TRUE; } // count total invalid attempts $totX = $totX + substr_count($row[1], 'X'); $ss = $row[2]; // keep athlete's ID } mysql_free_result($result); // insert last pending data in temp table if ($ss != 0 && $leistung != 0) { mysql_query("\r\n INSERT INTO tempresult\r\n VALUES(\r\n {$serienstart}\r\n , {$serie}\r\n , {$leistung}\r\n , {$topX}\r\n , {$totX})\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } } if ($eval == $cfgEvalType[$strEvalTypeHeat]) { // eval per heat $order = "xSerie ,"; } else { // default: rank results from all heats together $order = ""; } // Read rows from temporary table ordered by performance, // nbr of invalid attempts for top performance and // total nbr of invalid attempts to determine ranking. $result = mysql_query("\r\n SELECT\r\n xSerienstart\r\n , xSerie\r\n , Leistung\r\n , TopX\r\n , TotalX\r\n FROM\r\n tempresult\r\n ORDER BY\r\n {$order}\r\n Leistung DESC\r\n ,TopX ASC\r\n ,TotalX ASC\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $heat = 0; $perf = 0; $topX = 0; $totalX = 0; $i = 0; $rank = 0; // set rank for every athlete while ($row = mysql_fetch_row($result)) { if ($eval == $cfgEvalType[$strEvalTypeHeat] && $heat != $row[1]) { $i = 0; // restart ranking $perf = 0; $topX = 0; $totalX = 0; } $j++; // increment ranking if ($perf != $row[2] || $topX != $row[3] || $totalX != $row[4]) { $rank = $j; // next rank (only if not same performance) } mysql_query("\r\n UPDATE serienstart SET\r\n Rang = {$rank}\r\n WHERE xSerienstart = {$row['0']}\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } $heat = $row[1]; // keep current heat ID $perf = $row[2]; $topX = $row[3]; $totalX = $row[4]; } mysql_free_result($result); } mysql_query("DROP TABLE IF EXISTS tempresult"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } // ET DB error (create temp table) // read all starting athletes with no valid result (rank=0) // and add disqualification code $result = mysql_query("\r\n SELECT DISTINCT\r\n serienstart.xSerienstart\r\n FROM\r\n resultat\r\n , serienstart\r\n , serie\r\n WHERE resultat.xSerienstart = serienstart.xSerienstart\r\n AND serienstart.xSerie = serie.xSerie\r\n AND serienstart.Rang = 0\r\n AND serie.xRunde = {$round}\r\n AND resultat.Leistung >= 0\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // while ($row = mysql_fetch_row($result)) { // check if "disqualified" result already there $res = mysql_query("\r\n SELECT\r\n xResultat\r\n FROM\r\n resultat\r\n WHERE xSerienstart = {$row['0']}\r\n AND (Leistung = " . $cfgInvalidResult['DSQ']['code'] . "OR Leistung = " . $cfgInvalidResult['NRS']['code'] . ")"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res) <= 0) { mysql_query("\r\n INSERT INTO\r\n resultat\r\n SET\r\n Leistung = " . $cfgInvalidResult['NRS']['code'] . "\r\n , Info = '{$cfgResultsHighOut}'\r\n , xSerienstart = {$row['0']}\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } mysql_free_result($res); } } mysql_free_result($result); } mysql_query("UNLOCK TABLES"); } // ET DB error (drop temp table) 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']); } } // // calculate ranking points if needed // if ($_GET['arg'] == 'results_done' || $_POST['arg'] == 'save_rank') { AA_utils_calcRankingPoints($round); } if ($_POST['arg'] == 'save_remark') { AA_utils_saveRemark($_POST['item'], $_POST['remark'], $_POST['xAthlete']); } // // 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 && $prog_mode != 2) { $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"); // display all athletes $result = mysql_query("\r\n SELECT rt.Name\r\n , rt.Typ\r\n , s.xSerie\r\n , s.Bezeichnung\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 . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)) \r\n , LPAD(s.Bezeichnung,5,'0') as heatid\r\n , rs.xResultat\r\n , rs.Leistung\r\n , rs.Info\r\n , at.Land\r\n , ss.Bemerkung\r\n , at.xAthlet\r\n , r.xRunde \r\n , ss.RundeZusammen \r\n FROM\r\n runde AS r\r\n , serie AS s\r\n , serienstart AS ss\r\n , start AS st\r\n , anmeldung AS a\r\n , athlet AS at\r\n , verein AS v\r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN rundentyp AS rt\r\n ON rt.xRundentyp = r.xRundentyp\r\n LEFT JOIN resultat AS rs\r\n ON rs.xSerienstart = ss.xSerienstart\r\n WHERE r.xRunde = {$round}\r\n AND s.xRunde = r.xRunde\r\n AND ss.xSerie = s.xSerie\r\n AND st.xStart = ss.xStart\r\n AND a.xAnmeldung = st.xAnmeldung\r\n AND at.xAthlet = a.xAthlet\r\n AND v.xVerein = at.xVerein\r\n ORDER BY\r\n heatid\r\n , ss.Position\r\n , rs.xResultat DESC\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { AA_results_printMenu($round, $status, $prog_mode, 'high'); // initialize variables $a = 0; $h = 0; $i = 0; if (!empty($_GET['athlete'])) { $_POST['athlete'] = $_GET['athlete']; } if (empty($_POST['athlete']) || mysql_num_rows($result) < $_POST['athlete']) { $_POST['athlete'] = 1; // focus to first athlete } $rowclass = 'odd'; if ($cfgProgramMode[$prog_mode]['name'] == $strProgramModeBackoffice) { $focus = 0; // keep focus on this athlete if Backoffice Mode } else { $focus = 1; // focus on next athlete if Field Mode } ?> <p/> <table class='dialog'> <?php $btn = new GUI_Button('', ''); // create button object while ($row = mysql_fetch_row($result)) { if ($row[20] > 0) { $singleRound = $row[20]; } else { $singleRound = $row[19]; } // terminate last row if new athlete and not first item if ($a != $row[4] && $i != 0) { if ($_POST['athlete'] == $i + 1 && $cfgProgramMode[$prog_mode]['name'] == $strProgramModeField) { if ($row[15] == 'XXX' && !$click) { $_POST['athlete'] = $_POST['athlete'] + 1; } } if ($_POST['athlete'] == $i) { echo "<td>"; $btn->set("event_results.php?arg=del_start&item={$a}&round={$round}", $strDelete); $btn->printButton(); echo "</td>"; } echo "</tr>"; } /* * 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 $title = "{$row['0']}"; } $c = 0; if ($status == $cfgRoundStatus['results_done']) { $c = 1; // increment colspan to include ranking } ?> <tr> <form action='event_results.php#heat_<?php echo $row[3]; ?> ' method='post' name='heat_id_<?php echo $h; ?> '> <th class='dialog' colspan='<?php echo 7 + $c; ?> ' /> <?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='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[2]; ?> ' /> <input class='nbr' type='text' name='id' maxlength='2' value='<?php echo $row[3]; ?> ' onChange='document.heat_id_<?php echo $h; ?> .submit()' /> <a name='heat_<?php echo $row[3]; ?> ' /> </th> </form> </tr> <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> <?php if ($status == $cfgRoundStatus['results_done']) { ?> <th class='dialog'><?php echo $strRank; ?> </th> <?php } ?> <th class='dialog' ><?php echo $strResultRemark; ?> </th> <th class='dialog' colspan='2'><?php echo $strPerformance; ?> </th> </tr> <?php } // ET new heat /* * Athlete data lines */ if ($a != $row[4]) { $a = $row[4]; // keep athlete ID $i++; // increment athlete counter $l = 0; // reset result counter if ($_POST['athlete'] == $i) { // active item $rowclass = 'active'; } else { if ($row[5] % 2 == 0) { // even row numer $rowclass = 'even'; } else { // odd row number $rowclass = 'odd'; } } if ($rowclass == 'active') { ?> <tr class='active'> <?php } else { ?> <tr class='<?php echo $rowclass; ?> ' onclick='selectAthlete(<?php echo $i; ?> )'> <?php } ?> <td class='forms_right'><?php echo $row[5]; ?> </td> <td class='forms_right'><?php echo $row[7]; /* start nbr */ ?> </td> <td nowrap><?php echo $row[8] . " " . $row[9]; /* name */ ?> </td> <td class='forms_ctr'><?php echo AA_formatYearOfBirth($row[10]); ?> </td> <td><?php echo $row[16] != '' && $row[16] != '-' ? $row[16] : ' '; ?> </td> <td nowrap><?php echo $row[11]; /* club */ ?> </td> <?php if ($status == $cfgRoundStatus['results_done']) { if ($_POST['athlete'] == $i) { ?> <form action='event_results.php' method='post' name='rank'> <td> <input type='hidden' name='arg' value='save_rank' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[4]; ?> ' /> <input class='nbr' type='text' name='rank' maxlength='3' value='<?php echo $row[6]; ?> ' onChange='document.rank.submit()' /> </td> </form> <?php } else { echo "<td>" . $row[6] . "</td>"; } echo "<td>" . $row[17] . "</td>"; } else { ?> <form action='event_results.php' method='post' name='remark_<?php echo $i; ?> '> <td> <input type='hidden' name='arg' value='save_remark' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[4]; ?> ' /> <input type='hidden' name='xAthlete' value='<?php echo $row[18]; ?> ' /> <input class='textshort' type='text' name='remark' maxlength='5' value='<?php echo $row[17]; ?> ' onchange='document.remark_<?php echo $i; ?> .submit()' /> </td> </form> <?php } } // ET new athlete $new_perf = ''; if ($_POST['athlete'] == $i) { if (is_null($row[14])) { // no result yet: show form $last_perf = 0; } else { $last_perf = $row[14]; } $item = ''; if ($l == 0) { // read all performances achieved in current heat and // better than last entered performance if ($cfgProgramMode[$prog_mode]['name'] == $strProgramModeField) { if (in_array($row[15], $cfgResultsHighStayDecentral)) { $new_perf = AA_formatResultMeter($last_perf); $new_info = $row[15]; $item = $row[13]; } else { $new_perf = getNextHeight($row[2], $last_perf); $new_info = ''; } } else { if (in_array($row[15], $cfgResultsHighStay)) { $new_perf = AA_formatResultMeter($last_perf); $new_info = $row[15]; $item = $row[13]; } else { $new_perf = getNextHeight($row[2], $last_perf); $new_info = ''; } } ?> <form action='event_results.php' method='post' name='perf'> <td nowrap colspan='2'> <input type='hidden' name='arg' value='save_res' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='start' value='<?php echo $row[4]; ?> ' /> <input type='hidden' name='xSerie' value='<?php echo $row[2]; ?> ' /> <input type='hidden' name='item' value='<?php echo $item; ?> ' /> <input class='perfheight' type='text' name='perf' maxlength='5' value='<?php echo $new_perf; ?> ' onChange='checkSubmit(document.perf)' /> <input class='texttiny' type='text' name='attempts' maxlength='3' value='<?php echo $new_info; ?> ' onChange='document.perf.submit()' onBlur='document.perf.submit()' /> </td> </form> <?php } if (is_null($row[14]) == false && empty($item)) { // next height ?> <td nowrap> <?php echo AA_formatResultMeter($row[14]) . "<br/>( {$row['15']} )"; ?> </td> <td> <?php $btn = new GUI_Button("event_results.php?arg=delete&round={$round}&item={$row['13']}&athlete={$i}", "X"); $btn->printButton(); ?> </td> <?php } $l++; } else { if (is_null($row[14]) == false) { echo "<td colspan='2' nowrap>" . AA_formatResultMeter($row[14]) . " ( {$row['15']} )</td>"; } } } if ($a != 0) { if ($_POST['athlete'] == $i) { echo "<td>"; $btn->set("event_results.php?arg=del_start&item={$a}&round={$round}", $strDelete); $btn->printButton(); echo "</td>"; } echo "</tr>"; } ?> </table> <?php mysql_free_result($result); } // ET DB error } } } } else { if ($round > 0 && $prog_mode == 2) { $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"); $ph = 0; // find max height per athlete $sql_max_h = "SELECT \r\n LPAD(s.Bezeichnung,5,'0') as heatid\r\n , count(*) \r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart) \r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n LEFT JOIN resultat AS rs ON rs.xSerienstart = ss.xSerienstart\r\n WHERE r.xRunde = {$round} \r\n GROUP BY ss.xSerienstart\r\n ORDER BY\r\n heatid\r\n , ss.Position DESC\r\n , rs.xResultat"; $res_max_h = mysql_query($sql_max_h); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $ph = 0; // height column $starts = 0; // all started athletes while ($row_max_h = mysql_fetch_row($res_max_h)) { $starts++; if ($row_max_h[1] > $ph) { $ph = $row_max_h[1]; } } } // fill last infos (included previous info by 'XXX') in an array $sql_info = "SELECT rt.Name\r\n , rt.Typ\r\n , s.xSerie\r\n , s.Bezeichnung\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 . "', t.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)) \r\n , LPAD(s.Bezeichnung,5,'0') as heatid\r\n , rs.xResultat\r\n , rs.Leistung\r\n , rs.Info\r\n , at.Land\r\n , ss.Bemerkung\r\n , at.xAthlet\r\n , r.xRunde \r\n , ss.RundeZusammen \r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart) \r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n LEFT JOIN resultat AS rs ON rs.xSerienstart = ss.xSerienstart \r\n WHERE r.xRunde = {$round} \r\n ORDER BY\r\n heatid\r\n , ss.Position \r\n , rs.xResultat\r\n \r\n "; $res_info = mysql_query($sql_info); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $c = 0; $arr_info = array(); $arr_info_remark = array(); // previous info 'p' $count_results = 0; $count_ends = 0; // athletes with results 'XXX' while ($row_info = mysql_fetch_row($res_info)) { if ($row_info[4] != $a && $c > 0) { if (!empty($keep_info)) { if ($c == $ph) { $arr_info[] = $keep_info; $arr_info_remark[] = ''; $count_results++; } else { if ($keep_info == 'XXX') { $arr_info[] = $keep_info; $arr_info_remark[] = 'p'; // previous $count_results++; } else { $arr_info[] = ''; $arr_info_remark[] = ''; $count_results++; } } $c = 0; } } $c++; if ($row_info[15] == 'XXX') { $count_ends++; } $a = $row_info[4]; $keep_info = $row_info[15]; } if (!empty($keep_info)) { if ($c == $ph) { $arr_info[] = $keep_info; $arr_info_remark[] = ''; $count_results++; } else { if ($keep_info == 'XXX') { $arr_info[] = $keep_info; $arr_info_remark[] = 'p'; // previous $count_results++; } else { $arr_info[] = ''; $arr_info_remark[] = ''; $count_results++; } } } } // array for infos to jump $arr_info_toJump = array(); foreach ($arr_info as $key => $val) { if (!in_array($val, $cfgResultsHighStayDecentralEnd)) { $arr_info_toJump[$key] = $val; } } // find out new column (= newHight ) $sql_hight = "SELECT \r\n LPAD(s.Bezeichnung,5,'0') as heatid \r\n , rs.Leistung\r\n , rs.Info \r\n , d.Code \r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart) \r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n LEFT JOIN team AS t ON(a.xTeam = t.xTeam) \r\n LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n LEFT JOIN resultat AS rs ON rs.xSerienstart = ss.xSerienstart\r\n LEFT JOIN wettkampf AS w ON (w.xWettkampf = r.xWettkampf) \r\n LEFT JOIN disziplin AS d ON (d.xDisziplin = w.xDisziplin) \r\n WHERE r.xRunde = {$round} \r\n ORDER BY\r\n heatid\r\n , rs.Leistung DESC\r\n , ss.Position ASC\r\n "; $res_hight = mysql_query($sql_hight); $e = 0; // count performance when is finished with this high $z = 0; $first = true; $disCode = 0; while ($row_hight = mysql_fetch_row($res_hight)) { if ($perf_keep != $row_hight[1] && !$first) { $z++; if ($z > 1) { break; } else { $e_keep = $e; $e = 0; } } $first = false; if (in_array($row_hight[2], $cfgResultsHighStayDecentralEnd)) { if ($row_hight[2] != 'XXX') { $e++; } } $perf_keep = $row_hight[1]; $disCode = $row_hight[3]; } $newHight = false; if (is_null($e_keep)) { $e_keep = $e; } if ($e_keep == $starts - $count_ends) { $newHight = true; } if (empty($_POST)) { if ($ph > $max) { $max = $ph; } } if (empty($_POST)) { $y = 0; while ($row = mysql_fetch_row($res_c_h)) { $name = "hight_" . $y; $hiddenName = "hiddeHight_" . $y; $performance_new = AA_formatResultMeter($row[0]); $_POST[$name] = $performance_new; $_POST[$hiddenName] = $performance_new; $y++; } } // found active athlete $a_activ = 0; $flen = 0; $f_len_keep = 0; $r_f_len = 0; $r_f_len_keep = 0; $a_activ_set = false; $f = 0; $reset_activ = false; for ($r = $starts - 1; $r >= 0; $r--) { if ($arr_info[$r] == '' || $arr_info_remark[$r] == 'p') { $f++; } else { if ($f > 0) { $a_activ = $r + 2; for ($j = $a_activ - 1; $j < $starts; $j++) { if ($arr_info_remark[$a_activ - 1] == 'p') { $a_activ++; } } $a_activ_set = true; } if ($a_activ > $starts) { $a_activ_set = false; $reset_activ = true; } break; } } if (!$a_activ_set) { if ($newHight) { for ($r = 0; $r < $starts; $r++) { if ($arr_info[$r] != 'XXX') { $a_activ = $r + 1; $a_activ_set = true; break; } } if (!$a_activ_set) { $a_activ = 1; } } elseif ($reset_activ) { $val_keep = ''; foreach ($arr_info_toJump as $key => $val) { if (strlen($val) == 1) { $arr_info_toJump_1[$key] = $val; } elseif (strlen($val) == 2) { $arr_info_toJump_2[$key] = $val; } } if (count($arr_info_toJump_1) > 0) { foreach ($arr_info_toJump_1 as $key => $val) { $a_activ = $key + 1; break; } } else { foreach ($arr_info_toJump_2 as $key => $val) { $a_activ = $key + 1; break; } } } else { for ($r = $starts - 1; $r >= 0; $r--) { if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValidFirst = false; } else { $f_len = strlen($arr_info[$r]); $r_f_len = $r; if ($f_len_keep > 0) { if ($f_len_keep < $f_len) { $a_activ = $r_f_len_keep + 1; break; } elseif ($f_len_keep = $f_len) { $a_activ = $r_f_len + 1; } elseif ($f_len_keep > $f_len) { break; } } else { $a_activ = $r_f_len + 1; } $f_len_keep = $f_len; $r_f_len_keep = $r_f_len; } } } } if (is_null($_POST['athlete'])) { $_POST['athlete'] = $a_activ; } $aClick = false; if (isset($_POST['result'])) { // this means that user makes a click to a athlete $aClick = true; } if (isset($_GET['arg']) && $_GET['arg'] == 'delete') { $aClick = true; } $athleteValidAfter = true; if ($_POST['athlete'] >= 1 && !$aClick) { $athleteValidAfter = true; if ($starts != $count_ends) { if (count($arr_info) == $starts) { for ($r = $starts - 1; $r >= 0; $r--) { if ($r < $_POST['athlete'] - 1) { break; } if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValidAfter = false; } else { $athleteValidAfter = true; break; } } if ($_POST['athlete'] > $starts) { $athleteValidAfter = false; } } } else { $athleteValidAfter = false; if (!$aClick) { $_POST['athlete'] = 1; $a_activ = 1; } } if (!$athleteValidAfter && !$aClick && !$newHight) { // set to first athlete when no valid athletes after $_POST['athlete'] = 1; } } // find out first valid athlete $athleteValidFirst = true; $a_first = 0; if ($_POST['athlete'] >= 1 && !$aClick) { $athleteValidFirst = true; if ($starts != $count_ends) { if (count($arr_info) == $starts) { for ($r = 0; $r < $starts; $r++) { if ($arr_info[$r] == 'XXX') { $athleteValidFirst = false; } else { $athleteValidFirst = true; $a_first = $r + 1; break; } } } } else { $athleteValidAfter = false; if (!$aClick) { $_POST['athlete'] = 1; $a_activ = 1; } } if ($a_first > 0 && !$athleteValidAfter && !$click) { $_POST['athlete'] = $a_first; } } if (isset($_POST['result']) || $aClick) { // this means that user makes a click to a athlete $a_activ = $_POST['athlete']; } if ($starts == $count_ends && !$aClick) { $_POST['athlete'] = 1; $a_activ = 1; } if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { AA_results_printMenu($round, $status, $prog_mode, 'high'); // initialize variables $a = 0; $h = 0; $i = 0; if (!empty($_GET['athlete'])) { $_POST['athlete'] = $_GET['athlete']; } if (empty($_POST['athlete']) || $starts < $_POST['athlete']) { $_POST['athlete'] = 1; // focus to first athlete } $rowclass = 'odd'; if ($cfgProgramMode[$prog_mode]['name'] == $strProgramModeBackoffice) { $focus = 0; // keep focus on this athlete if Backoffice Mode } else { $focus = 1; // focus on next athlete if Field Mode } ?> <p/> <table class='dialog'> <?php $l = 0; $newAthl = false; $flagField = false; $skip = false; $s = 0; $s_keep = 0; $k = 0; $p = 0; // all pass $btn = new GUI_Button('', ''); // create button object $flagField = false; $res_info = mysql_query($sql_info); while ($row = mysql_fetch_row($res_info)) { if ($a != $row[4] && $i != 0) { // new athlete $k = 0; if ($s >= $s_keep) { $s_keep = $s; } $s = 0; } $p++; $k++; $s++; if ($row[15] == 'XXX') { $skip = true; } else { if (in_array($row[15], $cfgResultsHighStayDecentralEnd) && $ph == $k && !$newHight) { $skip = true; } else { $skip = false; } } if ($row[20] > 0) { $singleRound = $row[20]; } else { $singleRound = $row[19]; } // terminate last row if new athlete and not first item if ($a != $row[4] && $i != 0) { $athleteValid = true; $athleteValidAfter = true; if ($starts != $count_ends) { if (count($arr_info) == $starts) { for ($r = $starts - 1; $r >= 0; $r--) { if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValid = false; } else { $athleteValid = true; break; } } for ($r = $starts - 1; $r >= 0; $r--) { if ($r < $_POST['athlete'] - 1) { break; } if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValidAfter = false; } else { $athleteValidAfter = true; break; } } } } else { $athleteValid = false; $athleteValidAfter = false; if (!$aClick) { $_POST['athlete'] = 1; $a_activ = 1; } } if ($_POST['athlete'] == $i || !$athleteValid && $newHight && $k != 1 || $aClick && $a_activ == $i) { if (!$flagField) { ?> <form action='event_results.php' method='post' name='perf'> <td nowrap colspan='2'> <input type='hidden' name='arg' value='save_res' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='start' value='<?php echo $a; ?> ' /> <input type='hidden' name='item' value='<?php echo $item; ?> ' /> <input class='perfheight' type='hidden' name='perf' maxlength='5' value='<?php echo $new_perf; ?> ' /> <?php foreach ($_POST as $key => $val) { $arr_key = explode('_', $key); $hiddenName = $arr_key[0] . "_" . $arr_key[1]; ?> <input type='hidden' name='<?php echo $hiddenName; ?> ' value='<?php echo $val; ?> ' /> <?php } ?> <input class='texttiny' type='text' name='attempts' maxlength='3' onfocus="this.value = '<?php echo $new_info; ?> '" value='<?php echo $new_info; ?> ' /> <button type='button' name="butt" onclick="document.perf.submit()">ok</button> </td> </form> <?php $flagField = true; echo "<td colspan='31'> "; echo "</td>"; echo "<td>"; $btn->set("event_results.php?arg=del_start&item={$a}&round={$round}", $strDelete); $btn->printButton(); echo "</td>"; } } echo "</tr>"; } /* * 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 $title = "{$row['0']}"; } $c = 0; if ($status == $cfgRoundStatus['results_done']) { $c = 1; // increment colspan to include ranking } ?> <tr> <form action='event_results.php#heat_<?php echo $row[3]; ?> ' method='post' name='heat_id_<?php echo $h; ?> '> <th class='dialog' colspan='<?php echo 7 + $c; ?> ' /> <?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='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[2]; ?> ' /> <input class='nbr' type='text' name='id' maxlength='2' value='<?php echo $row[3]; ?> ' onchange='document.heat_id_<?php echo $h; ?> .submit()' /> <a name='heat_<?php echo $row[3]; ?> ' /> </th> <?php if (isset($_POST['max'])) { $colspanPerf = $_POST['max'] * 2 + 2; } else { $colspanPerf = $cfgCountHeight * 2 + 2; } ?> <th colspan="<?php echo $colspanPerf; ?> "><?php echo $strPerformance; ?> </th> <?php ?> </form> </tr> <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 $strRank; ?> </th> <th class='dialog' ><?php echo $strResultRemark; ?> </th> <?php $height_start = $cfgHeightStartJump; // default jump if ($disCode == '310') { // jump $height_start = $cfgHeightStartJump; } elseif ($disCode == '320') { $height_start = $cfgHeightStartPole; // pole } ?> <form action='event_results.php' method='post' name='hight_id'> <input type='hidden' name='arg' value='save_height' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='heat' value='<?php echo $row[2]; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <?php $count_height = AA_checkHeight($round, $row[2]); $arr_height = array(); if ($count_height > 0) { $max = $count_height; $sql = "SELECT h.Hoehe \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 \r\n h.xRunde = " . $round . " \r\n AND h.xSerie = " . $row[2] . " \r\n AND w.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n ORDER BY hoehe"; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $g = 0; while ($row_height = mysql_fetch_row($res)) { $arr_height[] = $row_height[0]; $height = AA_formatResultMeter($row_height[0]); $dis = ''; // disable the hight done if ($newHight) { $ph_vgl = $ph - 1; if ($g <= $ph_vgl) { $dis = 'disabled="disabled"'; } } else { $ph_vgl = ceil($ph - 1); if ($g <= $ph_vgl) { $dis = 'disabled="disabled"'; } if ($count_results == 0 && $g == 0) { $dis = ''; } } ?> <input class='perfheight' type='hidden' name='hiddenHeight_<?php echo $g; ?> ' maxlength='5' value='<?php echo $height; ?> '/> <th class='dialog' colspan='2'><input class='perfheight' type='text' name='hight_<?php echo $g; ?> ' maxlength='5' value='<?php echo $height; ?> ' onchange='document.hight_id.submit()' <?php echo $dis; ?> /></th> <?php $g++; } } } else { $max = $cfgCountHeight; for ($g = 0; $g < $cfgCountHeight; $g++) { $_POST['start'] = 0; $height_start_tmp = new PerformanceAttempt($height_start); $height_start_tmp = $height_start_tmp->getPerformance(); $arr_height[] = $height_start_tmp; AA_setHeight($height_start_tmp, $round, $row[2], ''); ?> <input class='perfheight' type='hidden' name='hiddenHeight_<?php echo $g; ?> ' maxlength='5' value='<?php echo sprintf("%.2f", $height_start); ?> '/> <th class='dialog' colspan='2'><input class='perfheight' type='text' name='hight_<?php echo $g; ?> ' maxlength='5' value='<?php echo sprintf("%.2f", $height_start); ?> ' onchange='document.hight_id.submit()' /></th> <?php if ($disCode == '310') { // jump $height_start += $cfgHeightDiffJump; } elseif ($disCode == '320') { $height_start += $cfgHeightDiffPole; // pole } else { $height_start += $cfgHeightDiffJump; } } } ?> <input class='perfheight' type='hidden' name='hiddenHeight_<?php echo $g; ?> ' maxlength='5' value=''/> <th class='dialog' colspan='2'><input class='perfheight' type='text' name='hight_<?php echo $max; ?> ' maxlength='5' value='' onchange='document.hight_id.submit()' /></th> <input type='hidden' name='max' value='<?php echo $max; ?> ' /> <input type='hidden' name='disCode' value='<?php echo $disCode; ?> ' /> </form> </tr> <?php } // ET new heat /* * Athlete data lines */ if ($newAthl) { if ($k == $ph) { // k = results per athlete ph = hight column $athleteValid = true; $athleteValidAfter = true; if ($starts != $count_ends) { if (count($arr_info) == $starts) { for ($r = $starts - 1; $r >= 0; $r--) { if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValid = false; } else { $athleteValid = true; break; } } for ($r = $starts - 1; $r >= 0; $r--) { if ($r < $_POST['athlete'] - 1) { break; } if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValidAfter = false; } else { $athleteValidAfter = true; break; } } } } else { $athleteValid = false; $athleteValidAfter = false; if (!$aClick) { $_POST['athlete'] = 1; $a_activ = 1; } } if (!$athleteValid) { $l = 1; if (!$click) { if ($a_first == 0) { $_POST['athlete'] = 1; $l = 0; } } } } if (in_array($row[15], $cfgResultsHighStayDecentralNotPassed)) { // find O (example: O, XO , XXO ) $l = 0; // reset result counter $newAthl = false; } else { if (is_null($row[15])) { $l = 0; $newAthl = false; } else { if (in_array($row[15], $cfgResultsHighStayDecentralEnd) && $_POST['athlete'] == $i && $skip) { if ($athleteValidAfter && !$aClick) { $_POST['athlete']++; } $newAthl = false; $l = 1; } elseif (in_array($row[15], $cfgResultsHighStayDecentralEnd) && $_POST['athlete'] == $i && !$skip && $p != $ph) { $l = 1; } else { $l = 1; } } } } if ($a != $row[4]) { if ($k == $ph) { $athleteValid = true; if ($starts != $count_ends) { if (count($arr_info) == $starts) { for ($r = $starts - 1; $r >= 0; $r--) { if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValid = false; } else { $athleteValid = true; break; } } } } else { $athleteValid = false; if (!$aClick) { $_POST['athlete'] = 1; $a_activ = 1; } } $athleteValidAfter = true; for ($r = $starts - 1; $r >= 0; $r--) { if ($r >= $_POST['athlete']) { break; } if (in_array($arr_info[$r], $cfgResultsHighStayDecentralEnd)) { $athleteValidAfter = false; } else { $athleteValidAfter = true; break; } } if (!$athleteValid) { $l = 1; if (!$click) { if ($a_first == 0) { $_POST['athlete'] = 1; $l = 0; } } } } $a = $row[4]; // keep athlete ID $info_keep = $row[15]; // keep info $i++; // increment athlete counter $newAthl = true; if (in_array($row[15], $cfgResultsHighStayDecentralNotPassed)) { // find O (example: O, XO , XXO ) $l = 0; // reset result counter $newAthl = false; } else { if (is_null($row[15])) { $l = 0; $newAthl = false; } else { if (in_array($row[15], $cfgResultsHighStayDecentralEnd) && $_POST['athlete'] == $i && $skip && !$aClick) { if ($starts != $count_ends) { $_POST['athlete']++; } $newAthl = false; $l = 1; } elseif (in_array($row[15], $cfgResultsHighStayDecentralEnd) && $_POST['athlete'] == $i && !$skip && $p != $ph) { $l = 1; } else { $l = 1; } } } if ($a_activ == $i) { // active item $rowclass = 'active'; if (isset($_POST['start'])) { AA_setCurrAthlete($row[2], $row[4]); } } else { if ($row[5] % 2 == 0) { // even row numer $rowclass = 'even'; } else { // odd row number $rowclass = 'odd'; } } if ($rowclass == 'active') { ?> <tr id="athlete_<?php echo $i; ?> " class='active'> <?php } else { ?> <tr id="athlete_<?php echo $i; ?> " class='<?php echo $rowclass; ?> ' onclick='selectAthlete(<?php echo $i; ?> )'> <?php } ?> <td class='forms_right'><?php echo $row[5]; ?> </td> <td class='forms_right'><?php echo $row[7]; /* start nbr */ ?> </td> <td nowrap><?php echo $row[8] . " " . $row[9]; /* name */ ?> </td> <td class='forms_ctr'><?php echo AA_formatYearOfBirth($row[10]); ?> </td> <td><?php echo $row[16] != '' && $row[16] != '-' ? $row[16] : ' '; ?> </td> <td nowrap><?php echo $row[11]; /* club */ ?> </td> <?php if ($a_activ == $i) { ?> <form action='event_results.php' method='post' name='rank'> <td> <input type='hidden' name='arg' value='save_rank' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[4]; ?> ' /> <input class='nbr' type='text' name='rank' maxlength='3' value='<?php echo $row[6]; ?> ' onchange='document.rank.submit()' /> </td> </form> <?php if ($zaehler == 0) { ?> <form action='event_results.php' method='post' name='remark_<?php echo $i; ?> '> <td> <input type='hidden' name='arg' value='save_remark' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[4]; ?> ' /> <input type='hidden' name='xAthlete' value='<?php echo $row[18]; ?> ' /> <input class='textshort' type='text' name='remark' maxlength='5' value='<?php echo $row[17]; ?> ' onchange='document.remark_<?php echo $i; ?> .submit()' /> </td> </form> <?php $zaehler++; } } else { echo "<td>" . $row[6] . "</td>"; echo "<td>" . $row[17] . "</td>"; } } // ET new athlete $new_perf = ''; if ($_POST['athlete'] == $i) { // only current athlet $item = ''; $ph_perf = $ph - 1; $hiddenName = "hiddenHight_" . $ph_perf; if ($newHight) { $ph_perf += 1; } $hiddenName = "hiddenHight_" . $ph_perf; $new_perf = $arr_height[$ph_perf]; $new_perf = new PerformanceAttempt($new_perf); $new_perf = $new_perf->getPerformance(); // read all performances achieved in current heat and // better than last entered performance if (in_array($row[15], $cfgResultsHighStayDecentral)) { $new_info = $row[15]; if (in_array($row[15], $cfgResultsHighStayDecentralEnd)) { $new_info = ''; } else { $item = $row[13]; } } else { $new_info = ''; } if (is_null($row[14]) == false && empty($item)) { // next height ?> <td nowrap> <?php echo $row[15]; ?> </td> <?php if ($_POST['athlete'] == $a_activ) { ?> <td> <?php $btn = new GUI_Button("event_results.php?arg=delete&round={$round}&item={$row['13']}&athlete={$i}", "del"); $btn->printButton(); ?> </td> <?php } else { ?> <td></td> <?php } } if ($l == 0) { // first item $find = strpos(strtoupper($row[15], 'O')); if ($row[15] == '-') { if (!$skip) { $l++; } } elseif (!in_array($row[15], $cfgResultsHighStayDecentralNotPassed)) { $l++; } $flagField = true; ?> <form action='event_results.php' method='post' name='perf'> <td nowrap colspan='2'> <input type='hidden' name='arg' value='save_res' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='start' value='<?php echo $row[4]; ?> ' /> <input type='hidden' name='xSerie' value='<?php echo $row[2]; ?> ' /> <input type='hidden' name='item' value='<?php echo $item; ?> ' /> <input class='perfheight' type='hidden' name='perf' maxlength='5' value='<?php echo $new_perf; ?> ' /> <?php foreach ($_POST as $key => $val) { $arr_key = explode('_', $key); $hiddenName = $arr_key[0] . "_" . $arr_key[1]; ?> <input type='hidden' name='<?php echo $hiddenName; ?> ' value='<?php echo $val; ?> ' /> <?php } ?> <input class='texttiny' type='text' name='attempts' maxlength='3' onfocus="this.value = '<?php echo $new_info; ?> '" value='<?php echo $new_info; ?> ' /> <button type='button' name="butt" onclick="document.perf.submit()">ok</button> </td> </form> <?php $prev_info = ''; echo "<td colspan='31'> "; echo "</td>"; echo "<td>"; $btn->set("event_results.php?arg=del_start&item={$a}&round={$round}", $strDelete); $btn->printButton(); echo "</td>"; } } else { if (is_null($row[14]) == false) { // result entered $showNotValidRes = ''; if ($row[14] < 0) { $showNotValidRes = "({$row['14']})"; } echo "<td colspan='2' nowrap>{$showNotValidRes} {$row['15']} </td>"; } } } if ($a != 0) { if ($s == $s_keep || $s_keep == 1 || $info_keep == '-' && $ph == $k) { if (!$aClick) { $skip = true; $_POST['athlete']++; } } else { $skip = false; } if ($_POST['athlete'] == $i) { if (!$flagField && !$skip) { ?> <form action='event_results.php' method='post' name='perf'> <td nowrap colspan='2'> <input type='hidden' name='arg' value='save_res' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='singleRound' value='<?php echo $singleRound; ?> ' /> <input type='hidden' name='athlete' value='<?php echo $i + $focus; ?> ' /> <input type='hidden' name='start' value='<?php echo $a; ?> ' /> <input type='hidden' name='item' value='<?php echo $item; ?> ' /> <input class='perfheight' type='hidden' name='perf' maxlength='5' value='<?php echo $new_perf; ?> ' /> <?php foreach ($_POST as $key => $val) { $arr_key = explode('_', $key); $hiddenName = $arr_key[0] . "_" . $arr_key[1]; ?> <input type='hidden' name='<?php echo $hiddenName; ?> ' value='<?php echo $val; ?> ' /> <?php } ?> <input class='texttiny' type='text' name='attempts' maxlength='3' onfocus="this.value = '<?php echo $new_info; ?> '" value='<?php echo $new_info; ?> ' /> <button type='button' name="butt" onclick="document.perf.submit()">ok</button> </td> </form> <?php echo "<td colspan='15'> "; echo "</td>"; echo "<td>"; $btn->set("event_results.php?arg=del_start&item={$a}&round={$round}", $strDelete); $btn->printButton(); echo "</td>"; } } echo "</tr>"; } ?> </table> <?php mysql_free_result($res); } // ET DB error } } } } } ?> <script type="text/javascript"> <!-- var prog = "<?php echo $prog_mode; ?> "; if (prog == 2) { if(document.perf) { document.perf.attempts.focus(); window.scrollBy(0,100); } } else { if(document.perf) { document.perf.perf.focus(); document.perf.perf.select(); window.scrollBy(0,100); } if(document.rank) { document.rank.rank.focus(); document.rank.rank.select(); window.scrollBy(0,100); } } //--> </script> </body> </html> <?php } else { AA_printErrorMsg($strErrMergedRound); } }
function AA_results_Tech($round, $layout) { require './lib/cl_gui_button.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/cl_wind.lib.php'; $presets = AA_results_getPresets($round); // read GET/POST variables $nextRound = AA_getNextRound($presets['event'], $round); $svm = AA_checkSVM(0, $round); // decide whether to show club or team name $prog_mode = AA_results_getProgramMode(); // // terminate result processing // if ($_GET['arg'] == 'results_done' || $prog_mode == 2 && $_GET['arg'] != 'change_results' && $_GET['arg'] != 'del_results') { $eval = AA_results_getEvaluationType($round); $combined = AA_checkCombined(0, $round); mysql_query("LOCK TABLES r READ, s READ, ss READ, runde READ"); // if this is a combined event, rank all rounds togheter $roundSQL = ""; $roundSQL2 = ""; if ($combined) { $roundSQL = " s.xRunde IN ("; $roundSQL2 = " s.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] . ","; $roundSQL2 .= $row_c[0] . ","; } $roundSQL = substr($roundSQL, 0, -1) . ")"; $roundSQL2 = substr($roundSQL2, 0, -1) . ")"; } else { $roundSQL = " s.xRunde = {$round}"; $roundSQL2 = " s.xRunde = {$round}"; } // number of athletes $sql = "SELECT \r\n ss.xSerienstart \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 WHERE r.xRunde = " . $round . "\r\n "; $res = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $count_athlete = mysql_num_rows($res); } // evaluate max. nbr of results entered $r = 0; if ($prog_mode == 2) { // create array for calculate field focus $sql_r = "SELECT \r\n ru.Versuche, \r\n LPAD(s.Bezeichnung,5,'0') as heatid, \r\n if (ss.Position2 > 0, if (ss.Position3 > 0, ss.Position3, ss.Position2) , ss.Position ) as posOrder \r\n , ss.Position\r\n , ss.Position2\r\n , ss.Position3 \r\n , ss.xSerienstart\r\n , ss.Rang\r\n , s.MaxAthlet\r\n , s.xSerie \r\n , r.Leistung \r\n FROM \r\n resultat AS r\r\n LEFT JOIN serienstart AS ss ON (r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie )\r\n LEFT JOIN runde AS ru ON (s.xRunde = ru.xRunde) \r\n WHERE " . $roundSQL2 . " \r\n ORDER BY posOrder, r.xResultat "; $result_r = mysql_query($sql_r); $heatStart = ''; $arr_perfAthlete = array(); $arr_perfAthleteValids = array(); $c = 0; $h = 0; $pos2 = 0; // calculate attempts of athletes while ($row_r = mysql_fetch_row($result_r)) { if ($heatStart != $row_r[6]) { // new heat start if (!empty($heatStart)) { $arr_perfAthlete[$h] = $c; if ($c > 0) { $arr_perfAthleteValids[$h] = $c; } $h++; if ($h >= $row_r[8] && $row_r[4] > 0) { // maxAthlete reached by second/third Position break; } } $c = 0; if ($row_r[10] > 0 || $row_r[10] < $cfgInvalidResult['DSQ']['code']) { $c++; } elseif ($row_r[10] == $cfgInvalidResult['DNS']['code']) { $c = $cfgInvalidResult['DNS']['code']; } elseif ($row_r[10] == $cfgInvalidResult['DNF']['code']) { $c = $cfgInvalidResult['DNF']['code']; } elseif ($row_r[10] == $cfgInvalidResult['DSQ']['code']) { $c = $cfgInvalidResult['DSQ']['code']; } } else { if ($row_r[10] > 0 || $row_r[10] < $cfgInvalidResult['DSQ']['code']) { $c++; } elseif ($row_r[10] == $cfgInvalidResult['DNS']['code']) { $c = $cfgInvalidResult['DNS']['code']; } elseif ($row_r[10] == $cfgInvalidResult['DNF']['code']) { $c = $cfgInvalidResult['DNF']['code']; } elseif ($row_r[10] == $cfgInvalidResult['DSQ']['code']) { $c = $cfgInvalidResult['DSQ']['code']; } } $heatStart = $row_r[6]; $maxAthlete = $row_r[8]; $pos2 = $row_r[4]; } // last athlete if ($h >= $maxAthlete && $pos2 > 0) { } else { $arr_perfAthlete[$h] = $c; if ($c > 0) { $arr_perfAthleteValids[$h] = $c; } } $p1 = 0; $p2 = 0; //calculate doing new position foreach ($arr_perfAthlete as $key => $val) { if ($val == 3 || $val < 0) { $p1++; } elseif ($val == 5 || $val < 0) { $p2++; } } if (count($arr_perfAthlete) == $p1) { AA_rankingForNewPosition($round, 2); AA_newPosition($round, 2); } elseif (count($arr_perfAthlete) == $p2) { AA_rankingForNewPosition($round, 3); AA_newPosition($round, 3); } $sql = "SELECT \r\n COUNT(*), \r\n ru.Versuche, \r\n LPAD(s.Bezeichnung,5,'0') as heatid, \r\n if (ss.Position2 > 0, if (ss.Position3 > 0, ss.Position3, ss.Position2) , ss.Position ) as posOrder \r\n , ss.Position\r\n , ss.Position2\r\n , ss.Position3 \r\n , ss.xSerienstart\r\n , ss.Rang\r\n , s.MaxAthlet\r\n , s.xSerie \r\n , r.Leistung\r\n \r\n FROM \r\n resultat AS r\r\n LEFT JOIN serienstart AS ss ON (r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie )\r\n LEFT JOIN runde AS ru ON (s.xRunde = ru.xRunde) \r\n WHERE " . $roundSQL2 . " \r\n GROUP BY r.xSerienstart\r\n ORDER BY posOrder "; $result = mysql_query($sql); } else { $result = mysql_query("SELECT COUNT(*), ru.Versuche" . " FROM resultat AS r" . " LEFT JOIN serienstart AS ss ON (r.xSerienstart = ss.xSerienstart)" . " LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie)" . " LEFT JOIN runde AS ru ON (s.xRunde = ru.xRunde)" . " WHERE " . " {$roundSQL2} " . " GROUP BY r.xSerienstart" . " ORDER BY 1 DESC"); } if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if ($prog_mode == 2) { // decentral with ranking $z = 0; $pass = 0; $arr_attAthlete = array(); $maxAthlete = 0; while ($row = mysql_fetch_row($result)) { if ($z == 0) { // first row $maxatt = $row[1]; $maxAthlete = $row[9]; $xSerie = $row[10]; } if ($row[11] != $cfgInvalidResult['DNS']['code']) { $arr_attAthlete[] = $row[0]; } $keep_rank = $row[8]; $z++; } if ($count_athlete < $maxAthlete) { $maxAthlete = $count_athlete; // update max athlete in serie AA_setMaxAthlete($xSerie, $maxAthlete); } $maxAthleteAtt = max($arr_attAthlete); $minAthleteAtt = min($arr_attAthlete); $onlyMaxAthlete = false; if ($count_athlete > $cfgMaxAthlete) { if ($maxAthleteAtt == $minAthleteAtt && $minAthleteAtt == $cfgAfterAttempts1) { $onlyMaxAthlete = true; } elseif ($maxAthleteAtt > $cfgAfterAttempts1) { $onlyMaxAthlete = true; } } if ($onlyMaxAthlete && $count_athlete > $cfgMaxAthlete) { $c = 0; $arr_attAthlete_new = array(); foreach ($arr_attAthlete as $key => $val) { $c++; $arr_attAthlete_new[] = $val; if ($c >= $maxAthlete) { break; } } $arr_attAthlete = $arr_attAthlete_new; $maxAthleteAtt = max($arr_attAthlete); $minAthleteAtt = min($arr_attAthlete); } $r = $maxAthleteAtt; $first_row = false; $maxAthleteAtt = max($arr_perfAthleteValids); $minAthleteAtt = min($arr_perfAthleteValids); if ($maxAthleteAtt == $cfgAfterAttempts1 && $maxAthleteAtt == $minAthleteAtt) { $pass = 2; } elseif ($maxAthleteAtt == $cfgAfterAttempts2 && $maxAthleteAtt == $minAthleteAtt) { $pass = 3; } elseif ($maxAthleteAtt > $cfgAfterAttempts1 && $maxAthleteAtt < $cfgAfterAttempts2 + 1) { $pass = 2; } elseif ($maxAthleteAtt == $cfgAfterAttempts2 + 1) { $pass = 3; } elseif ($maxAthleteAtt == $minAthleteAtt && $z == $count_athlete) { $first_row = true; $maxAthleteAtt++; } $fieldFocus = 1; } else { $row = mysql_fetch_row($result); $r = $row[0]; } mysql_free_result($result); } $minPerfAthl = min($arr_perfAthleteValids); $maxPerfAthl = max($arr_perfAthleteValids); $keep_val = ''; $keep_key = ''; foreach ($arr_perfAthlete as $key => $val) { if (empty($keep_val) && !empty($val)) { $fieldFocus = $maxatt + 1 + $maxPerfAthl; } $keep_key = $key; if ($keep_val > $val) { if ($val == $cfgInvalidResult['DNS']['code'] || $val == $cfgInvalidResult['DNF']['code'] || $val == $cfgInvalidResult['DSQ']['code']) { continue; } $fieldFocus = $key * ($maxatt + 1) + $maxPerfAthl; break; } $keep_val = $val; } if ($pos2 == 0) { if ($count_athlete > count($arr_perfAthlete)) { $fieldFocus = ($keep_key + 1) * ($maxatt + 1) + $maxPerfAthl; } elseif ($count_athlete == count($arr_perfAthlete) && $minPerfAthl == $maxPerfAthl) { $fieldFocus = $maxPerfAthl + 1; } } else { if ($minPerfAthl == $maxPerfAthl) { $fieldFocus = $maxPerfAthl + 1; } } if ($r > 0) { mysql_query("DROP TABLE IF EXISTS tempresult"); // temporary table if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { mysql_query("\r\n LOCK TABLES\r\n resultat READ\r\n , serie READ\r\n , wettkampf READ\r\n , serienstart WRITE\r\n , tempresult WRITE\r\n "); // Set up a temporary table to hold all results for ranking. // The number of result columns varies according to the maximum // number of results per athlete. $qry = "\r\n CREATE TABLE tempresult (\r\n xSerienstart int(11)\r\n , xSerie int(11)"; for ($i = 1; $i <= $r; $i++) { $qry = $qry . ", Res" . $i . " int(9) default '0'"; $qry = $qry . ", Wind" . $i . " char(5) default '0'"; } $qry = $qry . ") TYPE=HEAP"; mysql_query($qry); // create temporary table if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // reset rank to 0 first $sql = " SELECT\r\n r.Leistung\r\n , r.Info\r\n , ss.xSerienstart\r\n , ss.xSerie\r\n FROM\r\n resultat as r\r\n LEFT JOIN serienstart as ss ON (r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie)\r\n WHERE \r\n {$roundSQL}\r\n AND r.Leistung <= 0\r\n ORDER BY\r\n ss.xSerienstart\r\n ,r.Leistung DESC"; $result = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row = mysql_fetch_row($result)) { mysql_query("\r\n UPDATE serienstart SET\r\n Rang = 0\r\n WHERE xSerienstart = {$row['2']}\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } } $result = mysql_query("\r\n SELECT\r\n r.Leistung\r\n , r.Info\r\n , ss.xSerienstart\r\n , ss.xSerie\r\n FROM\r\n resultat as r\r\n LEFT JOIN serienstart as ss ON (r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie)\r\n WHERE \r\n {$roundSQL}\r\n AND r.Leistung >= 0\r\n ORDER BY\r\n ss.xSerienstart\r\n ,r.Leistung DESC\r\n "); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $ss = 0; $i = 0; // process every result while ($row = mysql_fetch_row($result)) { if ($ss != $row[2]) { // add one row per athlete to temp table if ($ss != 0) { for (; $i < $r; $i++) { // fill remaining result cols. $qry = $qry . ",0,''"; } mysql_query($qry . ")"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } // (re)set SQL statement $qry = "INSERT INTO tempresult VALUES({$row['2']},{$row['3']}"; $i = 0; } $qry = $qry . ",{$row['0']},'{$row['1']}'"; // add current result to query $ss = $row[2]; // keep athlete's ID $i++; // count nbr of results } mysql_free_result($result); // insert last pending data in temp table if ($ss != 0) { for (; $i < $r; $i++) { // fill remaining result cols. $qry = $qry . ",0,''"; } mysql_query($qry . ")"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } } if ($eval == $cfgEvalType[$strEvalTypeHeat]) { // eval per heat $qry = "\r\n SELECT\r\n *\r\n FROM\r\n tempresult\r\n ORDER BY\r\n xSerie"; for ($i = 1; $i <= $r; $i++) { $qry = $qry . ", Res" . $i . " DESC"; } } else { // default: rank results from all heats together $qry = "\r\n SELECT\r\n *\r\n FROM\r\n tempresult\r\n ORDER BY "; $comma = ""; // order by available result columns for ($i = 1; $i <= $r; $i++) { $qry = $qry . $comma . "Res" . $i . " DESC"; $comma = ", "; } } $result = mysql_query($qry); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $heat = 0; $perf_old[] = ''; $j = 0; $rank = 0; // set rank for every athlete while ($row = mysql_fetch_row($result)) { for ($i = 0; $i <= $r; $i++) { $perf[$i] = $row[2 * $i + 2]; $wind[$i] = $row[2 * $i + 3]; } if ($eval == $cfgEvalType[$strEvalTypeHeat] && $heat != $row[1]) { $j = 0; // restart ranking $perf_old[] = ''; } $j++; // increment ranking if ($perf_old != $perf) { // compare performances $rank = $j; // next rank (only if not same performance) } mysql_query("\r\n UPDATE serienstart SET\r\n Rang = {$rank}\r\n WHERE xSerienstart = {$row['0']}\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } $heat = $row[1]; // keep current heat ID $perf_old = $perf; } mysql_free_result($result); } mysql_query("DROP TABLE IF EXISTS tempresult"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } // ET DB error (create temp table) mysql_query("UNLOCK TABLES"); } // ET DB error (drop temp table) } // ET any results found AA_results_setNotStarted($round); // update athletes with no result if ($_GET['arg'] == 'results_done') { AA_utils_changeRoundStatus($round, $cfgRoundStatus['results_done']); } if (!empty($GLOBALS['AA_ERROR'])) { AA_printErrorMsg($GLOBALS['AA_ERROR']); } AA_results_resetQualification($round); } // // calculate ranking points if needed // if ($_GET['arg'] == 'results_done' || $_POST['arg'] == 'save_rank' || $prog_mode == 2 && $_GET['arg'] != 'change_results' && $_GET['arg'] != 'del_results') { AA_utils_calcRankingPoints($round); } // // Qualify athletes after ranks are set // if ($_GET['arg'] == 'results_done' || $_POST['arg'] == 'save_rank' || $_POST['arg'] == 'set_qual' || $prog_mode == 2 && $_GET['arg'] != 'change_results' && $_GET['arg'] != 'del_results') { // 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 DESC" . ", 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 } // // 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']) { // get program mode $prog_mode = AA_results_getProgramMode(); AA_heats_printNewStart($presets['event'], $round, "event_results.php"); if ($pass == 2) { $fieldPos = "ss.Position2"; $order = "posOrder"; } elseif ($pass == 3) { $fieldPos = "ss.Position3"; $order = "ss.Rang DESC"; } else { $fieldPos = "ss.Position"; $order = "posOrder"; } // display all athletes $sql = "SELECT rt.Name" . ", rt.Typ" . ", s.xSerie" . ", s.Bezeichnung" . ", s.Wind" . ", an.Bezeichnung" . ", ss.xSerienstart" . ", ss.Position" . ", ss.Rang" . ", 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" . ", r.Versuche" . ", ss.Qualifikation" . ", at.Land" . ", r.nurBestesResultat" . ", ss.Bemerkung" . ", at.xAthlet" . ", if (ss.Position2 > 0, if (ss.Position3 > 0, ss.Position3, ss.Position2) , ss.Position ) as posOrder " . " 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, posOrder"; $result = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $sum_athlet = mysql_num_rows($result); AA_results_printMenu($round, $status, $prog_mode, 'tech'); // initialize variables $h = 0; $i = 0; $r = 0; $rowclass = 'odd'; $r_rem = 0; $nextRound = AA_getNextRound($presets['event'], $round); // show qualification form if another round follows if ($nextRound > 0) { // next round $sql = "SELECT QualifikationSieger, \r\n QualifikationLeistung \r\n FROM runde \r\n WHERE xRunde = " . $round . ";"; $result2 = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $row2 = mysql_fetch_row($result2); if ($row2 == true) { // round found ?> <p/> <form name="qualification" action="event_results.php" method="post"> <input type="hidden" name="arg" value="set_qual"/> <input type="hidden" name="round" value="<?php echo $round; ?> "/> <table class="dialog"> <tr> <td class="dialog"><?php echo $strQualification; ?> <?php echo $strQualifyTop; ?> </td> <td class="dialog"><input type="text" name="qual_top" class="nbr" maxlength="4" value="<?php echo $row2[0]; ?> "/></td> <td class='dialog'><?php echo $strQualification; ?> <?php echo $strQualifyPerformance; ?> </td> <td class='dialog'><input type="text" name="qual_perf" class="nbr" maxlength="4" value="<?php echo $row2[1]; ?> "/></td> <td><button type="submit"><?php echo $strChange; ?> </button></td> </tr> </table> </form> <form name="frmQual" action="event_results.php" method="post"> <input type="hidden" name="arg" value="change_qual"/> <input type="hidden" name="round" value="<?php echo $round; ?> "/> <input type="hidden" name="focus" value="qual_0"/> <input type="hidden" name="item" value="0"/> <input type="hidden" name="oldqual" value="0"/> <input type="hidden" name="heat" value="0"/> <input type="hidden" name="qual" value="0"/> </form> <script type="text/javascript"> function changequal(valFocus, valItem, valOldQual, valHeat, valQual){ var obj = document.frmQual; obj.focus.value = valFocus; obj.item.value = valItem; obj.oldqual.value = valOldQual; obj.heat.value = valHeat; obj.qual.value = valQual; obj.submit(); } </script> <p/> <?php } // ET round found } // ET DB error } // ET next round ?> <p/> <table class='dialog'> <?php $btn = new GUI_Button('', ''); // create button object while ($row = mysql_fetch_row($result)) { // // get entered number of attempts // $maxatt = $row[15]; if ($maxatt != 0) { $cfgProgramMode[$prog_mode]['tech_res'] = $maxatt; } /* * 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 $title = "{$row['0']}"; } $c = 0; if ($status == $cfgRoundStatus['results_done'] || $prog_mode == 2) { $c++; // increment colspan to include ranking } ?> <tr> <form action='event_results.php#heat_<?php echo $row[3]; ?> ' method='post' name='heat_id_<?php echo $h; ?> '> <th class='dialog' colspan=' <?php echo 5 + $cfgProgramMode[$prog_mode]['tech_res'] + $c; ?> '> <?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[2]; ?> ' /> <input class='nbr' type='text' name='id' maxlength='2' value='<?php echo $row[3]; ?> ' onChange='document.heat_id_<?php echo $h; ?> .submit()' /> <a name='heat_<?php echo $row[3]; ?> ' /> </th> </form> </tr> <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> <?php if ($status == $cfgRoundStatus['results_done'] || $prog_mode == 2) { ?> <th class='dialog'><?php echo $strRank; ?> </th> <?php if ($nextRound > 0) { ?> <th class='dialog'><?php echo $strQualification; ?> </th> <?php } } if ($cfgProgramMode[$prog_mode]['tech_res'] <= 1) { ?> <th class='dialog'><?php echo $strPerformance; ?> </th> <?php } else { for ($c = 1; $c <= $cfgProgramMode[$prog_mode]['tech_res']; $c++) { ?> <th class='dialog'><?php echo $c . "."; ?> </th> <?php } ?> <th class='dialog'><?php echo $strResultRemark; ?> </th> <?php } ?> </tr> <?php } // ET new heat /* * Athlete data lines */ $i++; if ($row[7] % 2 == 0) { // even row numer $rowclass = 'odd'; } else { // odd row number $rowclass = 'even'; } ?> <tr class='<?php echo $rowclass; ?> '> <td class='forms_right'><?php echo $row[7]; /* position */ ?> </td> <td class='forms_right'><?php echo $row[9]; /* start nbr */ ?> </td> <td nowrap><?php echo $row[10] . " " . $row[11]; /* name */ ?> </td> <td class='forms_ctr'><?php echo AA_formatYearOfBirth($row[12]); ?> </td> <td><?php echo $row[17] != '' && $row[17] != '-' ? $row[17] : ' '; ?> </td> <td nowrap><?php echo $row[13]; /* club */ ?> </td> <?php $res = mysql_query("SELECT rs.xResultat" . ", rs.Leistung" . ", rs.Info" . " FROM resultat AS rs" . " WHERE rs.xSerienstart = " . $row[6] . "\r\n ORDER BY rs.xResultat"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // Show rank if ($status == $cfgRoundStatus['results_done'] || $prog_mode == 2) { $disField = ($maxatt + 1) * $maxAthlete; // attempts * 8 (first 8 athletes) if ($pass >= 2 && $r + 1 > $disField) { $dis = 'disabled=" disabled"'; } else { $dis = ''; } ?> <form action='event_results.php' method='post' name='rank_<?php echo $r; ?> '> <td> <input type='hidden' name='arg' value='save_rank' /> <input type='hidden' name='round' value='<?php echo $round; ?> ' /> <input type='hidden' name='item' value='<?php echo $row[6]; ?> ' /> <input type='hidden' name='focus' value='rank_<?php echo $r; ?> ' /> <input class='nbr' type='text' name='rank' maxlength='3' <?php echo $dis; ?> value='<?php echo $row[8]; ?> ' onChange='document.rank_<?php echo $r; ?> .submit()' /> </td> <?php if ($status == $cfgRoundStatus['results_done'] || $prog_mode == 2) { if ($nextRound > 0) { ?> <form name="qual_<?php echo $i; ?> " action="event_results.php" method="post"> <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[6]; ?> "/> <input type="hidden" name="oldqual" value="<?php echo $row[16]; ?> "/> <input type="hidden" name="heat" value="<?php echo $row[2]; ?> "/> <?php $dropdown = new GUI_Select('qual', 1, 'changequal("qual_' . $i . '", ' . $row[6] . ', ' . $row[16] . ', ' . $row[2] . ', this.value)'); $dropdown->addOptionNone(); foreach ($cfgQualificationType as $type) { $dropdown->addOption($type['text'], $type['code']); if ($type['code'] == $row[16]) { $dropdown->selectOption($type['code']); } } $dropdown->printList(); ?> </td> </form> <?php $i++; // next element } // qualification info } else { // no rank ?> <td /> <?php if ($nextRound > 0) { ?> <td /> <?php } } // ET valid rank ?> </form> <?php } $disField = ($maxatt + 1) * $maxAthlete; // attempts * 8 (first 8 athletes) for ($c = 1; $c <= $cfgProgramMode[$prog_mode]['tech_res']; $c++) { // Result focus: // - Backoffice mode: same athlete, next result // - Field mode: next athlete, same result $r++; // increment result form counter if ($cfgProgramMode[$prog_mode]['name'] == $strProgramModeBackoffice) { if ($row[18] == 'y') { // only best result --> focus next line $focus = "perf_" . ($r + $cfgProgramMode[$prog_mode]['tech_res'] + 1); if (mysql_num_rows($result) == $i) { // no more athletes if ($c == $cfgProgramMode[$prog_mode]['tech_res']) { // last result $focus = "perf_" . ($r + 1); // keep focus on this athlete } else { $focus = "perf_" . ($c + 1); // focus to next result of first athlete } } } else { if ($c == $cfgProgramMode[$prog_mode]['tech_res']) { // last result of this line if (mysql_num_rows($result) == $i) { // no more athletes $focus = "perf_" . $r; // keep focus on last athlete } else { $focus = "perf_" . ($r + 2); // focus to next line result } } else { $focus = "perf_" . ($r + 1); // focus to next result } } } else { // field mode $focus = "perf_" . ($r + $cfgProgramMode[$prog_mode]['tech_res'] + 1); if (mysql_num_rows($result) == $i) { // no more athletes if ($c == $cfgProgramMode[$prog_mode]['tech_res']) { // last result $focus = "perf_" . $r; // keep focus on this athlete } else { $focus = "perf_" . ($c + 1); // focus to next result of first athlete } } } // ET program mode $item = ''; $perf = ''; $info = ''; if ($resrow = mysql_fetch_row($res)) { $item = $resrow[0]; $perf = AA_formatResultMeter($resrow[1]); $info = $resrow[2]; } if ($status != $cfgRoundStatus['results_done'] || $prog_mode == 2) { ?> <form action='controller.php' method='post' name='perf_<?php echo $r; ?> ' target='controller'> <td nowrap> <input type='hidden' name='act' value='saveResult' /> <input type='hidden' name='obj' value='perf_<?php echo $r; ?> ' /> <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[6]; ?> ' /> <input type='hidden' name='item' value='<?php echo $item; ?> ' /> <input type='hidden' name='row_col' value='<?php echo $r . "_" . $c; ?> ' /> <input type='hidden' name='maxatt' value='<?php echo $maxatt; ?> ' /> <input type='hidden' name='heat' value='<?php echo $row[2]; ?> ' /> <?php // technical disciplines with wind if ($layout == $cfgDisciplineType[$strDiscTypeJump]) { ?> <input class='perfmeter' type='text' id='perf_<?php echo $r; ?> ' name='perf' maxlength='6' <?php echo $dis; ?> value='<?php echo $perf; ?> ' onChange='checkSubmit(document.perf_<?php echo $r; ?> , <?php echo $focus; ?> )' /> <input class='nbr' type='text' name='wind' maxlength='5' value='<?php echo $info; ?> ' onChange='submitResult(document.perf_<?php echo $r; ?> , <?php echo $focus; ?> )' /> <?php } else { ?> <input class='perfmeter' type='text' id='perf_<?php echo $r; ?> ' name='perf' maxlength='6' <?php echo $dis; ?> value='<?php echo $perf; ?> ' onChange='submitResult(document.perf_<?php echo $r; ?> , <?php echo $focus; ?> )' /> <?php } ?> </td> </form> <?php if ($c == $cfgProgramMode[$prog_mode]['tech_res']) { $r++; if (mysql_num_rows($result) != $i) { // more athletes $focus = "perf_" . ($c + $r + 1); } else { $focus = "perf_" . $r; } ?> <form action='controller.php' method='post' name='perf_<?php echo $r; ?> ' target='controller'> <td> <input type='hidden' name='act' value='saveResult' /> <input type='hidden' name='obj' value='perf_<?php echo $r; ?> ' /> <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[6]; ?> ' /> <input type='hidden' name='item' value='<?php echo $item; ?> ' /> <input type='hidden' name='xAthlete' value='<?php echo $row[20]; ?> ' /> <input class='textshort' type='text' name='remark' maxlength='5' <?php echo $dis; ?> value='<?php echo $row[19]; ?> ' onChange='submitResult(document.perf_<?php echo $r; ?> , <?php echo $focus; ?> )' /> </td> </form> <?php } ?> <?php } else { // results done ?> <td nowrap> <?php // technical disciplines with wind if ($layout == $cfgDisciplineType[$strDiscTypeJump]) { echo "{$perf} ( {$info} )"; } else { echo "{$perf}"; } ?> </td> <?php if ($c == $cfgProgramMode[$prog_mode]['tech_res']) { ?> <td nowrap><?php echo $row[19]; ?> </td> <?php } } // ET results done } // end loop every tech result acc. programm mode ?> <td> <?php $btn->set("event_results.php?arg=del_start&item={$row['6']}&round={$round}", $strDelete); $btn->printButton(); ?> </td> <?php } // ET DB error } ?> </table> <?php mysql_free_result($result); } // ET DB error } } } } // ET round selected if (!empty($presets['focus'])) { ?> <script type="text/javascript"> <!-- if(document.<?php echo $presets['focus']; ?> ) { document.<?php echo $presets['focus']; ?> .rank.focus(); document.<?php echo $presets['focus']; ?> .rank.select(); window.scrollBy(0,200); } //--> </script> <?php } else { ?> <script type="text/javascript"> <!-- document.perf_<?php echo $fieldFocus; ?> .elements['perf_<?php echo $fieldFocus; ?> '].focus(); //--> </script> <?php } ?> </body> </html> <?php } else { AA_printErrorMsg($strErrMergedRound); } }
function AA_speaker_Track($event, $round, $layout) { require './lib/cl_gui_menulist.lib.php'; require './lib/cl_gui_resulttable.lib.php'; require './lib/cl_performance.lib.php'; require './config.inc.php'; require './lib/common.lib.php'; $mergedMain = AA_checkMainRound($round); if ($mergedMain != 1) { $relay = AA_checkRelay($event); // check, if this is a relay event $status = AA_getRoundStatus($round); $svm = AA_checkSVM(0, $round); // decide whether to show club or team name // No action yet if ($status == $cfgRoundStatus['open'] || $status == $cfgRoundStatus['enrolement_done'] || $status == $cfgRoundStatus['heats_in_progress']) { AA_printWarningMsg($strHeatsNotDone); } else { if ($status == $cfgRoundStatus['enrolement_pending']) { AA_printWarningMsg($strEnrolementNotDone); } else { if ($status >= $cfgRoundStatus['heats_done']) { // show link to rankinglist if results done if ($status == $cfgRoundStatus['results_done']) { $menu = new GUI_Menulist(); $menu->addButton("print_rankinglist.php?event={$event}&round={$round}&type=single&formaction=speaker&show_efforts=none", $GLOBALS['strRankingList']); $menu->addButton("print_rankinglist.php?event={$event}&round={$round}&type=single&formaction=speaker&show_efforts=sb_pb", $GLOBALS['strRankingListEfforts']); $menu->printMenu(); echo "<p/>"; } // show qualification info if another round follows $nextRound = AA_getNextRound($event, $round); if ($nextRound > 0) { $result = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tQualifikationSieger\r\n\t\t\t\t\t, QualifikationLeistung\r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde\r\n\t\t\t\tWHERE xRunde = {$round}\r\n\t\t\t"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { if (($row = mysql_fetch_row($result)) == TRUE) { } echo "{$strQualification}: {$row['0']} {$strQualifyTop}, {$row['1']} {$strQualifyPerformance}"; echo "<p/>"; } // ET DB error mysql_free_result($result); } // ET next round // display all athletes if ($relay == FALSE) { // single event $query = "\r\n SELECT\r\n r.Bahnen\r\n , rt.Name\r\n , rt.Typ\r\n , s.xSerie\r\n , s.Bezeichnung\r\n , s.Wind\r\n , s.Film\r\n , s.Status\r\n , ss.xSerienstart\r\n , ss.Position\r\n , ss.Rang\r\n , ss.Qualifikation\r\n , a.Startnummer\r\n , at.Name\r\n , at.Vorname\r\n , at.Jahrgang\r\n , if('" . $svm . "', te.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo)) \r\n , LPAD(s.Bezeichnung,5,'0') as heatid\r\n , at.Land\r\n , st.Bestleistung\r\n , at.xAthlet\r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie )\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n LEFT JOIN team AS te ON(a.xTeam = te.xTeam)\r\n LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n WHERE \r\n r.xRunde = {$round} \r\n ORDER BY\r\n heatid\r\n , ss.Position\r\n "; } else { // relay event $query = "\r\n SELECT\r\n r.Bahnen\r\n , rt.Name\r\n , rt.Typ\r\n , s.xSerie\r\n , s.Bezeichnung\r\n , s.Wind\r\n , s.Film\r\n , s.Status\r\n , ss.xSerienstart\r\n , ss.Position\r\n , ss.Rang\r\n , ss.Qualifikation\r\n , sf.Name\r\n , if('" . $svm . "', te.Name, v.Name) \r\n , LPAD(s.Bezeichnung,5,'0') as heatid\r\n , r.xRunde\r\n , st.xStart\r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart )\r\n LEFT JOIN staffel AS sf ON (sf.xStaffel = st.xStaffel )\r\n LEFT JOIN verein AS v ON (v.xVerein = sf.xVerein)\r\n LEFT JOIN team AS te ON(sf.xTeam = te.xTeam)\r\n LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n WHERE \r\n r.xRunde = {$round} \r\n ORDER BY\r\n heatid\r\n , ss.Position"; } $result = mysql_query($query); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $h = 0; // heat counter $p = 0; // position counter (to evaluate empty heats $tracks = 0; $resTable = new GUI_TrackResultTable($round, $layout, $status, $nextRound); while ($row = mysql_fetch_row($result)) { $p++; // increment position counter /* * Heat headerline */ if ($h != $row[3]) { $tracks = $row[0]; // keep nbr of planned tracks // fill previous heat with empty tracks if ($p > 1) { $resTable->printEmptyTracks($p, $tracks, 5 + $c); } $h = $row[3]; // keep heat ID $p = 1; // start with track one if (is_null($row[1])) { // only one round $title = "{$strFinalround} {$row['4']}"; } else { // more than one round $title = "{$row['1']}: {$row['2']}{$row['4']}"; } // increment colspan to include ranking and qualification $c = 0; if ($status == $cfgRoundStatus['results_done']) { $c++; if ($nextRound > 0) { $c++; } } $resTable->printHeatTitle($row[3], $row[4], $title, $row[7], $row[6], $row[5]); if ($relay == FALSE) { // athlete display $resTable->printAthleteHeader('', $round); } else { // relay display $resTable->printRelayHeader('', $round); } } // ET new heat /* * Empty tracks */ if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) { // current track and athlete's position not identical if ($p < $row[9]) { $p = $resTable->printEmptyTracks($p, $row[9] - 1, 6 + $c); } } // ET empty tracks /* * Athlete/Relay data lines */ // get performance $perf = ''; $perfRounded = ''; $res = mysql_query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\trs.xResultat\r\n\t\t\t\t\t\t, rs.Leistung\r\n\t\t\t\t\t\t, rs.Info\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tresultat AS rs\r\n\t\t\t\t\tWHERE rs.xSerienstart = {$row['8']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\trs.Leistung ASC\r\n\t\t\t\t"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $resrow = mysql_fetch_row($res); if ($resrow != NULL) { // result found $perf = AA_formatResultTime($resrow[1]); $perfRounded = AA_formatResultTime($resrow[1], true); } mysql_free_result($res); } // ET DB error // print lines if ($relay == FALSE) { $resTable->printAthleteLine($row[9], $row[12], "{$row['13']} {$row['14']}", AA_formatYearOfBirth($row[15]), $row[16], AA_formatResultTime($row[19], true), $perfRounded, $row[10], $row[11], $row[18], $row[20]); } else { // relay // get Athletes $arrAthletes = array(); $sql = "SELECT at.Vorname, at.Name, at.Jahrgang, a.Startnummer FROM\r\n\t\t\t\t\t\t\t\tstaffelathlet as sfat\r\n\t\t\t\t\t\t\t\tLEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n\t\t\t\t\t\t\t\tLEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\tLEFT JOIN athlet as at USING(xAthlet)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tsfat.xStaffelstart = {$row['16']}\r\n\t\t\t\t\t\t\tAND\tsfat.xRunde = {$row['15']}\r\n\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\tsfat.Position"; $res_at = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row_at = mysql_fetch_array($res_at)) { $arrAthletes[] = array($row_at[1], $row_at[0], AA_formatYearOfBirth($row_at[2]), $row_at[3]); } } $arrAthletes = count($arrAthletes) > 0 ? $arrAthletes : 0; $resTable->printRelayLine($row[9], $row[12], $row[13], $perfRounded, $row[10], $row[11], $arrAthletes); } } // Fill last heat with empty tracks for disciplines run in // individual tracks if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) { if ($p > 0) { // heats set up $p++; $resTable->printEmptyTracks($p, $tracks, 6 + $c); } } // ET track disciplines $resTable->endTable(); mysql_free_result($result); } // ET DB error } } } // ET heat seeding done } else { AA_printErrorMsg($strErrMergedRoundSpeaker); } }
function AA_speaker_Tech($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); $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']) { $temp = mysql_query("\r\n\t\t\tCREATE TABLE `temp` (\r\n `id` int(10) NOT NULL auto_increment,\r\n `athlet` int(10) NOT NULL default '0',\r\n `leistung` int(11) NOT NULL default '0',\r\n `rang` int(10) NOT NULL default '0',\r\n PRIMARY KEY (`id`)\r\n) TYPE=MyISAM AUTO_INCREMENT=1\r\n\t\t"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } $sql = "\r\n SELECT\r\n rt.Name\r\n , rt.Typ\r\n , s.xSerie\r\n , s.Bezeichnung\r\n , s.Wind\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 , v.Name\r\n , LPAD(s.Bezeichnung,5,'0') as heatid\r\n , w.Windmessung\r\n , at.xAthlet\r\n , at.Land\r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde )\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n LEFT JOIN wettkampf AS w ON (w.xWettkampf = r.xWettkampf)\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\r\n "; $temp = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($row = mysql_fetch_row($temp)) { $tempsql = "SELECT\r\n\t\t\t\t\t\tMAX(r.Leistung) As maxLeistung\r\n\t\t\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['6']}"; $tempres = mysql_query($tempsql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($restemp = mysql_fetch_row($tempres)) { if (!empty($restemp[0])) { mysql_query("INSERT INTO `temp` ( `athlet` , `leistung` , `rang`) \r\n\t\t\t\t VALUES ({$row['6']}, {$restemp['0']} , 1);"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } } } } mysql_free_result($tempres); } mysql_free_result($temp); } $xrang = 1; $templeistung = 0; $temprang = mysql_query("SELECT * FROM temp ORDER BY leistung DESC"); while ($rowrang = mysql_fetch_row($temprang)) { if ($rowrang[2] == $templeistung) { $rangieren = mysql_query("UPDATE temp SET rang = {$yrang} WHERE id={$rowrang['0']}"); } else { $rangieren = mysql_query("UPDATE temp SET rang = {$xrang} WHERE id={$rowrang['0']}"); $yrang = $xrang; } $templeistung = $rowrang[2]; $xrang = $xrang + 1; } // if this is a combined event, rank all rounds togheter $roundSQL = ""; if ($combined) { $roundSQL = "AND s.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 = "AND s.xRunde = {$round}"; } $countAthlete = 0; $sql_at = "SELECT \r\n Count(*)\r\n FROM \r\n start AS s \r\n WHERE \r\n s.xWettkampf = " . $event; $result_at = mysql_query($sql_at); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } $row_at = mysql_fetch_row($result_at); if (mysql_num_rows($result_at) > 0) { $countAthlete = $row_at[0]; } // 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/>"; } $svm = AA_checkSVM(0, $round); // decide whether to show club or team name $prog_mode = AA_results_getProgramMode(); // find current athlete (show yellow) when more than one attempt $roundSQL_C = substr($roundSQL, 4); $sql_curr = "SELECT \r\n count( * ) , \r\n ss.xSerienstart,\r\n if (ss.Position2 > 0, if (ss.Position3 > 0, ss.Position3, ss.Position2) , ss.Position ) as posOrder,\r\n s.MaxAthlet,\r\n ss.Position2,\r\n ss.Position3\r\n FROM \r\n resultat as r \r\n LEFT JOIN serienstart AS ss ON ( r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN serie AS s ON (ss.xSerie = s.xSerie )\r\n WHERE \r\n {$roundSQL_C} \r\n GROUP BY ss.xSerienstart\r\n ORDER BY posOrder "; $res_curr = mysql_query($sql_curr); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $ss = 0; $keep_ss = 0; // current athlete to show yellow $keep_ss_first = 0; // first athlete is current when all have same count of attempts $c = 0; $z = 0; $maxAthlete = 0; while ($row_curr = mysql_fetch_row($res_curr)) { if ($z > 0 && $z == $maxAthlete) { break; } if ($c > 0) { if ($row_curr[0] < $c) { $keep_ss_save = $keep_ss; $keep_ss = $row_curr[1]; break; } } $c = $row_curr[0]; $ss = $row_curr[1]; if ($z == 0) { $keep_ss_first = $row_curr[1]; if ($row_curr[4] > 0 || $row_curr[5] > 0) { $maxAthlete = $row_curr[3]; } } $z++; } } if ($prog_mode == 0) { if ($keep_ss == 0 && $r < $r_attempts) { $keep_ss = $keep_ss_first; } else { if ($r < $r_attempts) { $keep_ss = $keep_ss_save; } } } else { if ($keep_ss == 0 && $z % $countAthlete == 0) { $keep_ss = $keep_ss_first; } } $arg = isset($_GET['arg']) ? $_GET['arg'] : (isset($_COOKIE['sort_speaker']) ? $_COOKIE['sort_speaker'] : 'pos'); setcookie('sort_speaker', $arg, time() + 2419200); // display all athletes if ($arg == "nbr" && !$relay) { $argument = "a.Startnummer"; $img_nbr = "img/sort_act.gif"; } else { if ($arg == "pos") { $argument = "ss.Position"; $img_pos = "img/sort_act.gif"; } else { if ($arg == "name") { $argument = "at.Name, at.Vorname"; $img_name = "img/sort_act.gif"; } else { if ($arg == "club") { if ($svm) { $argument = "te.Name, a.Startnummer"; } else { $argument = "v.Name, a.Startnummer"; } $img_club = "img/sort_act.gif"; } else { if ($arg == "perf") { $argument = "st.Bestleistung, ss.Position"; $img_perf = "img/sort_act.gif"; } else { if ($arg == "rang") { $argument = "t.rang, ss.Position"; $img_rang = "img/sort_act.gif"; } else { if ($relay == FALSE) { // single event $argument = "ss.Position"; $img_pos = "img/sort_act.gif"; } } } } } } } $sql = "\r\n SELECT\r\n rt.Name\r\n , rt.Typ\r\n , s.xSerie\r\n , s.Bezeichnung\r\n , s.Wind\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 , w.Windmessung\r\n , st.Bestleistung\r\n , at.xAthlet\r\n , at.Land\r\n , t.rang\r\n , r.xRunde\r\n FROM\r\n runde AS r\r\n LEFT JOIN serie AS s ON (s.xRunde = r.xRunde )\r\n LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n LEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n LEFT JOIN team AS te ON(a.xTeam = te.xTeam) \r\n LEFT JOIN wettkampf AS w ON (w.xWettkampf = r.xWettkampf)\r\n LEFT JOIN temp AS t ON (t.athlet = ss.xSerienstart)\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 s.xSerie, \r\n " . $argument . "\r\n "; $result = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { // initialize variables $h = 0; $i = 0; $r = 0; $resTable = new GUI_TechResultTable($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; $c++; // increment colspan to include ranking $resTable->printHeatTitle($row[2], $row[3], $title, $row[5]); $resTable->printAthleteHeader('', $row[20]); } // ET new heat /* * Athlete data lines */ $perfs = array(); $fett = array(); $sql = "SELECT\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['6']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\tr.xResultat"; $res = mysql_query($sql); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { while ($resrow = mysql_fetch_row($res)) { $sql2 = "SELECT\r\n\t\t\t\t\t\tleistung\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\ttemp\r\n\t\t\t\t\t\tWHERE athlet = {$row['6']}"; $res2 = mysql_query($sql2); while ($row2 = mysql_fetch_row($res2)) { if ($row2[0] == $resrow[0]) { $fett[] = 1; } else { $fett[] = 0; } $perf = AA_formatResultMeter($resrow[0]); if ($row[15] == 1) { // with wind $info = $resrow[1]; $perfs[] = "{$perf} ( {$info} )"; } else { $perfs[] = "{$perf}"; } } } // end loop every tech result acc. programm mode mysql_free_result($res); } //print_r($perfs); if ($keep_ss > 0) { if ($keep_ss == $row[6]) { $curr_class = "active"; } } else { if (empty($perfs) && !$current_athlete) { $current_athlete = true; $curr_class = "active"; } } $resTable->printAthleteLine($row[7], $row[9], "{$row['10']} {$row['11']}", AA_formatYearOfBirth($row[12]), $row[13], AA_formatResultMeter($row[16]), $perfs, $fett, $row[19], $row[18], $row[17], $curr_class); $curr_class = ""; } $resTable->endTable(); mysql_free_result($result); } // ET DB error } } } // ET heat seeding done $temp = mysql_query("\r\n\t\tDROP TABLE IF EXISTS `temp`\r\n\t"); } 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 }
function AA_results_Tech($round, $layout, $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 $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 $sql = "SELECT rt.Name" . ", rt.Typ" . ", s.xSerie" . ", s.Bezeichnung" . ", s.Wind" . ", an.Bezeichnung" . ", ss.xSerienstart" . ", ss.Position" . ", ss.Rang" . ", 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" . ", r.Versuche" . ", ss.Qualifikation" . ", at.Land" . ", r.nurBestesResultat" . ", ss.Bemerkung" . ", at.xAthlet" . " FROM athletica.runde AS r" . " LEFT JOIN athletica.serie AS s ON (s.xRunde = r.xRunde)" . " LEFT JOIN athletica.serienstart AS ss ON (ss.xSerie = s.xSerie)" . " LEFT JOIN athletica.start AS st ON (st.xStart = ss.xStart)" . " LEFT JOIN athletica.anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)" . " LEFT JOIN athletica.athlet AS at ON (at.xAthlet = a.xAthlet)" . " LEFT JOIN athletica.verein AS v ON (v.xVerein = at.xVerein)" . " LEFT JOIN athletica.team AS t ON(a.xTeam = t.xTeam)" . " LEFT JOIN athletica.rundentyp_" . $_COOKIE['language'] . " AS rt" . " ON rt.xRundentyp = r.xRundentyp" . " LEFT JOIN athletica.anlage AS an" . " ON an.xAnlage = s.xAnlage" . " WHERE r.xRunde = " . $round . " ORDER BY heatid, 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; $r = 0; $rowclass = 'odd'; $r_rem = 0; ?> <?php 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}"; } else { // more than one round if ($row[1] == '0') { $title = ""; } else { $title = "{$row['0']}"; } } $c = 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>"; for ($c = 1; $c <= $row[15]; $c++) { $content .= "<th class='dialog'>" . $c . "</th>"; } $content .= "</tr>"; } // ET new heat /* * Athlete data lines */ $i++; if ($row[7] % 2 == 0) { // even row numer $rowclass = 'odd'; } else { // odd row number $rowclass = 'even'; } $content .= "<tr class='" . $rowclass . "'>"; $content .= "<td class='forms_right'>" . $row[7] . "</td>"; /* position */ $content .= "<td class='forms_right'>" . $row[9] . "</td>"; /* start nbr */ $content .= "<td nowrap>" . $row[10] . " " . $row[11] . "</td>"; /* name */ $content .= "<td class='forms_ctr_pc'>" . AA_formatYearOfBirth($row[12]) . "</td>"; $content .= "<td class='forms_pc'>"; if ($row[17] != '' && $row[17] != '-') { $content .= $row[17]; /* club */ } else { $content .= " "; } $content .= "</td>"; $content .= "<td class='forms_pc' nowrap>" . $row[13] . "</td>"; $res = mysql_query("SELECT rs.xResultat" . ", rs.Leistung" . ", rs.Info" . " FROM athletica.resultat AS rs" . " WHERE rs.xSerienstart = " . $row[6] . "\r\n ORDER BY rs.xResultat"); if (mysql_errno() > 0) { // DB error AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } for ($c = 1; $c <= $row[15]; $c++) { $item = ''; $perf = ''; $info = ''; if ($resrow = mysql_fetch_row($res)) { $item = $resrow[0]; $perf = AA_formatResultMeter($resrow[1]); $info = $resrow[2]; } if ($perf < 0) { if ($perf == $cfgMissedAttempt['dbx']) { $perf = $cfgInvalidResult['NAA']['code']; } elseif (perf == $cfgMissedAttempt['db']) { $perf = $cfgInvalidResult['WAI']['short']; } else { foreach ($cfgInvalidResult as $value) { if ($value['code'] == $row_res[3]) { $perf = $value['short']; } } } } // technical disciplines with wind if ($layout == $cfgDisciplineType[$strDiscTypeJump]) { $content .= "<td>" . $perf . " (" . $info . ") </td>"; // info = wind } else { $content .= "<td>" . $perf . "</td>"; } } } // end while $content .= "</table>"; $content .= $cfgHtmlFooter; $content .= "</div ></div>"; $content .= $cfgHtmlEnd; if (!fwrite($fp, $content)) { AA_printErrorMsg($GLOBALS['strErrFileWriteFailed']); return; } fclose($fp); mysql_free_result($result); } // ET DB error } // ET round selected AA_UpdateStatusChanged($round); ?> </body> </html> <?php }