Exemplo n.º 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;
}
Exemplo n.º 2
1
                echo '<td>&nbsp;<input type="hidden" name="MaxArrows" id="MaxArrows" value="' . $RowTour->MaxArrows . '"><input type="hidden" name="NumEnds" id="NumEnds" value="' . $RowTour->TtNumEnds . '"></td>';
                for ($i = 1; $i <= $NumArrows; $i++) {
                    echo '<th>' . $i . '</th>';
                }
                echo '<th>' . get_text('TotalProg', 'Tournament') . '</th><th>' . get_text('TotalShort', 'Tournament') . '</th></tr>';
                $ArrowString = str_pad($MyRow->ArrowString, $RowTour->MaxArrows, ' ', STR_PAD_RIGHT);
                $TotRunning = 0;
                for ($i = 0; $i < $NumEnds; $i++) {
                    echo '<tr>';
                    echo '<th>' . ($i + 1) . '</th>';
                    $ArrNo = $i * $NumArrows;
                    $TotEnd = 0;
                    for ($j = 0; $j < $NumArrows; $j++) {
                        echo '<td class="Center">' . '<input type="text" id="arr_' . $_REQUEST['x_Dist'] . '_' . ($ArrNo + $j) . '_' . $MyRow->EnId . '" ' . 'size="2" maxlength="2" value="' . DecodeFromLetter($ArrowString[$ArrNo + $j]) . '" ' . 'onBlur="javascript:UpdateArrow(\'arr_' . $_REQUEST['x_Dist'] . '_' . ($ArrNo + $j) . '_' . $MyRow->EnId . '\');">' . '</td>';
                        $TotEnd += ValutaArrowString($ArrowString[$ArrNo + $j]);
                        $TotRunning += ValutaArrowString($ArrowString[$ArrNo + $j]);
                    }
                    echo '<td class="Right"><div id="idEnd_' . $_REQUEST['x_Dist'] . '_' . (($i + 1) * ($RowTour->MaxArrows / $RowTour->TtNumEnds) - 1) . '_' . $MyRow->EnId . '">' . $TotEnd . '</div></td>';
                    echo '<td class="Bold Right"><div id="idScore_' . $_REQUEST['x_Dist'] . '_' . (($i + 1) * ($RowTour->MaxArrows / $RowTour->TtNumEnds) - 1) . '_' . $MyRow->EnId . '">' . $TotRunning . '</div></td>';
                    echo '</tr>';
                }
                echo '</tr>';
                echo '<tr>';
                echo '<td colspan="' . ($NumArrows + 1) . '">&nbsp;</td>';
                echo '<th>' . get_text('Total') . '</th>';
                echo '<td class="Bold Right"><div id="idTotScore_' . $_REQUEST['x_Dist'] . '_' . $MyRow->EnId . '">' . $MyRow->SelScore . '</div></td>';
                echo '</tr>';
                echo '</table>';
                ?>
</td>
</tr>
Exemplo n.º 3
1
             ${"PosArr" . $Side}[$v * $nARR + $FirstEmpty[$Side]] = $Coords;
         } else {
             ${"Tie" . $Side}[$FirstEmpty[$Side]] = " ";
             foreach ($MySym as $kk => $vv) {
                 if ($MySym[$kk]['R'] == $Value) {
                     ${"Tie" . $Side}[$v * $nARR + $FirstEmpty[$Side]] = $kk;
                     break;
                 }
             }
             ${"PosTie" . $Side}[$FirstEmpty[$Side]] = $Coords;
         }
     }
 }
 //Gestisco i totali
 $TotSx = ValutaArrowString($ArrSx);
 $TotDx = ValutaArrowString($ArrDx);
 // Preparo le query di update
 if (debug) {
     print 'ArrSx --> ' . $ArrSx . '<br>';
     print 'TieSx --> ' . $TieSx . '<br>';
     print 'TotSx --> ' . $TotSx . '<br>';
     print 'PosArrSx --> ' . $PosArrSx . '<br>';
 }
 $MyUpQuerySx = "UPDATE TeamFinals SET " . "TfArrowString='" . $ArrSx . "'," . "TfTieBreak=" . StrSafe_DB($TieSx) . "," . "TfScore=" . StrSafe_DB($TotSx) . "," . "TfArrowPosition='" . implode('|', $PosArrSx) . "'," . "TfTiePosition='" . implode('|', $PosTieSx) . "'," . "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE TfMatchNo=" . StrSafe_DB($MatchSx) . " AND TfEvent=" . StrSafe_DB($_REQUEST['Event']) . " " . "AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
 $MyUpQueryDx = "UPDATE TeamFinals SET " . "TfArrowString=" . StrSafe_DB($ArrDx) . "," . "TfTieBreak=" . StrSafe_DB($TieDx) . "," . "TfScore=" . StrSafe_DB($TotDx) . "," . "TfArrowPosition='" . implode('|', $PosArrDx) . "'," . "TfTiePosition=" . StrSafe_DB(implode('|', $PosTieDx)) . "," . "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE TfMatchNo=" . StrSafe_DB($MatchDx) . " AND TfEvent=" . StrSafe_DB($_REQUEST['Event']) . " " . "AND TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
 if (debug) {
     print $MyUpQuerySx . '<br>';
     print $MyUpQueryDx . '<br>';
     exit;
 }
 $RsSx = safe_w_sql($MyUpQuerySx);
Exemplo n.º 4
1
             //print $arrG[$i].'<br>';
             $arrG_P[] = DecodeFromLetter($arrG[$i]);
             //$arrG_N[]=$LetterPoint[$arrG[$i]]['N'];
             $arrG_N[] = ValutaArrowString($arrG[$i]);
         }
         //								print '<pre>';
         //								print_r($arrG_P);
         //								print_r($arrG_N);
         //								print '</pre>';
         //								exit;
         $arrX_P = array();
         $arrX_N = array();
         for ($i = 0; $i < count($arrX); ++$i) {
             $arrX_P[] = DecodeFromLetter($arrX[$i]);
             //$arrX_N[]=$LetterPoint[$arrX[$i]]['N'];
             $arrX_N[] = ValutaArrowString($arrX[$i]);
         }
         // inclusione
         if (array_intersect($arrX_P, $arrG_P) !== array() || array_intersect($arrX_N, $arrG_N) !== array()) {
             if ($Value > $Row->Gold) {
                 $Errore = 1;
             }
         } else {
             if ($Row->Score - $Row->Gold * $minG - $Value * $minX < 0) {
                 $Errore = 1;
             }
         }
     }
 } else {
     $Errore = 1;
 }
Exemplo n.º 5
1
 /**
  * read()
  *
  * @Override
  *
  * (non-PHPdoc)
  * @see ianseo/Common/Rank/Obj_Rank#calculate()
  */
 public function read()
 {
     $f = $this->safeFilter();
     $filter = $f !== false ? $f : "";
     if (array_key_exists('cutRank', $this->opts) && is_numeric($this->opts['cutRank']) && $this->opts['cutRank'] > 0) {
         $filter .= "AND Teams.teRank<={$this->opts['cutRank']} ";
     }
     $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tTeTournament,CoId,TeSubTeam,CoCode,CoName, TeEvent,EvEventName,ToNumEnds,ToNumDist,ToMaxDistScore,FlContAssoc,\r\n\t\t\t\t\tEvMaxTeamPerson, EvProgr, EvFinalFirstPhase,\r\n\t\t\t\t\tClDescription, DivDescription,\r\n\t\t\t\t\tEnId,EnCode,EnFirstName,upper(EnFirstName) EnFirstNameUpper,EnName,EnClass,EnDivision,EnAgeClass,EnSubClass,\r\n\t\t\t\t\tIF(EvFinalFirstPhase=48, 104, IF(EvFinalFirstPhase=24, 56, (EvFinalFirstPhase*2))) AS QualifiedNo,\tEvQualPrintHead,\r\n\t\t\t\t\tSUBSTRING(QuTargetNo,1,1) AS Session, SUBSTRING(QuTargetNo,2) AS TargetNo,\r\n\t\t\t\t\tQuHits*EvMaxTeamPerson AS Arrows_Shot, QuScore, TeScore,TeRank, TeGold, TeXnine, ToGolds, ToXNine,TeHits,\r\n\t\t\t\t\tTeRank, EvRunning, IF(EvRunning=1,IFNULL(ROUND(TeScore/TeHits,3),0),0) as RunningScore,\r\n\t\t\t\t\tABS(TeSO) AS RankBeforeSO,\r\n\t\t\t\t\ttie.Quanti,\r\n\t\t\t\t\tTeTieBreak,(TeSO>0) AS isSO,IFNULL(sqY.Quanti,1) AS `NumCT`,\r\n\t\t\t\t\tIFNULL(Td1,'.1.') as Td1, IFNULL(Td2,'.2.') as Td2, IFNULL(Td3,'.3.') as Td3, IFNULL(Td4,'.4.') as Td4, IFNULL(Td5,'.5.') as Td5, IFNULL(Td6,'.6.') as Td6, IFNULL(Td7,'.7.') as Td7, IFNULL(Td8,'.8.') as Td8,\r\n\t\t\t\t\tTeTimeStamp, DiEnds, DiArrows\r\n\t\t\t\tFROM\r\n\t\t\t\t\tTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeams\r\n\t\t\t\t\tON ToId=TeTournament AND TeFinEvent=1\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tCountries\r\n\t\t\t\t\tON TeCoId=CoId AND TeTournament=CoTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEvents\r\n\t\t\t\t\tON TeEvent=EvCode AND ToId=EvTournament AND EvTeamEvent=1\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tTeEvent as tieEvent, TeFinEvent as tieFinEvent, TeTournament as tieTournament, TeScore as tieScore, Count(*) as Quanti\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tTeTournament = {$this->tournament}  {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tTeEvent, TeFinEvent, TeTournament, TeScore\r\n\t\t\t\t\t\t) AS tie\r\n\t\t\t\t\tON Teams.TeEvent=tie.tieEvent AND Teams.TeTournament=tie.tieTournament AND Teams.TeFinEvent=tie.tieFinEvent AND Teams.TeScore=tie.tieScore\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeamComponent AS tc\r\n\t\t\t\t\tON Teams.TeCoId=tc.TcCoId AND Teams.TeSubTeam=tc.TcSubTeam AND  Teams.TeEvent=tc.TcEvent AND Teams.TeTournament=tc.TcTournament AND Teams.TeFinEvent=tc.TcFinEvent\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEntries\r\n\t\t\t\t\tON TcId=EnId\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tQualifications\r\n\t\t\t\t\tON EnId=QuId\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tDivisions\r\n\t\t\t\t\tON EnDivision=DivId AND EnTournament=DivTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tClasses\r\n\t\t\t\t\tON EnClass=ClId AND EnTournament=ClTournament\r\n\t\t\t\t/* Contatori per CT (gialli)*/\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tTeEvent as sqyEvent,Count(*) as Quanti, TeSO as sqyRank, TeTournament as sqyTournament\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tTeTournament = {$this->tournament} AND TeFinEvent=1 AND TeSO!=0 {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tTeSO, TeEvent, TeTournament\r\n\t\t\t\t\t\t) AS sqY\r\n\t\t\t\t\tON sqY.sqyRank=TeSO AND sqY.sqyEvent=Teams.TeEvent AND Teams.TeFinEvent=1 AND sqY.sqyTournament=Teams.TeTournament\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tTournamentDistances\r\n\t\t\t\t\tON ToType=TdType AND TdTournament=ToId AND TeEvent like TdClasses\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tFlags\r\n\t\t\t\t\t\tON FlIocCode='FITA' and FlCode=CoCode and FlTournament=-1\r\n\t\t\t\t\tleft join DistanceInformation on EnTournament=DiTournament and DiSession=1 and DiDistance=1 and DiType='Q'\r\n\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\tTeams.TeTournament={$this->tournament}\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tEvProgr,TeEvent, RunningScore DESC, TeRank ASC, TeGold DESC, TeXnine DESC, CoCode, TeSubTeam ,tc.TcOrder\r\n\t\t\t";
     $r = safe_r_sql($q);
     $this->data['meta']['title'] = get_text('ResultSqAbs', 'Tournament');
     $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00';
     $this->data['sections'] = array();
     $myEv = '';
     $myTeam = '';
     if (safe_num_rows($r) > 0) {
         $section = null;
         while ($row = safe_fetch($r)) {
             if ($myEv != $row->TeEvent) {
                 if ($myEv != '') {
                     foreach ($section["meta"]["arrowsShot"] as $k => $v) {
                         if ($v) {
                             $section["meta"]["sesArrows"][$k] = get_text('AfterXArrows', 'Common', $v);
                         }
                     }
                     $this->data['sections'][$myEv] = $section;
                     $section = null;
                 }
                 $myEv = $row->TeEvent;
                 $fields = array('id' => 'Id', 'countryCode' => get_text('CountryCode'), 'countryName' => get_text('Country'), 'subteam' => get_text('PartialTeam'), 'athletes' => array('name' => get_text('Athletes'), 'fields' => array('id' => 'Id', 'bib' => get_text('Code', 'Tournament'), 'session' => get_text('Session'), 'target' => get_text('Target'), 'athlete' => get_text('Athlete'), 'familyname' => get_text('FamilyName', 'Tournament'), 'givenname' => get_text('Name', 'Tournament'), 'div' => get_text('Division'), 'class' => get_text('Cl'), 'ageclass' => get_text('AgeCl'), 'subclass' => get_text('SubCl', 'Tournament'), 'quscore' => get_text('TotaleScore'))), 'rank' => get_text('PositionShort'), 'rankBeforeSO' => '', 'score' => $row->EvRunning == 1 ? get_text('ArrowAverage') : get_text('TotaleScore'), 'gold' => $row->ToGolds, 'xnine' => $row->ToXNine, 'hits' => get_text('Arrows', 'Tournament'), 'tiebreak' => get_text('TieArrows'), 'tie' => get_text('Tie'), 'ct' => get_text('CoinTossShort', 'Tournament'), 'so' => get_text('ShotOffShort', 'Tournament'));
                 $distFields = array();
                 $distValid = $row->ToNumDist;
                 foreach (range(1, 8) as $n) {
                     $distFields['dist_' . $n] = $row->{'Td' . $n};
                     if ($distFields['dist_' . $n] == '-') {
                         $distValid--;
                     }
                 }
                 $section = array('meta' => array('event' => $myEv, 'firstPhase' => $row->EvFinalFirstPhase, 'descr' => get_text($row->EvEventName, '', '', true), 'qualifiedNo' => $row->QualifiedNo, 'printHeader' => $row->EvQualPrintHead, 'order' => $row->EvProgr, 'numDist' => $distValid, 'maxScore' => $row->ToMaxDistScore * $row->EvMaxTeamPerson, 'maxArrows' => ($row->DiEnds ? $row->DiEnds * $row->DiArrows : $row->ToNumEnds * 3) * $row->EvMaxTeamPerson, 'arrowsShot' => array(), 'sesArrows' => array(), 'running' => $row->EvRunning == 1 ? 1 : 0, 'fields' => $fields), 'items' => array());
             }
             if ($myTeam != $row->CoId . $row->TeSubTeam . $row->TeEvent) {
                 $tmpArr = array();
                 for ($countArr = 0; $countArr < strlen(trim($row->TeTieBreak)); $countArr = $countArr + $row->EvMaxTeamPerson) {
                     $tmpArr[] = ValutaArrowString(substr(trim($row->TeTieBreak), $countArr, $row->EvMaxTeamPerson)) . ",";
                 }
                 $item = array('id' => $row->CoId, 'countryCode' => $row->CoCode, 'contAssoc' => $row->FlContAssoc, 'countryName' => $row->CoName, 'subteam' => $row->TeSubTeam, 'athletes' => array(), 'rank' => $row->TeRank, 'rankBeforeSO' => $row->RankBeforeSO, 'score' => $row->EvRunning == 1 ? $row->RunningScore : $row->TeScore, 'gold' => $row->TeGold, 'xnine' => $row->TeXnine, 'hits' => $row->TeHits, 'recordGap' => $row->Arrows_Shot * 10 - $row->TeScore, 'tiebreak' => $row->TeTieBreak, 'tiebreakDecoded' => $row->TeTieBreak ? 'T.' . implode(',', $tmpArr) : '', 'ct' => $row->NumCT, 'tie' => $row->Quanti > 1, 'so' => $row->isSO);
                 //Gestisco il numero di frecce tirate per sessione
                 if (empty($section["meta"]["arrowsShot"][$row->Session]) || $section["meta"]["arrowsShot"][$row->Session] <= $row->Arrows_Shot) {
                     $section["meta"]["arrowsShot"][$row->Session] = $row->Arrows_Shot;
                 }
                 $section['items'][] = $item;
                 if ($row->TeTimeStamp > $this->data['meta']['lastUpdate']) {
                     $this->data['meta']['lastUpdate'] = $row->TeTimeStamp;
                 }
                 $myTeam = $row->CoId . $row->TeSubTeam . $row->TeEvent;
             }
             if (!array_key_exists('components', $this->opts) || $this->opts['components']) {
                 $athlete = array('id' => $row->EnId, 'bib' => $row->EnCode, 'session' => $row->Session, 'target' => $row->TargetNo, 'athlete' => $row->EnFirstNameUpper . ' ' . $row->EnName, 'familyname' => $row->EnFirstName, 'familynameUpper' => $row->EnFirstNameUpper, 'givenname' => $row->EnName, 'div' => $row->EnDivision, 'class' => $row->EnClass, 'ageclass' => $row->EnAgeClass, 'subclass' => $row->EnSubClass, 'quscore' => $row->QuScore);
                 $section['items'][count($section['items']) - 1]['athletes'][] = $athlete;
             }
         }
         foreach ($section["meta"]["arrowsShot"] as $k => $v) {
             if ($v) {
                 $section["meta"]["sesArrows"][$k] = str_replace("<br/>", " ", get_text('AfterXArrows', 'Common', $v));
             }
         }
         // ultimo giro
         $this->data['sections'][$myEv] = $section;
     }
 }
