function validate($performance, $info) { require './lib/cl_performance.lib.php'; // validate result $perf = new PerformanceAttempt($performance); $this->performance = $perf->getPerformance(); if ($this->performance == NULL) { $GLOBALS['AA_ERROR'] = $GLOBALS['strErrInvalidResult'] . $performance; } // validate attempts if ($this->performance > 0) { $info = strtoupper($info); $info = strtr($info, '0', 'O'); $info = str_replace("OOO", "O", $info); $info = str_replace("OO", "O", $info); if (preg_match($GLOBALS['cfgResultsHigh'], $info) == 0) { // invalid result $GLOBALS['AA_ERROR'] = $GLOBALS['strErrInvalidResult'] . $info; $info = NULL; } } else { // negative or zero result $info = 'XXX'; } $this->info = $info; }
//} } if (!empty($_POST[$p])) { if ($_POST[$t] == 'time') { $secflag = false; if (substr($_POST[$p], 0, 2) >= 60) { $secflag = true; } $pt = new PerformanceTime($_POST[$p], $secflag); $perf = $pt->getPerformance(); $ps = new PerformanceTime($previousSeasonBest, $secflag); $perfSeason = $ps->getPerformance(); } else { $pa = new PerformanceAttempt($_POST[$p]); $perf = $pa->getPerformance(); $ps = new PerformanceAttempt($previousSeasonBest); $perfSeason = $ps->getPerformance(); } if ($perf == NULL) { // invalid performance $perf = 0; } if ($perfSeason == NULL) { // invalid performance $perfSeason = 0; } } if (isset($_POST['start_' . $event])) { // add every event (no duplicates) mysql_query("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINSERT INTO start SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\txWettkampf = {$event}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t, xAnmeldung = {$xAnmeldung}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t, Bestleistung = {$perf}\r\n , VorjahrLeistung = {$perfSeason}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t"); if (mysql_errno() == 0) {
$_POST[$p] = $row_p[1]; // best effort current or previous year (Indoor: best of both / Outdoor: best of outdoor) } } } } if (!empty($_POST[$p])) { if ($_POST[$t] == 'time') { $secflag = false; if (substr($_POST[$p], 0, 2) >= 60) { $secflag = true; } $pt = new PerformanceTime($_POST[$p], $secflag); $perf = $pt->getPerformance(); } else { $pa = new PerformanceAttempt($_POST[$p]); $perf = $pa->getPerformance(); } if ($perf == NULL) { // invalid performance $perf = 0; } } if (isset($_POST['start_' . $event])) { // add every event (no duplicates) mysql_query("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINSERT INTO start SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\txWettkampf = {$event}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t, xAnmeldung = {$xAnmeldung}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t, Bestleistung = {$perf}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t"); if (mysql_errno() == 0) { // check if event already started $res = mysql_query("SELECT d.Name" . " FROM disziplin AS d" . ", runde AS r" . ", wettkampf AS w" . " WHERE r.xWettkampf=" . $event . " AND (r.Status = 1 OR r.Status = 2 OR r.Status = 3 OR r.Status = 4 OR r.Status = 6) " . " AND w.xWettkampf = " . $event . " AND d.xDisziplin = w.xDisziplin"); if (mysql_errno() > 0) { AA_printErrorMsg("Line " . __LINE__ . ": " . mysql_errno() . ": " . mysql_error());
$nbr = $lastnbr + 1; // check if startnumber is used for athletes $res = mysql_query("SELECT * FROM anmeldung \r\n WHERE Startnummer = {$nbr} \r\n AND xMeeting = " . $_COOKIE['meeting_id']); if (mysql_num_rows($res) > 0) { $nbr = AA_getNextStartnbr($nbr); } } } if (!$_POST['techDisc']) { $group = ''; } if (empty($_POST['perf'])) { $perf = 0; } else { if ($_POST['techDisc']) { $perf = new PerformanceAttempt($_POST['perf']); $perf->performance = $perf->getPerformance(); $perf = $perf->getPerformance(); } else { $perf = new PerformanceTime($_POST['perf'], false); $perf->performance = $perf->getPerformance(); $perf = $perf->getPerformance(); } } $quali = $_POST['quali']; if (empty($_POST['quali'])) { $quali = 0; } // add mysql_query("INSERT INTO teamsm SET\r\n\t\t\t\t\tName = '" . $_POST['name'] . "'\r\n\t\t\t\t\t, xKategorie = " . $_POST['category'] . "\r\n\t\t\t\t\t, xVerein = " . $_POST['club'] . "\r\n\t\t\t\t\t, xWettkampf = " . $_POST['event'] . "\r\n , Startnummer = " . $nbr . " \r\n , Gruppe = '" . $group . "'\r\n , Quali = " . $quali . " \r\n , Leistung = " . $perf . " \r\n\t\t\t\t\t, xMeeting = " . $_COOKIE['meeting_id'] . ""); if (mysql_errno() > 0) {
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 processDiscipline($event, $disctype, $catname, $discname, $windmeas, $list) { global $rFrom, $rTo, $limitRank, $date; require 'config.inc.php'; $teams = array(); // team array $countRes = 3; // results per team counting $order_perf = ""; $order_perf_sort = ""; $valid_result = ""; if ($disctype == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $disctype == $cfgDisciplineType[$strDiscTypeThrow]) { $order_perf = "DESC"; $order_perf_sort = "DESC"; } else { if ($disctype == $cfgDisciplineType[$strDiscTypeJump]) { if ($windmeas == 1) { // with wind $order_perf = "DESC, r.Info ASC"; $order_perf_sort = "DESC"; } else { // without wind $order_perf = "DESC"; $order_perf_sort = "DESC"; } } else { if ($disctype == $cfgDisciplineType[$strDiscTypeHigh]) { $order_perf = "DESC"; $order_perf_sort = "DESC"; $valid_result = " AND (r.Info LIKE '%O%' OR r.Leistung < 0)"; } else { $order_perf = "ASC"; $order_perf_sort = "ASC"; } } } $sql_leistung = $order_perf == 'ASC' ? "r.Leistung" : "IF(r.Leistung<0, (If(r.Leistung = -99, -9, r.Leistung) * -1), r.Leistung)"; $sql = "\r\n SELECT\r\n ts.xTeamsm\r\n , ts.Name\r\n , v.Name\r\n , at.Name\r\n , at.Vorname\r\n , a.Startnummer\r\n , " . $sql_leistung . " AS leistung_neu\r\n , at.xAthlet\r\n , r.Leistung \r\n , ss.Rang\r\n FROM\r\n teamsm AS ts\r\n LEFT JOIN verein AS v ON (v.xVerein = ts.xVerein)\r\n LEFT JOIN teamsmathlet AS tsa ON (tsa.xTeamsm = ts.xTeamsm)\r\n LEFT JOIN anmeldung AS a ON (a.xAnmeldung = tsa.xAnmeldung)\r\n LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n LEFT jOIN start AS st ON (st.xAnmeldung = tsa.xAnmeldung)\r\n LEFT JOIN serienstart AS ss ON (ss.xStart = st.xStart )\r\n LEFT JOIN resultat AS r ON ( r.xSerienstart = ss.xSerienstart)\r\n LEFT JOIN serie AS se ON (ss.xSerie = se.xSerie)\r\n LEFT JOIN runde as ru ON (se.xRunde = ru.xRunde) \r\n WHERE\r\n ts.xWettkampf = {$event} \r\n AND st.xWettkampf = {$event} \r\n AND ru.Datum LIKE '" . $date . "' \r\n {$valid_result} \r\n ORDER BY\r\n ts.xTeamsm\r\n , leistung_neu {$order_perf}\r\n "; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg(mysql_errno() . ": " . mysql_error()); } else { $team = 0; // current team $c = 0; // count results $athletes = array(); $teams_notValid = array(); // team array while ($row = mysql_fetch_array($res)) { $row_res[6] = $row_res[6] == 1 || $row_res[6] == 2 || $row_res[6] == 3 || $row_res[6] == 4 ? $row_res[6] * -1 : ($row_res[6] == 9 ? -99 : $row_res[6]); if (isset($athletes[$row[7]])) { continue; } else { $athletes[$row[7]] = 1; } if ($team != $row[0]) { if ($team > 0) { $countAthl = count($teams[$team]['athletes']); if ($countAthl < $countRes) { $teams[$team]['perf'] = 0; $teams[$team]['perfTot'] = 0; $teams[$team]['rankTot'] = 0; $teams[$team]['perfBest'] = 0; $teams[$team]['rankBest'] = 0; $teams[$team]['perfNotValid'] = 0; $teams_notValid[$team]['club'] = $teams[$team]['club']; $teams_notValid[$team]['name'] = $teams[$team]['name']; $teams_notValid[$team]['perf'] = 0; $teams_notValid[$team]['athletes'] = $teams[$team]['athletes']; } else { $notValidPerf = false; $countNotValid = 0; foreach ($teams[$team]['athletes'] as $key => $val) { if ($pos = strpos($val, "-1") || ($pos = strpos($val, "-2") || ($pos = strpos($val, "-3") || ($pos = strpos($val, "-4"))))) { $notValidPerf = true; $countNotValid++; } } if (!$notValidPerf) { $teams[$team]['perf'] /= $countRes; } else { $countValid = $countRes - $countNotValid; if (isset($teams[$team]['athletes'][3])) { if ($pos = strpos($teams[$team]['athletes'][0], "-1") || ($pos = strpos($teams[$team]['athletes'][0], "-2") || ($pos = strpos($teams[$team]['athletes'][0], "-3") || ($pos = strpos($teams[$team]['athletes'][0], "-4"))))) { $tmp_at = $teams[$team]['athletes'][0]; $teams[$team]['athletes'][0] = substr($teams[$team]['athletes'][3], 1, -1); list($at, $atPerf) = split('[,]', $teams[$team]['athletes'][0]); $teams[$team]['athletes'][3] = "[" . $tmp_at . "]"; } elseif ($pos = strpos($teams[$team]['athletes'][1], "-1") || ($pos = strpos($teams[$team]['athletes'][1], "-2") || ($pos = strpos($teams[$team]['athletes'][1], "-3") || ($pos = strpos($teams[$team]['athletes'][1], "-4"))))) { $tmp_at = $teams[$team]['athletes'][1]; $teams[$team]['athletes'][1] = substr($teams[$team]['athletes'][3], 1, -1); list($at, $atPerf) = split('[,]', $teams[$team]['athletes'][1]); $teams[$team]['athletes'][3] = "[" . $tmp_at . "]"; } elseif ($pos = strpos($teams[$team]['athletes'][2], "-1") || ($pos = strpos($teams[$team]['athletes'][2], "-2") || ($pos = strpos($teams[$team]['athletes'][2], "-3") || ($pos = strpos($teams[$team]['athletes'][2], "-4"))))) { $tmp_at = $teams[$team]['athletes'][2]; $teams[$team]['athletes'][2] = substr($teams[$team]['athletes'][3], 1, -1); list($at, $atPerf) = split('[,]', $teams[$team]['athletes'][2]); $teams[$team]['athletes'][3] = "[" . $tmp_at . "]"; } if ($disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeNone']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeTrack']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeTrackNoWind']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeDistance']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeRelay']]) { $perf = new PerformanceTime($atPerf, $secFlag); $atPerf = $perf->getPerformance(); } else { if ($disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeJump']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeJumpNoWind']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeThrow']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeHigh']]) { $perf = new PerformanceAttempt($performance); $atPerf = $perf->getPerformance(); } } if ($countNotValid == 2) { $teams[$team]['perf'] += $atPerf; $teams[$team]['perf'] = $teams[$team]['perf'] / $countNotValid; } elseif ($countNotValid == 1) { $teams[$team]['perf'] += $atPerf; $teams[$team]['perf'] = $teams[$team]['perf'] / $countRes; $notValidPerf = false; } elseif ($countNotValid == 3) { $teams[$team]['perf'] += $atPerf; } } } if ($order_perf == 'ASC') { if ($notValidPerf) { $teams[$team]['perfNotValid'] = $teams[$team]['perf']; $teams[$team]['perf'] = 99999999; } } else { if ($notValidPerf) { $teams[$team]['perfNotValid'] = $teams[$team]['perf']; } } } } $team = $row[0]; $teams[$team]['club'] = $row[2]; $teams[$team]['name'] = $row[1]; $c = 0; } $perf = 0; $perf_print = 0; $rank = 0; $asc = true; if ($disctype == $cfgDisciplineType[$strDiscTypeJump] || $disctype == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $disctype == $cfgDisciplineType[$strDiscTypeThrow] || $disctype == $cfgDisciplineType[$strDiscTypeHigh]) { $perf = $row[6]; $asc = false; if ($row[8] >= 0) { $perf_print = AA_formatResultMeter($row[6]); } else { $perf_print = $perf * -1; } } else { $perf = ceil($row[6] / 10) * 10; // round up 1000 $asc = true; if ($disctype == $cfgDisciplineType[$strDiscTypeTrack] || $disctype == $cfgDisciplineType[$strDiscTypeTrackNoWind]) { $perf_print = AA_formatResultTime($row[6], true, true); } else { $perf_print = AA_formatResultTime($row[6], true); } } $rank = $row[9]; if ($c < $countRes) { $teams[$team]['perf'] += $perf; $teams[$team]['perfTot'] += $perf; $teams[$team]['rankTot'] += $rank; if ($asc) { if ($perf < $teams[$team]['perfBest'] || $teams[$team]['perfBest'] == 0) { $teams[$team]['perfBest'] = $perf; $teams[$team]['rankBest'] = $rank; } } else { if ($perf > $teams[$team]['perfBest']) { $teams[$team]['perfBest'] = $perf; $teams[$team]['rankBest'] = $rank; } } $teams[$team]['athletes'][] = "{$row['3']} {$row['4']}, {$perf_print}"; } else { $teams[$team]['athletes'][] = "[{$row['3']} {$row['4']}, {$perf_print}]"; } $c++; } if ($team > 0) { // calc last team $countAthl = count($teams[$team]['athletes']); if ($countAthl < $countRes) { $teams[$team]['perf'] = 0; $teams[$team]['perfNotValid'] = 0; $teams_notValid[$team]['club'] = $teams[$team]['club']; $teams_notValid[$team]['name'] = $teams[$team]['name']; $teams_notValid[$team]['perf'] = 0; $teams_notValid[$team]['athletes'] = $teams[$team]['athletes']; } else { $notValidPerf = false; $countNotValid = 0; foreach ($teams[$team]['athletes'] as $key => $val) { if ($pos = strpos($val, "-1") || ($pos = strpos($val, "-2") || ($pos = strpos($val, "-3") || ($pos = strpos($val, "-4"))))) { $notValidPerf = true; $countNotValid++; } } if (!$notValidPerf) { $teams[$team]['perf'] /= $countRes; } else { $countValid = $countRes - $countNotValid; if (isset($teams[$team]['athletes'][3])) { if ($pos = strpos($teams[$team]['athletes'][0], "-1") || ($pos = strpos($teams[$team]['athletes'][0], "-2") || ($pos = strpos($teams[$team]['athletes'][0], "-3") || ($pos = strpos($teams[$team]['athletes'][0], "-4"))))) { $tmp_at = $teams[$team]['athletes'][0]; $teams[$team]['athletes'][0] = substr($teams[$team]['athletes'][3], 1, -1); list($at, $atPerf) = split('[,]', $teams[$team]['athletes'][0]); $teams[$team]['athletes'][3] = "[" . $tmp_at . "]"; } elseif ($pos = strpos($teams[$team]['athletes'][1], "-1") || ($pos = strpos($teams[$team]['athletes'][1], "-2") || ($pos = strpos($teams[$team]['athletes'][1], "-3") || ($pos = strpos($teams[$team]['athletes'][1], "-4"))))) { $tmp_at = $teams[$team]['athletes'][1]; $teams[$team]['athletes'][1] = substr($teams[$team]['athletes'][3], 1, -1); list($at, $atPerf) = split('[,]', $teams[$team]['athletes'][1]); $teams[$team]['athletes'][3] = "[" . $tmp_at . "]"; } elseif ($pos = strpos($teams[$team]['athletes'][2], "-1") || ($pos = strpos($teams[$team]['athletes'][2], "-2") || ($pos = strpos($teams[$team]['athletes'][2], "-3") || ($pos = strpos($teams[$team]['athletes'][2], "-4"))))) { $tmp_at = $teams[$team]['athletes'][2]; $teams[$team]['athletes'][2] = substr($teams[$team]['athletes'][3], 1, -1); list($at, $atPerf) = split('[,]', $teams[$team]['athletes'][2]); $teams[$team]['athletes'][3] = "[" . $tmp_at . "]"; } if ($disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeNone']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeTrack']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeTrackNoWind']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeDistance']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeRelay']]) { $perf = new PerformanceTime($atPerf, $secFlag); $atPerf = $perf->getPerformance(); } else { if ($disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeJump']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeJumpNoWind']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeThrow']] || $disctype == $GLOBALS['cfgDisciplineType'][$GLOBALS['strDiscTypeHigh']]) { $perf = new PerformanceAttempt($performance); $atPerf = $perf->getPerformance(); } } if ($countNotValid == 2) { $teams[$team]['perf'] += $atPerf; $teams[$team]['perf'] = $teams[$team]['perf'] / $countNotValid; } elseif ($countNotValid == 1) { $teams[$team]['perf'] += $atPerf; $teams[$team]['perf'] = $teams[$team]['perf'] / $countRes; $notValidPerf = false; } elseif ($countNotValid == 3) { $teams[$team]['perf'] += $atPerf; } } } if ($order_perf == 'ASC') { if ($notValidPerf) { $teams[$team]['perfNotValid'] = $teams[$team]['perf']; $teams[$team]['perf'] = 99999999; } } else { if ($notValidPerf) { $teams[$team]['perfNotValid'] = $teams[$team]['perf']; } } } } $teams_valid = array(); foreach ($teams as $k => $arr_team) { if (!isset($teams_notValid[$k]['name'])) { $teams_valid[$k]['name'] = $teams[$k]['name']; $teams_valid[$k]['club'] = $teams[$k]['club']; $teams_valid[$k]['perf'] = $teams[$k]['perf']; $teams_valid[$k]['perfTot'] = $teams[$k]['perfTot']; $teams_valid[$k]['rankTot'] = $teams[$k]['rankTot']; $teams_valid[$k]['perfBest'] = $teams[$k]['perfBest']; $teams_valid[$k]['rankBest'] = $teams[$k]['rankBest']; $teams_valid[$k]['perfNotValid'] = $teams[$k]['perfNotValid']; $teams_valid[$k]['athletes'] = $teams[$k]['athletes']; } } $teams = $teams_valid; // // print team ranking // if (count($teams) > 0) { $list->printSubTitle($catname, $discname, ""); $list->startList(); $list->printHeaderLine(); usort($teams, "cmp_{$order_perf_sort}"); // sort by performance $teams = array_merge($teams, $teams_notValid); $rank = 1; // initialize rank $r = 0; // start value for ranking $p = 0; foreach ($teams as $team) { $r++; if ($limitRank && ($r < $rFrom || $r > $rTo)) { // limit ranks if set (export) continue; } if ($team['perf'] > 0) { $rank = $r; } else { $rank = ''; } if ($team['perf'] == 99999999) { $team['perf'] = $team['perfNotValid']; } $perf = 0; if ($disctype == $cfgDisciplineType[$strDiscTypeJump] || $disctype == $cfgDisciplineType[$strDiscTypeJumpNoWind] || $disctype == $cfgDisciplineType[$strDiscTypeThrow] || $disctype == $cfgDisciplineType[$strDiscTypeHigh]) { $perf = AA_formatResultMeter($team['perf']); } else { if ($disctype == $cfgDisciplineType[$strDiscTypeTrack] || $disctype == $cfgDisciplineType[$strDiscTypeTrackNoWind]) { $perf = AA_formatResultTime($team['perf'], true, true); } else { $perf = AA_formatResultTime($team['perf'], true); } } if ($perf == 0 || !empty($team['perfNotValid'])) { $rank = ''; } $list->printLine($rank, $team['name'], $team['club'], $perf); // print each athlete with result for team $tmp = ""; foreach ($team['athletes'] as $athlete) { $end = ""; list($name, $perfNotValid) = split(',', $athlete); if (strpos($perfNotValid, "]")) { $perfNotValid = substr($perfNotValid, 0, -1); $end = "]"; } if ($perfNotValid == $cfgInvalidResult['DNS']['code']) { $perfNotValid = $cfgInvalidResult['DNS']['short']; $athlete = $name . ', ' . $perfNotValid . $end; } elseif ($perfNotValid == $cfgInvalidResult['DNF']['code']) { $perfNotValid = $cfgInvalidResult['DNF']['short']; $athlete = $name . ', ' . $perfNotValid . $end; } elseif ($perfNotValid == $cfgInvalidResult['DSQ']['code']) { $perfNotValid = $cfgInvalidResult['DSQ']['short']; $athlete = $name . ', ' . $perfNotValid . $end; } elseif ($perfNotValid == $cfgInvalidResult['NRS']['code']) { $perfNotValid = $cfgInvalidResult['NRS']['short']; $athlete = $name . ', ' . $perfNotValid . $end; } //$list->printInfo($athlete); $tmp .= $athlete . " / "; } $list->printInfo(substr($tmp, 0, -2)); $p = $team['perf']; // keep current performance $keep_team = $team; // keep current performance } $list->endList(); } } }
function XML_regZLV_start($parser, $name, $attr) { global $bCombined, $arr_noCat; global $strBaseAthleteNotFound, $strLicenseNr; global $cfgDisciplineType, $strDiscTypeTrack, $strDiscTypeTrackNoWind, $strDiscTypeRelay, $strDiscTypeDistance, $strNoSuchCategory; global $cfgCombinedDef, $cfgCombinedWO; if ($name == "ATHLETE") { $regNr = $attr['ANMELDENR']; $license = $attr['LIZENZNR']; $name = $attr['NAME']; $firstname = $attr['VORNAME']; $birth = $attr['GEBDAT']; $arr_birth = explode(".", $birth); $birthdate = $arr_birth[2] . "-" . $arr_birth[1] . "-" . $arr_birth[0]; $birthyear = $arr_birth[2]; $club = $attr['VEREIN']; $sex = $attr['GESCHLECHT']; $nationality = $attr['NATIONALITAET']; $cat = $attr['KATEGORIE']; $group = $attr['GRUPPENR']; $starttime = $attr['STARTZEIT']; $license_paid = $attr['BEZ']; if ($license_paid == '') { $license_paid = 'n'; } $registerNr = $attr['ANMELDENR']; $meetingDate = ''; $discode = 0; if ($license > 0) { // check if event exist for this cateory and select event to get all generated events ids $sql = "SELECT \r\n w.xWettkampf,\r\n w.Mehrkampfcode,\r\n m.DatumVon \r\n FROM\r\n wettkampf as w\r\n LEFT JOIN kategorie as k on (w.xKategorie = k.xKategorie)\r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d on (w.xDisziplin = d.xDisziplin)\r\n LEFT JOIN meeting AS m ON (m.xMeeting = w.xMeeting)\r\n WHERE \r\n w.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n AND k.Code = '" . $cat . "'"; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-1-" . mysql_errno() . ": " . mysql_error()); } if (mysql_num_rows($res) > 0) { while ($row_dis = mysql_fetch_assoc($res)) { $xDis[] = $row_dis['xWettkampf']; if ($row_dis['Mehrkampfcode'] > 0) { $discode = $row_dis['Mehrkampfcode']; // same for all combined disciplines } $meetingDate = $row_dis['DatumVon']; } $athlete_id = 0; $sql2 = "SELECT TRIM(lastname) AS lastname, \r\n TRIM(firstname) AS firstname, \r\n substring(birth_date, 1,4) AS jahrgang, \r\n license, \r\n TRIM(sex) AS sex, \r\n nationality, \r\n birth_date, \r\n account_code, \r\n second_account_code,\r\n id_athlete,\r\n license_paid \r\n FROM base_athlete \r\n WHERE license = '" . $license . "';"; $query2 = mysql_query($sql2); if (mysql_errno() > 0) { AA_printErrorMsg("xml-2-" . mysql_errno() . ": " . mysql_error()); } else { if ($query2 && mysql_num_rows($query2) == 1) { // athlete exist in base data $row2 = mysql_fetch_assoc($query2); $club = $row2['account_code']; $club2 = $row2['second_account_code']; $athlete_id = $row2['id_athlete']; $result2 = mysql_query("SELECT xVerein FROM verein WHERE xCode = '" . $club . "'"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-3-" . mysql_errno() . ": " . mysql_error()); } else { $rowClub1 = mysql_fetch_array($result2); $club = $rowClub1[0]; if (!empty($club2)) { $result2 = mysql_query("SELECT xVerein FROM verein WHERE xCode = '" . $club2 . "'"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-4-" . mysql_errno() . ": " . mysql_error()); $club2 = 0; // prevents from insert error in next statement } else { $rowClub2 = mysql_fetch_array($result2); $club2 = $rowClub2[0]; } } else { $club2 = 0; } } mysql_free_result($result2); // check if athlete exist // check if athlete is already in "athlet" table $sql4 = "SELECT xAthlet FROM athlet WHERE Lizenznummer = '" . $license . "'"; $query4 = mysql_query($sql4); if (mysql_errno() > 0) { AA_printErrorMsg("xml-5-" . mysql_errno() . ": " . mysql_error()); } if (mysql_num_rows($query4) > 0) { $row4 = mysql_fetch_assoc($query4); $sql3 = "UPDATE athlet \r\n SET Name = '" . trim($row2['lastname']) . "', \r\n Vorname = '" . trim($row2['firstname']) . "', \r\n Jahrgang = '" . trim($row2['jahrgang']) . "', \r\n Geschlecht = '" . trim($row2['sex']) . "', \r\n Land = '" . trim($row2['nationality']) . "', \r\n Geburtstag = '" . trim($row2['birth_date']) . "', \r\n xVerein = '" . trim($club) . "', \r\n xVerein2 = '" . trim($club2) . "', \r\n Lizenznummer = '" . trim($license) . "',\r\n Bezahlt = '" . trim($row2['license_paid']) . "',\r\n Manuell = 0 \r\n WHERE (Lizenznummer = '" . trim($license) . "' \r\n OR (Name = '" . trim($row2['lastname']) . "' \r\n AND Vorname = '" . trim($row2['firstname']) . "' \r\n AND Jahrgang = '" . trim($row2['jahrgang']) . "' \r\n AND xVerein = '" . trim($club) . "'));"; $query3 = mysql_query($sql3); $xAthlete = $row4['xAthlet']; } else { // if club is valid // insert athlete from base data if (is_numeric($club)) { $sql = "INSERT INTO athlet \r\n (Name, Vorname, Jahrgang, \r\n Lizenznummer, Geschlecht, Land, \r\n Geburtstag, xVerein, xVerein2, Bezahlt, Lizenztyp)\r\n SELECT \r\n TRIM(lastname), TRIM(firstname), substring(birth_date, 1,4), \r\n license, TRIM(sex), nationality, \r\n birth_date, '{$club}', '{$club2}', license_paid, '1'\r\n FROM\r\n base_athlete\r\n WHERE\r\n license = {$license}"; mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-6-" . mysql_errno() . ": " . mysql_error()); } else { $xAthlete = mysql_insert_id(); } } } if ($xAthlete > 0) { // check if already registered $result = mysql_query("SELECT xAnmeldung FROM anmeldung WHERE xAthlet = {$xAthlete} AND xMeeting = " . $_COOKIE['meeting_id'] . ""); if (mysql_errno() > 0) { AA_printErrorMsg("xml-7-" . mysql_errno() . ": " . mysql_error()); } else { // get license category from base data $res = mysql_query(" \r\n SELECT k.xKategorie FROM\r\n kategorie as k\r\n LEFT JOIN base_athlete as b on (k.Code = b.license_cat)\r\n WHERE b.license = " . $license); if (mysql_errno() > 0) { AA_printErrorMsg("xml-8-" . mysql_errno() . ": " . mysql_error()); } else { $row = mysql_fetch_array($res); $xCat = $row[0]; if ($xCat != '') { if (mysql_num_rows($result) == 0) { // not yet registered // insert mysql_query("INSERT INTO anmeldung SET\r\n Startnummer = 0\r\n , Bezahlt = '" . $row2['license_paid'] . "'\r\n , Gruppe = '" . $group . "' \r\n , xAthlet = {$xAthlete}\r\n , xMeeting = " . $_COOKIE['meeting_id'] . "\r\n , xKategorie = {$xCat}\r\n , Anmeldenr_ZLV = {$registerNr}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-9-" . mysql_errno() . ": " . mysql_error()); } else { $xReg = mysql_insert_id(); } } else { // update $row = mysql_fetch_array($result); mysql_query("Update anmeldung SET\r\n Startnummer = 0\r\n , Bezahlt = '" . $row2['license_paid'] . "' \r\n , Gruppe = '" . $group . "' \r\n , xAthlet = {$xAthlete}\r\n , xMeeting = " . $_COOKIE['meeting_id'] . "\r\n , xKategorie = {$xCat}\r\n , Anmeldenr_ZLV = {$registerNr}\r\n WHERE xAnmeldung = {$row['0']}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-10-" . mysql_errno() . ": " . mysql_error()); } else { $xReg = $row[0]; } } } else { $result2 = mysql_query("SELECT license_cat \r\n FROM base_athlete\r\n WHERE license = {$license};"); $row2 = mysql_fetch_array($result2); $license_cat = $row2[0]; AA_printErrorMsg(str_replace('%cat%', $license_cat, $strNoSuchCategory)); } } // only combined events for ZLV // effort are points, saved on registration $sql = "SELECT notification_effort \r\n FROM base_performance\r\n WHERE id_athlete = {$athlete_id}\r\n AND discipline = {$discode}"; $res_effort = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-11-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res_effort) > 0) { $row_effort = mysql_fetch_assoc($res_effort); $effort = $row_effort['notification_effort']; mysql_query("UPDATE anmeldung SET\r\n BestleistungMK = '{$effort}'\r\n , xMeeting = " . $_COOKIE['meeting_id'] . " \r\n WHERE\r\n xAnmeldung = {$xReg}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-12-" . mysql_errno() . ": " . mysql_error()); } } } if ($xReg > 0) { // check if athlete alredy starts for this discipline(s) foreach ($xDis as $xDis1) { // because we can get multiple disciplines (combined event), // it is nessesary to determinate distype and discode for each discipline // (catcode won't change) $res_distype = mysql_query("\r\n SELECT d.Typ, d.Code, d.Appellzeit, d.Stellzeit FROM \r\n disziplin_" . $_COOKIE['language'] . " as d\r\n LEFT JOIN wettkampf as w ON (w.xDisziplin = d.xDisziplin)\r\n WHERE \r\n w.xWettkampf = {$xDis1}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-13-" . mysql_errno() . ": " . mysql_error()); } else { $row_distype = mysql_fetch_Array($res_distype); $distype = $row_distype[0]; $temp_discode = $row_distype[1]; } $result = mysql_query("SELECT xStart FROM start WHERE xAnmeldung = {$xReg} and xWettkampf = {$xDis1}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-14-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($result) == 0) { // not yet starting, add start $saison = $_SESSION['meeting_infos']['Saison']; if ($saison == '') { $saison = "O"; //if no saison is set take outdoor } $sql = "SELECT\r\n base_performance.notification_effort\r\n FROM\r\n athletica.base_performance\r\n INNER JOIN athletica.disziplin_" . $_COOKIE['language'] . " AS d \r\n ON (base_performance.discipline = d.Code)\r\n INNER JOIN athletica.wettkampf \r\n ON (d.xDisziplin = wettkampf.xDisziplin)\r\n WHERE (base_performance.id_athlete ={$athlete_id}\r\n AND wettkampf.xWettkampf ={$xDis1}\r\n AND wettkampf.xMeeting =" . $_COOKIE['meeting_id'] . "\r\n AND base_performance.season ='I')"; $res_effort = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-15-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res_effort) > 0) { $row_effort = mysql_fetch_assoc($res_effort); $effort = $row_effort['notification_effort']; } // // convert effort // if ($distype == $cfgDisciplineType[$strDiscTypeTrack] || $distype == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $distype == $cfgDisciplineType[$strDiscTypeRelay] || $distype == $cfgDisciplineType[$strDiscTypeDistance]) { $pt = new PerformanceTime($effort); $perf = $pt->getPerformance(); } else { //echo $bigger; $pa = new PerformanceAttempt($effort); $perf = $pa->getPerformance(); //$perf = (ltrim($effort,"0"))*100; } if ($perf == NULL) { // invalid performance $perf = 0; } mysql_query("INSERT INTO start SET\r\n xWettkampf = {$xDis1} \r\n , Bezahlt = '{$license_paid}'\r\n , xAnmeldung = {$xReg} \r\n , Bestleistung = '" . $perf . "' \r\n , BaseEffort = 'y'"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-16-" . mysql_errno() . ": " . mysql_error()); } } } } // update group in round for every event $sql_r = "SELECT Gruppe FROM runde WHERE xWettkampf = " . $xDis1; $res_r = mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-16a-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res_r) > 0) { while ($row_r = mysql_fetch_row($res_r)) { $arr_row[] = $row_r[0]; } if ($arr_row[0] == "") { //update group in round for every event $sql_r = "UPDATE IGNORE runde SET Gruppe = '" . $group . "' WHERE xWettkampf = " . $xDis1; mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-17-" . mysql_errno() . ": " . mysql_error()); } } elseif (!in_array($group, $arr_row)) { $stdEtime = strtotime($row_distype[2]); // hold standard delay for enrolement time $stdMtime = strtotime($row_distype[3]); // and manipulation time list($hr, $min) = AA_formatEnteredTime($starttime); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdEtime; $appellTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdMtime; $putTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); //insert group in round for every event $sql_r = "INSERT INTO runde SET\r\n Datum = '" . $meetingDate . "', \r\n Startzeit = '" . $starttime . "', \r\n Appellzeit= '" . $appellTime . "', \r\n Stellzeit= '" . $putTime . "', \r\n Gruppe = '" . $group . "', \r\n xRundentyp = 8, \r\n xWettkampf = " . $xDis1; mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-18-" . mysql_errno() . ": " . mysql_error()); } } } else { $stdEtime = strtotime($row_distype[2]); // hold standard delay for enrolement time $stdMtime = strtotime($row_distype[3]); // and manipulation time list($hr, $min) = AA_formatEnteredTime($starttime); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdEtime; $appellTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdMtime; $putTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); //insert group in round for every event $sql_r = "INSERT INTO runde SET\r\n Datum = '" . $meetingDate . "', \r\n Startzeit = '" . $starttime . "', \r\n Appellzeit= '" . $appellTime . "', \r\n Stellzeit= '" . $putTime . "', \r\n Gruppe = '" . $group . "', \r\n xRundentyp = 8, \r\n xWettkampf = " . $xDis1; mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-18I-" . mysql_errno() . ": " . mysql_error()); } } } } // enf foreach } // end xReg > 0 } } // end xAthlete > 0 } else { // athlete with this license not in base if (!in_array($license, $arr_noCat)) { $arr_noCat['lic'][] = $license; } } } } else { // category not in meeting if (!in_array($cat, $arr_noCat)) { $arr_noCat['cat'][] = $cat; } } } else { // license = 0 // select event to get all generated events ids $sql = "SELECT \r\n w.xWettkampf,\r\n w.Mehrkampfcode,\r\n k.xKategorie,\r\n m.DatumVon \r\n FROM\r\n wettkampf as w\r\n LEFT JOIN kategorie as k on (w.xKategorie = k.xKategorie )\r\n LEFT JOIN disziplin_" . $_COOKIE['language'] . " as d on (w.xDisziplin = d.xDisziplin)\r\n LEFT JOIN meeting AS m ON (m.xMeeting = w.xMeeting) \r\n WHERE \r\n w.xMeeting = " . $_COOKIE['meeting_id'] . "\r\n AND k.Kurzname = '" . $cat . "'"; $res = mysql_query($sql); if (mysql_num_rows($res) >= 1) { while ($row_dis = mysql_fetch_assoc($res)) { $xDis[] = $row_dis['xWettkampf']; if ($row_dis['Mehrkampfcode'] > 0) { $discode = $row_dis['Mehrkampfcode']; // same for all combined disciplines } $catnr = $row_dis['xKategorie']; $meetingDate = $row_dis['DatumVon']; } $result2 = mysql_query("SELECT xVerein FROM verein WHERE xCode = '" . $club . "'"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-19-" . mysql_errno() . ": " . mysql_error()); } else { $rowClub1 = mysql_fetch_array($result2); $clubnr = $rowClub1[0]; } mysql_free_result($result2); // if club is valid // insert athlete from base data if (is_numeric($clubnr)) { $name = mysql_real_escape_string(str_replace("\r", "\n", trim(utf8_decode($name)))); $firstname = mysql_real_escape_string(str_replace("\r", "\n", trim(utf8_decode($firstname)))); // if athlet exist $sql = "SELECT * FROM athlet WHERE Name= '" . $name . "' AND Vorname = '" . $firstname . "' AND Geburtstag = '" . $birthdate . "'"; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-20-" . mysql_errno() . ": " . mysql_error()); } else { $row = mysql_fetch_array($res); if (mysql_num_rows($res) == 0) { $sql = "INSERT IGNORE INTO athlet SET\r\n Name = '" . $name . "',\r\n Vorname = '" . $firstname . "', \r\n Jahrgang = '" . $birthyear . "', \r\n Lizenznummer = 0 , \r\n Geschlecht = '" . $sex . "', \r\n Land = '" . $nationality . "', \r\n Geburtstag = '" . $birthdate . "',\r\n Athleticagen = 'n', \r\n xVerein = '" . $clubnr . "', \r\n Bezahlt = '" . $license_paid . "', \r\n Lizenztyp = 3"; mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-21-" . mysql_errno() . ": " . mysql_error()); } else { $xAthlete = mysql_insert_id(); } } else { $sql = "UPDATE athlet SET \r\n Jahrgang = '" . $birthyear . "', \r\n Geschlecht = '" . $sex . "', \r\n Land = '" . $nationality . "', \r\n xVerein = '" . $clubnr . "', \r\n Bezahlt = '" . $license_paid . "'\r\n WHERE Name= '" . $name . "' AND Vorname = '" . $firstname . "' AND Geburtstag = '" . $birthdate . "'"; mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-22-" . mysql_errno() . ": " . mysql_error()); } else { $xAthlete = $row[0]; } } } } else { // club not found if (!in_array($license, $arr_noCat)) { $arr_noCat['club'][] = $club; } } } // end athlete found if ($xAthlete > 0) { // check if already registered $result = mysql_query("SELECT xAnmeldung FROM anmeldung WHERE xAthlet = {$xAthlete} AND xMeeting = " . $_COOKIE['meeting_id'] . ""); if (mysql_errno() > 0) { AA_printErrorMsg("xml-23-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($result) == 0) { // not yet registered if ($catnr != '') { mysql_query("INSERT INTO anmeldung SET\r\n Startnummer = 0\r\n , Bezahlt = '{$license_paid}'\r\n , xAthlet = {$xAthlete}\r\n , xMeeting = " . $_COOKIE['meeting_id'] . "\r\n , xKategorie = {$catnr}\r\n , Anmeldenr_ZLV = {$registerNr}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-24-" . mysql_errno() . ": " . mysql_error()); } else { $xReg = mysql_insert_id(); } } } else { // registered $row = mysql_fetch_array($result); mysql_query("Update anmeldung SET\r\n Startnummer = 0\r\n , Bezahlt = '{$license_paid}'\r\n , xAthlet = {$xAthlete}\r\n , xMeeting = " . $_COOKIE['meeting_id'] . "\r\n , xKategorie = {$xCat}\r\n , Anmeldenr_ZLV = {$registerNr}\r\n WHERE xAnmeldung = {$row['0']}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-25-" . mysql_errno() . ": " . mysql_error()); } else { $xReg = $row[0]; } } if ($xReg > 0) { // check if athlete alredy starts for this discipline(s) foreach ($xDis as $xDis1) { // because we can get multiple disciplines (combined event), // it is nessesary to determinate distype and discode for each discipline // (catcode won't change) $res_distype = mysql_query("\r\n SELECT d.Typ, d.Code, d.Appellzeit, d.Stellzeit FROM \r\n disziplin_" . $_COOKIE['language'] . " as d\r\n LEFT JOIN wettkampf as w ON (w.xDisziplin = d.xDisziplin)\r\n WHERE w.xWettkampf = {$xDis1}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-26-" . mysql_errno() . ": " . mysql_error()); } else { $row_distype = mysql_fetch_Array($res_distype); $distype = $row_distype[0]; $temp_discode = $row_distype[1]; } $result = mysql_query("SELECT xStart FROM start WHERE xAnmeldung = {$xReg} and xWettkampf = {$xDis1}"); if (mysql_errno() > 0) { AA_printErrorMsg("xml-27-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($result) == 0) { // not yet starting, add start $saison = $_SESSION['meeting_infos']['Saison']; if ($saison == '') { $saison = "O"; //if no saison is set take outdoor } mysql_query("INSERT INTO start SET\r\n xWettkampf = {$xDis1}\r\n , Bezahlt = '{$license_paid}'\r\n , xAnmeldung = {$xReg}\r\n "); if (mysql_errno() > 0) { AA_printErrorMsg("xml-28-" . mysql_errno() . ": " . mysql_error()); } } } // update group in round for every event $sql_r = "SELECT Gruppe FROM runde WHERE xWettkampf = " . $xDis1; $res_r = mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-28a-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($res_r) > 0) { while ($row_r = mysql_fetch_row($res_r)) { $arr_row[] = $row_r[0]; } if ($arr_row[0] == "") { //update group in round for every event $sql_r = "UPDATE IGNORE runde SET Gruppe = " . $group . " WHERE xWettkampf = " . $xDis1; mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-29-" . mysql_errno() . ": " . mysql_error()); } } elseif (!in_array($group, $arr_row)) { $stdEtime = strtotime($row_distype[2]); // hold standard delay for enrolement time $stdMtime = strtotime($row_distype[3]); // and manipulation time list($hr, $min) = AA_formatEnteredTime($starttime); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdEtime; $appellTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdMtime; $putTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); //insert group in round for every event $sql_r = "INSERT INTO runde SET\r\n Datum = '" . $meetingDate . "', \r\n Startzeit = '" . $starttime . "', \r\n Appellzeit= '" . $appellTime . "', \r\n Stellzeit= '" . $putTime . "', \r\n Gruppe = '" . $group . "', \r\n xRundentyp = 8, \r\n xWettkampf = " . $xDis1; mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-30-" . mysql_errno() . ": " . mysql_error()); } } } else { $stdEtime = strtotime($row_distype[2]); // hold standard delay for enrolement time $stdMtime = strtotime($row_distype[3]); // and manipulation time list($hr, $min) = AA_formatEnteredTime($starttime); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdEtime; $appellTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); $tmp = strtotime($hr . ":" . $min . ":00"); $tmp = $tmp - $stdMtime; $putTime = floor($tmp / 3600) . ":" . floor($tmp % 3600 / 60); //insert group in round for every event $sql_r = "INSERT INTO runde SET\r\n Datum = '" . $meetingDate . "', \r\n Startzeit = '" . $starttime . "', \r\n Appellzeit= '" . $appellTime . "', \r\n Stellzeit= '" . $putTime . "', \r\n Gruppe = '" . $group . "', \r\n xRundentyp = 8, \r\n xWettkampf = " . $xDis1; mysql_query($sql_r); if (mysql_errno() > 0) { AA_printErrorMsg("xml-18I-" . mysql_errno() . ": " . mysql_error()); } } } // end foreach } } // end xReg > 0 } } // end xAthlete > 0 } } // end ATHLETE if ($name == "ANMELDUNG") { $regNr = $attr['ANMELDENR']; $team = $attr['MANNSCHAFT']; $cat = $attr['KATEGORIE']; $license = $attr['LIZENZNR']; $group = $attr['GRUPPENR']; $club = $attr['VEREIN']; $registerNr = $attr['ANMELDENR']; $sql = "SELECT id_athlete FROM base_athlete WHERE license = '" . $license . "';"; $query = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-31-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($query) > 0 || $license == '') { // athlete not in base if (!in_array($cat, $arr_noCat)) { // get the eventnumber of this meeting for generating a team id in the form eventnumber999 (xxxxxx999) $res = mysql_query("SELECT xControl FROM meeting WHERE xMeeting = " . $_COOKIE['meeting_id']); if (mysql_errno() > 0) { AA_printErrorMsg("xml-32-" . mysql_errno() . ": " . mysql_error()); } else { $row = mysql_fetch_array($res); $eventnr = $row[0]; if (empty($eventnr)) { $idcounter = ""; } else { mysql_free_result($res); $arrid = array(); $res = mysql_query("select max(xStaffel) from staffel where xStaffel like '{$eventnr}%'"); $row = mysql_fetch_array($res); $arrid[] = $row[0]; $res = mysql_query("select max(xTeam) from team where xTeam like '{$eventnr}%'"); $row = mysql_fetch_array($res); $arrid[] = $row[0]; $res = mysql_query("select max(id_relay) from base_relay where id_relay like '{$eventnr}%'"); $row = mysql_fetch_array($res); $arrid[] = $row[0]; $res = mysql_query("select max(id_svm) from base_svm where id_svm like '{$eventnr}%'"); $row = mysql_fetch_array($res); $arrid[] = $row[0]; rsort($arrid); $biggestId = $arrid[0]; if ($biggestId == 0 || strlen($biggestId) != 9) { $idcounter = "001"; } else { $idcounter = substr($biggestId, 6, 3); $idcounter++; $idcounter = sprintf("%03d", $idcounter); } $xTeamSQL = ", xTeam = " . $eventnr . $idcounter . ", Athleticagen ='y' "; } } $sql = "SELECT xKategorie FROM kategorie WHERE Kurzname = '" . $cat . "'"; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-33-" . mysql_errno() . ": " . mysql_error()); } else { $row = mysql_fetch_row($res); $catnr = $row[0]; $sql = "SELECT xVerein FROM verein WHERE xCode = '" . $club . "'"; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-34-" . mysql_errno() . ": " . mysql_error()); } else { $row = mysql_fetch_row($res); $clubnr = $row[0]; if ($license > 0) { $sql_a = "SELECT \r\n an.xAnmeldung\r\n FROM\r\n athlet AS a\r\n LEFT JOIN anmeldung AS an ON (a.xAthlet = an.xAthlet)\r\n WHERE\r\n a.Lizenznummer = " . $license . "\r\n AND an.xMeeting = " . $_COOKIE['meeting_id']; } else { $sql_a = "SELECT \r\n an.xAnmeldung\r\n FROM\r\n athlet AS a\r\n LEFT JOIN anmeldung AS an ON (a.xAthlet = an.xAthlet)\r\n WHERE\r\n an.Anmeldenr_ZLV = " . $registerNr . "\r\n AND an.xMeeting = " . $_COOKIE['meeting_id']; } $result = mysql_query($sql_a); if (mysql_errno() > 0) { AA_printErrorMsg("xml-35-" . mysql_errno() . ": " . mysql_error()); } else { if (mysql_num_rows($result) >= 1) { $row_a = mysql_fetch_row($result); $sql = "SELECT xTeam FROM team WHERE Name = '" . $team . "' AND xMeeting=" . $_COOKIE['meeting_id'] . " AND xKategorie = " . $catnr . " AND xVerein=" . $clubnr; $res = mysql_query($sql); if (mysql_num_rows($res) > 0) { $row = mysql_fetch_array($res); $xTeam = $row[0]; } else { if ($clubnr > 0) { // no club exist --> error msg in ATHLETE $sql = "INSERT IGNORE INTO team SET \r\n Name=\"" . $team . "\"\r\n , xMeeting=" . $_COOKIE['meeting_id'] . "\r\n , xKategorie = " . $catnr . "\r\n , xVerein=" . $clubnr . $xTeamSQL; mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-36-" . mysql_errno() . ": " . mysql_error()); } else { $xTeam = mysql_insert_id(); // get new ID } } } $sql = "UPDATE anmeldung SET xTeam = '" . $xTeam . "', Gruppe = '" . $group . "' WHERE xAnmeldung = " . $row_a[0] . " AND xMeeting = " . $_COOKIE['meeting_id']; $res = mysql_query($sql); if (mysql_errno() > 0) { AA_printErrorMsg("xml-37-" . mysql_errno() . ": " . mysql_error()); } } } } } } } } } // end ANMELDUNG }