function SetElimArrowValue($Phase, $Event, $Target, $ArIndex, $ArSymbol, $Output = 'XML', $CompId = '')
{
    require_once 'Common/Lib/Obj_RankFactory.php';
    $JsonResult = array();
    $JsonResult['error'] = 1;
    $JsonResult['qutarget'] = $_REQUEST['qutarget'];
    $JsonResult['distnum'] = $_REQUEST['distnum'];
    $JsonResult['arrowindex'] = $_REQUEST['arrowindex'];
    $JsonResult['arrowsymbol'] = '';
    $JsonResult['curscore'] = '';
    $JsonResult['curgold'] = '';
    $JsonResult['curxnine'] = '';
    $JsonResult['score'] = '';
    $JsonResult['gold'] = '';
    $JsonResult['xnine'] = '';
    if (empty($CompId)) {
        $CompId = $_SESSION['TourId'];
    }
    $q = safe_r_sql("select * from Eliminations\r\n\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\tand ElEventCode='{$Event}'\r\n\t\tand ElTargetNo='{$Target}'\r\n\t\tand ElTournament={$CompId}\r\n\t\t");
    if ($r = safe_fetch($q)) {
        $Arrowstring = str_pad($r->ElArrowString, $ArIndex + 1, ' ', STR_PAD_RIGHT);
        $xx = GetLetterFromPrint($ArSymbol);
        $Arrowstring[$ArIndex] = str_pad($xx, 1, ' ', STR_PAD_RIGHT);
        list($CurScore, $CurGold, $CurXNine) = ValutaArrowStringGX($Arrowstring);
        safe_w_sql("update Eliminations\r\n\t\t\tset ElArrowString='{$Arrowstring}',\r\n\t\t\tElScore={$CurScore},\r\n\t\t\tElGold={$CurGold},\r\n\t\t\tElXnine={$CurXNine}\r\n\t\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\t\tand ElEventCode='{$Event}'\r\n\t\t\tand ElTargetNo='{$Target}'\r\n\t\t\tand ElTournament={$CompId}");
        if (safe_w_affected_rows()) {
            if ($Phase[1] == 1) {
                require_once 'Common/Fun_Sessions.inc.php';
                ResetElimRows($Event, 2);
            }
            Obj_RankFactory::create('ElimInd', array('tournament' => $CompId, 'eventsC' => array($Event . '@' . $Phase[1])))->calculate();
        }
        $JsonResult['error'] = 0;
        $JsonResult['arrowsymbol'] = $xx ? strtoupper($ArSymbol) : '';
        $JsonResult['curscore'] = $CurScore;
        $JsonResult['curgold'] = $CurGold;
        $JsonResult['curxnine'] = $CurXNine;
        $JsonResult['score'] = $CurScore;
        $JsonResult['gold'] = $CurGold;
        $JsonResult['xnine'] = $CurXNine;
    }
    return $JsonResult;
}
예제 #2
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);
 }