Exemplo n.º 6
0
 }
 $score = $score1 . ' - ' . $score2;
 $setPoints1 = '';
 $setPoints2 = '';
 if ($myRow->tie1 == 2 && $myRow->tie2 != 2) {
     $setPoints1 = get_text('Bye');
 } elseif ($myRow->tie1 != 2 && $myRow->tie2 == 2) {
     $setPoints2 = get_text('Bye');
 } elseif ($myRow->matchMode == 1) {
     list($setPoints1, $setPoints2) = purgeSetPoints($myRow->setPoints1, $myRow->setPoints2);
 } else {
     for ($cEnd = 0; $cEnd < strlen($myRow->arrowString1); $cEnd += $obj->arrows) {
         $setPoints1 = $setPoints1 . ValutaArrowString(substr($myRow->arrowString1, $cEnd, $obj->arrows)) . " ";
     }
     for ($cEnd = 0; $cEnd < strlen($myRow->arrowString2); $cEnd += $obj->arrows) {
         $setPoints2 = $setPoints2 . ValutaArrowString(substr($myRow->arrowString2, $cEnd, $obj->arrows)) . " ";
     }
 }
 // le frecce di tiebreak
 for ($index = 1; $index <= 2; ++$index) {
     $arrowstring = $myRow->{'tiebreak' . $index};
     if (trim($arrowstring) != '') {
         //print 'pp';
         $tmp = array();
         for ($i = 0; $i < strlen($arrowstring); ++$i) {
             $tmp[] = DecodeFromLetter($arrowstring[$i]);
         }
         ${'setPoints' . $index} .= ' ' . implode(' ', $tmp);
     }
 }
 /*
Exemplo n.º 7
0
     $tmp0 = explode("|", $vItem['setPoints']);
     $tmp1 = explode("|", $vItem['oppSetPoints']);
     for ($i = 0; $i < $objParam->ends; $i++) {
         if ($tmp0[$i] || $tmp1[$i]) {
             $end[] = array('endnum' => $i + 1, 'endscore' => $tmp0[$i], 'points' => $tmp0[$i] > $tmp1[$i] ? 2 : ($tmp0[$i] == $tmp1[$i] ? 1 : 0));
             $oppEnd[] = array('endnum' => $i + 1, 'endscore' => $tmp1[$i], 'points' => $tmp1[$i] > $tmp0[$i] ? 2 : ($tmp0[$i] == $tmp1[$i] ? 1 : 0));
         }
     }
     if ($vItem['tiebreakDecoded'] && $vItem['oppTiebreakDecoded']) {
         $end[] = array('endnum' => 'S.O.', 'endscore' => $vItem['tiebreakDecoded'], 'points' => $vItem['tie'] ? 1 : 0);
         $oppEnd[] = array('endnum' => 'S.O.', 'endscore' => $vItem['oppTiebreakDecoded'], 'points' => $vItem['oppTie'] ? 1 : 0);
     }
 } else {
     $running = array(0, 0);
     for ($i = 0; $i < $objParam->ends; $i++) {
         $tmp = array(ValutaArrowString(substr($vItem['arrowstring'], $i * $objParam->arrows, $objParam->arrows)), ValutaArrowString(substr($vItem['oppArrowstring'], $i * $objParam->arrows, $objParam->arrows)));
         $running[0] += $tmp[0];
         $running[1] += $tmp[1];
         if ($tmp[0] || $tmp[1]) {
             $end[] = array('endnum' => $i + 1, 'endscore' => $tmp[0], 'points' => $running[0]);
             $oppEnd[] = array('endnum' => $i + 1, 'endscore' => $tmp[1], 'points' => $running[1]);
         }
     }
     if ($vItem['tiebreakDecoded'] && $vItem['oppTiebreakDecoded']) {
         $end[] = array('endnum' => 'S.O.', 'endscore' => $vItem['tiebreakDecoded'], 'points' => $running[0]);
         $oppEnd[] = array('endnum' => 'S.O.', 'endscore' => $vItem['oppTiebreakDecoded'], 'points' => $running[1]);
     }
 }
 $json_array['competitors'] = array();
 $json_array['competitors'][] = array('winner' => (int) $vItem['winner'], 'matchid' => $kSec . "|" . ($EventType ? "T" : "I") . "|" . $vItem['matchNo'], 'score' => $vSec['meta']['matchMode'] ? $vItem['setScore'] : $vItem['score'], 'ends' => $end);
 $json_array['competitors'][] = array('winner' => (int) $vItem['oppWinner'], 'matchid' => $kSec . "|" . ($EventType ? "T" : "I") . "|" . $vItem['oppMatchNo'], 'score' => $vSec['meta']['matchMode'] ? $vItem['oppSetScore'] : $vItem['oppScore'], 'ends' => $oppEnd);
Exemplo n.º 8
0
                $out .= '<tr>';
                $out .= '<th>' . ($i + 1) . '</th>';
                // celle di input
                $idx = -1;
                for ($j = 0; $j < $cols; ++$j) {
                    $idx = $i * $cols + $j;
                    $name = 's_' . $myRow->{'match' . $m} . '_' . $idx;
                    /*
                     * il nome della textbox indica il gruppo ed è nella forma
                     * s_match_row
                     *
                     * mentre l'id è nella forma
                     * s_match_arrowIndex
                     */
                    if (!empty($myRow->{'arrowString' . $m}) && array_key_exists($myRow->{'arrowString' . $m}[$idx], $validData["Arrows"])) {
                        $pr += ValutaArrowString($myRow->{'arrowString' . $m}[$idx]);
                    } else {
                        $prValues = false;
                    }
                    $out .= '<td class="Center"><input type="text" id="' . $name . '" size="2" maxlength="3" onclick="this.select();"
									value="' . (!empty($myRow->{'arrowString' . $m}) ? DecodeFromLetter($myRow->{'arrowString' . $m}[$idx]) : '') . '"' . ($j == 0 ? 'onfocus="setStarter(this.id);"' : '') . ' /></td>';
                }
                // aggiungo i progressivi in $setPoints
                $setPoints[$m][$i] = $pr;
                $setLoaded[$m][$i] = $prValues;
                $totCum += $pr;
                // il totale cumulativo è la somma dei progressivi
                /*
                 * questi id sono nella forma
                 *
                 * cosa_$match_$from_$idx
Exemplo n.º 9
0
// IN QUESTO PUNTO VA INSERITO L'EVENTUALE AZZERAMENTO DELLE FRECCE DI VOLEE
// BASATO SULLA DISTANZA NEL TEMPO DI FinDateTime
if (false and $r->TooOld) {
    $Arrows = '';
    $OppArrows = '';
}
// setpoints
// setpoints/setscore: se setscore è il punteggio totale degli scontri (es. 4 - 0),
//     setpoints è il totale freccie del set in corso ( 54 - 51)
//		se invece siamo a far vedere i ties, allora fa vedere l'ultima freccia di spareggio
if ($T1 or $T2) {
    $tot1 = $T1;
    $tot2 = $T2;
} else {
    $tot1 = ValutaArrowString($Arrows) . ($Arrows != strtoupper($Arrows) ? '*' : '');
    $tot2 = ValutaArrowString($OppArrows) . ($OppArrows != strtoupper($OppArrows) ? '*' : '');
}
$Tg = $XmlDoc->createElement('setpoints', $tot1);
$Opp1->appendChild($Tg);
$Tg = $XmlDoc->createElement('setpoints', $tot2);
$Opp2->appendChild($Tg);
// arrows
for ($n = 0; $n < 6; $n++) {
    $End = substr($Arrows, $n, 1);
    $tot = !empty($Target[$End]['R']) ? $Target[$End]['R'] : '';
    $Tg = $XmlDoc->createElement('arrow' . ($n + 1), $tot);
    $Opp1->appendChild($Tg);
    $End = substr($OppArrows, $n, 1);
    $tot = !empty($Target[$End]['R']) ? $Target[$End]['R'] : '';
    $Tg = $XmlDoc->createElement('arrow' . ($n + 1), $tot);
    $Opp2->appendChild($Tg);
Exemplo n.º 10
0
function DrawScore(&$pdf, $MyRow, $MyRowOpp)
{
    global $CFG, $GridTotH, $CellH, $GoldW, $ArrowTotW, $TotalW, $NumRow, $StdCols, $NumColStd, $NumColField, $Fita3D, $FollowingRows, $WhereStartX, $WhereStartY, $FillWithArrows;
    $NumColStd = $MyRow->CalcArrows;
    $NumCol = $StdCols == 1 ? $NumColStd : $NumColField;
    $NumRows = $MyRow->CalcEnds;
    // ($Fita3D == 1  ? 8 : $MyRow->CalcEnds);
    $ColWidth = $ArrowTotW / $MyRow->CalcArrows;
    $TmpCellH = $GridTotH / $NumRows;
    if ($MyRow->GrMatchNo % 2 == 0 && $FollowingRows) {
        $pdf->AddPage();
    }
    $FollowingRows = true;
    $WhichScore = $MyRow->GrMatchNo % 2;
    $WhereX = $WhereStartX;
    $WhereY = $WhereStartY;
    //Intestazione Atleta
    $pdf->SetLeftMargin($WhereStartX[$WhichScore]);
    $pdf->SetY(35);
    // Flag of Country/Club
    if ($pdf->PrintFlags) {
        if (is_file($file = $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-Fl-' . $MyRow->CoCode . '.jpg')) {
            $H = 12;
            $W = 18;
            $OrgY = $pdf->gety();
            $OrgX = $ArrowTotW + 2 * $TotalW + $GoldW - 18;
            $pdf->Image($file, $pdf->getx() + $OrgX, $OrgY, $W, $H, 'JPG', '', '', true, 300, '', false, false, 1, true);
            $FlagOffset = $W + 1;
        }
    }
    $pdf->SetFont($pdf->FontStd, '', 10);
    $pdf->Cell(20, 12, get_text('Country') . ': ', 'LT', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell($ArrowTotW + 2 * $TotalW + $GoldW - 20, 12, $MyRow->TeamName . (strlen($MyRow->CoCode) > 0 ? ' (' . $MyRow->CoCode . ')' : ''), 'T', 1, 'L', 0);
    $pdf->SetFont($pdf->FontStd, '', 10);
    $pdf->Cell(20, 6, get_text('DivisionClass') . ': ', 'LB', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell($ArrowTotW + $TotalW + $GoldW - 20, 6, get_text($MyRow->EvEventName, '', '', true), 'B', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 8);
    $pdf->Cell($TotalW, 6, get_text('Target') . ' ' . $MyRow->FSTarget, '1', 1, 'C', 1);
    $pdf->SetXY($ArrowTotW + 2 * $TotalW + $GoldW + $WhereStartX[$WhichScore], 35);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell(2 * $GoldW, 6, get_text('Rank'), 'TLR', 1, 'C', 1);
    $pdf->SetXY($ArrowTotW + 2 * $TotalW + $GoldW + $WhereStartX[$WhichScore], $pdf->GetY());
    $pdf->SetFont($pdf->FontStd, 'B', 25);
    $pdf->Cell(2 * $GoldW, 12, $MyRow->TeRank, 'BLR', 1, 'C', 1);
    //Header
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell($GoldW, $CellH, '', 0, 0, 'C', 0);
    $pdf->Cell(2 * $GoldW + 2 * $TotalW + $ArrowTotW, $CellH, $MyRow->GrPhase !== '' ? get_text($MyRow->GrPhase . '_Phase') : '', 1, 0, 'C', 1);
    //	$WhereY[$WhichScore]=$pdf->GetY();
    //Winner Checkbox
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Rect($WhereX[$WhichScore] + $GoldW + 2, $WhereY[$WhichScore] + 2, $ColWidth - 4, $CellH - 4, 'DF', array(), array(255, 255, 255));
    if ($FillWithArrows && ($MyRow->Score > $MyRowOpp->Score || $MyRow->Score == $MyRowOpp->Score && $MyRow->TfTie > $MyRowOpp->TfTie)) {
        $tmpWidth = $pdf->GetLineWidth();
        $pdf->SetLineWidth($tmpWidth * 5);
        $pdf->Line($WhereX[$WhichScore] + $GoldW + 1, $WhereY[$WhichScore] + 1, $WhereX[$WhichScore] + $GoldW + $ColWidth - 1, $WhereY[$WhichScore] + $CellH - 1);
        $pdf->Line($WhereX[$WhichScore] + $GoldW + 1, $WhereY[$WhichScore] + $CellH - 1, $WhereX[$WhichScore] + $GoldW + $ColWidth - 1, $WhereY[$WhichScore] + 1);
        $pdf->SetLineWidth($tmpWidth);
    }
    $pdf->SetDefaultColor();
    $pdf->Cell($GoldW + $ColWidth, $CellH, '', 0, 0, 'C', 0);
    $pdf->Cell(2 * $GoldW + 2 * $TotalW + ($NumCol - 1) * $ColWidth, $CellH, get_text('Winner'), 0, 1, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY();
    // Row 2: Arrow numbers, Gold, Xs, Sto points, etc
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell($GoldW, $CellH, '', 0, 0, 'C', 0);
    for ($j = 0; $j < $MyRow->CalcArrows; $j++) {
        $pdf->Cell($ColWidth, $CellH, $j + 1, 1, 0, 'C', 1);
    }
    $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), $CellH, get_text($MyRow->EvMatchMode == 0 ? 'TotalProg' : 'SetTotal', 'Tournament'), 1, 0, 'C', 1);
    $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), $CellH, get_text('TotalShort', 'Tournament'), 1, 0, 'C', 1);
    if ($MyRow->EvMatchMode == 0) {
        $pdf->Cell($GoldW, $CellH, $pdf->prnGolds, 1, 0, 'C', 1);
        $pdf->Cell($GoldW, $CellH, $pdf->prnXNine, 1, 1, 'C', 1);
    } else {
        $pdf->Cell(2 * $GoldW, $CellH, get_text('SetPoints', 'Tournament'), 1, 0, 'C', 1);
        $pdf->Cell(2 / 5 * $TotalW, $CellH, get_text('TotalShort', 'Tournament'), 1, 1, 'C', 1);
    }
    $WhereY[$WhichScore] = $pdf->GetY();
    //Righe
    $ScoreTotal = 0;
    $ScoreGold = 0;
    $ScoreXnine = 0;
    $SetTotal = '';
    for ($i = 1; $i <= $NumRows; $i++) {
        $ScoreEndTotal = 0;
        $ScoreEndGold = 0;
        $ScoreEndXnine = 0;
        $pdf->SetFont($pdf->FontStd, 'B', 10);
        $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
        $pdf->Cell($GoldW, $TmpCellH, ($Fita3D || !$StdCols) && $MyRow->FSTarget ? (intval($MyRow->FSTarget) + $i - 2) % $NumRows + 1 : $i, 1, 0, 'C', 1);
        $pdf->SetFont($pdf->FontStd, '', 10);
        for ($j = 0; $j < $MyRow->CalcArrows; $j++) {
            $pdf->Cell($ColWidth, $TmpCellH, $FillWithArrows ? DecodeFromLetter(substr($MyRow->TfArrowString, ($i - 1) * $NumCol + $j, 1)) : '', 1, 0, 'C', 0);
        }
        $IsEndScore = trim(substr($MyRow->TfArrowString, ($i - 1) * $NumCol, $NumCol));
        list($ScoreEndTotal, $ScoreEndGold, $ScoreEndXnine) = ValutaArrowStringGX(substr($MyRow->TfArrowString, ($i - 1) * $NumCol, $NumCol), $pdf->goldsChars, $pdf->xNineChars);
        $ScoreTotal += $ScoreEndTotal;
        $ScoreGold += $ScoreEndGold;
        $ScoreXnine += $ScoreEndXnine;
        $pdf->SetFont($pdf->FontStd, '', $MyRow->EvMatchMode == 0 ? 10 : 12);
        $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), $TmpCellH, $FillWithArrows && $IsEndScore ? $ScoreEndTotal : '', 1, 0, 'C', 0);
        $pdf->SetFont($pdf->FontStd, '', $MyRow->EvMatchMode == 0 ? 12 : 10);
        $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), $TmpCellH, $FillWithArrows && $IsEndScore ? $ScoreTotal : '', 1, 0, 'C', 0);
        if ($MyRow->EvMatchMode == 0) {
            $pdf->Cell($GoldW, $TmpCellH, $FillWithArrows && strlen(substr($MyRow->TfArrowString, ($i - 1) * $NumCol, $j)) ? $ScoreEndGold : '', 1, 0, 'C', 0);
            $pdf->Cell($GoldW, $TmpCellH, $FillWithArrows && strlen(substr($MyRow->TfArrowString, ($i - 1) * $NumCol, $j)) ? $ScoreEndXnine : '', 1, 1, 'C', 0);
        } else {
            $SetTotSx = '';
            if ($IsEndScore && $FillWithArrows) {
                $SetPointSx = ValutaArrowString(substr($MyRow->TfArrowString, ($i - 1) * $NumCol, $NumCol));
                $SetPointDx = ValutaArrowString(substr($MyRowOpp->TfArrowString, ($i - 1) * $NumCol, $NumCol));
                if ($SetPointSx > $SetPointDx) {
                    $SetTotSx = 2;
                } elseif ($SetPointSx < $SetPointDx) {
                    $SetTotSx = 0;
                } else {
                    $SetTotSx = 1;
                }
                $SetTotal = intval($SetTotal) + $SetTotSx;
            }
            $pdf->SetFont($pdf->FontStd, 'B', 11);
            if ($SetTotSx == 2 && $FillWithArrows) {
                $pdf->Circle($pdf->GetX() + $GoldW / 3, $pdf->GetY() + $TmpCellH / 2, $GoldW / 3, 0, 360, 'FD');
            }
            $pdf->Cell(2 * $GoldW / 3, $TmpCellH, '2', 1, 0, 'C', 0);
            if ($SetTotSx == 1 && $FillWithArrows) {
                $pdf->Circle($pdf->GetX() + $GoldW / 3, $pdf->GetY() + $TmpCellH / 2, $GoldW / 3, 0, 360, 'FD');
            }
            $pdf->Cell(2 * $GoldW / 3, $TmpCellH, '1', 1, 0, 'C', 0);
            if ($SetTotSx == 0 && $IsEndScore && $FillWithArrows) {
                $pdf->Circle($pdf->GetX() + $GoldW / 3, $pdf->GetY() + $TmpCellH / 2, $GoldW / 3, 0, 360, 'FD');
            }
            $pdf->Cell(2 * $GoldW / 3, $TmpCellH, '0', 1, 0, 'C', 0);
            $pdf->Cell($TotalW * 2 / 5, $TmpCellH, $IsEndScore && $FillWithArrows ? $SetTotal : '', 1, 1, 'C', 0);
        }
        $WhereY[$WhichScore] = $pdf->GetY();
    }
    //Tie Break
    $closeToCenter = false;
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore] + $CellH / 4);
    $pdf->SetFont($pdf->FontStd, 'B', 8);
    $pdf->Cell($GoldW, $TmpCellH + 1 + $GoldW, get_text('TB'), 1, 0, 'C', 1);
    $pdf->SetFont($pdf->FontStd, '', 10);
    for ($j = 0; $j < $MyRow->CalcSO; $j++) {
        $pdf->Cell($ArrowTotW / $MyRow->CalcSO, $TmpCellH, $FillWithArrows ? DecodeFromLetter(substr($MyRow->TfTieBreak, $j, 1)) : '', 1, 0, 'C', 0);
        if (substr($FillWithArrows ? DecodeFromLetter(substr($MyRow->TfTieBreak, $j, 1)) : '', -1, 1) == "*") {
            $closeToCenter = true;
        }
    }
    $SOY = $pdf->GetY();
    //Totale
    $pdf->SetXY($pdf->GetX(), $WhereY[$WhichScore]);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    if ($MyRow->EvMatchMode == 0) {
        $pdf->Cell($TotalW, $TmpCellH, get_text('Total'), 0, 0, 'R', 0);
        $pdf->SetFont($pdf->FontStd, 'B', 12);
        $pdf->Cell($TotalW, $TmpCellH, $FillWithArrows && strlen($MyRow->TfArrowString) ? $ScoreTotal : '', 1, 0, 'C', 0);
        $pdf->SetFont($pdf->FontStd, '', 12);
        $pdf->Cell($GoldW, $TmpCellH, $FillWithArrows && strlen($MyRow->TfArrowString) ? $ScoreGold : '', 1, 0, 'C', 0);
        $pdf->Cell($GoldW, $TmpCellH, $FillWithArrows && strlen($MyRow->TfArrowString) ? $ScoreXnine : '', 1, 1, 'C', 0);
    } else {
        $pdf->Cell($TotalW * 8 / 5, $TmpCellH, '', 0, 0, 'R', 0);
        $pdf->SetFont($pdf->FontStd, 'B', 10);
        $pdf->Cell(2 * $GoldW, $TmpCellH, get_text('Total'), 0, 0, 'R', 0);
        $pdf->SetFont($pdf->FontStd, 'B', 14);
        $pdf->Cell(2 / 5 * $TotalW, $TmpCellH, $FillWithArrows ? $MyRow->TfSetScore : '', 1, 1, 'C', 0);
    }
    //Closet to the center
    $pdf->SetFont($pdf->FontStd, '', 9);
    $pdf->SetXY($WhereX[$WhichScore] + $GoldW, $SOY + $TmpCellH + 1);
    $pdf->Cell($ColWidth, $GoldW, '', 1, 0, 'R', 0);
    if ($closeToCenter) {
        $tmpWidth = $pdf->GetLineWidth();
        $pdf->SetLineWidth($tmpWidth * 5);
        $pdf->Line($WhereX[$WhichScore] + $GoldW, $SOY + $TmpCellH + 1, $WhereX[$WhichScore] + $GoldW + $ColWidth, $SOY + $TmpCellH + 1 + $GoldW);
        $pdf->Line($WhereX[$WhichScore] + $GoldW, $SOY + $TmpCellH + 1 + $GoldW, $WhereX[$WhichScore] + $GoldW + $ColWidth, $SOY + $TmpCellH + 1);
        $pdf->SetLineWidth($tmpWidth);
    }
    $pdf->Cell($ColWidth * ($NumCol - 1), $CellH * 2 / 4, get_text('Close2Center', 'Tournament'), 0, 0, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY() + 10;
    //Firme
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->SetFont($pdf->FontStd, 'I', 7);
    $pdf->Cell($ColWidth + $GoldW, 4, get_text('Archer'), 'B', 0, 'L', 0);
    $pdf->Cell(($NumCol - 1) * $ColWidth + 2 * ($TotalW + $GoldW), 4, '', 'B', 1, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY() + 6;
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell($ColWidth + $GoldW, 4, get_text('Scorer'), 'B', 0, 'L', 0);
    $pdf->Cell(($NumCol - 1) * $ColWidth + 2 * ($TotalW + $GoldW), 4, '', 'B', 1, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY() + 6;
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell($ColWidth + $GoldW, 4, get_text('JudgeNotes'), 'B', 0, 'L', 0);
    $pdf->Cell(($NumCol - 1) * $ColWidth + 2 * ($TotalW + $GoldW), 4, '', 'B', 1, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY();
}
Exemplo n.º 11
0
         $dLeft = ValutaArrowString(substr($myRow->tiebreak1, 0, $obj->so));
         $dRight = ValutaArrowString(substr($myRow->tiebreak2, 0, $obj->so));
         $lTot = $dLeft;
         $rTot = $dRight;
         $tlArr = str_pad(substr($myRow->tiebreak1, 0, $obj->so), 3, " ");
         $trArr = str_pad(substr($myRow->tiebreak2, 0, $obj->so), 3, " ");
         for ($j = 0; $j < $obj->so; $j++) {
             if (substr($tlArr, $j, 1) <= "a") {
                 $lArr .= DecodeFromLetter(substr($tlArr, $j, 1)) != "10" ? DecodeFromLetter(substr($tlArr, $j, 1)) : chr(158);
             } else {
                 $lArr .= DecodeFromLetter(substr($tlArr, $j, 1)) != "10*" ? chr(160 + ValutaArrowString(substr($tlArr, $j, 1))) : chr(158);
             }
             if (substr($trArr, $j, 1) <= "a") {
                 $rArr .= DecodeFromLetter(substr($trArr, $j, 1)) != "10" ? DecodeFromLetter(substr($trArr, $j, 1)) : chr(158);
             } else {
                 $rArr .= DecodeFromLetter(substr($trArr, $j, 1)) != "10*" ? chr(160 + ValutaArrowString(substr($trArr, $j, 1))) : chr(158);
             }
         }
         $lSum = 'TB';
         $rSum = 'TB';
     }
     $dCenter = "";
 }
 /*
 echo "Left Arrows:" . $lArr . "<br>";
 echo "Right Arrows:" . $rArr . "<br>";
 echo "Left Sum:" . $lSum . "<br>";
 echo "Right Sum:" . $rSum . "<br>";
 echo "Left Total:" . $lTot . "<br>";
 echo "Right Total:" . $rTot . "<br><br>";
 echo "Left Display:" . $dLeft . "<br>";
Exemplo n.º 12
0
for ($n = 0; $n < 6; $n++) {
    $End = substr($Arrows, $n, 1);
    $tot = ValutaArrowString($End);
    $Tg = $XmlDoc->createElement('arrow' . ($n + 1));
    $Tg->appendChild($XmlDoc->createCDATASection($tot));
    $Opp1->appendChild($Tg);
    $End = substr($OppArrows, $n, 1);
    $tot = ValutaArrowString($End);
    $Tg = $XmlDoc->createElement('arrow' . ($n + 1));
    $Tg->appendChild($XmlDoc->createCDATASection($tot));
    $Opp2->appendChild($Tg);
}
// controllo della freccia mancante "X to win/tie/lead"
if (false and abs($dif = strlen(trim($Arrows)) - strlen(trim($OppArrows))) == 1) {
    $v1 = ValutaArrowString($Arrows);
    $v2 = ValutaArrowString($OppArrows);
    $v = $dif == 1 ? $v1 - $v2 : $v2 - $v1;
    // se la freccia da fare è il valore massimo di quel bersaglio allora settiamo il "totie"
    if ($v == GetHigherTargetValue($Target)) {
        $Tg = $XmlDoc->createElement('xtotieset', $dif == 1 ? 0 : 1);
        $Opp1->appendChild($Tg);
        $Tg = $XmlDoc->createElement('xtotieset', $dif == 1 ? 1 : 0);
        $Opp2->appendChild($Tg);
    } else {
        $Tg = $XmlDoc->createElement('xtotieset', 0);
        $Opp1->appendChild($Tg);
        $Tg = $XmlDoc->createElement('xtotieset', 0);
        $Opp2->appendChild($Tg);
    }
    $Tg = $XmlDoc->createElement('xtowin', $dif == 1 ? $v : 1000);
    $Opp1->appendChild($Tg);
Exemplo n.º 13
0
 $SemaforoDx = '&nbsp;';
 $ScoreSx = '';
 $ScoreDx = '';
 $InsertSx = '';
 $InsertDx = '';
 /*************************
 Conteggio i punti di Set
 *************************/
 $SetPointSx = array();
 $SetPointDx = array();
 $SetTotSx = array();
 $SetTotDx = array();
 if ($MyRow->MatchMode != 0) {
     for ($i = 0; $i < $maxArrows; $i = $i + $nARR) {
         $SetPointSx[] = ValutaArrowString(substr($MyRow->ArrowString, $i, $nARR));
         $SetPointDx[] = ValutaArrowString(substr($MyRow->OppArrowString, $i, $nARR));
         if (strlen(trim(substr($MyRow->ArrowString, $i, $nARR))) == $nARR && strlen(trim(substr($MyRow->OppArrowString, $i, $nARR))) == $nARR && ctype_upper(substr($MyRow->ArrowString, $i, $nARR)) && ctype_upper(substr($MyRow->OppArrowString, $i, $nARR))) {
             if ($SetPointSx[$i / $nARR] > $SetPointDx[$i / $nARR]) {
                 $SetTotSx[] = 2;
                 $SetTotDx[] = 0;
             } else {
                 if ($SetPointSx[$i / $nARR] < $SetPointDx[$i / $nARR]) {
                     $SetTotSx[] = 0;
                     $SetTotDx[] = 2;
                 } else {
                     $SetTotSx[] = 1;
                     $SetTotDx[] = 1;
                 }
             }
         }
     }
Exemplo n.º 14
0
 /**
  * Importa le sezioni <entry> verificando che siano nella forma giusta
  *
  */
 public function import()
 {
     // il vettore contiene gli indici dei nodi entry non importati
     $badEntries = array();
     // contatore dei nodi importati
     $importedEntries = 0;
     $G = $this->G;
     $X = $this->X;
     if (debug) {
         print 'Phase: ' . $this->getPhase() . '<br>';
         print 'Session: ' . $this->getSession() . '<br>';
         print 'Distance: ' . $this->getDistance() . '<br>';
         print 'End: ' . $this->getEnd() . '<br>';
         print 'Arrows: ' . $this->getArrows() . '<br>';
         print 'MaxArrows: ' . $this->getMaxArrows() . '<br>';
     }
     // Metodo da chimare dopo tutti gli import (in base alla fase importata)
     $postImportMethod = '';
     // parametro per il metodo $postImportMethod
     $postParam = null;
     switch ($this->getPhase()) {
         case ARF::QUALIFICATION:
             $postImportMethod = 'resetQualsShootOff';
             break;
         case ARF::ELIMINATION:
             $postImportMethod = 'resetElimShootOff';
             break;
         case ARF::INDIVIDUAL_FINAL:
         case ARF::TEAM_FINAL:
             $postImportMethod = 'nextPhase';
             break;
     }
     // collezione di entry
     $entries = $this->xmlDoc->getElementsByTagName('entry');
     $c = $entries->length;
     if ($c == 0) {
         $this->setError(1);
         return false;
     }
     // il vettore contiene gli id delle persone a cui occorre azzerrare lo shootoff (QUALIFICATION e ELIMINATION)
     $shootOffIds = array();
     // Vettore delle chiavi per il passaggio di fase (INDIVIDULAL_FINAL TEAM_FINAL)
     $keysNextPhase = array();
     for ($i = 0; $i < $c; ++$i) {
         $arrowString = '##@@##';
         $e = $entries->item($i);
         // verifico la forma del nodo
         if (!$this->verifyEntry($e)) {
             $badEntries[] = $i;
             continue;
         }
         $targetNo = null;
         $position = null;
         $matchNo = null;
         $curPhase = null;
         if ($this->getSession() != 'MATCH') {
             $targetNo = str_pad($e->getElementsByTagName('target')->item(0)->textContent, TargetNoPadding + 1, '0', STR_PAD_LEFT);
         } else {
             $position = $e->getElementsByTagName('position')->item(0)->textContent;
             $event = $e->getElementsByTagName('event')->item(0)->textContent;
             $curPhase = $e->getElementsByTagName('cur_phase')->item(0)->textContent;
         }
         $valid = $e->getElementsByTagName('valid')->item(0)->textContent;
         $endScore = $e->getElementsByTagName('end_total')->item(0)->textContent;
         $points = array();
         $arrows = $e->getElementsByTagName('arrow');
         foreach ($arrows as $a) {
             /*
              * Per ora se non c'è l'attributo num, la freccia viene ignorata
              */
             /*$index=$a->getAttribute('num');
             		if (is_numeric($index))
             			$points[$index]=$a->textContent;*/
             /*
              * Edit del precedente commento:
              * per ora anche se non c'è l'attributo num la freccia viene importata
              */
             $points[] = $a->textContent;
         }
         /*
          * Sicuramente ho il numero corretto di frecce (lo ha verificato $this->verifyNode)
          * quindi posso procedere
          */
         // Cerco la riga nella tabella appropriata
         $query = "";
         switch ($this->getPhase()) {
             case ARF::QUALIFICATION:
                 $query = "SELECT " . "QuId AS AthId,EnStatus AS AthStatus,QuD" . $this->getDistance() . "ArrowString AS ArrowString " . "FROM " . "Qualifications INNER JOIN Entries ON QuId=EnId AND EnTournament=" . $this->getTourId() . " " . "WHERE " . "QuSession=" . StrSafe_DB($this->getSession()) . " AND QuTargetNo=" . StrSafe_DB($this->getSession() . $targetNo) . " ";
                 break;
             case ARF::ELIMINATION:
                 $query = "SELECT " . "ElId AS AthId,EnStatus AS AthStatus,ElArrowString AS ArrowString " . "FROM " . "Eliminations INNER JOIN Entries ON ElId=EnId AND EnTournament=" . $this->getTourId() . " " . "WHERE " . "ElElimPhase=" . StrSafe_DB($this->getSession() - 1) . " AND ElTargetNo=" . StrSafe_DB($targetNo) . " ";
                 break;
             case ARF::INDIVIDUAL_FINAL:
                 if ($this->getSession() != 'MATCH') {
                     $query = "SELECT " . "FinAthlete AS AthId,IF(FinAthlete!=0,0,9) AS AthStatus,FinMatchNo AS MatchNo,GrPhase,FinEvent AS Event,FSTarget,FinArrowString AS ArrowString, CONCAT(FSScheduledDate,' ',FSScheduledTime) AS Scheduled " . "FROM " . "Finals INNER JOIN FinSchedule ON FinMatchNo=FSMatchNo AND FinTournament=FSTournament " . "AND FinEvent=FSEvent AND FSTeamEvent=0 " . "INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "WHERE " . "FinTournament=" . $this->getTourId() . " AND " . "FSTarget='" . substr($targetNo, 0, -1) . "' AND " . "CONCAT(FSScheduledDate,' ',FSScheduledTime)=" . StrSafe_DB($this->getSession()) . " " . "ORDER BY " . "FinEvent,FinMatchNo ASC " . "LIMIT " . (substr($targetNo, -1) == 'A' ? 0 : 1) . ",1 ";
                     //print $query;exit;
                 } else {
                     $query = "SELECT " . "FinAthlete AS AthId,IF(FinAthlete!=0,0,9) AS AthStatus,FinMatchNo AS MatchNo,GrPhase,FinEvent AS Event,FSTarget,FinArrowString AS ArrowString " . "FROM " . "Finals INNER JOIN FinSchedule ON FinMatchNo=FSMatchNo AND FinTournament=FSTournament " . "AND FinEvent=FSEvent AND FSTeamEvent=0 " . "INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "WHERE " . "FinTournament=" . $this->getTourId() . " AND " . "GrPosition=" . StrSafe_DB($position) . " AND " . "GrPhase=" . StrSafe_DB($curPhase) . " AND " . "FinEvent=" . StrSafe_DB($event) . " " . "ORDER BY " . "FinEvent,FinMatchNo ASC ";
                 }
                 break;
             case ARF::TEAM_FINAL:
                 if ($this->getSession() != 'MATCH') {
                     $query = "SELECT TfTeam AS AthId,IF(TfTeam!=0,0,9) AS AthStatus,TfMatchNo AS MatchNo,GrPhase,TfEvent AS Event,FSTarget,TfArrowString AS ArrowString " . "FROM TeamFinals INNER JOIN FinSchedule ON TfMatchNo=FSMatchNo AND TfTournament=FSTournament " . "AND TfEvent=FSEvent AND FSTeamEvent=1 " . "INNER JOIN Grids ON TfMatchNo=GrMatchNo " . "WHERE TfTournament=" . $this->getTourId() . " AND " . "FSTarget='" . substr($targetNo, 0, -1) . "' AND " . "CONCAT(FSScheduledDate,' ',FSScheduledTime)=" . StrSafe_DB($this->getSession()) . " " . "ORDER BY TfEvent,TfMatchNo ASC " . "LIMIT " . (substr($targetNo, -1) == 'A' ? 0 : 1) . ",1";
                 } else {
                     $query = "SELECT TfTeam AS AthId,IF(TfTeam!=0,0,9) AS AthStatus,TfMatchNo AS MatchNo,GrPhase,TfEvent AS Event,FSTarget,TfArrowString AS ArrowString " . "FROM TeamFinals INNER JOIN FinSchedule ON TfMatchNo=FSMatchNo AND TfTournament=FSTournament " . "AND TfEvent=FSEvent AND FSTeamEvent=1 " . "INNER JOIN Grids ON TfMatchNo=GrMatchNo " . "WHERE TfTournament=" . $this->getTourId() . " AND " . "GrPosition=" . StrSafe_DB($position) . " AND " . "GrPhase=" . StrSafe_DB($curPhase) . " AND " . "TfEvent=" . StrSafe_DB($event) . " " . "ORDER BY TfEvent,TfMatchNo ASC ";
                 }
                 break;
         }
         if (debug) {
             print $query . '<br><br>';
         }
         $rs = safe_r_sql($query);
         $myRow = null;
         $good = false;
         // true se il nodo è ok
         if ($rs) {
             // non trovo il bersaglio in db
             if (safe_num_rows($rs) == 0) {
                 if ($valid == 1) {
                     $badEntries[] = $i;
                     continue;
                 } else {
                     continue;
                 }
             } elseif (safe_num_rows($rs) == 1) {
                 $myRow = safe_fetch($rs);
                 // la tabella dice che tira
                 if ($myRow->AthStatus <= 1) {
                     // ma il file dice no
                     if ($valid == 0) {
                         $badEntries[] = $i;
                         continue;
                     } elseif ($valid == 1) {
                         $arrowString = str_pad($myRow->ArrowString, $this->getMaxArrows(), ' ', STR_PAD_RIGHT);
                     }
                 } else {
                     // il file è d'accordo
                     if ($valid == 0) {
                         continue;
                     } else {
                         $badEntries[] = $i;
                         continue;
                     }
                 }
             }
         } else {
             $badEntries[] = $i;
             continue;
         }
         // Creo la nuova arrowstring e verifico il totale della volee
         $subArrowString = '';
         $totEnd = 0;
         foreach ($points as $value) {
             $value2write = ' ';
             // inizializzato a blank
             if ($value != '#') {
                 $totEnd += $value != 'M' && $value != 'm' ? $value : 0;
                 $value2write = GetLetterFromPrint($value);
             }
             // Questa condizione in realtà sarebbe un errore
             if ($value2write == '') {
                 $value2write = ' ';
             }
             $subArrowString .= $value2write;
         }
         // se il totale dichiarato in end_total non è coerente con i punti passati, il nodo non viene importato
         if ($endScore != $totEnd) {
             $badEntries[] = $i;
             continue;
         }
         if (debug) {
             print '..' . $subArrowString . '..(' . strlen($subArrowString) . ')<br>';
         }
         $Ip = $this->getArrows() * ($this->getEnd() - 1);
         $Fp = $Ip + ($this->getArrows() - 1);
         $arrowString = substr_replace($arrowString, $subArrowString, $Ip, strlen($subArrowString));
         //print $arrowString . '<br><br>';
         if (debug) {
             print '..' . $arrowString . '..<br><br>';
         }
         // Posso calcolare i punti
         $score = 0;
         $gold = 0;
         $xnine = 0;
         if ($this->getPhase() == ARF::QUALIFICATION || $this->getPhase() == ARF::ELIMINATION) {
             list($score, $gold, $xnine) = ValutaArrowStringGX($arrowString, $G, $X);
         } else {
             $score = ValutaArrowString($arrowString);
         }
         if (debug) {
             print 'Score: ' . $score . '<br>';
             print 'Gold: ' . $gold . '<br>';
             print 'Xnine: ' . $xnine . '<br><br>';
         }
         // posso fare l'update
         $query = "";
         switch ($this->getPhase()) {
             case ARF::QUALIFICATION:
                 $query = "UPDATE " . "Qualifications " . "SET " . "QuD" . $this->getDistance() . "Score=" . StrSafe_DB($score) . "," . "QuD" . $this->getDistance() . "Gold=" . StrSafe_DB($gold) . "," . "QuD" . $this->getDistance() . "Xnine=" . StrSafe_DB($xnine) . ", " . "QuD" . $this->getDistance() . "ArrowString=" . StrSafe_DB($arrowString) . ", " . "QuScore=QuD1Score+QuD2Score+QuD3Score+QuD4Score+QuD5Score+QuD6Score+QuD7Score+QuD8Score," . "QuGold=QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold+QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold," . "QuXnine=QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine+QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine, " . "QuTimestamp=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE " . "QuId=" . StrSafe_DB($myRow->AthId) . " ";
                 if (debug) {
                     print $query . '<br><br>';
                 }
                 $rs = safe_w_sql($query);
                 if ($rs) {
                     ++$importedEntries;
                     $shootOffIds[] = StrSafe_DB($myRow->AthId);
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
             case ARF::ELIMINATION:
                 $query = "UPDATE " . "Eliminations " . "SET " . "ElScore=" . Strsafe_DB($score) . "," . "ElGold=" . Strsafe_DB($gold) . "," . "ElXnine=" . Strsafe_DB($xnine) . ", " . "ElArrowString=" . StrSafe_DB($arrowString) . " " . "WHERE " . "ElId=" . StrSafe_DB($myRow->AthId) . " AND ElElimPhase=" . StrSafe_DB($this->getSession() - 1) . " ";
                 //print $query . '<br><br>';
                 $rs = safe_w_sql($query);
                 if ($rs) {
                     ++$importedEntries;
                     $shootOffIds[] = StrSafe_DB($myRow->AthId);
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
             case ARF::INDIVIDUAL_FINAL:
                 $query = "UPDATE Finals SET " . "FinScore=" . StrSafe_DB($score) . "," . "FinArrowString=" . StrSafe_DB($arrowString) . "," . "FinTie=0," . "FinTiebreak=NULL," . "FinTiePosition=NULL " . "WHERE FinMatchNo=" . StrSafe_DB($myRow->MatchNo) . " AND " . "FinEvent=" . StrSafe_DB($myRow->Event) . " AND FinTournament=" . $this->getTourId() . " ";
                 $rs = safe_w_sql($query);
                 //print $query . '<br><br>';
                 if ($rs) {
                     ++$importedEntries;
                     $keysNextPhase[$myRow->GrPhase]["'" . $myRow->Event . "'"] = 1;
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
             case ARF::TEAM_FINAL:
                 $query = "UPDATE TeamFinals SET " . "TfScore=" . StrSafe_DB($score) . "," . "TfArrowString=" . StrSafe_DB($arrowString) . "," . "TfTie=0," . "TfTiebreak=NULL," . "TfTiePosition=NULL " . "WHERE TfMatchNo=" . StrSafe_DB($myRow->MatchNo) . " AND " . "TfEvent=" . StrSafe_DB($myRow->Event) . " AND TfTournament=" . $this->getTourId() . " ";
                 $rs = safe_w_sql($query);
                 //print $query . '<br><br>';
                 if ($rs) {
                     ++$importedEntries;
                     $keysNextPhase[$myRow->GrPhase]["'" . $myRow->Event . "'"] = 1;
                 } else {
                     $badEntries[] = $i;
                     continue;
                 }
                 break;
         }
     }
     //exit;
     // Provo a post-processare i dati importati
     switch ($this->getPhase()) {
         case ARF::QUALIFICATION:
         case ARF::ELIMINATION:
             $postParam = $shootOffIds;
             break;
         case ARF::INDIVIDUAL_FINAL:
         case ARF::TEAM_FINAL:
             $postParam = $keysNextPhase;
             break;
     }
     $postError = false;
     // true se la prossima chiamata ritorna un errore
     if ($this->getPhase() == ARF::QUALIFICATION || $this->getPhase() == ARF::ELIMINATION) {
         call_user_func(array($this, $postImportMethod), $postParam, &$postError);
     } elseif ($this->getPhase() == ARF::INDIVIDUAL_FINAL || $this->getPhase() == ARF::TEAM_FINAL) {
         $team = $this->getPhase() == ARF::INDIVIDUAL_FINAL ? 0 : 1;
         call_user_func(array($this, $postImportMethod), $postParam, $team, &$postError);
     }
     return array($this->getTourCode(), $importedEntries, $badEntries, $postError);
 }
Exemplo n.º 15
0
 /**
  * read()
  *
  * @Override
  *
  * (non-PHPdoc)
  * @see ianseo/Common/Rank/Obj_Rank#read()
  */
 public function read()
 {
     $f = $this->safeFilterR();
     $filter = "";
     if ($f !== false) {
         $filter = $f;
     }
     if (array_key_exists('cutRank', $this->opts) && is_numeric($this->opts['cutRank']) && $this->opts['cutRank'] > 0) {
         $filter .= "AND IF(EvFinalFirstPhase=0, TeRank, TeRankFinal)<={$this->opts['cutRank']} ";
     }
     $EnFilter = empty($this->opts['enid']) ? '' : " AND EnId=" . intval($this->opts['enid']);
     $EnFilter .= empty($this->opts['coid']) ? '' : " AND EnCountry=" . intval($this->opts['coid']);
     $phases = null;
     /*
      * prima passata per costruire la struttura del vettore.
      * Tiro fuori le posizioni di qualifica e le posizioni finali con i nomi.
      * La query è divisa in due: la prima parte tira fuori le squadre che sono andate in finale
      * e la seconda quelle che si son fermate prima.
      * Devo far così perchè i nomi dei membri dei team provengono da due tabelle diverse.
      */
     $q = "\r\n\t\t\t/* parte delle finali */\r\n\t\t\t\t(\r\n\t\t\t\t\tSELECT 1,\r\n\t\t\t\t\t\tCoId, TeSubTeam, CoCode, CoName,\r\n\t\t\t\t\t\tEvProgr, TeEvent, EvEventName, EvMaxTeamPerson,\r\n\t\t\t\t\t\tEvFinalPrintHead as PrintHeader,\r\n\t\t\t\t\t\tEvFinalFirstPhase, EvMatchMode, EvMedals,\r\n\t\t\t\t\t\tEnId,EnCode,EnFirstName,upper(EnFirstName) EnFirstNameUpper,EnName,tc.TfcOrder AS personOrder,\r\n\t\t\t\t\t\tTeRank as QualRank, IF(EvFinalFirstPhase=0, TeRank, TeRankFinal) as FinalRank, TeScore,\r\n\t\t\t\t\t\tTeTimestamp,TeTimestampFinal/*,'0' AS rowType*/\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tTournament\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\tON ToId=TeTournament AND TeFinEvent=1\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tCountries\r\n\t\t\t\t\t\tON TeCoId=CoId AND TeTournament=CoTournament\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tTeamFinComponent AS tc\r\n\t\t\t\t\t\tON Teams.TeCoId=tc.TfcCoId AND Teams.TeSubTeam=tc.TfcSubTeam AND  Teams.TeEvent=tc.TfcEvent AND Teams.TeTournament=tc.TfcTournament AND Teams.TeFinEvent=1\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tEntries\r\n\t\t\t\t\t\tON TfcId=EnId\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tEvents\r\n\t\t\t\t\t\tON TeEvent=EvCode AND ToId=EvTournament AND EvTeamEvent=1\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tIF(EvFinalFirstPhase=0, TeRank, TeRankFinal)<=(EvFinalFirstPhase*2) AND TeScore != 0 AND ToId = {$this->tournament}\r\n\t\t\t\t\t\t{$filter}\r\n\t\t\t\t\t\t{$EnFilter}\r\n\r\n\t\t\t\t)\r\n\t\t\t\tUNION ALL\r\n\t\t\t\t(\r\n\t\t\t\t\tSELECT 2,\r\n\t\t\t\t\t\tCoId,TeSubTeam,CoCode,CoName,\r\n\t\t\t\t\t\tEvProgr,TeEvent,EvEventName,EvMaxTeamPerson,\r\n\t\t\t\t\t\tEvFinalPrintHead as PrintHeader,\r\n\t\t\t\t\t\tEvFinalFirstPhase,EvMatchMode,EvMedals,\r\n\t\t\t\t\t\tEnId,EnCode,EnFirstName,upper(EnFirstName) EnFirstNameUpper,EnName,tc.TcOrder,\r\n\t\t\t\t\t\tTeRank as QualRank, IF(EvFinalFirstPhase=0, TeRank, TeRankFinal) as FinalRank, TeScore,\r\n\t\t\t\t\t\tTeTimestamp,TeTimestampFinal\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tTournament\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\tON ToId=TeTournament AND TeFinEvent=1\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tCountries\r\n\t\t\t\t\t\tON TeCoId=CoId AND TeTournament=CoTournament\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tTeamComponent AS tc\r\n\t\t\t\t\t\tON Teams.TeCoId=tc.TcCoId AND Teams.TeSubTeam=tc.TcSubTeam AND  Teams.TeEvent=tc.TcEvent AND Teams.TeTournament=tc.TcTournament AND Teams.TeFinEvent=tc.TcFinEvent AND Teams.TeFinEvent=1\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tEntries\r\n\t\t\t\t\t\tON TcId=EnId\r\n\r\n\t\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t\tEvents\r\n\t\t\t\t\t\tON TeEvent=EvCode AND ToId=EvTournament AND EvTeamEvent=1\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tIF(EvFinalFirstPhase=0, TeRank, TeRankFinal)>(EvFinalFirstPhase*2)  AND TeScore != 0 AND ToId = {$this->tournament}\r\n\t\t\t\t\t\t/*AND CONCAT(TeCoId,'_',TeSubTeam) NOT IN (SELECT DISTINCT CONCAT(TfTeam,'_',TfSubTeam) FROM TeamFinals WHERE TfTournament={$this->tournament})*/\r\n\t\t\t\t\t\t{$filter}\r\n\t\t\t\t\t\t{$EnFilter}\r\n\t\t\t\t)\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tEvProgr, TeEvent,/*rowType ASC,*/ FinalRank ASC, CoCode ASC, TeSubTeam, personOrder ASC, EnFirstName, EnName\r\n\t\t\t";
     //			print $q;exit;
     //			debug_svela($q, true);
     $r = safe_r_sql($q);
     $this->data['meta']['title'] = get_text('TeamFinEvent', 'Tournament');
     $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00';
     $this->data['sections'] = array();
     $myEv = '';
     $myTeam = '';
     if (safe_num_rows($r) > 0) {
         $section = null;
         while ($myRow = safe_fetch($r)) {
             if ($myEv != $myRow->TeEvent) {
                 if ($myEv != '') {
                     $this->data['sections'][$myEv] = $section;
                     $section = null;
                 }
                 $myEv = $myRow->TeEvent;
                 $phases = getPhasesId($myRow->EvFinalFirstPhase);
                 $fields = array('id' => 'Id', 'countryCode' => '', 'countryName' => get_text('Country'), 'subteam' => get_text('PartialTeam'), 'athletes' => array('name' => get_text('Name', 'Tournament'), 'fields' => array('id' => 'Id', 'bib' => get_text('Code', 'Tournament'), 'athlete' => get_text('Athlete'), 'familyname' => get_text('FamilyName', 'Tournament'), 'givenname' => get_text('Name', 'Tournament'))), 'qualRank' => get_text('RankScoreShort'), 'qualScore' => get_text('PositionShort'), 'rank' => get_text('PositionShort'), 'finals' => array());
                 foreach ($phases as $k => $v) {
                     if ($v <= valueFirstPhase($myRow->EvFinalFirstPhase)) {
                         $fields['finals'][$v] = get_text(namePhase($myRow->EvFinalFirstPhase, $v) . "_Phase");
                     }
                 }
                 $fields['finals']['fields'] = array('score' => get_text('TotalShort', 'Tournament'), 'setScore' => get_text('SetTotal', 'Tournament'), 'setPoints' => get_text('SetPoints', 'Tournament'), 'tie' => 'S.O.', 'arrowstring' => get_text('Arrows', 'Tournament'), 'tiebreak' => get_text('TieArrows'));
                 $section = array('meta' => array('event' => $myEv, 'descr' => get_text($myRow->EvEventName, '', '', true), 'printHeader' => get_text($myRow->PrintHeader, '', '', true), 'firstPhase' => $myRow->EvFinalFirstPhase, 'matchMode' => $myRow->EvMatchMode, 'maxTeamPerson' => $myRow->EvMaxTeamPerson, 'order' => $myRow->EvProgr, 'lastUpdate' => '0000-00-00 00:00:00', 'fields' => $fields, 'medals' => $myRow->EvMedals), 'items' => array());
             }
             if ($myTeam != $myRow->CoId . $myRow->TeSubTeam . $myRow->TeEvent) {
                 $item = array('id' => $myRow->CoId, 'countryCode' => $myRow->CoCode, 'countryName' => $myRow->CoName, 'subteam' => $myRow->TeSubTeam, 'athletes' => array(), 'qualScore' => $myRow->TeScore, 'qualRank' => $myRow->QualRank, 'rank' => $myRow->FinalRank == 9999 ? 'DSQ' : $myRow->FinalRank, 'finals' => array());
                 $section['items'][$myRow->CoId . '_' . $myRow->TeSubTeam] = $item;
                 if ($myRow->TeTimestampFinal > $section['meta']['lastUpdate']) {
                     $section['meta']['lastUpdate'] = $myRow->TeTimestampFinal;
                 }
                 if ($myRow->TeTimestampFinal > $this->data['meta']['lastUpdate']) {
                     $this->data['meta']['lastUpdate'] = $myRow->TeTimestampFinal;
                 }
                 $myTeam = $myRow->CoId . $myRow->TeSubTeam . $myRow->TeEvent;
             }
             if (!array_key_exists('components', $this->opts) || $this->opts['components']) {
                 $athlete = array('id' => $myRow->EnId, 'bib' => $myRow->EnCode, 'athlete' => $myRow->EnFirstNameUpper . ' ' . $myRow->EnName, 'familyname' => $myRow->EnFirstName, 'familynameUpper' => $myRow->EnFirstNameUpper, 'givenname' => $myRow->EnName);
                 //$section['items'][count($section['items'])-1]['athletes'][]=$athlete;
                 $section['items'][$myRow->CoId . '_' . $myRow->TeSubTeam]['athletes'][] = $athlete;
             }
         }
         // ultimo giro
         $this->data['sections'][$myEv] = $section;
     }
     //	print count($this->data['sections']['OLMT']['items']);exit;
     /*
      * A questo punto ho i nomi e le qualifiche
      * e punti+rank delle precedenti.
      * Mi mancano le finali.
      *
      */
     $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tf1.TfEvent AS `event`,CONCAT(f1.TfTeam,'_',f1.TfSubTeam) AS `athlete`,f1.TfMatchNo AS `matchNo`,f1.TfScore AS `score`,f1.TfSetScore AS `setScore`,f1.TfSetPoints AS `setPoints`,f1.TfTie AS `tie`,f1.TfArrowstring AS `arrowstring`,f1.TfTiebreak AS `tiebreak`,\r\n\t\t\t\t\tCONCAT(f2.TfTeam,'_',f2.TfSubTeam) AS `oppAthlete`,f2.TfMatchNo AS `oppMatchNo`,f2.TfScore AS `oppScore`,f2.TfSetScore AS `oppSetScore`,f2.TfSetPoints AS `oppSetPoints`,f2.TfTie AS `oppTie`,f2.TfArrowstring AS `oppArrowstring`,f2.TfTiebreak AS `oppTiebreak`,\r\n\t\t\t\t\tGrPhase, EvMaxTeamPerson\r\n\t\t\t\tFROM\r\n\t\t\t\t\tTeams\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeamFinals AS f1\r\n\t\t\t\t\tON TeTournament=f1.TfTournament AND TeEvent=f1.TfEvent AND CONCAT(TeCoId,'_',TeSubTeam)=CONCAT(f1.TfTeam,'_',f1.TfSubTeam)\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeamFinals AS f2\r\n\t\t\t\t\tON f1.TfEvent=f2.TfEvent AND f1.TfMatchNo=IF((f1.TfMatchNo % 2)=0,f2.TfMatchNo-1,f2.TfMatchNo+1) AND f1.TfTournament=f2.TfTournament\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tGrids\r\n\t\t\t\t\tON f1.TfMatchNo=GrMatchNo\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEvents\r\n\t\t\t\t\tON f1.TfTournament=EvTournament AND f1.TfEvent=EvCode AND EvTeamEvent=1\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tf1.TfTournament={$this->tournament}\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tEvProgr ASC,EvCode,TeRankFinal ASC,GrPhase DESC\r\n\t\t\t";
     $rr = safe_r_sql($q);
     if (safe_num_rows($rr) > 0) {
         while ($row = safe_fetch($rr)) {
             $arrowstring = array();
             for ($i = 0; $i < strlen($row->arrowstring); ++$i) {
                 if (trim($row->arrowstring[$i]) != '') {
                     $arrowstring[] = DecodeFromLetter($row->arrowstring[$i]);
                 }
             }
             $tiebreak = array();
             for ($i = 0; $i < strlen($row->tiebreak); ++$i) {
                 if (trim($row->tiebreak[$i]) != '') {
                     $tiebreak[] = DecodeFromLetter($row->tiebreak[$i]);
                 }
             }
             $oppArrowstring = array();
             for ($i = 0; $i < strlen($row->oppArrowstring); ++$i) {
                 if (trim($row->oppArrowstring[$i]) != '') {
                     $oppArrowstring[] = DecodeFromLetter($row->oppArrowstring[$i]);
                 }
             }
             $oppTiebreak = array();
             for ($i = 0; $i < strlen($row->oppTiebreak); ++$i) {
                 if (trim($row->oppTiebreak[$i]) != '') {
                     $oppTiebreak[] = DecodeFromLetter($row->oppTiebreak[$i]);
                 }
             }
             $tmpArr = array();
             $oppArr = array();
             if ($row->tiebreak) {
                 for ($countArr = 0; $countArr < strlen(trim($row->tiebreak)); $countArr += $row->EvMaxTeamPerson) {
                     $tmp = ValutaArrowString(substr(trim($row->tiebreak), $countArr, $row->EvMaxTeamPerson));
                     if (!ctype_upper(trim($row->tiebreak))) {
                         $tmp .= "*";
                     }
                     $tmpArr[] = $tmp;
                 }
                 //debug_svela($myRow);
             }
             if ($row->oppTiebreak) {
                 for ($countArr = 0; $countArr < strlen(trim($row->oppTiebreak)); $countArr += $row->EvMaxTeamPerson) {
                     $tmp = ValutaArrowString(substr(trim($row->oppTiebreak), $countArr, $row->EvMaxTeamPerson));
                     if (!ctype_upper(trim($row->oppTiebreak))) {
                         $tmp .= "*";
                     }
                     $oppArr[] = $tmp;
                 }
             }
             if (isset($this->data['sections'][$row->event]['items'][$row->athlete]['finals'])) {
                 $this->data['sections'][$row->event]['items'][$row->athlete]['finals'][$row->GrPhase] = array('score' => $row->score, 'setScore' => $row->setScore, 'setPoints' => $row->setPoints, 'tie' => $row->tie, 'arrowstring' => implode('|', $arrowstring), 'tiebreak' => implode('|', $tiebreak), 'tiebreakDecoded' => implode(',', $tmpArr), 'oppAthlete' => $row->oppAthlete, 'oppScore' => $row->oppScore, 'oppSetScore' => $row->oppSetScore, 'oppSetPoints' => $row->oppSetPoints, 'oppTie' => $row->oppTie, 'oppArrowstring' => implode('|', $oppArrowstring), 'oppTiebreak' => implode('|', $oppTiebreak), 'oppTiebreakDecoded' => implode(',', $oppArr));
             }
         }
     }
 }
Exemplo n.º 16
0
 $tot2 = ValutaArrowString($OppArrows) . ($OppArrows != strtoupper($OppArrows) ? '*' : '');
 $len = max(2, strlen($tot1), strlen($tot2));
 $pad1 = GetPaddedNames($tot1, $len);
 $pad2 = GetPaddedNames($tot2, $len);
 $Tg = $XmlDoc->createElement('setpoints');
 $Tg->appendChild($XmlDoc->createCDATASection(str_pad($tot1, $pad1, ' ', STR_PAD_LEFT)));
 $Opp1->appendChild($Tg);
 $Tg = $XmlDoc->createElement('setpoints');
 $Tg->appendChild($XmlDoc->createCDATASection(str_pad($tot2, $pad2, ' ', STR_PAD_LEFT)));
 $Opp2->appendChild($Tg);
 // arrows
 for ($n = 0; $n < 6; $n++) {
     $End1 = substr($Arrows, $n, 1);
     $tot1 = ValutaArrowString($End1);
     $End2 = substr($OppArrows, $n, 1);
     $tot2 = ValutaArrowString($End2);
     $len = max(2, strlen($tot1), strlen($tot2));
     $pad1 = GetPaddedNames($tot1, $len);
     $pad2 = GetPaddedNames($tot2, $len);
     if ($End1 != 'A' and !$tot1) {
         $tot1 = '';
     }
     if ($End2 != 'A' and !$tot2) {
         $tot2 = '';
     }
     $Tg = $XmlDoc->createElement('arrow' . ($n + 1));
     $Tg->appendChild($XmlDoc->createCDATASection(str_pad($tot1, $pad1, ' ', STR_PAD_LEFT)));
     $Opp1->appendChild($Tg);
     $Tg = $XmlDoc->createElement('arrow' . ($n + 1));
     $Tg->appendChild($XmlDoc->createCDATASection(str_pad($tot2, $pad2, ' ', STR_PAD_LEFT)));
     $Opp2->appendChild($Tg);
Exemplo n.º 17
0
function DecodeFromString($Letter = '', $sum = false)
{
    global $LetterPoint;
    $SumMaybe = '';
    $SumReturn = 0;
    if (!$Letter) {
        return array();
    }
    $maybe = false;
    $ret = array();
    foreach (range(1, strlen($Letter)) as $n) {
        $maybe = false;
        /*
         * Se non esiste la chiave nel vettore potrebbe essere un dubbio.
         * Se una volta convertita in maiuscola non trovo la lettera
         * allora ho un errore
         */
        if (!array_key_exists($Letter[$n - 1], $LetterPoint)) {
            $Letter[$n - 1] = strtoupper($Letter[$n - 1]);
            $maybe = true;
            $SumMaybe = true;
        }
        if (array_key_exists($Letter[$n - 1], $LetterPoint)) {
            $ret[] = $LetterPoint[$Letter[$n - 1]]['P'] . ($maybe ? '*' : '');
        } else {
            $ret[] = ' ';
        }
    }
    if ($sum) {
        return ValutaArrowString($Letter) . ($maybe ? '*' : '');
    }
    if (strlen($Letter) == 1) {
        return $ret[0];
    }
    return $ret;
}
Exemplo n.º 18
-1
}
$q = safe_r_sql("select EnFirstname, EnName, QuTargetNo, QuD5Arrowstring from Qualifications\n\t\tinner join Entries on EnId=QuId and EnTournament={$TourId}\n\t\tWhere QuSession=8\n\t\torder by QuTargetNo");
$XmlDoc = new DOMDocument('1.0', 'UTF-8');
$XmlRoot = $XmlDoc->createElement('shootoff');
$XmlDoc->appendChild($XmlRoot);
$Ends = 0;
$n = 0;
while ($r = safe_fetch($q)) {
    $archer = $XmlDoc->createElement('archer' . $n++);
    $XmlRoot->AppendChild($archer);
    $a = $XmlDoc->createElement('name');
    $a->AppendChild($XmlDoc->createCDATASection(substr($r->EnFirstname, 0, 3) . ' ' . $r->EnName[0]));
    $archer->AppendChild($a);
    $a = $XmlDoc->createElement('target');
    $a->AppendChild($XmlDoc->createCDATASection(ltrim(substr($r->QuTargetNo, 1, -1), '0')));
    $archer->AppendChild($a);
    $Arrows = substr($r->QuD5Arrowstring, $StartEnds, 3);
    $Star = $Arrows == strtoupper($Arrows) ? '' : '*';
    $a = $XmlDoc->createElement('score');
    $a->AppendChild($XmlDoc->createCDATASection(ValutaArrowString($Arrows) . $Star));
    $archer->AppendChild($a);
}
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Content-type: text/xml; charset=' . PageEncode);
echo $XmlDoc->SaveXML();
/*
[15:48:27] Ardingo: basta e avanza
[15:48:35] Christian Deligant: 7) link all'immagine della società
[15:48:40] Ardingo: se ci aggiungi anche la foto poi lo uso a far anche un'altra cosa
[15:48:41] Christian Deligant: 8) link alla foto atleta
*/
Exemplo n.º 19
-1
function MatchTotal($MatchNo, $EvCode, $TeamEvent = 0)
{
    if (is_null($MatchNo) || is_null($EvCode)) {
        //Devono esistere sia il MatchNo che l'evento
        return;
    }
    $MatchFinished = false;
    // serve per vedere se il match è finito
    $TablePrefix = "Fin";
    $Select = "SELECT " . "f.FinEvent as EvCode, f.FinMatchNo as MatchNo, f2.FinMatchNo as OppMatchNo, EvMatchMode, EvMatchArrowsNo, " . "IF(f.FinDateTime>=f2.FinDateTime, f.FinDateTime, f2.FinDateTime) AS DateTime," . "f.FinScore AS Score, f.FinSetScore AS SetScore, f.FinTie as Tie, IFNULL(f.FinArrowString,'') as ArString, IFNULL(f.FinTieBreak,'') as TbString, " . "f2.FinScore AS OppScore, f2.FinSetScore AS OppSetScore, f2.FinTie as OppTie, IFNULL(f2.FinArrowString,'') as OppArString, IFNULL(f2.FinTieBreak,'') as OppTbString, " . "GrPhase " . "FROM Finals AS f " . "INNER JOIN Finals AS f2 ON f.FinEvent=f2.FinEvent AND f.FinMatchNo=IF((f.FinMatchNo % 2)=0,f2.FinMatchNo-1,f2.FinMatchNo+1) AND f.FinTournament=f2.FinTournament " . "INNER JOIN Events ON f.FinEvent=EvCode AND f.FinTournament=EvTournament AND EvTeamEvent=0 " . "INNER JOIN Grids ON f.FinMatchNo=GrMatchNo " . "WHERE f.FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND (f.FinMatchNo % 2)=0 AND GrMatchNo=" . StrSafe_DB($MatchNo % 2 == 0 ? $MatchNo : $MatchNo - 1) . " AND f.FinEvent=" . StrSafe_DB($EvCode) . " " . "ORDER BY f.FinEvent, f.FinMatchNo ";
    if ($TeamEvent) {
        $TablePrefix = "Tf";
        $Select = "SELECT " . "f.TfEvent as EvCode, f.TfMatchNo as MatchNo, f2.TfMatchNo as OppMatchNo, EvMatchMode, EvMatchArrowsNo, " . "IF(f.TfDateTime>=f2.TfDateTime, f.TfDateTime, f2.TfDateTime) AS DateTime," . "f.TfScore AS Score, f.TfSetScore AS SetScore, f.TfTie as Tie, IFNULL(f.TfArrowString,'') as ArString, IFNULL(f.TfTieBreak,'') as TbString, " . "f2.TfScore AS OppScore, f2.TfSetScore AS OppSetScore, f2.TfTie as OppTie, IFNULL(f2.TfArrowString,'') as OppArString, IFNULL(f2.TfTieBreak,'') as OppTbString, " . "GrPhase " . "FROM TeamFinals AS f " . "INNER JOIN TeamFinals AS f2 ON f.TfEvent=f2.TfEvent AND f.TfMatchNo=IF((f.TfMatchNo % 2)=0,f2.TfMatchNo-1,f2.TfMatchNo+1) AND f.TfTournament=f2.TfTournament " . "INNER JOIN Events ON f.TfEvent=EvCode AND f.TfTournament=EvTournament AND EvTeamEvent=1 " . "INNER JOIN Grids ON f.TfMatchNo=GrMatchNo " . "WHERE f.TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND (f.TfMatchNo % 2)=0 AND GrMatchNo=" . StrSafe_DB($MatchNo % 2 == 0 ? $MatchNo : $MatchNo - 1) . " AND f.TfEvent=" . StrSafe_DB($EvCode) . " " . "ORDER BY f.TfEvent, f.TfMatchNo ";
    }
    //print $Select . "<br>";exit;
    $MatchUpdated = false;
    // serve per aggiornare il timestamp
    $Rs = safe_r_sql($Select);
    if (safe_num_rows($Rs) == 1) {
        $MyRow = safe_fetch($Rs);
        $obj = getEventArrowsParams($MyRow->EvCode, $MyRow->GrPhase, $TeamEvent);
        $TotArrows = $obj->ends * $obj->arrows;
        $Winner = -1;
        // set winner... of Ties
        if ($MyRow->Tie) {
            $Winner = $MyRow->MatchNo;
            $MatchFinished = true;
        } elseif ($MyRow->OppTie) {
            $Winner = $MyRow->OppMatchNo;
            $MatchFinished = true;
        }
        $Score = ValutaArrowString(substr($MyRow->ArString, 0, $TotArrows));
        $OppScore = ValutaArrowString(substr($MyRow->OppArString, 0, $TotArrows));
        if ($MyRow->EvMatchMode == 0) {
            //Sistema Cumulativo
            if (strlen(str_replace(' ', '', $MyRow->ArString)) == $TotArrows and strlen(str_replace(' ', '', $MyRow->OppArString)) == $TotArrows and strlen(str_replace(' ', '', $MyRow->TbString)) == strlen(str_replace(' ', '', $MyRow->OppTbString))) {
                $MatchFinished = true;
                // if match is over establish the winner
                // only if not already decided by the tie
                // and if there are no doubts
                // and no SO are going on
                if ($Winner == -1 and $MyRow->ArString == strtoupper($MyRow->ArString) and $MyRow->OppArString == strtoupper($MyRow->OppArString) and strlen(trim($MyRow->TbString)) == strlen(trim($MyRow->OppTbString))) {
                    if ($Score > $OppScore) {
                        $Winner = $MyRow->MatchNo;
                    } elseif ($Score < $OppScore) {
                        $Winner = $MyRow->OppMatchNo;
                    }
                }
            }
            $query = "UPDATE " . ($TeamEvent == 0 ? "Finals" : "TeamFinals") . " " . "SET " . "{$TablePrefix}WinLose=" . ($Winner == $MyRow->MatchNo ? '1' : '0') . ", " . "{$TablePrefix}Score=" . $Score . ", " . "{$TablePrefix}SetScore=0, " . "{$TablePrefix}SetPoints='', " . "{$TablePrefix}DateTime={$TablePrefix}DateTime " . "WHERE " . " {$TablePrefix}Event=" . StrSafe_DB($MyRow->EvCode) . " " . " AND {$TablePrefix}MatchNo=" . StrSafe_DB($MyRow->MatchNo) . " " . " AND {$TablePrefix}Tournament=" . StrSafe_DB($_SESSION['TourId']);
            safe_w_sql($query);
            $MatchUpdated = ($MatchUpdated or safe_w_affected_rows());
            //print $query.'<br><br>';
            $query = "UPDATE " . ($TeamEvent == 0 ? "Finals" : "TeamFinals") . " " . "SET " . "{$TablePrefix}WinLose=" . ($Winner == $MyRow->OppMatchNo ? '1' : '0') . ", " . "{$TablePrefix}Score=" . $OppScore . ", " . "{$TablePrefix}SetScore=0, " . "{$TablePrefix}SetPoints='', " . "{$TablePrefix}DateTime={$TablePrefix}DateTime " . "WHERE " . " {$TablePrefix}Event=" . StrSafe_DB($MyRow->EvCode) . " " . " AND {$TablePrefix}MatchNo=" . StrSafe_DB($MyRow->OppMatchNo) . " " . " AND {$TablePrefix}Tournament=" . StrSafe_DB($_SESSION['TourId']);
            safe_w_sql($query);
            $MatchUpdated = ($MatchUpdated or safe_w_affected_rows());
            //print $query.'<br><br>';
        } else {
            //Sistema a Set
            $SetPointsAth = array();
            $SetPointsOpp = array();
            $SetAth = 0;
            $SetOpp = 0;
            $SetAthWin = 0;
            $SetOppWin = 0;
            $WinnerId = -1;
            for ($i = 0; $i < $TotArrows; $i = $i + $obj->arrows) {
                //Cicla per tutte le volee dell'incontro
                $AthEndString = substr($MyRow->ArString, $i, $obj->arrows);
                $OppEndString = substr($MyRow->OppArString, $i, $obj->arrows);
                $MatchString = $AthEndString . $OppEndString;
                $AthSetPoints = ValutaArrowString($AthEndString);
                $OppSetPoints = ValutaArrowString($OppEndString);
                $SetPointsAth[] = $AthSetPoints;
                $SetPointsOpp[] = $OppSetPoints;
                if (strpos($MatchString, ' ') === false and ctype_upper($MatchString)) {
                    if ($AthSetPoints > $OppSetPoints) {
                        $SetAth += 2;
                        $SetAthWin++;
                    } elseif ($AthSetPoints < $OppSetPoints) {
                        $SetOpp += 2;
                        $SetOppWin++;
                    } else {
                        $SetAth++;
                        $SetOpp++;
                    }
                }
            }
            if ($SetAth == $SetOpp && !empty($MyRow->TbString) && !empty($MyRow->OppTbString) && strlen(trim($MyRow->TbString)) == strlen(trim($MyRow->OppTbString))) {
                //Verifico le stringhe CASE INSENSITIVE - in questo momento me ne frego degli "*"
                $AthTbValue = ValutaArrowString($MyRow->TbString);
                $OppTbValue = ValutaArrowString($MyRow->OppTbString);
                if ($AthTbValue < $OppTbValue) {
                    $Winner = $MyRow->OppMatchNo;
                    //OppTbString è maggiore di TbString --> il secondo vince
                    $WinnerId = $MyRow->OppMatchNo;
                    //OppTbString è maggiore di TbString --> il secondo vince
                    $SetOpp++;
                } elseif ($AthTbValue > $OppTbValue) {
                    $Winner = $MyRow->MatchNo;
                    //TbString è maggiore di OppTbString --> il primo vince
                    $WinnerId = $MyRow->MatchNo;
                    //TbString è maggiore di OppTbString --> il primo vince
                    $SetAth++;
                } elseif ($AthTbValue > 0 and $OppTbValue > 0) {
                    //le stringhe CASE INSENSITIVE sono uguali
                    if (!ctype_upper(trim($MyRow->OppTbString)) and ctype_upper(trim($MyRow->TbString))) {
                        // Verifico gli "*" e lo star è nella stringa del secondo (è maggiore)
                        $Winner = $MyRow->OppMatchNo;
                        $WinnerId = $MyRow->OppMatchNo;
                        $SetOpp++;
                    } elseif (ctype_upper(trim($MyRow->OppTbString)) and !ctype_upper(trim($MyRow->TbString))) {
                        // Verifico gli "*" e lo star è nella stringa del primo (è maggiore)
                        $Winner = $MyRow->MatchNo;
                        $WinnerId = $MyRow->MatchNo;
                        $SetAth++;
                    }
                }
            } elseif ($SetAth >= $obj->winAt) {
                $Winner = $MyRow->MatchNo;
            } elseif ($SetOpp >= $obj->winAt) {
                $Winner = $MyRow->OppMatchNo;
            }
            $query = "UPDATE " . ($TeamEvent == 0 ? "Finals" : "TeamFinals") . " " . "SET " . "{$TablePrefix}WinLose=" . ($Winner == $MyRow->MatchNo ? '1' : '0') . ", " . "{$TablePrefix}Score=" . $Score . ", " . "{$TablePrefix}SetScore=" . $SetAth . ", " . "{$TablePrefix}SetPoints=" . StrSafe_DB(implode($SetPointsAth, '|')) . ", " . "{$TablePrefix}WinnerSet=" . $SetAthWin . ", " . "{$TablePrefix}Tie=" . ($WinnerId == $MyRow->MatchNo ? '1' : '0') . ", " . "{$TablePrefix}DateTime={$TablePrefix}DateTime " . "WHERE " . "{$TablePrefix}Event=" . StrSafe_DB($MyRow->EvCode) . " " . "AND {$TablePrefix}MatchNo=" . StrSafe_DB($MyRow->MatchNo) . " " . "AND {$TablePrefix}Tournament=" . StrSafe_DB($_SESSION['TourId']);
            // 			debug_svela($Winner==$MyRow->MatchNo, true);
            safe_w_sql($query);
            $MatchUpdated = ($MatchUpdated or safe_w_affected_rows());
            $query = "UPDATE " . ($TeamEvent == 0 ? "Finals" : "TeamFinals") . " " . "SET " . "{$TablePrefix}WinLose=" . ($Winner == $MyRow->OppMatchNo ? '1' : '0') . ", " . "{$TablePrefix}Score=" . $OppScore . ", " . "{$TablePrefix}SetScore=" . $SetOpp . ", " . "{$TablePrefix}SetPoints=" . StrSafe_DB(implode($SetPointsOpp, '|')) . ", " . "{$TablePrefix}WinnerSet=" . $SetOppWin . ", " . "{$TablePrefix}Tie=" . ($WinnerId == $MyRow->OppMatchNo ? '1' : '0') . ", " . "{$TablePrefix}DateTime={$TablePrefix}DateTime " . "WHERE " . "{$TablePrefix}Event=" . StrSafe_DB($MyRow->EvCode) . " " . "AND {$TablePrefix}MatchNo=" . StrSafe_DB($MyRow->OppMatchNo) . " " . "AND {$TablePrefix}Tournament=" . StrSafe_DB($_SESSION['TourId']);
            safe_w_sql($query);
            $MatchUpdated = ($MatchUpdated or safe_w_affected_rows());
            if ($SetAth >= $obj->winAt || $SetOpp >= $obj->winAt) {
                $MatchFinished = true;
            }
        }
        if ($MatchUpdated) {
            $query = "UPDATE " . ($TeamEvent == 0 ? "Finals" : "TeamFinals") . " " . "SET " . "{$TablePrefix}DateTime=now() " . "WHERE " . " {$TablePrefix}Event=" . StrSafe_DB($MyRow->EvCode) . " " . "AND {$TablePrefix}MatchNo in (" . StrSafe_DB($MyRow->MatchNo) . ',' . StrSafe_DB($MyRow->OppMatchNo) . ") " . "AND {$TablePrefix}Tournament=" . StrSafe_DB($_SESSION['TourId']);
            safe_w_sql($query);
        }
        //Serve per ricalcolare le ranking, solo medaglie
        if ($MatchNo < 4 and $MatchFinished) {
            if ($TeamEvent) {
                move2NextPhaseTeam(NULL, $EvCode, $MatchNo);
            } else {
                move2NextPhase(NULL, $EvCode, $MatchNo);
            }
        }
    }
    return $MatchFinished;
}
Exemplo n.º 20
-1
 $SetOppArr = array();
 for ($i = 0; $i < $maxArrows; $i = $i + $stepArrow) {
     //In caso di spot, verifico in che volee sto inserendo
     if ($spotLimit[0] == 0) {
         if ($index >= $i && $index < $i + $stepArrow) {
             $spotLimit[1] = $i;
             $spotLimit[2] = $i + $stepArrow - 1;
         }
     } elseif ($spotLimit[0] == 1) {
         $spotLimit[1] = 0;
         $spotLimit[2] = $obj->so - 1;
     }
     $SetAth = 0;
     $SetOpp = 0;
     $SetPointsAth[] = ValutaArrowString(substr($MyRow->ArString, $i, $stepArrow));
     $SetPointsOpp[] = ValutaArrowString(substr($MyRow->OppArString, $i, $stepArrow));
     if (strpos(substr($MyRow->ArString, $i, $stepArrow), ' ') === false && strpos(substr($MyRow->OppArString, $i, $stepArrow), ' ') === false && ctype_upper(substr($MyRow->ArString, $i, $stepArrow)) && ctype_upper(substr($MyRow->OppArString, $i, $stepArrow))) {
         if ($SetPointsAth[$i / $stepArrow] > $SetPointsOpp[$i / $stepArrow]) {
             $SetAth += 2;
         } else {
             if ($SetPointsAth[$i / $stepArrow] < $SetPointsOpp[$i / $stepArrow]) {
                 $SetOpp += 2;
             } else {
                 $SetAth++;
                 $SetOpp++;
             }
         }
     }
     $SetAthArr[] = $SetAth;
     $SetOppArr[] = $SetOpp;
     // i progressivi
Exemplo n.º 21
-1
function DrawScore(&$pdf, $MyRow, $MyRowOpp)
{
    global $CFG, $defTotalW, $defGoldW, $defArrowTotW, $FollowingRows, $TrgOutdoor, $WhereStartX, $WhereStartY, $Score3D, $FillWithArrows;
    $NumRow = $MyRow->CalcEnds;
    $NumCol = $MyRow->CalcArrows;
    $ArrowW = $defArrowTotW / $NumCol;
    $TotalW = $defTotalW;
    $GoldW = $defGoldW;
    //		echo $MyRow->EvMatchArrowsNo . "." . $MyRow->GrPhase ."." . ($MyRow->EvMatchArrowsNo & ($MyRow->GrPhase>0 ? $MyRow->GrPhase*2:1)) . "/" . $NumRow . "--<br>";
    if ($MyRow->GrMatchNo % 2 == 0 && $FollowingRows) {
        $pdf->AddPage();
    }
    $FollowingRows = true;
    $WhichScore = $MyRow->GrMatchNo % 2;
    $WhereX = $WhereStartX;
    $WhereY = $WhereStartY;
    //Intestazione Atleta
    $pdf->SetLeftMargin($WhereStartX[$WhichScore]);
    $pdf->SetY(35);
    // Flag of Country/Club
    if ($pdf->PrintFlags) {
        if (is_file($file = $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-Fl-' . $MyRow->CoCode . '.jpg')) {
            $H = 12;
            $W = 18;
            $OrgY = $pdf->gety();
            $OrgX = $NumCol * $ArrowW + $TotalW + $GoldW + $TotalW - 18;
            $pdf->Image($file, $pdf->getx() + $OrgX, $OrgY, $W, $H, 'JPG', '', '', true, 300, '', false, false, 1, true);
            $FlagOffset = $W + 1;
        }
    }
    $pdf->SetFont($pdf->FontStd, '', 10);
    $pdf->Cell(20, 6, get_text('Athlete') . ': ', 'TL', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell($NumCol * $ArrowW + 2 * $TotalW + $GoldW - 20 - ($pdf->PrintFlags ? 18 : 0), 6, $MyRow->Athlete, 'T', 1, 'L', 0);
    $pdf->SetFont($pdf->FontStd, '', 10);
    $pdf->Cell(20, 6, get_text('Country') . ': ', 'L', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell($NumCol * $ArrowW + 2 * $TotalW + $GoldW - 20, 6, $MyRow->CoName . (strlen($MyRow->CoCode) > 0 ? ' (' . $MyRow->CoCode . ')' : ''), 0, 1, 'L', 0);
    $pdf->SetFont($pdf->FontStd, '', 10);
    $pdf->Cell(20, 6, get_text('DivisionClass') . ': ', 'LB', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell($NumCol * $ArrowW + $TotalW + $GoldW - 20, 6, get_text($MyRow->EvEventName, '', '', true), 'B', 0, 'L', 0);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell($TotalW, 6, get_text('Target') . ' ' . $MyRow->FSTarget, '1', 1, 'C', 1);
    $pdf->SetXY($NumCol * $ArrowW + 2 * $TotalW + $GoldW + $WhereStartX[$WhichScore], 35);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->Cell(2 * $GoldW, 6, get_text('Rank'), 'TLR', 1, 'C', 1);
    $pdf->SetXY($NumCol * $ArrowW + 2 * $TotalW + $GoldW + $WhereStartX[$WhichScore], $pdf->GetY());
    $pdf->SetFont($pdf->FontStd, 'B', 25);
    $pdf->Cell(2 * $GoldW, 12, $MyRow->IndRank, 'BLR', 1, 'C', 1);
    //Header
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell($GoldW, CellH, '', 0, 0, 'C', 0);
    $pdf->Cell(2 * $GoldW + 2 * $TotalW + $NumCol * $ArrowW, CellH, get_text(namePhase($MyRow->EvFinalFirstPhase, $MyRow->GrPhase) . '_Phase'), 1, 0, 'C', 1);
    //Winner Checkbox
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell(2 * $GoldW, CellH, '', 0, 0, 'C', 0);
    //$pdf->Rect($WhereX[$WhichScore]+$GoldW+2,$WhereY[$WhichScore]+2,$GoldW-4,CellH-4,'DF',array(),array(255,255,255));
    $pdf->Rect($WhereX[$WhichScore] + $GoldW + 2, $WhereY[$WhichScore] + 2, CellH - 4, CellH - 4, 'DF', array(), array(255, 255, 255));
    if ($FillWithArrows && ($MyRow->Score > $MyRowOpp->Score || $MyRow->Score == $MyRowOpp->Score && $MyRow->FinTie > $MyRowOpp->FinTie)) {
        $tmpWidth = $pdf->GetLineWidth();
        $pdf->SetLineWidth($tmpWidth * 5);
        $pdf->Line($WhereX[$WhichScore] + $GoldW + 1, $WhereY[$WhichScore] + 1, $WhereX[$WhichScore] + 2 * $GoldW - 1, $WhereY[$WhichScore] + CellH - 1);
        $pdf->Line($WhereX[$WhichScore] + $GoldW + 1, $WhereY[$WhichScore] + CellH - 1, $WhereX[$WhichScore] + 2 * $GoldW - 1, $WhereY[$WhichScore] + 1);
        $pdf->SetLineWidth($tmpWidth);
    }
    $pdf->SetDefaultColor();
    $pdf->Cell($GoldW + 2 * $TotalW + $NumCol * $ArrowW, CellH, get_text('Winner'), 0, 1, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY();
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell($GoldW, CellH, '', 0, 0, 'C', 0);
    if ($Score3D) {
        $pdf->Cell($NumCol * $ArrowW, CellH, get_text('Arrow'), 1, 0, 'C', 1);
    } else {
        for ($j = 0; $j < $NumCol; $j++) {
            $pdf->Cell($ArrowW, CellH, $j + 1, 1, 0, 'C', 1);
        }
    }
    $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), CellH, get_text($MyRow->EvMatchMode == 0 ? 'TotalProg' : 'SetTotal', 'Tournament'), 1, 0, 'C', 1);
    $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), CellH, get_text('RunningTotal', 'Tournament'), 1, 0, 'C', 1);
    if ($MyRow->EvMatchMode == 0) {
        $pdf->Cell($GoldW, CellH, $pdf->prnGolds, 1, 0, 'C', 1);
        $pdf->Cell($GoldW, CellH, $pdf->prnXNine, 1, 1, 'C', 1);
    } else {
        $pdf->Cell(2 * $GoldW, CellH, get_text('SetPoints', 'Tournament'), 1, 0, 'C', 1);
        $pdf->Cell(2 / 5 * $TotalW, CellH, get_text('TotalShort', 'Tournament'), 1, 1, 'C', 1);
    }
    $WhereY[$WhichScore] = $pdf->GetY();
    //Righe
    $ScoreTotal = 0;
    $ScoreGold = 0;
    $ScoreXnine = 0;
    $SetTotal = '';
    for ($i = 1; $i <= $NumRow; $i++) {
        $ScoreEndTotal = 0;
        $ScoreEndGold = 0;
        $ScoreEndXnine = 0;
        $pdf->SetFont($pdf->FontStd, 'B', 10);
        $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
        $pdf->Cell($GoldW, CellH, $i, 1, 0, 'C', 1);
        $pdf->SetFont($pdf->FontStd, '', 10);
        if ($Score3D) {
            $pdf->Cell($ArrowW / 5, CellH, '11', 1, 0, 'C', 0);
            $pdf->Cell($ArrowW / 5, CellH, '10', 1, 0, 'C', 0);
            $pdf->Cell($ArrowW / 5, CellH, '8', 1, 0, 'C', 0);
            $pdf->Cell($ArrowW / 5, CellH, '5', 1, 0, 'C', 0);
            $pdf->Cell($ArrowW / 5, CellH, 'M', 1, 0, 'C', 0);
        } else {
            for ($j = 0; $j < $NumCol; $j++) {
                $pdf->Cell($ArrowW, CellH, $FillWithArrows ? DecodeFromLetter(substr($MyRow->FinArrowString, ($i - 1) * $NumCol + $j, 1)) : '', 1, 0, 'C', 0);
            }
            $IsEndScore = trim(substr($MyRow->FinArrowString, ($i - 1) * $NumCol, $NumCol));
            list($ScoreEndTotal, $ScoreEndGold, $ScoreEndXnine) = ValutaArrowStringGX(substr($MyRow->FinArrowString, ($i - 1) * $NumCol, $NumCol), $pdf->goldsChars, $pdf->xNineChars);
            $ScoreTotal += $ScoreEndTotal;
            $ScoreGold += $ScoreEndGold;
            $ScoreXnine += $ScoreEndXnine;
        }
        $pdf->SetFont($pdf->FontStd, '', $MyRow->EvMatchMode == 0 ? 10 : 12);
        $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), CellH, $FillWithArrows && $IsEndScore ? $ScoreEndTotal : '', 1, 0, 'C', 0);
        $pdf->SetFont($pdf->FontStd, '', $MyRow->EvMatchMode == 0 ? 12 : 10);
        $pdf->Cell($TotalW * ($MyRow->EvMatchMode == 0 ? 1 : 4 / 5), CellH, $FillWithArrows && $IsEndScore ? $ScoreTotal : '', 1, 0, 'C', 0);
        if ($MyRow->EvMatchMode == 0) {
            $pdf->SetFont($pdf->FontStd, '', 9);
            $pdf->Cell($GoldW, CellH, $FillWithArrows && $IsEndScore ? $ScoreEndGold : '', 1, 0, 'C', 0);
            $pdf->Cell($GoldW, CellH, $FillWithArrows && $IsEndScore ? $ScoreEndXnine : '', 1, 1, 'C', 0);
        } else {
            $SetTotSx = '';
            if ($IsEndScore && $FillWithArrows) {
                $SetPointSx = ValutaArrowString(substr($MyRow->FinArrowString, ($i - 1) * $NumCol, $NumCol));
                $SetPointDx = ValutaArrowString(substr($MyRowOpp->FinArrowString, ($i - 1) * $NumCol, $NumCol));
                if ($SetPointSx > $SetPointDx) {
                    $SetTotSx = 2;
                } elseif ($SetPointSx < $SetPointDx) {
                    $SetTotSx = 0;
                } else {
                    $SetTotSx = 1;
                }
                $SetTotal = intval($SetTotal) + $SetTotSx;
            }
            $pdf->SetFont($pdf->FontStd, 'B', 11);
            if ($SetTotSx == 2 && $FillWithArrows) {
                $pdf->Circle($pdf->GetX() + $GoldW / 3, $pdf->GetY() + CellH / 2, $GoldW / 3, 0, 360, 'FD');
            }
            $pdf->Cell(2 * $GoldW / 3, CellH, '2', 1, 0, 'C', 0);
            if ($SetTotSx == 1 && $FillWithArrows) {
                $pdf->Circle($pdf->GetX() + $GoldW / 3, $pdf->GetY() + CellH / 2, $GoldW / 3, 0, 360, 'FD');
            }
            $pdf->Cell(2 * $GoldW / 3, CellH, '1', 1, 0, 'C', 0);
            if ($SetTotSx == 0 && $IsEndScore && $FillWithArrows) {
                $pdf->Circle($pdf->GetX() + $GoldW / 3, $pdf->GetY() + CellH / 2, $GoldW / 3, 0, 360, 'FD');
            }
            $pdf->Cell(2 * $GoldW / 3, CellH, '0', 1, 0, 'C', 0);
            $pdf->Cell($TotalW * 2 / 5, CellH, $IsEndScore && $FillWithArrows ? $SetTotal : '', 1, 1, 'C', 0);
        }
        $WhereY[$WhichScore] = $pdf->GetY();
    }
    //Shoot Off
    $closeToCenter = false;
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore] + CellH / 4);
    $pdf->SetFont($pdf->FontStd, 'B', 8);
    $pdf->Cell($GoldW, CellH * 11 / 8, get_text('TB'), 1, 0, 'C', 1);
    $ShootOffW = $MyRow->CalcSO <= $NumCol ? $ArrowW : $ArrowW * $NumCol / $MyRow->CalcSO;
    for ($j = 0; $j < $MyRow->CalcSO; $j++) {
        $pdf->SetXY($pdf->GetX() + 0.5, $pdf->GetY());
        $pdf->SetFont($pdf->FontStd, '', 10);
        $pdf->Cell($ShootOffW - 0.5, CellH * 3 / 4, $FillWithArrows ? DecodeFromLetter(substr($MyRow->FinTieBreak, $j, 1)) : '', 1, 0, 'C', 0);
        if (substr($FillWithArrows ? DecodeFromLetter(substr($MyRow->FinTieBreak, $j, 1)) : '', -1, 1) == "*") {
            $closeToCenter = true;
        }
    }
    if ($NumCol > $j) {
        $pdf->Cell($ArrowW * ($NumCol - $j), CellH * 3 / 4, '', 0, 0, 'L', 0);
    }
    //Totale
    $pdf->SetXY($pdf->GetX(), $WhereY[$WhichScore]);
    $pdf->SetFont($pdf->FontStd, 'B', 10);
    if ($MyRow->EvMatchMode == 0) {
        $pdf->Cell($TotalW, CellH, get_text('Total'), 0, 0, 'R', 0);
        $pdf->SetFont($pdf->FontStd, 'B', 11);
        $pdf->Cell($TotalW, CellH, $FillWithArrows ? $ScoreTotal : '', 1, 0, 'C', 0);
        $pdf->SetFont($pdf->FontStd, '', 10);
        $pdf->Cell($GoldW, CellH, $FillWithArrows ? $ScoreGold : '', 1, 0, 'C', 0);
        $pdf->Cell($GoldW, CellH, $FillWithArrows ? $ScoreXnine : '', 1, 1, 'C', 0);
    } else {
        $pdf->Cell($TotalW * 8 / 5, CellH, '', 0, 0, 'R', 0);
        $pdf->SetFont($pdf->FontStd, 'B', 10);
        $pdf->Cell(2 * $GoldW, CellH, get_text('Total'), 0, 0, 'R', 0);
        $pdf->SetFont($pdf->FontStd, 'B', 14);
        $pdf->Cell(2 / 5 * $TotalW, CellH, $FillWithArrows ? $MyRow->FinSetScore : '', 1, 1, 'C', 0);
    }
    $WhereY[$WhichScore] = $pdf->GetY();
    //Closet to the center
    $pdf->SetFont($pdf->FontStd, '', 9);
    $pdf->SetXY($WhereX[$WhichScore] + $GoldW + $ShootOffW / 2, $WhereY[$WhichScore] + CellH / 8);
    $pdf->Cell($ShootOffW / 2, CellH / 2, '', 1, 0, 'R', 0);
    if ($closeToCenter) {
        $tmpWidth = $pdf->GetLineWidth();
        $pdf->SetLineWidth($tmpWidth * 5);
        $pdf->Line($WhereX[$WhichScore] + $GoldW + $ShootOffW / 2 - 1, $WhereY[$WhichScore] + CellH / 8 - 1, $WhereX[$WhichScore] + $GoldW + $ShootOffW + 1, $WhereY[$WhichScore] + CellH * 5 / 8 + 1);
        $pdf->Line($WhereX[$WhichScore] + $GoldW + $ShootOffW / 2 - 1, $WhereY[$WhichScore] + CellH * 5 / 8 + 1, $WhereX[$WhichScore] + $GoldW + $ShootOffW + 1, $WhereY[$WhichScore] + CellH / 8 - 1);
        $pdf->SetLineWidth($tmpWidth);
    }
    $pdf->Cell($ArrowW * ($NumCol - 1), CellH * 2 / 4, get_text('Close2Center', 'Tournament'), 0, 0, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY() + 10;
    //Firme
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->SetFont($pdf->FontStd, 'I', 7);
    $pdf->Cell(3 * $GoldW + 2 * $TotalW + $NumCol * $ArrowW, 4, get_text('Archer'), 'B', 0, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY() + 10;
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell(3 * $GoldW + 2 * $TotalW + $NumCol * $ArrowW, 4, get_text('Scorer'), 'B', 0, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY() + 15;
    $pdf->SetXY($WhereX[$WhichScore], $WhereY[$WhichScore]);
    $pdf->Cell(3 * $GoldW + 2 * $TotalW + $NumCol * $ArrowW, 4, get_text('JudgeNotes'), 'B', 0, 'L', 0);
    $WhereY[$WhichScore] = $pdf->GetY();
}
Exemplo n.º 22
-1
                 // makes sense if a tie is not leading to archer 1 victory!
                 // 								if($v==$MaxTargetPoints) {
                 // 									// can only tie the set
                 // 									$X1towin=$v;
                 // 									$X1todescr='tie set';
                 // 								} else {
                 // 									$X1towin=$v+1;
                 // 									$X1todescr='win set';
                 // 								}
             }
         }
     }
 } else {
     // cumulative points...
     $v1 = ValutaArrowString($r['score']);
     $v2 = ValutaArrowString($r['oppScore']);
     $v = abs($v1 - $v2);
     // check if it wins or ties the match
     $CumArrows = $NumEnds * $NumArrows;
     if ($v <= $MaxTargetPoints) {
         // only if it is a coherent point
         if ($dif == 1) {
             // archer 2 is shooting
             $ArrowString = strlen(trim($r['arrowstring']));
             if ($ArrowString == $CumArrows) {
                 // ready to win or tie SO
                 if ($v == $MaxTargetPoints) {
                     // can only tie
                     $X2towin = $v;
                     $X2todescr = 'tie SO';
                 } else {
Exemplo n.º 23
-1
 $ScoreDx .= '</tr>' . "\n";
 $ScoreDx .= '<tr>';
 for ($j = 0; $j < $nARR; ++$j) {
     $ScoreDx .= '<th style="font-size:180%; font-weight:bold; text-align:center; width:15%; width:10%">' . ($j + 1) . '</th>';
 }
 $ScoreDx .= '</tr>' . "\n";
 $Tot = 0;
 $TotSet = 0;
 // ArrowString
 for ($i = 0; $i < $nEND; ++$i) {
     $TotSerie = 0;
     $ScoreDx .= '<tr>';
     $ScoreDx .= '<th style="font-size:180%; font-weight:bold; text-align:center;">' . ($i + 1) . '</th>';
     for ($j = 0; $j < $nARR; ++$j) {
         $ScoreDx .= '<td style="font-size:180%; font-weight:bold; text-align:center;">' . ($MyPValue = DecodeFromLetter($ArrDx[$i * $nARR + $j]) . '</td>');
         $TotSerie += ValutaArrowString($ArrDx[$i * $nARR + $j]);
     }
     $Tot += $TotSerie;
     $ScoreDx .= '<td style="font-size:180%; font-weight:bold; text-align:right;">' . $TotSerie . '</td>';
     if ($MyRowDx->MatchMode == 0) {
         $ScoreDx .= '<td style="font-size:180%; ' . ($MyRowDx->MatchMode == 0 ? 'font-weight:bold; ' : '') . 'text-align:right;">' . $Tot . '</td>';
     } else {
         $TotSet += empty($SetTotDx[$i]) ? 0 : $SetTotDx[$i];
         $ScoreDx .= '<td style="font-size:160%; font-weight:bold; text-align:right;">' . (empty($SetTotDx[$i]) ? '0' : $SetTotDx[$i]) . '</td>';
         $ScoreDx .= '<td style="font-size:180%; font-weight:bold; text-align:right;">' . $TotSet . '</td>';
     }
     $ScoreDx .= '</tr>' . "\n";
 }
 // Tiebreak
 $ScoreDx .= '<tr>';
 $ScoreDx .= '<th style="font-size:180%; font-weight:bold; text-align:center;">T.B.</th>';
Exemplo n.º 24
-2
 public function read()
 {
     $filter = $this->safeFilter();
     error_reporting(E_ALL);
     /*
      *  prima passata per costruire la struttura del vettore.
      *  Tiro fuori i nomi delle squadre
      */
     $MyQueryNames = "SELECT TfcId, TfcEvent, TfcCoId, TfcSubTeam, TfcOrder, ucase(EnFirstName) EnUpperName, EnFirstName, EnName, concat(ucase(EnFirstName), ' ', EnName) Athlete, CONCAT(TeRank,CHAR(64+TfcOrder)) AS BackNo  ";
     $MyQueryNames .= "FROM TeamFinComponent ";
     $MyQueryNames .= "INNER JOIN Events ON TfcEvent=EvCode AND TfcTournament=EvTournament AND EvTeamEvent=1 AND EvFinalFirstPhase!=0 ";
     $MyQueryNames .= "INNER JOIN Entries ON TfcId=EnId AND TfcTournament=EnTournament ";
     $MyQueryNames .= "INNER JOIN Teams ON TfcCoId=TeCoId AND TfcSubTeam=TeSubTeam AND TfcEvent=TeEvent AND TfcTournament=TeTournament AND TeFinEvent=1 ";
     $MyQueryNames .= "WHERE TfcTournament = " . $this->tournament . " ";
     if (!empty($this->opts['events'])) {
         $MyQueryNames .= CleanEvents($this->opts['events'], 'TfcEvent');
     }
     $MyQueryNames .= " ORDER BY EvProgr, TfcEvent, TfcCoId, TfcSubTeam, TfcOrder ";
     $this->data['sections'] = array();
     $q = safe_r_SQL($MyQueryNames);
     while ($r = safe_fetch($q)) {
         $this->data['sections'][$r->TfcEvent]['athletes'][$r->TfcCoId][$r->TfcSubTeam][] = array('athlete' => $r->Athlete, 'backNo' => $r->BackNo, 'id' => $r->TfcId, 'familyName' => $r->EnFirstName, 'familyUpperName' => $r->EnUpperName, 'givenName' => $r->EnName);
         if (!empty($this->opts['enid']) and $r->TfcId == $this->opts['enid']) {
             $this->EnIdFound[] = $r->TfcEvent;
             $this->TeamFound = $r->TfcCoId;
         }
     }
     if (!empty($this->opts['enid'])) {
         if (!$this->EnIdFound) {
             return;
         }
         foreach ($this->data['sections'] as $ev => $data) {
             if (!in_array($ev, $this->EnIdFound)) {
                 unset($this->data['sections'][$ev]);
             }
         }
     }
     $q = "SELECT * from (" . "select" . " EvCode Event," . " EvEventName EventDescr," . " EvFinalFirstPhase," . " EvMaxTeamPerson," . " EvFinalPrintHead," . " EvMatchMode," . " EvProgr," . " EvShootOff," . " GrPhase Phase," . " IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition) Position," . " TfTournament Tournament," . " TfTeam Team," . " TfSubTeam SubTeam," . " TfMatchNo MatchNo," . " TeRank QualRank," . " TeRankFinal FinRank," . " TeScore QualScore, " . " TfWinLose Winner, " . " TfDateTime LastUpdated, " . " CONCAT(CoName, IF(TfSubTeam>'1',CONCAT(' (',TfSubTeam,')'),'')) as CountryName," . " CoCode as CountryCode," . " TfScore AS Score," . " TfSetScore as SetScore," . " TfTie Tie," . " TfTieBreak TieBreak," . " TfStatus Status, " . " TfSetPoints SetPoints, " . " TfArrowstring arrowstring, TfLive LiveFlag," . " FSTarget Target," . " TarId, TarDescr, EvDistance as Distance, EvTargetSize as TargetSize, " . "\tEvFinEnds, EvFinArrows, EvFinSO, EvElimEnds, EvElimArrows, EvElimSO, " . " DATE_FORMAT(FSScheduledDate,'" . get_text('DateFmtDB') . "') as ScheduledDate," . " DATE_FORMAT(FSScheduledTime,'" . get_text('TimeFmt') . "') AS ScheduledTime " . " FROM TeamFinals " . " INNER JOIN Events ON TfEvent=EvCode AND TfTournament=EvTournament AND EvTeamEvent=1 AND EvFinalFirstPhase!=0 " . " INNER JOIN Grids ON TfMatchNo=GrMatchNo " . " INNER JOIN Targets ON EvFinalTargetType=TarId " . " LEFT JOIN Teams ON TfTeam=TeCoId AND TfSubTeam=TeSubTeam AND TfEvent=TeEvent AND TfTournament=TeTournament AND TeFinEvent=1 " . " LEFT JOIN Countries ON TfTeam=CoId AND TfTournament=CoTournament " . " LEFT JOIN FinSchedule ON TfEvent=FSEvent AND TfMatchNo=FSMatchNo AND TfTournament=FSTournament AND FSTeamEvent='1' " . " WHERE TfMatchNo%2=0 AND TfTournament = " . $this->tournament . " " . $filter . ") f1 inner join (" . "select" . " EvCode OppEvent," . " IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition) OppPosition," . " TfTournament OppTournament," . " TfTeam OppTeam," . " TfSubTeam OppSubTeam," . " TfMatchNo OppMatchNo," . " TeRank OppQualRank," . " TeRankFinal OppFinRank," . " TeScore OppQualScore, " . " TfWinLose OppWinner, " . " TfDateTime OppLastUpdated, " . " CONCAT(CoName, IF(TfSubTeam>'1',CONCAT(' (',TfSubTeam,')'),'')) as OppCountryName," . " CoCode as OppCountryCode," . " TfScore AS OppScore," . " TfSetScore as OppSetScore," . " TfTie OppTie," . " TfTieBreak OppTieBreak," . " TfStatus OppStatus, " . " TfSetPoints OppSetPoints, " . " TfArrowstring oppArrowstring, " . " FSTarget OppTarget " . " FROM TeamFinals " . " INNER JOIN Events ON TfEvent=EvCode AND TfTournament=EvTournament AND EvTeamEvent=1 AND EvFinalFirstPhase!=0 " . " INNER JOIN Grids ON TfMatchNo=GrMatchNo " . " LEFT JOIN Teams ON TfTeam=TeCoId AND TfSubTeam=TeSubTeam AND TfEvent=TeEvent AND TfTournament=TeTournament AND TeFinEvent=1 " . " LEFT JOIN Countries ON TfTeam=CoId AND TfTournament=CoTournament " . " LEFT JOIN FinSchedule ON TfEvent=FSEvent AND TfMatchNo=FSMatchNo AND TfTournament=FSTournament AND FSTeamEvent='1' " . " WHERE TfMatchNo%2=1 AND TfTournament = " . $this->tournament . " " . $filter . ") f2 on Tournament=OppTournament and Event=OppEvent and MatchNo=OppMatchNo-1 " . ($this->EnIdFound ? ' where Event in ("' . implode('","', $this->EnIdFound) . '") AND (Team=' . StrSafe_DB($this->TeamFound) . ' or oppTeam=' . StrSafe_DB($this->TeamFound) . ')' : '') . (empty($this->opts['coid']) ? '' : " where (Team=" . intval($this->opts['coid']) . " or OppTeam=" . intval($this->opts['coid']) . ") ") . (isset($this->opts['matchno']) ? " where MatchNo=" . intval($this->opts['matchno']) . ' ' : '') . (isset($this->opts['liveFlag']) ? " where LiveFlag=1 " : '') . " ORDER BY EvProgr ASC, event, Phase DESC, MatchNo ASC ";
     $r = safe_r_sql($q);
     $this->data['meta']['title'] = get_text('BracketsSq');
     $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00';
     $this->data['meta']['fields'] = array('scheduledDate' => get_text('Date', 'Tournament'), 'scheduledTime' => get_text('Time', 'Tournament'), 'winner' => get_text('Winner'), 'matchNo' => get_text('MatchNo'), 'bib' => get_text('Code', 'Tournament'), 'target' => get_text('Target'), 'athlete' => get_text('Athlete'), 'familyname' => get_text('FamilyName', 'Tournament'), 'givenname' => get_text('Name', 'Tournament'), 'countryCode' => '', 'countryName' => get_text('Country'), 'countryIocCode' => '', 'qualRank' => get_text('RankScoreShort'), 'finRank' => get_text('FinalRank', 'Tournament'), 'qualscore' => get_text('TotalShort', 'Tournament'), 'score' => get_text('TotalShort', 'Tournament'), 'setScore' => get_text('SetTotal', 'Tournament'), 'setPoints' => get_text('SetPoints', 'Tournament'), 'tie' => 'S.O.', 'arrowstring' => get_text('Arrows', 'Tournament'), 'tiebreak' => get_text('TieArrows'), 'status' => get_text('Status', 'Tournament'), 'oppMatchNo' => get_text('MatchNo'), 'oppBib' => get_text('Code', 'Tournament'), 'oppTarget' => get_text('Target'), 'oppAthlete' => get_text('Athlete'), 'oppFamilyname' => get_text('FamilyName', 'Tournament'), 'oppGivenname' => get_text('Name', 'Tournament'), 'oppCountryCode' => '', 'oppCountryName' => get_text('Country'), 'oppCountryIocCode' => '', 'oppQualRank' => get_text('RankScoreShort'), 'oppFinRank' => get_text('FinalRank', 'Tournament'), 'oppQualScore' => get_text('TotalShort', 'Tournament'), 'oppScore' => get_text('TotalShort', 'Tournament'), 'oppSetScore' => get_text('SetTotal', 'Tournament'), 'oppSetPoints' => get_text('SetPoints', 'Tournament'), 'oppTie' => 'S.O.', 'oppArrowstring' => get_text('Arrows', 'Tournament'), 'oppTiebreak' => get_text('TieArrows'), 'oppStatus' => get_text('Status', 'Tournament'));
     while ($myRow = safe_fetch($r)) {
         if ($myRow->LastUpdated > $this->data['meta']['lastUpdate']) {
             $this->data['meta']['lastUpdate'] = $myRow->LastUpdated;
         }
         if ($myRow->OppLastUpdated > $this->data['meta']['lastUpdate']) {
             $this->data['meta']['lastUpdate'] = $myRow->OppLastUpdated;
         }
         if (!isset($this->data['sections'][$myRow->Event]['meta'])) {
             $this->data['sections'][$myRow->Event]['meta'] = array('phase' => get_text('Phase'), 'eventName' => get_text($myRow->EventDescr, '', '', true), 'firstPhase' => $myRow->EvFinalFirstPhase, 'printHead' => get_text($myRow->EvFinalPrintHead, '', '', true), 'maxTeamPerson' => $myRow->EvMaxTeamPerson, 'matchMode' => $myRow->EvMatchMode, 'order' => $myRow->EvProgr, 'shootOffSolved' => $myRow->EvShootOff, 'finEnds' => $myRow->EvFinEnds, 'finArrows' => $myRow->EvFinArrows, 'finSO' => $myRow->EvFinSO, 'elimEnds' => $myRow->EvElimEnds, 'elimArrows' => $myRow->EvElimArrows, 'elimSO' => $myRow->EvElimSO, 'targetType' => $myRow->TarDescr, 'targetTypeId' => $myRow->TarId, 'targetSize' => $myRow->TargetSize, 'distance' => $myRow->Distance);
             $this->data['sections'][$myRow->Event]['phases'] = array();
         }
         if (!isset($this->data['sections'][$myRow->Event]['phases'][$myRow->Phase])) {
             $this->data['sections'][$myRow->Event]['phases'][$myRow->Phase]['meta'] = array('phaseName' => get_text($myRow->Phase . "_Phase"));
             $this->data['sections'][$myRow->Event]['phases'][$myRow->Phase]['items'] = array();
         }
         $tmpArr = array();
         $oppArr = array();
         if ($myRow->TieBreak) {
             for ($countArr = 0; $countArr < strlen(trim($myRow->TieBreak)); $countArr += $myRow->EvMaxTeamPerson) {
                 $tmp = ValutaArrowString(substr(trim($myRow->TieBreak), $countArr, $myRow->EvMaxTeamPerson));
                 if (!ctype_upper(trim($myRow->TieBreak))) {
                     $tmp .= "*";
                 }
                 $tmpArr[] = $tmp;
             }
             //debug_svela($myRow);
         }
         if ($myRow->OppTieBreak) {
             for ($countArr = 0; $countArr < strlen(trim($myRow->OppTieBreak)); $countArr += $myRow->EvMaxTeamPerson) {
                 $tmp = ValutaArrowString(substr(trim($myRow->OppTieBreak), $countArr, $myRow->EvMaxTeamPerson));
                 if (!ctype_upper(trim($myRow->OppTieBreak))) {
                     $tmp .= "*";
                 }
                 $oppArr[] = $tmp;
             }
         }
         $this->data['sections'][$myRow->Event]['phases'][$myRow->Phase]['items'][] = array('liveFlag' => $myRow->LiveFlag, 'scheduledDate' => $myRow->ScheduledDate, 'scheduledTime' => $myRow->ScheduledTime, 'matchNo' => $myRow->MatchNo, 'target' => $myRow->Target, 'countryCode' => $myRow->CountryCode, 'countryName' => $myRow->CountryName, 'qualRank' => $myRow->QualRank, 'finRank' => $myRow->FinRank, 'qualScore' => $myRow->QualScore, 'winner' => $myRow->Winner, 'score' => $myRow->Score, 'setScore' => $myRow->SetScore, 'setPoints' => $myRow->SetPoints, 'arrowstring' => $myRow->arrowstring, 'tie' => $myRow->Tie, 'tiebreak' => $myRow->TieBreak, 'tiebreakDecoded' => implode(',', $tmpArr), 'status' => $myRow->Status, 'position' => $myRow->QualRank ? $myRow->QualRank : $myRow->Position, 'teamId' => $myRow->Team, 'subTeam' => $myRow->SubTeam, 'oppMatchNo' => $myRow->OppMatchNo, 'oppTarget' => $myRow->OppTarget, 'oppCountryCode' => $myRow->OppCountryCode, 'oppCountryName' => $myRow->OppCountryName, 'oppQualRank' => $myRow->OppQualRank, 'oppFinRank' => $myRow->OppFinRank, 'oppQualScore' => $myRow->OppQualScore, 'oppWinner' => $myRow->OppWinner, 'oppScore' => $myRow->OppScore, 'oppSetScore' => $myRow->OppSetScore, 'oppSetPoints' => $myRow->OppSetPoints, 'oppArrowstring' => $myRow->oppArrowstring, 'oppTie' => $myRow->OppTie, 'oppTiebreak' => $myRow->OppTieBreak, 'oppTiebreakDecoded' => implode(',', $oppArr), 'oppStatus' => $myRow->OppStatus, 'oppPosition' => $myRow->OppQualRank ? $myRow->OppQualRank : $myRow->OppPosition, 'oppTeamId' => $myRow->OppTeam, 'oppSubTeam' => $myRow->OppSubTeam);
     }
 }