Пример #1
2
function move2NextPhaseTeam($Phase = NULL, $Event = NULL, $MatchNo = NULL)
{
    //verifico i parametri
    if (is_null($Phase) && is_null($MatchNo)) {
        //Devono esistere o la fase o il MatchNo
        return;
    }
    if (is_null($Phase) && is_null($Event)) {
        //Se non ho la Fase (e quindi ho il MatchNo) deve esistere l'evento
        return;
    }
    //Verifico la situazione tiebreak
    $Select = "SELECT " . "tf.TfEvent, EvMatchMode as MatchMode, tf.TfMatchNo as MatchNo, tf2.TfMatchNo as OppMatchNo,  " . "tf.TfTeam AS Team, tf.TfSubteam AS SubTeam, tf2.TfTeam AS OppTeam, tf2.TfSubTeam AS OppSubTeam," . "if(tf.TfMatchNo>15, EvElimEnds, EvFinEnds) FinEnds, if(tf.TfMatchNo>15, EvElimArrows, EvFinArrows) FinArrows, if(tf.TfMatchNo>15, EvElimSO, EvFinSO) FinSO, " . "IF(tf.TfDateTime>=tf2.TfDateTime, tf.TfDateTime, tf2.TfDateTime) AS DateTime," . "IF(EvMatchMode=0,tf.TfScore,tf.TfSetScore) AS Score, tf.TfTie as Tie, tf.TfTieBreak as TbString, IF(EvMatchMode=0,tf2.TfScore,tf2.TfSetScore) as OppScore, tf2.TfTie as OppTie, tf2.TfTieBreak as OppTbString, " . "tf.TfArrowString as ArrString, tf2.TfArrowString as OppArrString,  tf.TfSetPoints as SetPoint, tf2.TfSetPoints as OppSetPoint " . "FROM TeamFinals AS tf " . "INNER JOIN TeamFinals AS tf2 ON tf.TfEvent=tf2.TfEvent AND tf.TfMatchNo=IF((tf.TfMatchNo % 2)=0,tf2.TfMatchNo-1,tf2.TfMatchNo+1) AND tf.TfTournament=tf2.TfTournament " . "INNER JOIN Events ON tf.TfEvent=EvCode AND tf.TfTournament=EvTournament AND EvTeamEvent=1 ";
    if (!is_null($Phase)) {
        $Select .= "INNER JOIN Grids ON tf.TfMatchNo=GrMatchNo AND GrPhase=" . StrSafe_DB($Phase) . " ";
    } else {
        $Select .= "INNER JOIN Grids ON tf.TfMatchNo=GrMatchNo AND GrMatchNo=" . StrSafe_DB($MatchNo % 2 == 0 ? $MatchNo : $MatchNo - 1) . " ";
    }
    $Select .= "WHERE tf.TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND (tf.TfMatchNo % 2)=0 ";
    if (!is_null($Event) && $Event != '') {
        $Select .= "AND tf.TfEvent=" . StrSafe_DB($Event) . " ";
    }
    $Select .= "ORDER BY tf.TfEvent, tf.TfMatchNo ";
    $Rs = safe_r_sql($Select);
    if (safe_num_rows($Rs) > 0) {
        while ($MyRow = safe_fetch($Rs)) {
            //Se uno dei due ATLETI è ZERO ed ENTRAMBI GLI SCORES sono a ZERO imposto il Bye
            if ($MyRow->Team != 0 && $MyRow->OppTeam == 0 && $MyRow->Score == 0 && $MyRow->OppScore == 0) {
                $SqlUpdate = "UPDATE TeamFinals SET TfTie=0, TfWinLose=0, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($MyRow->OppMatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                safe_w_sql($SqlUpdate);
                $SqlUpdate = "UPDATE TeamFinals SET TfTie=2, TfWinLose=1, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($MyRow->MatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                safe_w_sql($SqlUpdate);
            } elseif ($MyRow->Team == 0 && $MyRow->OppTeam != 0 && $MyRow->Score == 0 && $MyRow->OppScore == 0) {
                $SqlUpdate = "UPDATE TeamFinals SET TfTie=0, TfWinLose=0, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($MyRow->MatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                safe_w_sql($SqlUpdate);
                $SqlUpdate = "UPDATE TeamFinals SET TfTie=2, TfWinLose=1, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($MyRow->OppMatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                safe_w_sql($SqlUpdate);
            } elseif ($MyRow->MatchMode != 0) {
                //Se non ho il BYE, rigestisco il numero di set vinti e aggiorno il conteggio del totale (se i punti set sono valorizzati & le arrowstring sono vuote)
                if (strlen(trim(str_replace("|", "", $MyRow->SetPoint))) && strlen(trim(str_replace("|", "", $MyRow->OppSetPoint))) && strlen(trim($MyRow->ArrString)) == 0 && strlen(trim($MyRow->OppArrString)) == 0) {
                    $AthSets = explode("|", $MyRow->SetPoint);
                    $OppSets = explode("|", $MyRow->OppSetPoint);
                    $AthScore = 0;
                    $OppScore = 0;
                    $AthWin = 0;
                    $OppWin = 0;
                    if (count($AthSets) == count($OppSets)) {
                        for ($i = 0; $i < count($AthSets); $i++) {
                            if (intval($AthSets[$i]) > intval($OppSets[$i])) {
                                $AthScore += 2;
                                $AthWin++;
                            } elseif (intval($AthSets[$i]) < intval($OppSets[$i])) {
                                $OppScore += 2;
                                $OppWin++;
                            } elseif (intval($AthSets[$i]) != 0 && intval($OppSets[$i]) != 0) {
                                $AthScore += 1;
                                $OppScore += 1;
                            }
                        }
                        $SqlUpdate = "UPDATE TeamFinals SET TfWinLose=" . ($AthScore > $MyRow->FinEnds ? 1 : 0) . ", TfSetScore=" . StrSafe_DB($AthScore) . ", TfWinnerSet=" . StrSafe_DB($AthWin) . ", TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($MyRow->MatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                        safe_w_sql($SqlUpdate);
                        $MyRow->Score = $AthScore;
                        $SqlUpdate = "UPDATE TeamFinals SET TfWinLose=" . ($OppScore > $MyRow->FinEnds ? 1 : 0) . ", TfSetScore=" . StrSafe_DB($OppScore) . ", TfWinnerSet=" . StrSafe_DB($OppWin) . ", TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($MyRow->OppMatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                        safe_w_sql($SqlUpdate);
                        $MyRow->OppScore = $OppScore;
                    }
                }
            }
            // Se uno dei due è diverso da ZERO e non sono uguali oppure se è a set e differiscono di più di un punto
            if (($MyRow->Score != 0 || $MyRow->OppScore != 0) && $MyRow->Score != $MyRow->OppScore && ($MyRow->MatchMode != 0 && abs($MyRow->Score - $MyRow->OppScore) > 1)) {
                //Azzero entrambi i flag di shootoff
                $SqlUpdate = "UPDATE TeamFinals SET TfTie=0, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo IN (" . StrSafe_DB($MyRow->MatchNo) . "," . StrSafe_DB($MyRow->OppMatchNo) . ") AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                safe_w_sql($SqlUpdate);
            }
            // Se i punteggi sono uguali e diversi da ZERO entro nel dettaglio E le stringhe di frecce sono lunghe uguali e non vuote
            if ($MyRow->Score != 0 and $MyRow->Score == $MyRow->OppScore and strlen(trim($MyRow->TbString)) > 0 and strlen(trim($MyRow->TbString)) == strlen(trim($MyRow->OppTbString))) {
                $WinnerId = -1;
                //Verifico le stringhe CASE INSENSITIVE - in questo momento me ne frego degli "*"
                if (ValutaArrowString($MyRow->TbString) < ValutaArrowString($MyRow->OppTbString)) {
                    $WinnerId = $MyRow->OppMatchNo;
                    //OppTbString è maggiore di TbString --> il secondo vince
                } elseif (ValutaArrowString($MyRow->TbString) > ValutaArrowString($MyRow->OppTbString)) {
                    $WinnerId = $MyRow->MatchNo;
                    //TbString è maggiore di OppTbString --> il primo vince
                } elseif (!ctype_upper(trim($MyRow->OppTbString)) and ctype_upper(trim($MyRow->TbString))) {
                    // Verifico gli "*" e lo star è nella stringa del secondo (è maggiore)
                    $WinnerId = $MyRow->OppMatchNo;
                } elseif (ctype_upper(trim($MyRow->OppTbString)) and !ctype_upper(trim($MyRow->TbString))) {
                    // Verifico gli "*" e lo star è nella stringa del primo (è maggiore)
                    $WinnerId = $MyRow->MatchNo;
                }
                //Azzero entrambi i flag di shootoff
                $SqlUpdate = "UPDATE TeamFinals SET TfTie=0, TfWinLose=0, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo IN (" . StrSafe_DB($MyRow->MatchNo) . "," . StrSafe_DB($MyRow->OppMatchNo) . ") AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                safe_w_sql($SqlUpdate);
                if ($WinnerId > -1) {
                    $SqlUpdate = "UPDATE TeamFinals SET TfTie=1, TfWinLose=1, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($WinnerId) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                    safe_w_sql($SqlUpdate);
                    if ($MyRow->MatchMode != 0 && $MyRow->Score == $MyRow->OppScore) {
                        $SqlUpdate = "UPDATE TeamFinals SET TfSetScore=TfSetScore+1, TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " WHERE TfEvent=" . StrSafe_DB($MyRow->TfEvent) . " AND TfMatchNo=" . StrSafe_DB($WinnerId) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']);
                        safe_w_sql($SqlUpdate);
                    }
                }
            }
        }
    }
    // Faccio i passaggi di fase
    $MyNextMatchNo = 'xx';
    $QueryFilter = '';
    $Select = "SELECT " . "tf.TfEvent AS Event, tf.TfMatchNo, tf2.TfMatchNo OppMatchNo, " . "GrPhase, tf.TfTeam AS Team,tf.TfSubTeam AS SubTeam, tf2.TfTeam AS OppTeam,tf2.TfSubTeam AS OppSubTeam, " . "IF(EvMatchMode=0,tf.TfScore,tf.TfSetScore) AS Score, tf.TfTie as Tie, IF(EvMatchMode=0,tf2.TfScore,tf2.TfSetScore) as OppScore, tf2.TfTie as OppTie, " . "IF(GrPhase>2, FLOOR(tf.TfMatchNo/2),FLOOR(tf.TfMatchNo/2)-2) AS NextMatchNo " . "FROM TeamFinals AS tf " . "INNER JOIN TeamFinals AS tf2 ON tf.TfEvent=tf2.TfEvent AND tf.TfMatchNo=IF((tf.TfMatchNo % 2)=0,tf2.TfMatchNo-1,tf2.TfMatchNo+1) AND tf.TfTournament=tf2.TfTournament " . "INNER JOIN Events ON tf.TfEvent=EvCode AND tf.TfTournament=EvTournament AND EvTeamEvent=1 ";
    if (!is_null($Phase)) {
        $Select .= "INNER JOIN Grids ON tf.TfMatchNo=GrMatchNo AND GrPhase=" . StrSafe_DB($Phase) . " ";
    } else {
        $Select .= "INNER JOIN Grids ON tf.TfMatchNo=GrMatchNo AND GrMatchNo=" . StrSafe_DB($MatchNo % 2 == 0 ? $MatchNo : $MatchNo - 1) . " ";
    }
    $Select .= "LEFT JOIN Countries ON tf.TfTeam=CoId AND tf.TfTournament=CoTournament " . "WHERE tf.TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND (tf.TfMatchNo % 2)=0 ";
    if (!is_null($Event) && $Event != '') {
        $Select .= "AND tf.TfEvent=" . StrSafe_DB($Event) . " ";
    }
    $Select .= "ORDER BY tf.TfEvent, NextMatchNo ASC, Score DESC, Tie DESC ";
    $Rs = safe_r_sql($Select);
    //print $Select . '<br>';exit;
    // conterrà i parametri per il calcolo delle RankFinal
    $coppie = array();
    $AthPropTs = NULL;
    if (safe_num_rows($Rs) > 0) {
        $AthPropTs = date('Y-m-d H:i:s');
        while ($MyRow = safe_fetch($Rs)) {
            /*
             * Dato che potrei avere più fasi gestite da questa funzione, io ricavo le coppie
             * per la RankFinal dalle righe del recordset.
             * Visto che mi imbatterò più volte nella stessa coppia evento/fase, solo se la coppia
             * non l'ho già contata la aggiungo nel vettore.
             */
            if (!in_array($MyRow->Event . '@' . $MyRow->GrPhase, $coppie)) {
                $coppie[] = $MyRow->Event . '@' . $MyRow->GrPhase;
            }
            $AthProp = '0';
            $AthSubProp = '0';
            $WhereProp = '0';
            $WhereSubProp = '0';
            // Flag for winlose
            $WinLose = -1;
            if (intval($MyRow->Score) > intval($MyRow->OppScore) || intval($MyRow->Score) == intval($MyRow->OppScore) && intval($MyRow->Tie) > intval($MyRow->OppTie)) {
                $WinLose = $MyRow->TfMatchNo;
                if ($MyRow->GrPhase >= 2) {
                    $MyUpQuery = "UPDATE TeamFinals SET ";
                    $MyUpQuery .= "TfTeam =" . StrSafe_DB($MyRow->Team) . ", ";
                    $MyUpQuery .= "TfSubTeam =" . StrSafe_DB($MyRow->SubTeam) . ", ";
                    $MyUpQuery .= "TfDateTime=" . StrSafe_DB($AthPropTs) . " ";
                    $MyUpQuery .= "WHERE TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfMatchNo=" . StrSafe_DB($MyRow->NextMatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                    $RsUp = safe_w_sql($MyUpQuery);
                    $AthProp = $MyRow->Team;
                    $AthSubProp = $MyRow->SubTeam;
                    $WhereProp = $MyRow->OppTeam;
                    $WhereSubProp = $MyRow->OppSubTeam;
                    if ($MyRow->GrPhase == 2) {
                        $MyUpQuery = "UPDATE TeamFinals SET ";
                        $MyUpQuery .= "TfTeam =" . StrSafe_DB($MyRow->OppTeam) . ", ";
                        $MyUpQuery .= "TfSubTeam =" . StrSafe_DB($MyRow->OppSubTeam) . ", ";
                        $MyUpQuery .= "TfDateTime=" . StrSafe_DB($AthPropTs) . " ";
                        $MyUpQuery .= "WHERE TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfMatchNo=" . StrSafe_DB($MyRow->NextMatchNo + 2) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                        $RsUp = safe_w_sql($MyUpQuery);
                    }
                }
            } elseif (intval($MyRow->Score) < intval($MyRow->OppScore) || intval($MyRow->Score) == intval($MyRow->OppScore) && intval($MyRow->Tie) < intval($MyRow->OppTie)) {
                $WinLose = $MyRow->OppMatchNo;
                if ($MyRow->GrPhase >= 2) {
                    $MyUpQuery = "UPDATE TeamFinals SET ";
                    $MyUpQuery .= "TfTeam =" . StrSafe_DB($MyRow->OppTeam) . ", ";
                    $MyUpQuery .= "TfSubTeam =" . StrSafe_DB($MyRow->OppSubTeam) . ", ";
                    $MyUpQuery .= "TfDateTime=" . StrSafe_DB($AthPropTs) . " ";
                    $MyUpQuery .= "WHERE TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfMatchNo=" . StrSafe_DB($MyRow->NextMatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                    $RsUp = safe_w_sql($MyUpQuery);
                    $AthProp = $MyRow->OppTeam;
                    $AthSubProp = $MyRow->OppSubTeam;
                    $WhereProp = $MyRow->Team;
                    $WhereSubProp = $MyRow->SubTeam;
                    if ($MyRow->GrPhase == 2) {
                        $MyUpQuery = "UPDATE TeamFinals SET ";
                        $MyUpQuery .= "TfTeam =" . StrSafe_DB($MyRow->Team) . ", ";
                        $MyUpQuery .= "TfSubTeam =" . StrSafe_DB($MyRow->SubTeam) . ", ";
                        $MyUpQuery .= "TfDateTime=" . StrSafe_DB($AthPropTs) . " ";
                        $MyUpQuery .= "WHERE TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfMatchNo=" . StrSafe_DB($MyRow->NextMatchNo + 2) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                        $RsUp = safe_w_sql($MyUpQuery);
                    }
                }
            } else {
                if ($MyRow->GrPhase >= 2) {
                    $MyUpQuery = "UPDATE TeamFinals SET ";
                    $MyUpQuery .= "TfTeam ='0', ";
                    $MyUpQuery .= "TfSubTeam ='0', ";
                    $MyUpQuery .= "TfDateTime=" . StrSafe_DB($AthPropTs) . " ";
                    $MyUpQuery .= "WHERE TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfMatchNo=" . StrSafe_DB($MyRow->NextMatchNo) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                    $RsUp = safe_w_sql($MyUpQuery);
                    if ($MyRow->GrPhase == 2) {
                        $MyUpQuery = "UPDATE TeamFinals SET ";
                        $MyUpQuery .= "TfWinLose ='0', ";
                        $MyUpQuery .= "TfTeam ='0', ";
                        $MyUpQuery .= "TfSubTeam ='0', ";
                        $MyUpQuery .= "TfDateTime=" . StrSafe_DB($AthPropTs) . " ";
                        $MyUpQuery .= "WHERE TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfMatchNo=" . StrSafe_DB($MyRow->NextMatchNo + 2) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                        $RsUp = safe_w_sql($MyUpQuery);
                    }
                }
            }
            // reset winners of previous matches
            safe_w_sql("update TeamFinals set TfWinLose=if(TfMatchNo={$WinLose}, 1, 0) WHERE TfMatchNo in (" . StrSafe_DB($MyRow->TfMatchNo) . "," . StrSafe_DB($MyRow->OppMatchNo) . ") AND TfEvent=" . StrSafe_DB($MyRow->Event) . " AND TfTournament=" . StrSafe_DB($_SESSION['TourId']));
            $OldId = $AthProp != 0 ? StrSafe_DB($WhereProp) : StrSafe_DB($MyRow->Team) . ',' . StrSafe_DB($MyRow->OppTeam);
            $OldSubId = $AthSubProp != 0 ? StrSafe_DB($WhereSubProp) : StrSafe_DB($MyRow->SubTeam) . ',' . StrSafe_DB($MyRow->OppSubTeam);
            $Update = "UPDATE TeamFinals SET " . "TfTeam=" . StrSafe_DB($AthProp) . ", " . "TfSubTeam=" . StrSafe_DB($AthSubProp) . ", " . "TfDateTime=" . StrSafe_DB($AthPropTs) . " " . ($AthProp == 0 ? ', TfWinLose=0 ' : '') . "WHERE TfTeam IN (" . $OldId . ") " . "AND TfSubTeam IN (" . $OldSubId . ") " . "AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "AND TfEvent=" . StrSafe_DB($MyRow->Event) . " " . "AND tfMatchNo<" . StrSafe_DB($MyRow->NextMatchNo) . " ";
            if ($OldId != "'0'") {
                $RsProp = safe_w_sql($Update);
            }
        }
    }
    // se ho delle coppie calcolo per queste la RankFinal
    if (count($coppie) > 0) {
        Obj_RankFactory::create('FinalTeam', array('eventsC' => $coppie))->calculate();
    }
    return $AthPropTs;
}
function SetElimArrowValue($Phase, $Event, $Target, $ArIndex, $ArSymbol, $Output = 'XML', $CompId = '')
{
    require_once 'Common/Lib/Obj_RankFactory.php';
    $JsonResult = array();
    $JsonResult['error'] = 1;
    $JsonResult['qutarget'] = $_REQUEST['qutarget'];
    $JsonResult['distnum'] = $_REQUEST['distnum'];
    $JsonResult['arrowindex'] = $_REQUEST['arrowindex'];
    $JsonResult['arrowsymbol'] = '';
    $JsonResult['curscore'] = '';
    $JsonResult['curgold'] = '';
    $JsonResult['curxnine'] = '';
    $JsonResult['score'] = '';
    $JsonResult['gold'] = '';
    $JsonResult['xnine'] = '';
    if (empty($CompId)) {
        $CompId = $_SESSION['TourId'];
    }
    $q = safe_r_sql("select * from Eliminations\r\n\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\tand ElEventCode='{$Event}'\r\n\t\tand ElTargetNo='{$Target}'\r\n\t\tand ElTournament={$CompId}\r\n\t\t");
    if ($r = safe_fetch($q)) {
        $Arrowstring = str_pad($r->ElArrowString, $ArIndex + 1, ' ', STR_PAD_RIGHT);
        $xx = GetLetterFromPrint($ArSymbol);
        $Arrowstring[$ArIndex] = str_pad($xx, 1, ' ', STR_PAD_RIGHT);
        list($CurScore, $CurGold, $CurXNine) = ValutaArrowStringGX($Arrowstring);
        safe_w_sql("update Eliminations\r\n\t\t\tset ElArrowString='{$Arrowstring}',\r\n\t\t\tElScore={$CurScore},\r\n\t\t\tElGold={$CurGold},\r\n\t\t\tElXnine={$CurXNine}\r\n\t\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\t\tand ElEventCode='{$Event}'\r\n\t\t\tand ElTargetNo='{$Target}'\r\n\t\t\tand ElTournament={$CompId}");
        if (safe_w_affected_rows()) {
            if ($Phase[1] == 1) {
                require_once 'Common/Fun_Sessions.inc.php';
                ResetElimRows($Event, 2);
            }
            Obj_RankFactory::create('ElimInd', array('tournament' => $CompId, 'eventsC' => array($Event . '@' . $Phase[1])))->calculate();
        }
        $JsonResult['error'] = 0;
        $JsonResult['arrowsymbol'] = $xx ? strtoupper($ArSymbol) : '';
        $JsonResult['curscore'] = $CurScore;
        $JsonResult['curgold'] = $CurGold;
        $JsonResult['curxnine'] = $CurXNine;
        $JsonResult['score'] = $CurScore;
        $JsonResult['gold'] = $CurGold;
        $JsonResult['xnine'] = $CurXNine;
    }
    return $JsonResult;
}
Пример #3
0
         print 'Faccio la rank abs di distanza<br>';
     }
     if (count($events4abs) > 0) {
         if (!Obj_RankFactory::create('Abs', array('events' => $events4abs, 'dist' => $_REQUEST['Dist']))->calculate()) {
             $Errore = 1;
         }
     }
 }
 // nuovo by simo
 // rank abs totale
 if ($Errore == 0) {
     if (debug) {
         print 'Faccio la rank abs totale<br>';
     }
     if (count($events4abs) > 0) {
         if (!Obj_RankFactory::create('Abs', array('events' => $events4abs, 'dist' => 0))->calculate()) {
             $Errore = 1;
         }
     }
 }
 if ($Errore == 0) {
     // se non ho errori calcolo le squadre
     if (MakeTeams($Societa, $Category)) {
         $Errore = 1;
     }
 }
 if ($Errore == 0) {
     // se non ho errori calcolo le squadre assolute
     if (MakeTeamsAbs($Societa, $Div, $Cl)) {
         $Errore = 1;
     }
Пример #4
0
function ExportLSTFinTeam($Event = null)
{
    $rank = Obj_RankFactory::create('FinalTeam', array());
    $rank->read();
    $rankData = $rank->getData();
    /*echo "<pre>";
    		print_r($rankData);
    		echo "</pre>";exit;*/
    $StrData = "";
    if (count($rankData['sections'])) {
        foreach ($rankData['sections'] as $section) {
            $NumPhases = numPhases($section['meta']['firstPhase']);
            $NumComponenti = $section['meta']['maxTeamPerson'] ? $section['meta']['maxTeamPerson'] : 3;
            if (count($section['items'])) {
                $StrData .= "\n" . get_text($section['meta']['descr'], '', '', true) . "\n";
                // Header vero e proprio
                $StrData .= str_pad(substr($section['meta']['fields']['rank'], 0, 5), 5, ' ', STR_PAD_RIGHT) . " ";
                $StrData .= str_pad(substr($section['meta']['fields']['countryName'], 0, 40), 40, ' ', STR_PAD_RIGHT) . "  ";
                $StrData .= str_pad(substr($section['meta']['fields']['qualRank'], 0, 10), 10, ' ', STR_PAD_LEFT) . " ";
                foreach ($section['meta']['fields']['finals'] as $k => $v) {
                    if (is_numeric($k) && $k != 1) {
                        $StrData .= str_pad(substr($v, 0, 8), 8, ' ', STR_PAD_LEFT) . " ";
                    }
                }
                $StrData .= "\n";
                foreach ($section['items'] as $item) {
                    $StrData .= str_pad($item['rank'] ? $item['rank'] : ' ', 5, ' ', STR_PAD_RIGHT) . " ";
                    $StrData .= str_pad(substr($item['countryCode'], 0, 10), 10, ' ', STR_PAD_RIGHT) . " ";
                    $StrData .= str_pad(substr($item['countryName'] . ($item['subteam'] <= 1 ? '' : ' (' . $item['subteam'] . ')'), 0, 30), 30, ' ', STR_PAD_RIGHT) . " ";
                    $StrData .= str_pad(substr(number_format($item['qualScore'], 0, get_text('NumberDecimalSeparator'), get_text('NumberThousandsSeparator')) . '-' . substr('00' . $item['qualRank'], -2, 2), 0, 10), 10, ' ', STR_PAD_LEFT) . " ";
                    //Risultati  delle varie fasi
                    foreach ($item['finals'] as $k => $v) {
                        $tmp = '';
                        if ($v['tie'] == 2) {
                            $tmp = get_text('Bye');
                        } else {
                            if ($k == 4 && $section['meta']['matchMode'] != 0 && $item['rank'] >= 5) {
                                $tmp = $v['setScore'] . " (" . $v['score'] . ")";
                            } else {
                                $tmp = $section['meta']['matchMode'] == 0 ? $v['score'] : $v['setScore'];
                                if (strlen($v['tiebreak']) > 0 && $k <= 1) {
                                    $tmpTxt = "";
                                    $tmpArr = explode("|", $v['tiebreak']);
                                    for ($countArr = 0; $countArr < count($tmpArr); $countArr += $NumComponenti) {
                                        $tmpTxt .= array_sum(array_slice($tmpArr, $countArr, $NumComponenti)) . ",";
                                    }
                                    $tmp .= " T." . substr($tmpTxt, 0, -1);
                                } elseif ($k <= 1 && $v['tie'] == 1) {
                                    $tmp .= "*";
                                }
                            }
                        }
                        $StrData .= str_pad(substr($tmp, 0, 8), 8, ' ', STR_PAD_LEFT) . " ";
                    }
                    $StrData .= "\n";
                }
            }
        }
    }
    return $StrData;
}
Пример #5
0
            $Update = "UPDATE Events SET " . "EvShootOff='1' " . "WHERE EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EvTeamEvent='0' " . (count($Events) > 0 ? " AND EvCode IN('" . implode("','", $Events) . "')" : "") . " " . ($VetoEvents ? " AND EvCode not in ('" . implode("','", $VetoEvents) . "')" : '');
            $RsUp = safe_w_sql($Update);
            set_qual_session_flags();
            // calcolo la finalrank di quelli che si son fermati alle quelifiche
            $coppie = array();
            $q = "SELECT EvCode FROM Events WHERE EvTournament={$_SESSION['TourId']} AND EvTeamEvent=0 AND EvCode NOT IN ('" . implode(',', $VetoEvents) . "')" . (count($Events) > 0 ? " AND EvCode IN('" . implode("','", $Events) . "') " : '');
            $r = safe_r_sql($q);
            while ($rr = safe_fetch($r)) {
                $coppie[$rr->EvCode] = $rr->EvCode . "@-3";
            }
            /*foreach ($Events as $e)
            		{
            			$coppie[$e]= $e . "@-3";
            		}*/
            //print_r($coppie);exit;
            Obj_RankFactory::create('FinalInd', array('eventsC' => $coppie))->calculate();
            foreach ($EventList as $key => $value) {
                move2NextPhase($value, $key, null);
            }
        }
    }
    //exit;
}
include 'Common/Templates/head.php';
?>
<table class="Tabella">
<TR><TH class="Title"><?php 
print get_text('ShootOff4Final') . ' - ' . get_text('Individual');
?>
</TH></TR>
<?php 
Пример #6
0
function getRankResult($type, $Event = '')
{
    $options = array('dist' => 0);
    if ($Event) {
        $options['events'] = $Event;
    }
    if ($type == 'IC') {
        $rank = Obj_RankFactory::create('DivClass', $options);
        $rank->read();
        $rankData = $rank->getData();
    } elseif ($type == 'TC') {
        $rank = Obj_RankFactory::create('DivClassTeam', $options);
        $rank->read();
        $rankData = $rank->getData();
    } elseif ($type == 'IQ') {
        $rank = Obj_RankFactory::create('Abs', $options);
        $rank->read();
        $rankData = $rank->getData();
    } elseif ($type == 'TQ') {
        $rank = Obj_RankFactory::create('AbsTeam', $options);
        $rank->read();
        $rankData = $rank->getData();
    } elseif ($type == 'IF') {
        if ($Event) {
            $options['eventsR'] = $Event;
        }
        $rank = Obj_RankFactory::create('FinalInd', $options);
        $rank->read();
        $rankData = $rank->getData();
    } elseif ($type == 'TF') {
        if ($Event) {
            $options['eventsR'] = $Event;
        }
        $rank = Obj_RankFactory::create('FinalTeam', $options);
        $rank->read();
        $rankData = $rank->getData();
    }
    return $rankData;
}
$row = safe_fetch($rs);
$xml = '<serverDate>' . $row->serverDate . '</serverDate>' . "\n";
$rankDataI = array();
$rankDataT = array();
$lastUpdate = 0;
if ($viewI && (!empty($optionsI['events']) || empty($optionsT['events']))) {
    $rank = Obj_RankFactory::create($viewSnap ? 'Snapshot' : $family, $optionsI);
    $rank->read();
    $rankDataI = $rank->getData();
    $lastUpdate = strtotime($rankDataI['meta']['lastUpdate']);
    //print '<pre>';print_r($rankDataI);print '</pre>';exit;
} else {
    $viewI = false;
}
if ($viewT && (!empty($optionsT['events']) || empty($optionsI['events']))) {
    $rank = Obj_RankFactory::create($family . 'Team', $optionsT);
    $rank->read();
    $rankDataT = $rank->getData();
    //print '<pre>';print_r($rankDataT);print '</pre>';exit;
    if ($rankDataT['meta']['lastUpdate'] != '0000-00-00 00:00:00') {
        if ($lastUpdate != 0) {
            $lastUpdate = max($lastUpdate, strtotime($rankDataT['meta']['lastUpdate']));
        } else {
            $lastUpdate = strtotime($rankDataT['meta']['lastUpdate']);
        }
    }
} else {
    $viewT = false;
}
if ($viewI && $lastUpdate >= $serverDate) {
    foreach ($rankDataI['sections'] as $keySection => $dataSection) {
Пример #8
0
 *
 * LEGGERE NOTA PIU' SOTTO RIGUARDO ALLA VISIBILITA' DELLE FRECCE (riga 163)
 *
 *
 *
 * Aggiunta per il calcolo della freccia X to win
 *
 * aggiunti 4 campi XML:
 * - xtowin: valore della freccia (e quindi della zona da non scurire). Se 1000 ignorare
 * - totieset: indica se il valore indicato è per vincere o pareggiare il set
 * - towinmatch: indica se il valore indicato è per vincere il match
 * - totiematch: indica se il valore indicato è per pareggiare il match
 *
 * */
require_once 'Common/Lib/Obj_RankFactory.php';
$rank = Obj_RankFactory::create('GridInd', $opts);
$rank->read();
$rankData = $rank->getData();
// $SQL="SELECT "
// 	. " f.FinEvent Event, "
// 	. " EvMatchArrowsNo, EvMixedTeam, EvTeamEvent, EvEventName, "
// 	. " GrPhase Phase, "
// 	. " f.FinVxF,"
// 	. " IF(f.FinDateTime>=f2.FinDateTime, f.FinDateTime, f2.FinDateTime) AS DateTime,"
// 	. " TIMESTAMPDIFF(SECOND, IF(f.FinDateTime>=f2.FinDateTime, f.FinDateTime, f2.FinDateTime), now())>90  AS TooOld,"
// 	. " f.FinMatchNo as MatchNo,"
// 	. " fs1.FsTarget Target, "
// 	. " fs2.FsTarget OppTarget, "
// 	. " f2.FinMatchNo as OppMatchNo,"
// 	. " EvMatchMode!=0 as SetMode, "
// 	// left side athlete
Пример #9
0
    exit;
}
$ToFit = isset($_REQUEST['ToFitarco']) ? $_REQUEST['ToFitarco'] : null;
$XmlDoc = new DOMDocument('1.0', 'UTF-8');
$TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleRanking.xsl" ');
$XmlDoc->appendChild($TmpNode);
$XmlRoot = $XmlDoc->createElement('Results');
$XmlRoot->setAttribute('IANSEO', ProgramVersion);
$XmlRoot->setAttribute('TS', date('Y-m-d H:i:s'));
$XmlDoc->appendChild($XmlRoot);
$ListHeader = NULL;
$options = array();
if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") {
    $options['eventsR'] = $_REQUEST["Event"];
}
$rank = Obj_RankFactory::create('FinalTeam', $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections'])) {
    foreach ($rankData['sections'] as $section) {
        $NumPhases = numPhases($section['meta']['firstPhase']);
        if (count($section['items'])) {
            $ListHeader = $XmlDoc->createElement('List');
            $ListHeader->setAttribute('Title', get_text($section['meta']['descr'], '', '', true));
            $ListHeader->setAttribute('Columns', 3 + $NumPhases);
            $XmlRoot->appendChild($ListHeader);
            $TitElem = array();
            $TitElem['Rank'] = $section['meta']['fields']['rank'];
            $TitElem['Country'] = $section['meta']['fields']['countryName'];
            $TitElem['Rank Score'] = $section['meta']['fields']['qualRank'];
            foreach ($section['meta']['fields']['finals'] as $k => $v) {
Пример #10
0
 /*
  * QUI il reset della fase successiva delle elim (se c'è)
  * e il calcolo della rank elim della fase attuale.
  *
  * Se fase è 0 sicuramente ho anche la 1 perchè in caso di solo un girone l'unica fase buona è la 1
  */
 $q = "SELECT ElEventCode FROM Eliminations WHERE ElId={$Atleta} AND ElElimPhase={$Fase}";
 $r = safe_r_sql($q);
 $ev = '';
 $row = safe_fetch($r);
 $ev = $row->ElEventCode;
 if ($ev != '') {
     if ($Fase == 0) {
         ResetElimRows($ev, 2);
     }
     Obj_RankFactory::create('ElimInd', array('eventsC' => array($ev . '@' . ($Fase + 1))))->calculate();
 }
 // azzero gli shootoff
 /*$Update
 			= "UPDATE Events INNER JOIN EventClass ON EvCode=EcCode AND EvTeamEvent='0' AND EcTournament=" . StrSafe_DB($_SESSION['TourId']) . " "
 			. "INNER JOIN Entries ON EcDivision=EnDivision AND EcClass=EnClass  AND EnId=" . StrSafe_DB($Atleta) . " "
 			. "SET EvShootOff='0' " . ($Fase==0 ? ", EvE2ShootOff='0' " : "")
 			. "WHERE EvTeamEvent='0' AND EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
 		$Rs=safe_w_sql($Update);
 		set_qual_session_flags();*/
 $q = "\r\n\t\t\t\t\t\tSELECT EvCode\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\tEvents\r\n\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\tEventClass\r\n\t\t\t\t\t\t\tON EvCode=EcCode AND EvTeamEvent='0' AND EcTournament={$_SESSION['TourId']}\r\n\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\tEntries\r\n\t\t\t\t\t\t\tON EcDivision=EnDivision AND EcClass=EnClass  AND EnId={$Atleta}\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t EvTeamEvent='0' AND EvTournament={$_SESSION['TourId']}\r\n\t\t\t\t\t";
 $Rs = safe_w_sql($q);
 if ($Rs && safe_num_rows($Rs) > 0) {
     while ($row = safe_fetch($Rs)) {
         //print $Fase.'<br>';
         ResetShootoff($row->EvCode, 0, $Fase == 0 ? 1 : 2);
Пример #11
0
            if ($item['rank'] > $qualifiedNo) {
                break;
            }
            $q = "";
            $date = date('Y-m-d H:i:s');
            if ($RequestedElim == 0 || $RequestedElim == 1) {
                $q = "\r\n\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\tEliminations\r\n\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\tElId={$item['id']},\r\n\t\t\t\t\t\t\tElDateTime='{$date}'\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tElElimPhase={$RequestedElim} AND\r\n\t\t\t\t\t\t\tElTournament={$_SESSION['TourId']} AND\r\n\t\t\t\t\t\t\tElEventCode='{$RequestedEvent}' AND\r\n\t\t\t\t\t\t\tElQualRank={$item['rank']}\r\n\t\t\t\t\t";
            } elseif ($RequestedElim == 2) {
                $q = "\r\n\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\tEvents\r\n\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\tFinals\r\n\t\t\t\t\t\t\tON EvCode=FinEvent AND EvTeamEvent=0 AND EvTournament=FinTournament\r\n\t\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\t\tGrids\r\n\t\t\t\t\t\t\tON FinMatchNo=GrMatchNo AND GrPhase=EvFinalFirstPhase AND FinTournament={$_SESSION['TourId']} AND FinEvent='{$RequestedEvent}'\r\n\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\tFinAthlete={$item['id']},\r\n\t\t\t\t\t\t\tFinDateTime='{$date}'\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tFinEvent='{$RequestedEvent}' AND IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition)={$item['rank']} AND FinTournament={$_SESSION['TourId']}\r\n\r\n\t\t\t\t\t";
            }
            //print $q.'<br><br>';
            $r = safe_w_sql($q);
        }
        //exit;
        // Adesso finalizzo chi si è fermato
        Obj_RankFactory::create('FinalInd', $optsFinal)->calculate();
        // setto a 1 i flags che dicono che ho fatto gli spareggi per gli eventi
        $Update = "UPDATE Events SET " . ($RequestedElim == 2 ? 'EvShootOff' : ($RequestedElim == 0 ? 'EvE1ShootOff' : 'EvE2ShootOff')) . "='1' " . "WHERE EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EvCode='" . $RequestedEvent . "'  AND EvTeamEvent='0' ";
        $RsUp = safe_w_sql($Update);
        //print $Update;exit;
        set_qual_session_flags();
    }
}
$JS_SCRIPT = array('');
include 'Common/Templates/head.php';
?>
<table class="Tabella">
<TR><TH class="Title"><?php 
print get_text('ShootOff4Elim');
?>
</TH></TR>
Пример #12
0
function RecalcFinRank_20110415($TournamentID)
{
    // per tutti gli eventi ricalcolo le rank finali
    $q = "\n\t\tSELECT\n\t\t\tEvCode,IF(EvTeamEvent=0,'I','T') AS `Team`,EvFinalFirstPhase,EvElim1,EvElim2\n\t\tFROM\n\t\t\tEvents\n\t\tWHERE\n\t\t\tEvTournament={$TournamentID}\n\t";
    $r = safe_r_sql($q);
    if (safe_num_rows($r) > 0) {
        $eventsI = array();
        $eventsT = array();
        while ($row = safe_fetch($r)) {
            // calcolo di sicuro chi si è fermato agli assoluti
            ${'events' . $row->Team}[] = $row->EvCode . '@-3';
            // se ho un girone elim
            if ($row->EvElim2 != 0 && $row->EvElim1 == 0) {
                ${'events' . $row->Team}[] = $row->EvCode . '@-2';
            } elseif ($row->EvElim2 != 0 && $row->EvElim1 != 0) {
                ${'events' . $row->Team}[] = $row->EvCode . '@-1';
                ${'events' . $row->Team}[] = $row->EvCode . '@-2';
            }
            // dalla prima fase finale
            ${'events' . $row->Team}[] = $row->EvCode . '@' . $row->EvFinalFirstPhase;
        }
        Obj_RankFactory::create('FinalInd', array('eventsC' => $eventsI, 'tournament' => $TournamentID))->calculate();
        Obj_RankFactory::create('FinalTeam', array('eventsC' => $eventsT, 'tournament' => $TournamentID))->calculate();
    }
}
Пример #13
0
        foreach ($Arr_Ph as $p) {
            $t = explode('+', $p);
            $l = array_shift($t);
            foreach ($t as $e) {
                $options['events'][] = $l . '@' . $e;
            }
        }
    } else {
        foreach ($Arr_Ph as $p) {
            $options['events'][] = '@' . $p;
        }
    }
} elseif ($Arr_Ev) {
    $options['events'] = $Arr_Ev;
}
$rank = Obj_RankFactory::create('GridTeam', $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections']) == 0) {
    return '';
}
$Columns = isset($TVsettings->TVPColumns) && !empty($TVsettings->TVPColumns) ? explode('|', $TVsettings->TVPColumns) : array();
$ViewAthls = (in_array('ATHL', $Columns) or in_array('ALL', $Columns));
$ViewByes = (in_array('BYE', $Columns) or in_array('ALL', $Columns));
$ViewFlags = (in_array('FLAG', $Columns) or in_array('ALL', $Columns));
$TotalColWidth = 7;
foreach ($Columns as $sub) {
    if (substr($sub, 0, 5) == 'WIDTH') {
        $TotalColWidth = substr($sub, 6);
    }
}
Пример #14
0
<?php

require_once 'Common/Lib/Obj_RankFactory.php';
$TVsettings->EventFilter = MakeEventFilter($TVsettings->TVPEventTeam);
$options = array('tournament' => $RULE->TVRTournament);
$options['dist'] = 0;
if (isset($TVsettings->TVPEventTeam) && !empty($TVsettings->TVPEventTeam)) {
    $options['events'] = explode('|', $TVsettings->TVPEventTeam);
}
if (isset($TVsettings->TVPNumRows) && $TVsettings->TVPNumRows > 0) {
    $options['cutRank'] = $TVsettings->TVPNumRows;
}
if (isset($TVsettings->TVPSession) && $TVsettings->TVPSession > 0) {
    $options['session'] = $TVsettings->TVPSession;
}
$rank = Obj_RankFactory::create('DivClassTeam', $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections']) == 0) {
    return '';
}
$Columns = isset($TVsettings->TVPColumns) && !empty($TVsettings->TVPColumns) ? explode('|', $TVsettings->TVPColumns) : array();
$ViewAths = (in_array('ATHL', $Columns) or in_array('ALL', $Columns));
$View10s = (in_array('10', $Columns) or in_array('ALL', $Columns));
$ViewX9s = (in_array('X9', $Columns) or in_array('ALL', $Columns));
$NumCol = 3 + $ViewAths + $View10s + $ViewX9s;
foreach ($rankData['sections'] as $IdEvent => $data) {
    // Titolo della tabella
    $tmp = '<tr><th class="Title" colspan="' . $NumCol . '">';
    $tmp .= $Arr_Pages[$TVsettings->TVPPage];
    $tmp .= '</th></tr>' . "\n";
Пример #15
0
require_once 'Common/Lib/Obj_RankFactory.php';
require_once 'Common/Fun_FormatText.inc.php';
$TourType = getTournamentType($TourId);
$TVsettings->EventFilter = MakeEventFilter($TVsettings->TVPEventInd);
$options = array('tournament' => $RULE->TVRTournament);
$options['subFamily'] = 'DivClass';
if (isset($TVsettings->TVPEventInd) && !empty($TVsettings->TVPEventInd)) {
    $options['events'] = explode('|', $TVsettings->TVPEventInd);
}
if (isset($TVsettings->TVPNumRows) && $TVsettings->TVPNumRows > 0) {
    $options['cutRank'] = $TVsettings->TVPNumRows;
}
if (isset($TVsettings->TVPSession) && $TVsettings->TVPSession > 0) {
    $options['session'] = $TVsettings->TVPSession;
}
$rank = Obj_RankFactory::create('Snapshot', $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections']) == 0) {
    return '';
}
$Columns = isset($TVsettings->TVPColumns) && !empty($TVsettings->TVPColumns) ? explode('|', $TVsettings->TVPColumns) : array();
$ViewTeams = ((in_array('TEAM', $Columns) or in_array('ALL', $Columns)) and $TourType != 14);
$ViewDists = ((in_array('DIST', $Columns) or in_array('ALL', $Columns)) and $TVsettings->TVPViewPartials);
$ViewTOT = (in_array('TOT', $Columns) or in_array('ALL', $Columns));
$NumColBase = 3 + $ViewTeams + $ViewTOT;
foreach ($rankData['sections'] as $IdEvent => $section) {
    // crea l'header della gara
    $tmp = '';
    $NumCol = $NumColBase + ($ViewDists && $TVsettings->TVPViewPartials ? $rankData['meta']['numDist'] : 0);
    $tmp .= '<tr><th class="Title" colspan="' . $NumCol . '">';
Пример #16
0
<?php

require_once dirname(dirname(__FILE__)) . '/config.php';
require_once 'Common/pdf/ResultPDF.inc.php';
require_once 'Common/Lib/Obj_RankFactory.php';
require_once 'Common/Fun_FormatText.inc.php';
if (!isset($isCompleteResultBook)) {
    $pdf = new ResultPDF(get_text('MedalIndClass', 'Tournament'));
}
$rank = Obj_RankFactory::create('DivClass', array('dist' => 0, 'cutRank' => 3));
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections'])) {
    $DistSize = 12;
    $AddSize = 0;
    $pdf->setDocUpdate($rankData['meta']['lastUpdate']);
    foreach ($rankData['sections'] as $section) {
        //Calcolo Le Misure per i Campi
        if ($rankData['meta']['numDist'] >= 4 && !$rankData['meta']['double']) {
            $DistSize = 48 / $rankData['meta']['numDist'];
        } elseif ($rankData['meta']['numDist'] >= 4 && $rankData['meta']['double']) {
            $DistSize = 48 / ($rankData['meta']['numDist'] / 2 + 1);
        } else {
            $AddSize = (48 - $rankData['meta']['numDist'] * 12) / 2;
        }
        //Verifico se l'header e qualche riga ci stanno nella stessa pagina altrimenti salto alla prosisma
        if (!$pdf->SamePage(28)) {
            $pdf->AddPage();
        }
        writeGroupHeader($pdf, $section['meta'], $DistSize, $AddSize, $rankData['meta']['numDist'], $rankData['meta']['double'], false);
        foreach ($section['items'] as $item) {
Пример #17
0
<?php

require_once 'Common/Lib/Obj_RankFactory.php';
$TVsettings->EventFilter = MakeEventFilter($TVsettings->TVPEventTeam);
$options = array('tournament' => $RULE->TVRTournament);
$options['dist'] = 0;
if (isset($TVsettings->TVPEventTeam) && !empty($TVsettings->TVPEventTeam)) {
    $options['events'] = explode('|', $TVsettings->TVPEventTeam);
}
if (isset($TVsettings->TVPNumRows) && $TVsettings->TVPNumRows > 0) {
    $options['cutRank'] = $TVsettings->TVPNumRows;
}
if (isset($TVsettings->TVPSession) && $TVsettings->TVPSession > 0) {
    $options['session'] = $TVsettings->TVPSession;
}
$rank = Obj_RankFactory::create('AbsTeam', $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections']) == 0) {
    return '';
}
$Columns = isset($TVsettings->TVPColumns) && !empty($TVsettings->TVPColumns) ? explode('|', $TVsettings->TVPColumns) : array();
$ViewAths = (in_array('ATHL', $Columns) or in_array('ALL', $Columns));
$View10s = (in_array('10', $Columns) or in_array('ALL', $Columns));
$ViewX9s = (in_array('X9', $Columns) or in_array('ALL', $Columns));
$NumCol = 3 + $ViewAths + $View10s + $ViewX9s;
foreach ($rankData['sections'] as $IdEvent => $data) {
    $RecTot = array();
    $RecTitle = '';
    $RecCut = 999999;
    if ($data['meta']['arrowsShot']) {
Пример #18
0
    $options['session'] = $TVsettings->TVPSession;
}
if (!empty($_REQUEST['SubClass']) and !preg_match('/[^a-zA-Z0-9.-]/', $_REQUEST['SubClass'])) {
    $options['SubClass'] = $_REQUEST['SubClass'];
}
$Columns = isset($TVsettings->TVPColumns) && !empty($TVsettings->TVPColumns) ? explode('|', $TVsettings->TVPColumns) : array();
$ViewTeams = ((in_array('TEAM', $Columns) or in_array('ALL', $Columns)) and $TourType != 14);
$ViewDists = ((in_array('DIST', $Columns) or in_array('ALL', $Columns)) and $TVsettings->TVPViewPartials);
$View10s = ((in_array('10', $Columns) or in_array('ALL', $Columns)) and $TourType != 14);
$ViewX9s = (in_array('X9', $Columns) or in_array('ALL', $Columns));
$comparedTo = preg_grep('/^COMP:/', $Columns);
if (!empty($comparedTo)) {
    list(, $comparedTo) = explode(":", reset($comparedTo));
}
$options['comparedTo'] = $comparedTo;
$rank = Obj_RankFactory::create('SubClass', $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections']) == 0) {
    return '';
}
$NumColBase = (empty($comparedTo) ? 3 : 4) + $ViewTeams + $View10s + $ViewX9s;
foreach ($rankData['sections'] as $IdEvent => $data) {
    //	debug_svela($data, true);
    // crea l'header della gara
    $NumDists = $rankData['meta']['numDist'];
    for ($i = 1; $i <= $rankData['meta']['numDist']; ++$i) {
        if ($data['meta']['fields']['dist_' . $i] == '-') {
            $NumDists--;
        }
    }
Пример #19
0
function XmlCreateBracketIndividual($EventRequested = '')
{
    $XmlDoc = new DOMDocument('1.0', 'UTF-8');
    $TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleBracket.xsl" ');
    $XmlDoc->appendChild($TmpNode);
    $XmlRoot = $XmlDoc->createElement('Results');
    $XmlRoot->setAttribute('IANSEO', ProgramVersion);
    $XmlRoot->setAttribute('TS', date('Y-m-d H:i:s'));
    $XmlDoc->appendChild($XmlRoot);
    $ListHeader = NULL;
    $options = array();
    if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") {
        $options['events'] = $_REQUEST["Event"];
    }
    if ($EventRequested) {
        $options['events'] = $EventRequested;
    }
    $rank = Obj_RankFactory::create('GridInd', $options);
    $rank->read();
    $rankData = $rank->getData();
    foreach ($rankData['sections'] as $Event => $Data) {
        // New Event
        $ListHeader = $XmlDoc->createElement('List');
        $ListHeader->setAttribute('Title', $Data['meta']['eventName']);
        $ListHeader->setAttribute('Columns', '4');
        $XmlRoot->appendChild($ListHeader);
        foreach ($Data['phases'] as $Phase => $items) {
            // new Phase
            $XmlPhase = $XmlDoc->createElement('Phase');
            $XmlPhase->setAttribute('Title', $items['meta']['phaseName']);
            $XmlPhase->setAttribute('Columns', '4');
            $ListHeader->appendChild($XmlPhase);
            // creo le colonne
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete') . ' 1');
            $TmpNode->setAttribute('Name', 'Athlete1');
            $TmpNode->setAttribute('Columns', '1');
            $XmlPhase->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete') . ' 2');
            $TmpNode->setAttribute('Name', 'Athlete2');
            $TmpNode->setAttribute('Columns', '1');
            $XmlPhase->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Total') . ' 1');
            $TmpNode->setAttribute('Name', 'Score1');
            $TmpNode->setAttribute('Columns', '1');
            $XmlPhase->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Total') . ' 2');
            $TmpNode->setAttribute('Name', 'Score2');
            $TmpNode->setAttribute('Columns', '2');
            $XmlPhase->appendChild($TmpNode);
            foreach ($items['items'] as $match) {
                // creo il nuovo match e leggo il secondo atleta
                $XmlMatch = $XmlDoc->createElement('Match');
                $XmlPhase->appendChild($XmlMatch);
                $Win1 = ($match['tie'] or $Data['meta']['matchMode'] ? $match['setScore'] > $match['oppSetScore'] : $match['score'] > $match['oppScore']);
                $Win2 = ($match['oppTie'] or $Data['meta']['matchMode'] ? $match['setScore'] < $match['oppSetScore'] : $match['score'] < $match['oppScore']);
                $Tiebreak1 = array();
                $Tiebreak2 = array();
                if ($match['tie'] == 1 || $match['oppTie'] == 1) {
                    for ($i = 0; $i < max(strlen($match['tiebreak']), strlen($match['oppTiebreak'])); ++$i) {
                        $Tiebreak1[] = DecodeFromLetter($match['tiebreak'][$i]);
                        $Tiebreak2[] = DecodeFromLetter($match['oppTiebreak'][$i]);
                    }
                }
                $Tiebreak1 = trim(join(' ', $Tiebreak1));
                if ($Tiebreak1 != '') {
                    $Tiebreak1 = '(' . $Tiebreak1 . ')';
                }
                $Tiebreak2 = trim(join(' ', $Tiebreak2));
                if ($Tiebreak2 != '') {
                    $Tiebreak2 = '(' . $Tiebreak2 . ')';
                }
                // ath1
                $XmlAthlete = $XmlDoc->createElement('Athlete');
                $XmlAthlete->setAttribute('Win', $Win1);
                $XmlAthlete->setAttribute('MatchNo', $match['matchNo']);
                $XmlMatch->appendChild($XmlAthlete);
                $TmpNode = $XmlDoc->createElement('Name', $match['athlete']);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Country', $match['countryCode'] ? '(' . $match['countryCode'] . ' - ' . $match['countryName'] . ')' : ' ');
                $XmlAthlete->appendChild($TmpNode);
                $score = ' ';
                if ($match['athlete']) {
                    if ($match['tie'] == 2) {
                        $score = get_text('Bye');
                    } elseif ($Data['meta']['matchMode']) {
                        $score = $match['setScore'] + $match['oppSetScore'] ? $match['setScore'] : ' ';
                    } else {
                        $score = $match['score'] + $match['oppScore'] ? $match['score'] : ' ';
                    }
                }
                $TmpNode = $XmlDoc->createElement('Score', $score);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Tiebreak', $Tiebreak1);
                $XmlAthlete->appendChild($TmpNode);
                // ath2
                $XmlAthlete = $XmlDoc->createElement('Athlete');
                $XmlAthlete->setAttribute('Win', $Win2);
                $XmlAthlete->setAttribute('MatchNo', $match['oppMatchNo']);
                $XmlMatch->appendChild($XmlAthlete);
                $TmpNode = $XmlDoc->createElement('Name', $match['oppAthlete']);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Country', $match['oppCountryCode'] ? '(' . $match['oppCountryCode'] . ' - ' . $match['oppCountryName'] . ')' : ' ');
                $XmlAthlete->appendChild($TmpNode);
                $score = ' ';
                if ($match['oppAthlete']) {
                    if ($match['oppTie'] == 2) {
                        $score = get_text('Bye');
                    } elseif ($Data['meta']['matchMode']) {
                        $score = $match['setScore'] + $match['oppSetScore'] ? $match['oppSetScore'] : ' ';
                    } else {
                        $score = $match['score'] + $match['oppScore'] ? $match['oppScore'] : ' ';
                    }
                }
                $TmpNode = $XmlDoc->createElement('Score', $score);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Tiebreak', $Tiebreak2);
                $XmlAthlete->appendChild($TmpNode);
            }
        }
    }
    return $XmlDoc;
}
Пример #20
0
    exit;
}
$ToFit = isset($_REQUEST['ToFitarco']) ? $_REQUEST['ToFitarco'] : null;
$XmlDoc = new DOMDocument('1.0', 'UTF-8');
$TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleRanking.xsl" ');
$XmlDoc->appendChild($TmpNode);
$XmlRoot = $XmlDoc->createElement('Results');
$XmlRoot->setAttribute('IANSEO', ProgramVersion);
$XmlRoot->setAttribute('TS', date('Y-m-d H:i:s'));
$XmlDoc->appendChild($XmlRoot);
$ListHeader = NULL;
$options = array();
if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") {
    $options['eventsR'] = $_REQUEST["Event"];
}
$rank = Obj_RankFactory::create('FinalInd', $options);
$rank->read();
$rankData = $rank->getData();
// se ho degli eventi
if (count($rankData['sections'])) {
    foreach ($rankData['sections'] as $section) {
        $ElimCols = 0;
        if ($section['meta']['elim1']) {
            $ElimCols++;
        }
        if ($section['meta']['elim2']) {
            $ElimCols++;
        }
        $NumPhases = numPhases($section['meta']['firstPhase']);
        //Se Esistono righe caricate....
        if (count($section['items'])) {
function ExportLSTTeam()
{
    $options = array('dist' => 0);
    $rank = Obj_RankFactory::create('DivClassTeam', $options);
    $rank->read();
    $rankData = $rank->getData();
    $MyHeader = array('Pos' => 8, 'Sigla' => 11, 'Societa' => 26, 'Cod.Tessera' => 13, 'Div' => 5, 'Cl' => 5, 'Clg' => 5, 'Ct' => 3, 'Cognome-Nome' => 27, 'Totale' => 8, 'O' => 6, 'X/9' => 6);
    $TotPad = 0;
    foreach ($MyHeader as $Key => $Value) {
        if ($Key == 'Totale') {
            break;
        }
        $TotPad += $Value;
    }
    $StrData = '';
    if (count($rankData['sections']) > 0) {
        // gli eventi
        $StrData .= "\n";
        foreach ($rankData['sections'] as $section) {
            $StrData .= "\n" . $section['meta']['descr'] . "\n\n";
            foreach ($MyHeader as $Key => $Value) {
                $StrData .= str_pad($Key, $Value, ' ', STR_PAD_RIGHT);
            }
            $StrData .= "\n";
            // i team
            if (count($section['items']) > 0) {
                foreach ($section['items'] as $item) {
                    $StrData .= str_pad($item['rank'], $MyHeader['Pos'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(substr($item['countryCode'], 0, 2) . '/' . substr($item['countryCode'], 2), $MyHeader['Sigla'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(stripslashes($item['countryName']), $MyHeader['Societa'], ' ', STR_PAD_RIGHT);
                    /*
                     * I membri del team.
                     * Il primo lo scrivo fuori dal ciclo, gli altri li faccio ciclare
                     */
                    $StrData .= str_pad($item['athletes'][0]['bib'], $MyHeader['Cod.Tessera'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad($item['athletes'][0]['div'], $MyHeader['Div'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad($item['athletes'][0]['class'], $MyHeader['Cl'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad($item['athletes'][0]['ageclass'], $MyHeader['Clg'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad($item['athletes'][0]['subclass'], $MyHeader['Ct'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(stripslashes(substr($item['athletes'][0]['athlete'], 0, $MyHeader['Cognome-Nome'])), $MyHeader['Cognome-Nome'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(str_pad($item['athletes'][0]['quscore'], 4, ' ', STR_PAD_LEFT), $MyHeader['Totale'], ' ', STR_PAD_RIGHT);
                    // per ora due *
                    $StrData .= str_pad(str_pad($item['athletes'][0]['qugold'], 3, ' ', STR_PAD_LEFT), $MyHeader['O'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(str_pad($item['athletes'][0]['quxnine'], 3, ' ', STR_PAD_LEFT), $MyHeader['X/9'], ' ', STR_PAD_RIGHT);
                    $StrData .= "\n";
                    // gli altri membri del team
                    for ($i = 1; $i < count($item['athletes']); ++$i) {
                        $StrData .= str_repeat(' ', $MyHeader['Pos'] + $MyHeader['Sigla'] + $MyHeader['Societa']);
                        $StrData .= str_pad($item['athletes'][$i]['bib'], $MyHeader['Cod.Tessera'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad($item['athletes'][$i]['div'], $MyHeader['Div'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad($item['athletes'][$i]['class'], $MyHeader['Cl'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad($item['athletes'][$i]['ageclass'], $MyHeader['Clg'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad($item['athletes'][$i]['subclass'], $MyHeader['Ct'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad(stripslashes(substr($item['athletes'][$i]['athlete'], 0, $MyHeader['Cognome-Nome'])), $MyHeader['Cognome-Nome'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad(str_pad($item['athletes'][$i]['quscore'], 4, ' ', STR_PAD_LEFT), $MyHeader['Totale'], ' ', STR_PAD_RIGHT);
                        // per ora due *
                        $StrData .= str_pad(str_pad($item['athletes'][$i]['qugold'], 3, ' ', STR_PAD_LEFT), $MyHeader['O'], ' ', STR_PAD_RIGHT);
                        $StrData .= str_pad(str_pad($item['athletes'][$i]['quxnine'], 3, ' ', STR_PAD_LEFT), $MyHeader['X/9'], ' ', STR_PAD_RIGHT);
                        $StrData .= "\n";
                    }
                    // il totale
                    $StrData .= str_repeat(' ', $TotPad);
                    $StrData .= str_pad(str_pad($item['score'], 4, ' ', STR_PAD_LEFT), $MyHeader['Totale'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(str_pad($item['gold'], 3, ' ', STR_PAD_LEFT), $MyHeader['O'], ' ', STR_PAD_RIGHT);
                    $StrData .= str_pad(str_pad($item['xnine'], 3, ' ', STR_PAD_LEFT), $MyHeader['X/9'], ' ', STR_PAD_RIGHT);
                    $StrData .= "\n\n";
                }
            }
        }
    }
    return $StrData;
}
Пример #22
0
}
if (isset($TVsettings->TVPSession) && $TVsettings->TVPSession > 0) {
    $options['session'] = $TVsettings->TVPSession;
}
$Columns = isset($TVsettings->TVPColumns) && !empty($TVsettings->TVPColumns) ? explode('|', $TVsettings->TVPColumns) : array();
$ViewTeams = (in_array('TEAM', $Columns) or in_array('ALL', $Columns));
$ViewDists = ((in_array('DIST', $Columns) or in_array('ALL', $Columns)) and $TVsettings->TVPViewPartials);
$View10s = (in_array('10', $Columns) or in_array('ALL', $Columns));
$ViewX9s = (in_array('X9', $Columns) or in_array('ALL', $Columns));
$comparedTo = preg_grep('/^COMP:/', $Columns);
if (!empty($comparedTo)) {
    list(, $comparedTo) = explode(":", reset($comparedTo));
}
$options['comparedTo'] = $comparedTo;
$family = 'Abs';
$rank = Obj_RankFactory::create($family, $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections']) == 0) {
    return '';
}
// set the width of the totals if any
$TotalsWidth = 7.5;
foreach ($Columns as $opt) {
    $tmpW = explode(':', $opt);
    if ($tmpW[0] == 'WIDTH' and $tmpW[1]) {
        $TotalsWidth = $tmpW[1];
        break;
    }
}
// debug_svela($Columns);
Пример #23
0
function getMedalStand($ORIS = false)
{
    $Data = new StdClass();
    $Data->Code = 'C95';
    $Data->Description = 'Medal Standings';
    $Data->Phase = "";
    $Data->Order = "0";
    $Data->LastUpdate = '';
    $Data->EvName = get_text('EvName');
    $Data->TourWhen = get_text('TourWhen', 'Tournament');
    $Data->Medal = get_text('Medal');
    $Data->Athlete = get_text('Athlete');
    $Data->Country = get_text('Country');
    for ($n = 0; $n < 7; $n++) {
        $Data->{'DayOfWeek_' . $n} = get_text('DayOfWeek_' . $n);
    }
    for ($n = 0; $n < 12; $n++) {
        $Data->{'Month_' . $n} = get_text('Month_' . $n);
    }
    $Data->Medal_1 = get_text('MedalGold');
    $Data->Medal_2 = get_text('MedalSilver');
    $Data->Medal_3 = get_text('MedalBronze');
    $Data->Rank = get_text('Rank');
    $Data->Individual = get_text('Individual');
    $Data->Team = get_text('Team');
    $Data->Total = get_text('Total');
    if (!$ORIS) {
        $Data->Description = get_text('MedalStanding');
    }
    $options = array();
    if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") {
        $options['eventsR'] = $_REQUEST["Event"];
    }
    $options['cutRank'] = 3;
    $rank = Obj_RankFactory::create('FinalInd', $options);
    $rank->read();
    if (empty($Data->Ind)) {
        $Data->Ind = new StdClass();
    }
    $Data->Ind->rankData = $rank->getData();
    $Data->LastUpdate = $Data->Ind->rankData['meta']['lastUpdate'];
    $CountryList = array();
    $colTots = array();
    $colRank = array();
    $rankData = $rank->getData();
    $tmp = new StdClass();
    $tmp->I[1] = 0;
    $tmp->I[2] = 0;
    $tmp->I[3] = 0;
    $tmp->T[1] = 0;
    $tmp->T[2] = 0;
    $tmp->T[3] = 0;
    $tmp->U[1] = 0;
    $tmp->U[2] = 0;
    $tmp->U[3] = 0;
    foreach ($rankData['sections'] as $Event => $section) {
        if ($section['meta']['medals']) {
            foreach ($section['items'] as $item) {
                if ($item['rank'] != 0) {
                    if (empty($CountryList[$item['countryCode']])) {
                        $CountryList[$item['countryCode']] = clone $tmp;
                        $CountryList[$item['countryCode']]->Name = $item['countryName'];
                        $colTots[$item['countryCode']] = 0;
                    }
                    $CountryList[$item['countryCode']]->I[$item['rank']]++;
                    $CountryList[$item['countryCode']]->U[$item['rank']]++;
                    $colTots[$item['countryCode']]++;
                    $colRank[$item['countryCode']] = 0;
                }
            }
        }
    }
    $options = array();
    if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") {
        $options['eventsR'] = $_REQUEST["Event"];
    }
    $options['cutRank'] = 3;
    $rank = Obj_RankFactory::create('FinalTeam', $options);
    $rank->read();
    $rankData = $rank->getData();
    foreach ($rankData['sections'] as $Event => $section) {
        if ($section['meta']['medals']) {
            foreach ($section['items'] as $item) {
                if ($item['rank'] != 0) {
                    if (empty($CountryList[$item['countryCode']])) {
                        $CountryList[$item['countryCode']] = clone $tmp;
                        $CountryList[$item['countryCode']]->Name = $item['countryName'];
                        $colTots[$item['countryCode']] = 0;
                    }
                    $CountryList[$item['countryCode']]->T[$item['rank']]++;
                    $CountryList[$item['countryCode']]->U[$item['rank']]++;
                    $colTots[$item['countryCode']]++;
                    $colRank[$item['countryCode']] = 0;
                }
            }
        }
    }
    uasort($CountryList, 'standComp');
    arsort($colTots);
    $MyRank = 0;
    $MyPos = 0;
    $TmpOldValue = -1;
    foreach ($colTots as $key => $value) {
        $MyPos++;
        if ($TmpOldValue != $value) {
            $MyRank = $MyPos;
            $TmpOldValue = $value;
        }
        $colRank[$key] = $MyRank;
    }
    $Data->CountryList = $CountryList;
    $Data->colTots = $colTots;
    $Data->colRank = $colRank;
    return $Data;
}