示例#1
0
                        $Update .= ",FinTie=" . StrSafe_DB($t) . " ";
                    } else {
                        $Tie_Error[$ee . '_' . $mm] = true;
                    }
                }
                $Update .= ",FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE FinEvent='" . $ee . "' AND FinMatchNo='" . $mm . "' AND FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
                $RsUp = safe_w_sql($Update);
                if (debug) {
                    print $Update . '<br><br>';
                }
            }
        }
    }
    // Faccio i passaggi di fase
    foreach ($AllowedEvents as $event => $phase) {
        move2NextPhase($phase, $event);
    }
}
$PAGE_TITLE = get_text('MenuLM_Data insert (Table view)');
$JS_SCRIPT = array('<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Final/Individual/Fun_JS.js"></script>');
include 'Common/Templates/head.php';
?>
<form name="Frm" method="post" action="InsertPoint2.php">
<input type="hidden" name="Command" value="">
<?php 
$useSession = false;
$PrecPhase = '';
//($_REQUEST['d_Phase']==0 ? 1 : ($_REQUEST['d_Phase']==32 ? 48 :$_REQUEST['d_Phase']*2));
$NextPhase = '';
//($_REQUEST['d_Phase']>1 ? ($_REQUEST['d_Phase']==48 ? 32 : ($_REQUEST['d_Phase']==24 ? 16 : $_REQUEST['d_Phase']/2)) : 0);
$PP = $PrecPhase;
示例#2
0
            set_qual_session_flags();
            // calcolo la finalrank di quelli che si son fermati alle quelifiche
            $coppie = array();
            $q = "SELECT EvCode FROM Events WHERE EvTournament={$_SESSION['TourId']} AND EvTeamEvent=0 AND EvCode NOT IN ('" . implode(',', $VetoEvents) . "')" . (count($Events) > 0 ? " AND EvCode IN('" . implode("','", $Events) . "') " : '');
            $r = safe_r_sql($q);
            while ($rr = safe_fetch($r)) {
                $coppie[$rr->EvCode] = $rr->EvCode . "@-3";
            }
            /*foreach ($Events as $e)
            		{
            			$coppie[$e]= $e . "@-3";
            		}*/
            //print_r($coppie);exit;
            Obj_RankFactory::create('FinalInd', array('eventsC' => $coppie))->calculate();
            foreach ($EventList as $key => $value) {
                move2NextPhase($value, $key, null);
            }
        }
    }
    //exit;
}
include 'Common/Templates/head.php';
?>
<table class="Tabella">
<TR><TH class="Title"><?php 
print get_text('ShootOff4Final') . ' - ' . get_text('Individual');
?>
</TH></TR>
<?php 
if (count($NotResolvedMsg) > 0) {
    ?>
示例#3
0
require_once 'Common/Fun_FormatText.inc.php';
require_once 'Fun_Final.local.inc.php';
require_once 'Fun_ChangePhase.inc.php';
CheckTourSession(true);
$event = isset($_REQUEST['event']) ? $_REQUEST['event'] : null;
$team = isset($_REQUEST['team']) ? $_REQUEST['team'] : null;
$match = isset($_REQUEST['match']) ? $_REQUEST['match'] : null;
$Errore = 0;
$msg = get_text('CmdOk');
$ok = false;
$isBlocked = $team == 0 ? IsBlocked(BIT_BLOCK_IND) : IsBlocked(BIT_BLOCK_TEAM);
if (is_null($event) || is_null($team) || is_null($match) || $isBlocked) {
    $Errore = 1;
} else {
    if ($team == 0) {
        $ok = move2NextPhase(null, $event, $match);
    } else {
        $ok = move2NextPhaseTeam(null, $event, $match);
    }
    if ($ok === false) {
        $Errore = 1;
    }
}
if ($Errore == 1) {
    $msg = get_text('Error');
}
if (!debug) {
    header('Content-Type: text/xml');
}
print '<response>' . "\n";
print '<error>' . $Errore . '</error>' . "\n";
示例#4
0
     }
 } elseif (substr($Key, 0, 4) == 'd_t_') {
     $tiebreak = '';
     $tiepoints = explode('|', $_REQUEST['d_t_' . $ee . '_' . $mm]);
     for ($i = 0; $i < count($tiepoints); ++$i) {
         $tiebreak .= GetLetterFromPrint($tiepoints[$i]);
     }
     $Update = "UPDATE Finals SET " . "FinTiebreak=" . StrSafe_DB($tiebreak) . ", " . "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND FinEvent=" . StrSafe_DB($ee) . " AND FinMatchNo=" . StrSafe_DB($mm) . " ";
     $Rs = safe_w_sql($Update);
 }
 $xml .= '<which>' . $Which . '</which>' . "\n";
 $xml .= '<field_error>' . $FieldError . '</field_error>' . "\n";
 // faccio il passaggio di fase di quel matchno e di quello accoppiato
 if ($Errore == 0) {
     //Faccio i passaggi di fase
     $updateTS = move2NextPhase(NULL, $ee, $mm);
     if (!is_null($updateTS)) {
         $Select = "SELECT " . "FinMatchNo, FinEvent,  FinAthlete, IF(EvMatchMode=0,FinScore,FinSetScore) AS Score, FinTie, " . "IFNULL(CONCAT(EnFirstName,' ',SUBSTRING(EnName,1,1),'.'),'#') AS Atleta, " . "IFNULL(CoCode,'#') AS Country " . "FROM Finals " . "INNER JOIN Events ON FinEvent=EvCode AND EvTeamEvent='0' AND EvTournament=FinTournament " . "LEFT JOIN Entries ON FinAthlete=EnId " . "LEFT JOIN Countries ON EnCountry=CoId " . "WHERE FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND FinEvent=" . StrSafe_DB($ee) . " AND FinDateTime=" . StrSafe_DB($updateTS) . " " . "ORDER BY FinEvent, FinMatchNo";
         $Rs = safe_w_sql($Select);
         if (safe_num_rows($Rs) > 0) {
             while ($MyRow = safe_fetch($Rs)) {
                 $xml .= '<ath>';
                 $xml .= '<name><![CDATA[' . $MyRow->Atleta . ']]></name>' . "\n";
                 $xml .= '<cty><![CDATA[' . $MyRow->Country . ']]></cty>' . "\n";
                 $xml .= '<event><![CDATA[' . $MyRow->FinEvent . ']]></event>' . "\n";
                 $xml .= '<matchno>' . $MyRow->FinMatchNo . '</matchno>' . "\n";
                 $xml .= '<tie>' . $MyRow->FinTie . '</tie>' . "\n";
                 $xml .= '</ath>' . "\n";
             }
         }
     }
示例#5
-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;
}