예제 #3
0
 }
 $Sql = "SELECT HhtData.*, QuD" . $Dist . "Arrowstring AS ArrowString " . "FROM HhtData " . "INNER JOIN Entries ON HdEnId=EnId AND EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "INNER JOIN Qualifications ON EnId=QuId " . "WHERE LEFT(HdTargetNo,1)=" . StrSafe_DB($xSession) . " AND HdDistance=" . StrSafe_DB($Dist) . " AND HdArrowStart=" . StrSafe_DB($FirstArr) . " AND HdTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND HdHhtId=" . StrSafe_DB($_REQUEST['x_Hht']) . " " . "ORDER BY HdTargetNo ASC ";
 $Rs = safe_r_sql($Sql);
 if (safe_num_rows($Rs) > 0 && !IsBlocked(BIT_BLOCK_QUAL)) {
     while ($myRow = safe_fetch($Rs)) {
         $Msg .= get_text('Importing', 'HTT', substr($myRow->HdTargetNo, 1)) . '...';
         $Start = $myRow->HdArrowStart - 1;
         $Len = $myRow->HdArrowEnd - $myRow->HdArrowStart + 1;
         $ArrowString = substr_replace(str_pad($myRow->ArrowString, 90, " ", STR_PAD_RIGHT), substr($myRow->HdArrowString, 0, $Len), $Start, $Len);
         //print $myRow->HdTargetNo . ' ...' . $ArrowString . '...<br><br>';
         // Ora posso calcolare i punti della distanza
         $Score = 0;
         $Gold = 0;
         $XNine = 0;
         $Update = "";
         list($Score, $Gold, $XNine) = ValutaArrowStringGX($ArrowString, $G, $X);
         // Ora posso aggiornare la riga di Qualifications
         $Update = "UPDATE Qualifications SET " . "QuD" . $Dist . "Score=" . StrSafe_DB($Score) . "," . "QuD" . $Dist . "Gold=" . StrSafe_DB($Gold) . "," . "QuD" . $Dist . "Xnine=" . StrSafe_DB($XNine) . "," . "QuD" . $Dist . "ArrowString=" . StrSafe_DB($ArrowString) . "," . "QuD" . $Dist . "Hits=GREATEST(LENGTH(RTRIM(QuD" . $Dist . "ArrowString))," . StrSafe_DB($LastArr) . ")," . "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, " . "QuHits=QuD1Hits+QuD2Hits+QuD3Hits+QuD4Hits+QuD5Hits+QuD6Hits+QuD7Hits+QuD8Hits, " . "QuTimestamp=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE QuId=" . StrSafe_DB($myRow->HdEnId) . " ";
         $RsUp = safe_w_sql($Update);
         useArrowsSnapshot($xSession, $Dist, substr($myRow->HdTargetNo, 1, -1), substr($myRow->HdTargetNo, 1, -1), $LastArr);
         recalSnapshot($xSession, $Dist, substr($myRow->HdTargetNo, 1, -1), substr($myRow->HdTargetNo, 1, -1));
         //print $Update . '<br><br>';
         //							if()
         if ($RsUp) {
             $Msg .= get_text('CmdOk') . '<br>';
         } else {
             $Msg .= '<br>';
         }
     }
     // rank distanza
     CalcQualRank($Dist, '%');
예제 #4
0
        $ArrowString = substr($ArrowString, $Arrows);
    }
    if ($Arrows > 3 and $Arrows % 3) {
        // arrows per end are more than 6 and not multiple of 3
        // so ends will be reduced to max 6 arrows
        $tmp = ceil($Arrows / 6);
        $Arrows = ceil($Arrows / $tmp);
    } else {
        $tmp = ceil($Arrows / 3);
        $Arrows = ceil($Arrows / $tmp);
    }
    $Distance = array('distancename' => $r->DiName, 'endarrows' => $Arrows, 'endscores' => array());
    $EndNum = 1;
    foreach ($RealEnds as $RealEnd) {
        $RealEnd = str_pad($RealEnd, $Arrows);
        while (strlen($RealEnd)) {
            $End = substr($RealEnd, 0, $Arrows);
            $EndArray = array('endnum' => $EndNum, 'arrowscores' => array(), 'endtotal' => 0, 'endgolds' => 0, 'endxnine' => 0);
            foreach (range(0, $Arrows - 1) as $Arrow) {
                $EndArray['arrowscores'][] = DecodeFromLetter(substr($End, $Arrow, 1));
            }
            list($EndArray['endtotal'], $EndArray['endgolds'], $EndArray['endxnine']) = ValutaArrowStringGX($End, $r->ToGoldsChars, $r->ToXNineChars);
            $EndNum++;
            $Distance['endscores'][] = $EndArray;
            $RealEnd = substr($RealEnd, $Arrows);
        }
    }
    $json_array[] = $Distance;
}
// Return the json structure with the callback function that is needed by the app
SendResult($json_array);
예제 #5
0
     //					{
     //						$ArrowString[$_REQUEST['Index']]=$Value2Write;
     //					}
     //					else
     //					{
     //						$Errore=1;
     //					}
 } else {
     $Errore = 1;
 }
 if (debug) {
     print '<pre>...' . $ArrowString . '...</pre><br>';
 }
 if ($Errore == 0) {
     // Ricalcolo i totali della distanza usando $ArrowString
     list($CurScore, $CurGold, $CurXNine) = ValutaArrowStringGX($ArrowString, $G, $X);
     if (debug) {
         print $Score . '<br>';
     }
     // Estraggo il vecchio valore
     $Select = "SELECT QuD" . $_REQUEST['Dist'] . "Score AS OldScore " . "FROM Qualifications " . "WHERE QuId=" . StrSafe_DB($_REQUEST['Id']) . " ";
     $Rs = safe_r_sql($Select);
     if (safe_num_rows($Rs) == 1) {
         $MyRow = safe_fetch($Rs);
         $OldValue = $MyRow->OldScore;
     } else {
         $Errore = 1;
     }
     if ($Errore == 0) {
         // Aggiorno i totali della distanza
         $Update = "UPDATE Qualifications SET " . "QuD" . $_REQUEST['Dist'] . "ArrowString=" . StrSafe_DB($ArrowString) . "," . "QuD" . $_REQUEST['Dist'] . "Score=" . StrSafe_DB($CurScore) . ", " . "QuD" . $_REQUEST['Dist'] . "Gold=" . StrSafe_DB($CurGold) . ", " . "QuD" . $_REQUEST['Dist'] . "Xnine=" . StrSafe_DB($CurXNine) . ", " . "QuD" . $_REQUEST['Dist'] . "Hits=" . StrSafe_DB(strlen(rtrim($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, " . "QuHits=QuD1Hits+QuD2Hits+QuD3Hits+QuD4Hits+QuD5Hits+QuD6Hits+QuD7Hits+QuD8Hits, " . "QuTimestamp=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE QuId=" . StrSafe_DB($_REQUEST['Id']) . " ";
function useArrowsSnapshot($Session, $Distance, $fromTarget, $toTarget, $numArrows)
{
    CheckTourSession();
    /*$Select
    			= "SELECT EnId as ID, ". $Distance . " AS Distance, ";
    		for($i=1; $i<$Distance; $i++)
    			$Select .= "QuD" . $i . "Hits+";
    		$Select .= $numArrows . " AS TotHits, ";
    
    		$Select .= "SUBSTRING(QuD" . $Distance . "ArrowString,1," . $numArrows . ") AS TotArrowString, ";
    
    		$Select
    			.= "TtGolds, TtXNine, QuTimeStamp as Tstamp "
    			. "FROM Entries "
    			. "INNER JOIN Qualifications ON EnId=QuId "
    			. "INNER JOIN Tournament ON EnTournament=ToId "
    			. "INNER JOIN Tournament*Type ON ToType=TtId "
    			. "WHERE EnAthlete=1 AND EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND QuTargetNo<>'' AND QuSession=" . StrSafe_DB($Session) . " "
    			. "AND QuTargetNo >='" . $Session . str_pad($fromTarget,TargetNoPadding,'0',STR_PAD_LEFT) . "A' AND QuTargetNo<='" . $Session . str_pad($toTarget,TargetNoPadding,'0',STR_PAD_LEFT) . "Z' "
    			. "ORDER BY QuTargetNo ASC ";*/
    $Select = "SELECT EnId as ID, " . $Distance . " AS Distance, ";
    for ($i = 1; $i < $Distance; $i++) {
        $Select .= "QuD" . $i . "Hits+";
    }
    $Select .= $numArrows . " AS TotHits, ";
    $Select .= "SUBSTRING(QuD" . $Distance . "ArrowString,1," . $numArrows . ") AS TotArrowString, ";
    $Select .= "ToGoldsChars, ToXNineChars, QuTimeStamp as Tstamp " . "FROM Entries " . "INNER JOIN Qualifications ON EnId=QuId " . "INNER JOIN Tournament ON EnTournament=ToId " . "WHERE EnAthlete=1 AND EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND QuTargetNo<>'' AND QuSession=" . StrSafe_DB($Session) . " " . "AND QuTargetNo >='" . $Session . str_pad($fromTarget, TargetNoPadding, '0', STR_PAD_LEFT) . "A' AND QuTargetNo<='" . $Session . str_pad($toTarget, TargetNoPadding, '0', STR_PAD_LEFT) . "Z' " . "ORDER BY QuTargetNo ASC ";
    //echo $Select."<br><br>";exit;
    $Rs = safe_r_sql($Select);
    if (safe_num_rows($Rs) > 0) {
        while ($myRow = safe_fetch($Rs)) {
            list($Score, $Gold, $XNine) = ValutaArrowStringGX($myRow->TotArrowString, $myRow->ToGoldsChars, $myRow->ToXNineChars);
            $Select = "REPLACE INTO ElabQualifications VALUES(" . StrSafe_DB($myRow->ID) . ", " . StrSafe_DB($myRow->TotHits) . ", " . StrSafe_DB($myRow->Distance) . ", " . StrSafe_DB($Score) . ", " . StrSafe_DB($numArrows) . ", " . StrSafe_DB($Gold) . ", " . StrSafe_DB($XNine) . ", " . StrSafe_DB($myRow->Tstamp) . ")";
            if (strlen(rtrim($myRow->TotArrowString)) == $numArrows) {
                $RsUpdate = safe_w_sql($Select);
            }
        }
    }
    return $numArrows;
}
예제 #7
0
 function DrawScore($TopX, $TopY, $Width, $Height, $NumEnd, $NumArrow, $Data = array(), $ArrValue = "", $TournamentTotal = "", $printGX = true)
 {
     global $CFG;
     static $ArrowEnds = array();
     // $ArrowEnds will contain the ends per arrows of each event and distance
     $Event = empty($Data["Cat"]) || !trim($Data["Cat"]) ? '--' : $Data["Cat"];
     $Session = empty($Data["Session"]) ? '1' : $Data["Session"];
     if (empty($ArrowEnds[$Event])) {
         $ArrowEnds[$Event] = getArrowEnds($Session);
     }
     // 		debug_svela($Data);
     //PARAMETRI CALCOLATI
     $TopOffset = 30;
     $BottomImage = 0;
     //HEADER LOGO SX & Dx
     $TmpLeft = 0;
     $TmpRight = 0;
     if ($this->PrintLogo && $this->PrintDrawing) {
         if (file_exists($IM = $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-ToLeft.jpg')) {
             $im = getimagesize($IM);
             $this->Image($IM, $TopX, $TopY, 0, $TopOffset / 2);
             $TmpLeft = 1 + $im[0] * ($TopOffset / 2) / $im[1];
         }
         if (file_exists($IM = $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-ToRight.jpg')) {
             $im = getimagesize($IM);
             $TmpRight = $im[0] * 15 / $im[1];
             $this->Image($IM, $TopX + $Width - $TmpRight, $TopY, 0, 15);
             $TmpRight++;
         }
         //IMMAGINE DEGLI SPONSOR
         // Sponsors disabled if QRCodes are to be printed!!!
         if (empty($_REQUEST['QRCode']) and file_exists($IM = $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-ToBottom.jpg')) {
             $BottomImage = 7.5;
             $im = getimagesize($IM);
             $imgW = $Width;
             $imgH = $imgW * $im[1] / $im[0];
             if ($imgH > $BottomImage) {
                 $imgH = $BottomImage;
                 $imgW = $imgH * $im[0] / $im[1];
             }
             $this->Image($IM, $TopX + ($Width - $imgW) / 2, $TopY + $Height - $imgH, $imgW, $imgH);
         }
     }
     $CellW = $Width / ($NumArrow + 5);
     $CellH = min(10, ($Height - 41 - $BottomImage) / ($NumEnd + 2));
     //TESTATA GARA
     if ($this->PrintHeader) {
         $tmpPad = $this->getCellPaddings();
         $this->SetCellPadding(0);
         $this->SetColors(false);
         $this->SetFont($this->FontStd, 'B', 9);
         $this->SetXY($TopX + $TmpLeft, $TopY);
         $this->MultiCell($Width - $TmpLeft - $TmpRight, 4, $this->Name, 0, 'L', 0);
         $this->SetFont($this->FontStd, '', 7);
         $this->SetXY($TopX + $TmpLeft, $this->GetY());
         if ($this->GetStringWidth($this->Where . ", " . TournamentDate2String($this->WhenF, $this->WhenT)) >= $Width - $TmpLeft - $TmpRight) {
             $this->MultiCell($Width - $TmpLeft - $TmpRight, 4, $this->Where, 0, 'L', 0);
             $this->SetXY($TopX + $TmpLeft, $this->GetY());
             $this->MultiCell($Width - $TmpLeft - $TmpRight, 4, TournamentDate2String($this->WhenF, $this->WhenT), 0, 'L', 0);
         } else {
             $this->MultiCell($Width - $TmpLeft - $TmpRight, 4, $this->Where . ", " . TournamentDate2String($this->WhenF, $this->WhenT), 0, 'L', 0);
         }
         $this->SetCellPaddings($tmpPad['L'], $tmpPad['T'], $tmpPad['R'], $tmpPad['B']);
     }
     //DATI ATLETA
     $FlagOffset = 0.2 * $CellW;
     $this->SetXY($FlagOffset + $TopX + 0.2 * $CellW, $TopY + $TopOffset * 7 / 12);
     if ($this->PrintFlags and !empty($Data['CoCode'])) {
         if (is_file($file = $CFG->DOCUMENT_PATH . 'TV/Photos/' . $_SESSION['TourCodeSafe'] . '-Fl-' . $Data['CoCode'] . '.jpg')) {
             $H = $TopOffset * 3 / 8;
             $W = $H * 3 / 2;
             $OrgY = $this->gety();
             $this->Image($file, $TopX, $this->gety(), $W, $H, 'JPG', '', '', true, 300, '', false, false, 1, true);
             $FlagOffset = $W + 1;
         }
     }
     $this->SetXY($FlagOffset + $TopX, $TopY + $TopOffset * 7 / 12);
     $this->SetFont($this->FontStd, '', 8);
     $this->SetColors(false);
     $ArcherStringLength = $this->GetStringWidth(get_text('Archer') . ": ");
     $this->Cell($ArcherStringLength, $TopOffset / 6, get_text('Archer') . ": ", 'B', 0, 'L', 0);
     $this->SetY($this->gety() - 2, false);
     $this->SetFont($this->FontStd, 'B', 13);
     $this->SetColors(true);
     $this->Cell($Width - ($this->PrintTotalCols && empty($Data["FirstDist"]) ? 2.7 * $CellW : 1.6 * $CellW) - $ArcherStringLength - $FlagOffset, 2 + $TopOffset / 6, array_key_exists("Ath", $Data) ? $Data["Ath"] : ' ', 'B', 0, 'L', 0);
     $this->SetXY($FlagOffset + $TopX, $TopY + $TopOffset * 19 / 24);
     $this->SetFont($this->FontStd, '', 8);
     // Country
     $this->SetColors(false);
     $CountryWidth = $this->GetStringWidth(get_text('Country') . ": ");
     $this->Cell($CountryWidth, $TopOffset / 6, get_text('Country') . ": ", 'B', 0, 'L', 0);
     $this->SetFont($this->FontStd, 'B', 8);
     $this->SetColors(true);
     $CellTmpWidth = $Width - ($this->PrintTotalCols && empty($Data["FirstDist"]) ? 2.7 * $CellW : 1.6 * $CellW) - $CountryWidth - $FlagOffset;
     if (array_key_exists("Noc", $Data)) {
         $str = $Data['CoCode'] . ' -';
         $strW = $this->GetStringWidth($str);
         $this->Cell($strW, $TopOffset / 6, $str, 'B', 0, 'L', 0);
         $this->Cell($CellTmpWidth - $strW, $TopOffset / 6, $Data['CoName'], 'B', 0, 'L', 0);
     } else {
         $this->Cell($CellTmpWidth, $TopOffset / 6, ' ', 'B', 0, 'L', 0);
     }
     //PAGLIONE
     $this->SetXY($TopX + $Width - 1.4 * $CellW, $TopY + $TopOffset * 13 / 24);
     $this->SetFont($this->FontStd, 'B', 20);
     $this->SetColors(true);
     $this->Cell(1.4 * $CellW, $TopOffset * 7 / 24, array_key_exists("tNo", $Data) ? ltrim($Data["tNo"], '0') : ' ', 0, 0, 'R', 1);
     $this->SetXY($TopX + $Width - 1.4 * $CellW, $TopY + $TopOffset * 10 / 12);
     $this->SetFont($this->FontStd, 'B', 10);
     $this->SetColors(true);
     $this->Cell(1.4 * $CellW, $TopOffset * 2 / 12, array_key_exists("Cat", $Data) ? $Data["Cat"] : ' ', 'T', 0, 'C', 1);
     if ($this->PrintTotalCols && empty($Data["FirstDist"])) {
         $this->SetFont($this->FontStd, 'B', 8);
         $this->SetFillColor(0xff, 0xe8, 0xe8);
         $this->SetXY($TopX + $Width - 2.5 * $CellW, $TopY + $TopOffset * 16 / 24);
         $this->Cell(1.1 * $CellW, $TopOffset * 4 / 24, get_text('Total'), 1, 0, 'C', 1);
         $this->SetXY($TopX + $Width - 2.5 * $CellW, $TopY + $TopOffset * 20 / 24);
         $this->Cell(1.1 * $CellW, $TopOffset * 4 / 24, $ArrValue == "" ? '' : $TournamentTotal, 1, 0, 'C', 1);
     }
     $CurDist = empty($Data["CurDist"]) ? 1 : $Data["CurDist"];
     //HEADER DELLO SCORE
     $ArCellW = ($this->PrintTotalCols ? 0.9 : 1) * $CellW;
     $EndNumCellW = 0.8 * $CellW;
     $TotalCellW = ($this->PrintTotalCols ? 1 : 1.4) * $CellW;
     $XNineW = 0.7 * $CellW;
     $this->SetXY($TopX, $TopY + $TopOffset);
     $this->SetFont($this->FontStd, 'I', 8);
     $this->SetFillColor(0xf8, 0xf8, 0xf8);
     $this->SetColors(true, true);
     $this->Cell($EndNumCellW, $CellH, array_key_exists("Dist", $Data) ? $Data["Dist"] : ' ', 0, 0, 'C', array_key_exists("Dist", $Data) ? 1 : 0);
     $this->SetFillColor(0xe8, 0xe8, 0xe8);
     $this->SetFont($this->FontStd, 'B', 10);
     $this->SetColors(false);
     for ($j = 1; $j <= $NumArrow; $j++) {
         $this->Cell($ArCellW, $CellH, $j, 1, 0, 'C', 1);
     }
     $this->SetFont($this->FontStd, 'B', 8);
     $this->Cell($TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 3 / 4 : 1), $CellH, get_text('TotalProg', 'Tournament'), 1, 0, 'C', 1);
     $this->Cell($TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 5 / 4 : 1), $CellH, get_text('TotalShort', 'Tournament'), 1, 0, 'C', 1);
     if ($this->PrintTotalCols) {
         $this->SetFillColor(0xff, 0xe8, 0xe8);
         $this->Cell($CellW * 1.1, $CellH, get_text('Total'), 1, 0, 'C', 1);
         $this->SetFillColor(0xe8, 0xe8, 0xe8);
     }
     $this->Cell($XNineW, $CellH, $this->prnGolds, 1, 0, 'C', 1);
     $this->Cell($XNineW, $CellH, $this->prnXNine, 1, 1, 'C', 1);
     // 		DISTANZA => $Data["CurDist"];
     //RIGHE DELLO SCORE
     $ScoreMultiLineTotal = 0;
     $ScoreTotal = 0;
     $ScoreGold = 0;
     $ScoreXnine = 0;
     $StartCell = true;
     $End = 1;
     $HeighEndCell = $CellH * ($NumEnd / $ArrowEnds[$Event][$CurDist]['ends']);
     for ($i = 1; $i <= $NumEnd; $i++) {
         $this->SetFont($this->FontStd, 'B', 10);
         $this->SetXY($TopX, $TopY + $TopOffset + $CellH * $i);
         if ($StartCell) {
             $this->Cell($EndNumCellW, $HeighEndCell, $End++, 1, 0, 'C', 1);
         } else {
             $this->SetX($TopX + $EndNumCellW);
         }
         $this->SetFont($this->FontStd, '', 9);
         for ($j = 0; $j < $NumArrow; $j++) {
             $this->Cell($ArCellW, $CellH, $ArrValue == "" ? '' : DecodeFromLetter(substr($ArrValue, ($i - 1) * $NumArrow + $j, 1)), 1, 0, 'C', 0);
         }
         list($ScoreEndTotal, $ScoreEndGold, $ScoreEndXnine) = ValutaArrowStringGX(substr($ArrValue, ($i - 1) * $NumArrow, $NumArrow), $this->goldsChars, $this->xNineChars);
         $ScoreMultiLineTotal += $ScoreEndTotal;
         $ScoreTotal += $ScoreEndTotal;
         $ScoreGold += $ScoreEndGold;
         $ScoreXnine += $ScoreEndXnine;
         $this->Cell($TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 3 / 4 : 1), $CellH, $ArrValue == "" ? '' : $ScoreEndTotal, 1, 0, 'C', 0);
         $this->SetFont($this->FontStd, '', 10);
         if ($NumArrow * $i % $ArrowEnds[$Event][$CurDist]['arrows']) {
             $this->Cell($TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 5 / 4 : 1), $CellH, '', 1, 0, 'C', 0);
             $this->Line($x1 = $this->getX(), $y1 = $this->getY(), $x1 - $TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 5 / 4 : 1), $y1 + $CellH);
             $this->Line($x1 - $TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 5 / 4 : 1), $y1, $x1, $y1 + $CellH);
             $StartCell = false;
         } else {
             if ($ArrowEnds[$Event][$CurDist]['arrows'] > 3) {
                 $this->Cell($TotalCellW * 2 / 4, $CellH, $ArrValue == "" ? '' : $ScoreMultiLineTotal, 1, 0, 'C', 0);
                 $this->Cell($TotalCellW * 3 / 4, $CellH, $ArrValue == "" ? '' : $ScoreTotal, 1, 0, 'C', 0);
                 $ScoreMultiLineTotal = 0;
             } else {
                 $this->Cell($TotalCellW, $CellH, $ArrValue == "" ? '' : $ScoreTotal, 1, 0, 'C', 0);
             }
             $StartCell = true;
         }
         if ($this->PrintTotalCols) {
             $this->SetFillColor(0xff, 0xe8, 0xe8);
             $this->SetFont($this->FontStd, '', 9);
             if ($NumArrow * $i % $ArrowEnds[$Event][$CurDist]['arrows']) {
                 $this->Cell(1.1 * $CellW, $CellH, '', 1, 0, 'C', 1);
                 $this->Line($x1 = $this->getX(), $y1 = $this->getY(), $x1 - 1.1 * $CellW, $y1 + $CellH);
                 $this->Line($x1 - 1.1 * $CellW, $y1, $x1, $y1 + $CellH);
             } else {
                 $this->Cell(1.1 * $CellW, $CellH, $ArrValue == "" ? '' : $ScoreTotal + $TournamentTotal, 1, 0, 'C', 1);
                 if (!empty($Data["FirstDist"]) && $ArrValue == "") {
                     $this->Line($this->GetX(), $this->GetY(), $this->GetX() - 1.1 * $CellW, $this->GetY() + $CellH);
                     $this->Line($this->GetX(), $this->GetY() + $CellH, $this->GetX() - 1.1 * $CellW, $this->GetY());
                 }
             }
             $this->SetFillColor(0xe8, 0xe8, 0xe8);
         }
         $this->SetFont($this->FontStd, '', 8);
         $this->Cell($XNineW, $CellH, $ArrValue == "" || !$ScoreEndGold ? '' : $ScoreEndGold, 1, 0, 'C', 0);
         $this->Cell($XNineW, $CellH, $ArrValue == "" || !$ScoreEndXnine ? '' : $ScoreEndXnine, 1, 1, 'C', 0);
     }
     // CODICE A BARRE
     $BCode = 0;
     if ($this->PrintBarcode and !empty($Data['EnCode'])) {
         $this->SetXY($TopX - 2, $TopY + $TopOffset + $CellH * ($NumEnd + 1) - 1);
         $this->SetFont('barcode', '', 22);
         $BCode = ($NumArrow + ($this->PrintTotalCols ? 0.6 : 1.3)) * $CellW;
         $this->Cell($BCode + 3, $CellH, mb_convert_encoding('*' . $Data['EnCode'] . '-' . $Data['Div'] . '-' . $Data['Cls'] . (array_key_exists("CurDist", $Data) ? '-' . $Data["CurDist"] : ''), "UTF-8", "cp1252") . "*", 0, 0, 'C', 0);
         $this->SetFont($this->FontStd, '', 7);
         $this->SetXY($TopX - 2, $TopY + $TopOffset + $CellH * ($NumEnd + 2) - 1);
         $this->Cell($BCode + 3, $CellH, mb_convert_encoding($Data['EnCode'] . '-' . $Data['Div'] . '-' . $Data['Cls'] . (array_key_exists("CurDist", $Data) ? '-' . $Data["CurDist"] : ''), "UTF-8", "cp1252"), 0, 0, 'C', 0);
     }
     //TOTALE DELLO SCORE
     // 		debug_svela($Data);
     $ErScoreTotal = empty($Data['CurDist']) ? '' : ($ArrValue and $Data["QuD{$Data['CurDist']}"] != $ScoreTotal);
     $ErScoreGold = empty($Data['CurDist']) ? '' : $Data["QuGD{$Data['CurDist']}"] != $ScoreGold;
     $ErScoreXNine = empty($Data['CurDist']) ? '' : $Data["QuXD{$Data['CurDist']}"] != $ScoreXnine;
     $this->SetXY($TopX + $BCode, $TopY + $TopOffset + $CellH * ($NumEnd + 1));
     $this->SetFont($this->FontStd, 'B', 11);
     $this->Cell(($NumArrow + ($this->PrintTotalCols ? 1.5 : 2.2)) * $CellW - $BCode + ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? $TotalCellW / 4 : 0), $CellH, get_text('Total') . " ", 0, 0, 'R', 0);
     $this->Cell($TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 3 / 4 : 1), $CellH, $ArrValue == "" ? '' : $ScoreTotal, 1, 0, 'C', 0);
     if ($this->FillWithArrows && $ErScoreTotal) {
         $this->Line($x1 = $this->getx() - ($this->PrintTotalCols ? 1 : 1.4) * $CellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 3 / 4 : 1), $y1 = $this->gety() + $CellH, $x1 + ($this->PrintTotalCols ? 1 : 1.4) * $CellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 3 / 4 : 1), $y1 - $CellH);
     }
     if ($this->PrintTotalCols) {
         $this->SetFillColor(0xff, 0xe8, 0xe8);
         $this->Cell(1.1 * $CellW, $CellH, $ArrValue == "" ? '' : $ScoreTotal + $TournamentTotal, 1, 0, 'C', 1);
         $this->SetFillColor(0xe8, 0xe8, 0xe8);
     }
     $this->SetFont($this->FontStd, 'B', 9);
     $this->Cell($XNineW, $CellH, $ArrValue == "" ? '' : $ScoreGold, 1, 0, 'C', 0);
     if ($this->FillWithArrows && $ErScoreGold) {
         $this->Line($x1 = $this->getx() - 0.7 * $CellW, $y1 = $this->gety() + $CellH, $x1 + 0.7 * $CellW, $y1 - $CellH);
     }
     $this->Cell($XNineW, $CellH, $ArrValue == "" ? '' : $ScoreXnine, 1, 0, 'C', 0);
     if ($this->FillWithArrows && $ErScoreXNine) {
         $this->Line($x1 = $this->getx() - 0.7 * $CellW, $y1 = $this->gety() + $CellH, $x1 + 0.7 * $CellW, $y1 - $CellH);
     }
     $this->ln();
     if ($this->FillWithArrows && ($ErScoreTotal or $ErScoreGold or $ErScoreXNine)) {
         $this->SetX($TopX + $BCode);
         $this->SetFont($this->FontStd, 'B', 11);
         $this->Cell(($NumArrow + ($this->PrintTotalCols ? 1.5 : 2.2)) * $CellW - $BCode + ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? $TotalCellW / 4 : 0), $CellH, get_text('SignedTotal', 'Tournament') . " ", 0, 0, 'R', 0);
         $this->Cell($TotalCellW * ($ArrowEnds[$Event][$CurDist]['arrows'] > 3 ? 3 / 4 : 1), $CellH, $Data["QuD{$Data['CurDist']}"], 1, 0, 'C', 0);
         if ($this->PrintTotalCols) {
             $this->Cell(1.1 * $CellW, $CellH, '', 0, 0, 'C', 0);
         }
         $this->SetFont($this->FontStd, 'B', 9);
         $this->Cell($XNineW, $CellH, $Data["QuGD{$Data['CurDist']}"], 1, 0, 'C', 0);
         $this->Cell($XNineW, $CellH, $Data["QuXD{$Data['CurDist']}"], 1, 0, 'C', 0);
         $this->ln();
     }
     //FIRME
     if (!$this->FillWithArrows) {
         $this->Line($TopX + 4, $TopY + $Height - ($BottomImage + 3), $TopX + $Width / 2 - 3, $TopY + $Height - ($BottomImage + 3));
         $this->Line($TopX + $Width / 2 + 3, $TopY + $Height - ($BottomImage + 3), $TopX + $Width - 4, $TopY + $Height - ($BottomImage + 3));
         $this->SetFont($this->FontFix, 'BI', 6);
         $this->SetXY($TopX, $TopY + $Height - ($BottomImage + 3));
         $this->Cell(4, 3, '', 0, 0, 'C', 0);
         $this->Cell($Width / 2 - 7, 3, get_text('Archer'), 0, 0, 'C', 0);
         $this->Cell(6, 3, '', 0, 0, 'C', 0);
         $this->Cell($Width / 2 - 7, 3, get_text('Scorer'), 0, 0, 'C', 0);
         $this->Cell(4, 3, '', 0, 0, 'C', 0);
     }
     //$this->Rect($TopX, $TopY, $Width, $Height);
 }
