Пример #1
0
/**
 * export start information on round for timing software
 *
 */
function AA_timing_setStartInfo($round, $silent = false)
{
    $timing = AA_timing_getTiming();
    if ($timing == "omega") {
        $omega = new omega();
        $omega->set_allFiles();
    } elseif ($timing == "alge") {
        $alge = new alge();
        $alge->export_round($round);
    } else {
        if (!$silent) {
            AA_printErrorMsg($GLOBALS['strErrTimingNotConfigured']);
        }
    }
}
Пример #2
0
 function AA_results_getTimingAlge($round, $arg = false, $noerror = false)
 {
     require './lib/results_track.lib.php';
     global $cfgInvalidResult, $strErrTimingWrongRegid, $cfgRoundStatus;
     $count_results = 0;
     $number_results = 0;
     $alge = new alge($noerror);
     if ($alge->is_configured() == false) {
         return;
     }
     $relay = AA_checkRelay(0, $round);
     /*if($arg){
     		$sqladd = "AND r.Status = ".$cfgRoundStatus['heats_done'];
     	}else{
     		$sqladd = "";
     	}*/
     if (!$arg) {
         // COMMENT ROH:
         // existing results should not be updated automatically. Either we require the user to manually
         // delete existing results, or we have to ask for confirmation.
         // for the moment, no results are imported if results exist.
     }
     mysql_query("\r\n\t\tLOCK TABLES \r\n\t\t\tserie as s WRITE\r\n\t\t\t, resultat as res WRITE\r\n\t\t\t, resultat WRITE\r\n            , resultat as re READ\r\n\t\t\t, runde as r WRITE\r\n            , runde as ru WRITE  \r\n            , runde WRITE  \r\n\t\t\t, serienstart as sst READ\r\n            , serienstart as se READ  \r\n            , serienstart as ss READ      \r\n\t\t\t, serie as s READ\r\n            , start as st READ\r\n\t\t\t, anmeldung as a READ\r\n\t\t\t, disziplin_de as d READ\r\n            , disziplin_fr as d READ \r\n            , disziplin_it as d READ \r\n\t\t\t, wettkampf as w READ\r\n\t\t\t, rundentyp_de as rt READ\r\n            , rundentyp_fr as rt READ\r\n            , rundentyp_it as rt READ\r\n\t\t\t, kategorie as k READ\r\n\t\t\t, staffel as sf READ\r\n\t\t\t, disziplin_de READ\r\n            , disziplin_fr READ  \r\n            , disziplin_it READ  \r\n\t\t\t, wettkampf READ");
     /*$res_film = mysql_query("
     		SELECT s.Film, s.xSerie, r.xWettkampf FROM 
     			serie as s
     			LEFT JOIN runde as r USING(xRunde)
     		WHERE s.xRunde = $round
     		$sqladd"
     	);*/
     // Fix during indoor SM: do not load if results exist for a serie
     $res_film = mysql_query("\r\n\t\tSELECT s.Film as film, s.xSerie as heat, r.xWettkampf as event, count(res.Leistung) as numResults FROM \r\n\t\t\trunde as r\r\n\t\t\tLEFT JOIN serie AS s USING ( xRunde )\r\n\t\t\tLEFT JOIN serienstart AS sst USING ( xSerie ) \r\n\t\t\tLEFT JOIN resultat AS res USING ( xserienstart )\r\n\t\tWHERE s.xRunde = {$round}\r\n\t\tGROUP BY sst.xSerie");
     if ($relay) {
         $sql = "SELECT \r\n                        count(*) \r\n                   FROM\r\n                        serie as s\r\n                        LEFT JOIN serienstart as sst USING(xSerie)\r\n                        LEFT JOIN start as st USING(xStart)\r\n                        LEFT JOIN staffel as sf USING(xStaffel)\r\n                        LEFT JOIN resultat as res ON (sst.xSerienstart=res.xSerienstart)\r\n                   WHERE s.xRunde = " . $round;
     } else {
         $sql = "SELECT \r\n                        count(*) \r\n                   FROM\r\n                        serie as s\r\n                        LEFT JOIN serienstart as sst USING(xSerie)\r\n                        LEFT JOIN start as st USING(xStart)                          \r\n                        LEFT JOIN resultat as res ON (sst.xSerienstart=res.xSerienstart)\r\n                   WHERE s.xRunde = " . $round;
     }
     $res = mysql_query($sql);
     $row = mysql_fetch_array($res);
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $number_results = $row[0];
     }
     if (mysql_errno() > 0) {
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         while ($row_film = mysql_fetch_array($res_film)) {
             if ($row_film[3] == 0) {
                 // check if results exist
                 $nr = $row_film[0];
                 $event = $row_film[2];
                 // COMMENT ROH:
                 // commented out the line below because results should only be inported if official
                 // the same line is inserted some lines below after the check
                 // $results = $alge->import_heat_results($row_film[1]);
                 $infos = $alge->import_heat_infos($row_film[1]);
                 if ($infos['Official']) {
                     // COMMENT ROH:
                     // import results only if official
                     $results = $alge->import_heat_results($row_film[1]);
                     $wind = $infos['RaceInfo']['Wind'];
                     if (empty($wind)) {
                         $wind = "";
                     } elseif (substr($wind, 0, 1) == "+") {
                         $wind = substr($wind, 1, 3);
                     } elseif (substr($wind, 0, 1) == "-") {
                         $wind = substr($wind, 0, 4);
                     }
                     mysql_query("UPDATE serie as s SET Wind = '" . $wind . "'\r\n\t\t\t\t\t\t\tWHERE xRunde = {$round} AND Film = {$nr}");
                     foreach ($results as $val) {
                         switch ($val[11]) {
                             case 0:
                                 $perf = $cfgInvalidResult['DNS']['code'];
                                 $points = 0;
                                 break;
                             case 1:
                                 $perf = $cfgInvalidResult['DNF']['code'];
                                 $points = 0;
                                 break;
                             case 2:
                                 $perf = $cfgInvalidResult['DSQ']['code'];
                                 $points = 0;
                                 break;
                             default:
                                 $perf = 0;
                                 if ($alge->typ == 'OPTIc2') {
                                     $perf = substr($val[9], 0, strlen($val[9]) - 1);
                                     // COMMENT ROH:
                                     // cutting digits is not according to competition rules
                                     // $perf = substr($val[9], 0, (strlen($val[9])-1));
                                     // alternative: round correctly
                                     // (ceil was not consistent with the official results when the 1/1000sec was xx0)
                                     $perf = floor($val[9] / 10) + 1;
                                 } else {
                                     $perf = $val[9];
                                 }
                                 $sex = 'M';
                                 if (!$relay) {
                                     /*$sql = "SELECT Geschlecht
                                     		  FROM serienstart AS sst
                                     	 LEFT JOIN serie AS s USING ( xSerie )
                                     	 LEFT JOIN start AS st ON sst.xStart = st.xStart
                                     	 LEFT JOIN anmeldung AS a ON st.xAnmeldung = a.xAnmeldung
                                     	 LEFT JOIN athlet USING ( xAthlet )
                                     		 WHERE s.xRunde = ".$round."
                                     		   AND s.Film = ".$nr."
                                     		   AND a.Startnummer = ".$val[1].";";*/
                                     $sql_sex = "SELECT DISTINCT(k.Geschlecht) AS Geschlecht\r\n\t\t\t\t\t\t\t\t\t\t\t  FROM kategorie as k\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN wettkampf USING(xKategorie) \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN start AS st USING(xWettkampf)\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN serienstart AS sst  USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN serie AS s USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\t\t WHERE s.XRunde = " . $round . " \r\n\t\t\t\t\t\t\t\t\t\t\t   AND s.Film = " . $nr . ";";
                                     $query = mysql_query($sql_sex);
                                     if (mysql_errno() > 0) {
                                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                     }
                                     if ($query && mysql_num_rows($query) == 1) {
                                         $sex = mysql_result($query, 0, 'Geschlecht');
                                     }
                                 }
                         }
                         if ($relay == false) {
                             // no relay event
                             /*	
                             							$res = mysql_query("
                             								SELECT xResultat 
                             									   , Geschlecht, sst.xSerienstart
                             								  FROM resultat as res
                             							 LEFT JOIN serienstart as sst USING(xSerienstart)
                             							 LEFT JOIN serie as s USING (xSerie)
                             							 LEFT JOIN start as st ON sst.xStart = st.xStart
                             							 LEFT JOIN anmeldung as a ON st.xAnmeldung = a.xAnmeldung
                             							 LEFT JOIN athlet USING(xAthlet)
                             								 WHERE s.xRunde = $round
                             								   AND s.Film = $nr
                             								   AND a.Startnummer = ".$val[1]
                             							);    
                             							
                             							// COMMENT ROH:
                             							// ok, here is the test to check if results already exist
                             							// however, something with this test did not work and results got imported multiple times
                             							// please verify!!! 
                             							// note: we check now before importing so that we never should get here if results already exist. 
                             							
                             							if(mysql_num_rows($res) == 0){   */
                             // insert result
                             $res = mysql_query("\r\n\t\t\t\t\t\t\t\t\tSELECT sst.xSerienstart FROM\r\n\t\t\t\t\t\t\t\t\t\tserie as s\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN serienstart as sst USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN start as st USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\t\tWHERE\ta.Startnummer = " . $val[1] . "\r\n\t\t\t\t\t\t\t\t\tAND\ts.Film = {$nr}\r\n\t\t\t\t\t\t\t\t\tAND\ts.xRunde = {$round}");
                             if (mysql_num_rows($res) == 0) {
                                 // no athlete with this registration id is started
                                 // if($noerror==false){ AA_printErrorMsg($strErrTimingWrongRegid); }
                             } else {
                                 $count_results++;
                                 $row = mysql_fetch_array($res);
                                 $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[0]);
                                 mysql_query("\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO resultat\r\n\t\t\t\t\t\t\t\t\t\tSET \tLeistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\t, xSerienstart = " . $row[0]);
                                 AA_StatusChanged(mysql_insert_id());
                             }
                             /*	}else{
                             				// update                                 
                                                         $count_results++; 
                                                         $row = mysql_fetch_array($res); 
                                                         $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[2]);  
                             				mysql_query("UPDATE resultat as res SET Leistung = '$perf'
                             						, Punkte = '$points'
                             					WHERE xResultat = ".$row[0]);
                             				
                             			}  */
                             //
                         } else {
                             // relay event
                             //
                             /*$res = mysql_query("
                             			SELECT xResultat FROM
                             				resultat as res
                             				LEFT JOIN serienstart as sst USING(xSerienstart)
                             				LEFT JOIN serie as s USING (xSerie)
                             				LEFT JOIN start as st ON sst.xStart = st.xStart
                             				LEFT JOIN staffel as sf ON st.xStaffel = sf.xStaffel
                             			WHERE s.xRunde = $round
                             			AND s.Film = $nr
                             			AND sf.Startnummer = ".$val[1]
                             		);
                             		
                             		if(mysql_num_rows($res) == 0){  */
                             // insert result
                             $res = mysql_query("\r\n\t\t\t\t\t\t\t\t\tSELECT sst.xSerienstart, k.Geschlecht FROM\r\n\t\t\t\t\t\t\t\t\t\tserie as s\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN serienstart as sst USING(xSerie)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN start as st USING(xStart)\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN staffel as sf USING(xStaffel)\r\n                                        LEFT JOIN kategorie AS k ON ( k.xKategorie = sf.xKategorie ) \r\n\t\t\t\t\t\t\t\t\tWHERE\tsf.Startnummer = " . $val[1] . "\r\n\t\t\t\t\t\t\t\t\tAND\ts.Film = {$nr}\r\n\t\t\t\t\t\t\t\t\tAND\ts.xRunde = {$round}");
                             if (mysql_num_rows($res) == 0) {
                                 // no athlete with this registration id is started
                                 //if($noerror==false){ AA_printErrorMsg($strErrTimingWrongRegid); }
                             } else {
                                 $count_results++;
                                 $row = mysql_fetch_array($res);
                                 $sex = $row[1];
                                 $points = AA_utils_calcPoints($event, $perf, 0, $sex, $row[0]);
                                 mysql_query("\r\n\t\t\t\t\t\t\t\t\t\tINSERT INTO resultat\r\n\t\t\t\t\t\t\t\t\t\tSET \tLeistung = '{$perf}'\r\n\t\t\t\t\t\t\t\t\t\t\t, Punkte = '{$points}'\r\n\t\t\t\t\t\t\t\t\t\t\t, xSerienstart = " . $row[0]);
                                 AA_StatusChanged(mysql_insert_id());
                             }
                             /*	}else{
                             				// update
                                                         $count_results++; 
                             				$row = mysql_fetch_array($res);
                             				mysql_query("UPDATE resultat as res SET Leistung = '$perf'
                             						, Punkte = '$points'
                             					WHERE xResultat = ".$row[0]);
                             				
                             			} */
                         }
                     }
                     // results updated, now set status for event time table
                     mysql_query("UPDATE runde as r SET StatusZeitmessung = 1 WHERE xRunde = {$round}");
                     if (mysql_errno() > 0) {
                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                     }
                 }
             }
             // check if results exist
         }
     }
     mysql_query("UNLOCK TABLES");
     // all results from omega for this round and automatic ranking is 'y'
     if ($count_results == $number_results && $_SESSION['meeting_infos']['AutoRangieren'] == 'y') {
         $layout = AA_getDisciplineType($round);
         // type determines layout
         $_GET['arg'] = 'results_done';
         $autoRank = true;
         AA_results_Track($round, $layout, $autoRank);
         // ranking
     }
 }