예제 #8
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();
}
예제 #9
0
<?php

require_once dirname(__FILE__) . '/config.php';
if (empty($_GET['distnum']) and empty($_GET['sesstarget']) and empty($_GET['endnum'])) {
    die;
}
require_once 'Common/Lib/ArrTargets.inc.php';
$TargetNo = getGroupedTargets($_GET['sesstarget']);
$Distance = intval($_GET['distnum']);
$End = intval($_GET['endnum']);
$json_array = array();
$tmp = explode('|', $TargetNo);
if (count($tmp) == 3) {
    // ELIMINATION
    $SQL = "select\n\t\t\tElScore DistScore,\n\t\t\tElGold DistGold,\n\t\t\tElXnine DistXnine,\n\t\t\tsubstr(ElArrowstring, 1+(EvElimArrows*({$End}-1)), EvElimArrows) Arrowstring,\n\t\t\tElScore QuScore, ElGold QuGold, ElXnine QuXnine, concat('{$tmp['0']}|{$tmp['1']}|', ElTargetNo) as QuTargetNo,\n\t\t\tToGoldsChars, ToXNineChars\n\t\t from Eliminations\n\t\t inner join Events on ElEventCode=EvCode and ElTournament=EvTournament and EvTeamEvent=0\n\t\t inner join Tournament on ElTournament=ToId\n\t\t where\n\t\t \tleft(ElTargetNo, 3) in ('{$tmp[2]}')\n\t\t \tand ElEventCode='{$tmp[1]}'\n\t\t \tAND ElElimPhase=" . ($tmp[0][1] - 1) . "\n\t\t \tand ElTournament={$CompId}\n\t\t order by ElTargetNo\n\t\t";
    // 	debug_svela($SQL);
} else {
    // QUALIFICATION
    $SQL = "select\n\t\t\tQuD{$Distance}Score DistScore,\n\t\t\tQuD{$Distance}Gold DistGold,\n\t\t\tQuD{$Distance}Xnine DistXnine,\n\t\t\tsubstr(QuD{$Distance}Arrowstring, 1+(DiArrows*({$End}-1)), DiArrows) Arrowstring,\n\t\t\tQuScore, QuGold, QuXnine, QuTargetNo,\n\t\t\tToGoldsChars, ToXNineChars\n\t\t from Qualifications\n\t\t inner join Entries on EnId=QuId and EnTournament={$CompId}\n\t\t inner join DistanceInformation on DiTournament={$CompId} and DiSession=QuSession and DiDistance={$Distance} and DiType='Q'\n\t\t inner join Tournament on ToId={$CompId}\n\t\t where left(QuTargetNo, 4) in ('{$TargetNo}')\n\t\t order by QuTargetNo\n\t\t";
}
$q = safe_r_sql($SQL);
while ($r = safe_fetch($q)) {
    list($Score, $Golds, $Xnine) = ValutaArrowStringGX($r->Arrowstring, $r->ToGoldsChars, $r->ToXNineChars);
    $json_array[] = array('qutarget' => $r->QuTargetNo, 'endscore' => $Score, 'endgolds' => $Golds, 'endxnine' => $Xnine, 'curscore' => $r->DistScore, 'curgolds' => $r->DistGold, 'curxnine' => $r->DistXnine, 'score' => $r->QuScore, 'golds' => $r->QuGold, 'xnine' => $r->QuXnine);
}
// Return the json structure with the callback function that is needed by the app
SendResult($json_array);
예제 #10
-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();
}