function writeDataRowElimInd($item, $distSize, $addSize, $running, $endQualified) { if ($endQualified) { $this->SetFont($this->FontStd, '', 1); $this->Cell(190, 1, '', 1, 1, 'C', 1); } $this->SetFont($this->FontStd, 'B', $this->FontSizeLines); $this->Cell(10, 4, $item['rank'], 1, 0, 'R', 0); $this->SetFont($this->FontStd, '', $this->FontSizeHeadSmall); $this->Cell(8, 4, $item['target'], 'TLB', 0, 'R', 0); $this->SetFont($this->FontStd, '', $this->FontSizeHead); $this->Cell(47, 4, $item['athlete'], 'TRB', 0, 'L', 0); $this->SetFont($this->FontStd, '', $this->FontSizeHeadSmall); $this->Cell(5, 4, $item['class'], 'TBL', 0, 'C', 0); $this->SetFont($this->FontStd, '', 5); $this->Cell(5, 4, $item['class'] != $item['ageclass'] ? ' ' . $item['ageclass'] : '', 'TBR', 0, 'C', 0); $this->SetFont($this->FontStd, '', $this->FontSizeHead); $this->Cell(10, 4, $item['countryCode'], 'LTB', 0, 'C', 0); $this->Cell(45, 4, $item['countryName'], 'RTB', 0, 'L', 0); $this->SetFont($this->FontFix, 'B', $this->FontSizeLines); $this->Cell(14, 4, number_format($item['completeScore'], 0, '', $this->NumberThousandsSeparator), 1, 0, 'R', 0); $this->SetFont($this->FontFix, '', $this->FontSizeLines); $this->Cell(10, 4, $item['gold'], 1, 0, 'R', 0); $this->Cell(10, 4, $item['xnine'], 1, 0, 'R', 0); if ($running) { $this->Cell(14, 4, $item['hits'], 1, 0, 'R', 0); $this->Cell(12, 4, number_format($item['score'], 3, $this->NumberDecimalSeparator, $this->NumberThousandsSeparator), 1, 1, 'R', 0); } else { $this->Cell(14, 4, number_format($item['score'], 0, '', $this->NumberThousandsSeparator), 1, 0, 'R', 0); //Definizione dello spareggio/Sorteggio $this->SetFont($this->FontStd, 'I', 5); if ($item['so'] > 0) { $tmpArr = ""; if (strlen(trim($item['tiebreak']))) { $tmpArr = "."; for ($countArr = 0; $countArr < strlen(trim($item['tiebreak'])); $countArr++) { $tmpArr .= DecodeFromLetter(substr(trim($item['tiebreak']), $countArr, 1)) . ","; } $tmpArr = substr($tmpArr, 0, -1); } //$pdf->Cell(12, 4 * ($double ? 2 : 1), (get_text('ShotOffShort','Tournament') . $tmpArr), 1, 1, 'L', 1); $this->Cell(12, 4, $this->ShotOffShort . $tmpArr, 1, 1, 'L', 1); } elseif ($item['ct'] > 1) { //$pdf->Cell(12, 4 * ($double ? 2 : 1), (get_text('CoinTossShort','Tournament')), 1, 1, 'L', 0); $this->Cell(12, 4, $this->CoinTossShort, 1, 1, 'L', 0); } else { //$pdf->Cell(12, 4 * ($double ? 2 : 1), '', 1, 1, 'R', 0); $this->Cell(12, 4, '', 1, 1, 'R', 0); } } }
echo '<table class="Tabella">'; echo '<tr>'; echo '<td> <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) . '"> </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>'; ?>
function XmlCreateBracketIndividual($EventRequested = '') { $XmlDoc = new DOMDocument('1.0', 'UTF-8'); $TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleBracket.xsl" '); $XmlDoc->appendChild($TmpNode); $XmlRoot = $XmlDoc->createElement('Results'); $XmlRoot->setAttribute('IANSEO', ProgramVersion); $XmlRoot->setAttribute('TS', date('Y-m-d H:i:s')); $XmlDoc->appendChild($XmlRoot); $ListHeader = NULL; $options = array(); if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") { $options['events'] = $_REQUEST["Event"]; } if ($EventRequested) { $options['events'] = $EventRequested; } $rank = Obj_RankFactory::create('GridInd', $options); $rank->read(); $rankData = $rank->getData(); foreach ($rankData['sections'] as $Event => $Data) { // New Event $ListHeader = $XmlDoc->createElement('List'); $ListHeader->setAttribute('Title', $Data['meta']['eventName']); $ListHeader->setAttribute('Columns', '4'); $XmlRoot->appendChild($ListHeader); foreach ($Data['phases'] as $Phase => $items) { // new Phase $XmlPhase = $XmlDoc->createElement('Phase'); $XmlPhase->setAttribute('Title', $items['meta']['phaseName']); $XmlPhase->setAttribute('Columns', '4'); $ListHeader->appendChild($XmlPhase); // creo le colonne $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete') . ' 1'); $TmpNode->setAttribute('Name', 'Athlete1'); $TmpNode->setAttribute('Columns', '1'); $XmlPhase->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete') . ' 2'); $TmpNode->setAttribute('Name', 'Athlete2'); $TmpNode->setAttribute('Columns', '1'); $XmlPhase->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Caption', get_text('Total') . ' 1'); $TmpNode->setAttribute('Name', 'Score1'); $TmpNode->setAttribute('Columns', '1'); $XmlPhase->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Caption', get_text('Total') . ' 2'); $TmpNode->setAttribute('Name', 'Score2'); $TmpNode->setAttribute('Columns', '2'); $XmlPhase->appendChild($TmpNode); foreach ($items['items'] as $match) { // creo il nuovo match e leggo il secondo atleta $XmlMatch = $XmlDoc->createElement('Match'); $XmlPhase->appendChild($XmlMatch); $Win1 = ($match['tie'] or $Data['meta']['matchMode'] ? $match['setScore'] > $match['oppSetScore'] : $match['score'] > $match['oppScore']); $Win2 = ($match['oppTie'] or $Data['meta']['matchMode'] ? $match['setScore'] < $match['oppSetScore'] : $match['score'] < $match['oppScore']); $Tiebreak1 = array(); $Tiebreak2 = array(); if ($match['tie'] == 1 || $match['oppTie'] == 1) { for ($i = 0; $i < max(strlen($match['tiebreak']), strlen($match['oppTiebreak'])); ++$i) { $Tiebreak1[] = DecodeFromLetter($match['tiebreak'][$i]); $Tiebreak2[] = DecodeFromLetter($match['oppTiebreak'][$i]); } } $Tiebreak1 = trim(join(' ', $Tiebreak1)); if ($Tiebreak1 != '') { $Tiebreak1 = '(' . $Tiebreak1 . ')'; } $Tiebreak2 = trim(join(' ', $Tiebreak2)); if ($Tiebreak2 != '') { $Tiebreak2 = '(' . $Tiebreak2 . ')'; } // ath1 $XmlAthlete = $XmlDoc->createElement('Athlete'); $XmlAthlete->setAttribute('Win', $Win1); $XmlAthlete->setAttribute('MatchNo', $match['matchNo']); $XmlMatch->appendChild($XmlAthlete); $TmpNode = $XmlDoc->createElement('Name', $match['athlete']); $XmlAthlete->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Country', $match['countryCode'] ? '(' . $match['countryCode'] . ' - ' . $match['countryName'] . ')' : ' '); $XmlAthlete->appendChild($TmpNode); $score = ' '; if ($match['athlete']) { if ($match['tie'] == 2) { $score = get_text('Bye'); } elseif ($Data['meta']['matchMode']) { $score = $match['setScore'] + $match['oppSetScore'] ? $match['setScore'] : ' '; } else { $score = $match['score'] + $match['oppScore'] ? $match['score'] : ' '; } } $TmpNode = $XmlDoc->createElement('Score', $score); $XmlAthlete->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Tiebreak', $Tiebreak1); $XmlAthlete->appendChild($TmpNode); // ath2 $XmlAthlete = $XmlDoc->createElement('Athlete'); $XmlAthlete->setAttribute('Win', $Win2); $XmlAthlete->setAttribute('MatchNo', $match['oppMatchNo']); $XmlMatch->appendChild($XmlAthlete); $TmpNode = $XmlDoc->createElement('Name', $match['oppAthlete']); $XmlAthlete->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Country', $match['oppCountryCode'] ? '(' . $match['oppCountryCode'] . ' - ' . $match['oppCountryName'] . ')' : ' '); $XmlAthlete->appendChild($TmpNode); $score = ' '; if ($match['oppAthlete']) { if ($match['oppTie'] == 2) { $score = get_text('Bye'); } elseif ($Data['meta']['matchMode']) { $score = $match['setScore'] + $match['oppSetScore'] ? $match['oppSetScore'] : ' '; } else { $score = $match['score'] + $match['oppScore'] ? $match['oppScore'] : ' '; } } $TmpNode = $XmlDoc->createElement('Score', $score); $XmlAthlete->appendChild($TmpNode); $TmpNode = $XmlDoc->createElement('Tiebreak', $Tiebreak2); $XmlAthlete->appendChild($TmpNode); } } } return $XmlDoc; }
} 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); } } /* * 0 => il match no è finito * 1 => il match è finito prima * 2 => il match è finito ora * 3 => shootoff */ $finished = 0; /* * <r> stabilisce lo stato di lettura della riga. * Normalmente è zero però il suo valore diventa 1 se: * 1) il match è finito in una volee precedente all'attuale check.
$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);
$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>";
</td> <td class="Center"><?php print $MyRow->EnClass; ?> </td> <td><?php print $MyRow->CoCode; ?> </td> <?php // elaboro l'arrowstring $CurArrowString = str_pad($MyRow->ArrowString, $RowTour->MaxArrows, ' ', STR_PAD_RIGHT); $SubArrowString = substr($CurArrowString, $Ip, $_REQUEST['x_Arrows']); //print '<td>...' . $CurArrowString . '...<br>...' . $SubArrowString . '...</td>'; for ($i = 0; $i < $_REQUEST['x_Arrows']; ++$i) { $vv = DecodeFromLetter($SubArrowString[$i]); $FieldId = 'arr_' . $_REQUEST['x_Dist'] . '_' . ($Ip + $i) . '_' . $MyRow->EnId; $ScoreTD .= '<td class="Center">' . '<input type="text" id="' . $FieldId . '" ' . 'size="2" maxlength="2" value="' . $vv . '" ' . 'onBlur="javascript:UpdateArrow(\'' . $FieldId . '\');">' . '</td>'; } print $ScoreTD; ?> <td class="Center Bold"> <div id="idScore_<?php print $_REQUEST['x_Dist'] . '_' . $MyRow->EnId; ?> "><?php print $MyRow->SelScore; ?> </div></td> <td class="Center Bold"><div id="idGold_<?php print $_REQUEST['x_Dist'] . '_' . $MyRow->EnId;
$MyGrid[$Row][$Col] .= '<td nowrap class="Bottom Top Right Left"><div id="idAth_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '">' . (!is_null($MyRow->Atleta) ? $MyRow->Atleta : ' ') . '</div></td>'; // Codice Nazione (o bandiera) $MyGrid[$Row][$Col] .= '<td nowrap class="Bottom Top Right Left"><div id="idCty_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '">' . (!is_null($MyRow->CoCode) ? $MyRow->CoCode : ' ') . '</div></td>'; // Punteggio $MyGrid[$Row][$Col] .= '<td nowrap class="Bottom Top Right Left TextRight"><input type="text" class="disabled" tabindex="' . $TabIndex++ . '" size="3" maxlength="3" name="d_S_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '" id="d_S_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '" value="' . $MyRow->Score . '" onBlur="javascript:SendToServer(\'d_S_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '\');" disabled></td>'; // tie $MyGrid[$Row][$Col] .= '<td nowrap class="Center">'; if (isset($_REQUEST['d_Tie']) && $_REQUEST['d_Tie'] == 1) { $MyGrid[$Row][$Col] .= '<select class="disabled" tabindex="' . $TabIndex++ . '" name="d_T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '" id="d_T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '" onChange="javascript:SendToServer(\'d_T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '\');" disabled>' . "\n"; $MyGrid[$Row][$Col] .= '<option value="0"' . ($MyRow->FinTie == 0 ? ' selected' : '') . '>' . get_text('NoTie', 'Tournament') . '</option>' . "\n"; $MyGrid[$Row][$Col] .= '<option value="1"' . ($MyRow->FinTie == 1 ? ' selected' : '') . '>' . get_text('TieWinner', 'Tournament') . '</option>' . "\n"; $MyGrid[$Row][$Col] .= '<option value="2"' . ($MyRow->FinTie == 2 ? ' selected' : '') . '>' . get_text('Bye') . '</option>' . "\n"; $MyGrid[$Row][$Col] .= '</select> ' . "\n"; $TieBreak = str_pad($MyRow->FinTiebreak, $obj->so, ' ', STR_PAD_RIGHT); for ($i = 0; $i < $obj->so; ++$i) { $MyGrid[$Row][$Col] .= '<input type="text" class="disabled" tabindex="' . $TabIndex++ . '" size="1" name="d_t_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '_' . $i . '" id="d_t_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '_' . $i . '" value="' . DecodeFromLetter($TieBreak[$i]) . '" onBlur="javascript:SendTieBreak(\'d_t_' . $MyRow->FinEvent . '_' . $MyRow->FinMatchNo . '\',' . $obj->so . ');" disabled>'; } } else { $MyGrid[$Row][$Col] .= ' '; } $MyGrid[$Row][$Col] .= '</td>'; ++$Row; ++$AthPrinted; ++$Ultima; } for ($i = 1; $i <= $HeadRows + 4; ++$i) { $MyGrid[$Row][$Col] = ''; $MyGrid[$Row++][$Col] .= '<td class="Center" colspan="5">' . ($i == 1 ? get_text('1_Phase') : ' ') . '</td>'; } } else { $Status = 1;
public function read() { $filter = $this->safeFilter(); /* * prima passata per costruire la struttura del vettore. * Tiro fuori le qualifiche, le posizioni finali e le eliminatorie (se ci sono) */ $q = "SELECT" . " * " . "FROM (select" . " FinEvent Event," . " EvProgr," . " EvEventName AS EventDescr," . " EvMatchMode," . " EvFinalFirstPhase, " . " EvFinalPrintHead, " . " GrPhase Phase," . " EvShootOff," . " IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition) Position," . " DATE_FORMAT(FSScheduledDate,'" . get_text('DateFmtDB') . "') as ScheduledDate," . " DATE_FORMAT(FSScheduledTime,'" . get_text('TimeFmt') . "') AS ScheduledTime, " . " FinTournament Tournament," . " FinDateTime LastUpdated," . " FinMatchNo MatchNo," . " EnCode Bib," . " EnId," . " FsTarget Target," . " TarId, TarDescr, EvDistance as Distance, EvTargetSize as TargetSize, " . " concat(upper(EnFirstName), ' ', EnName) Athlete," . " EnFirstName FamilyName," . " upper(EnFirstName) FamilyNameUpper," . " EnName GivenName," . " CoId CountryId," . " CoCode CountryCode," . " CoName CountryName," . " CoIocCode CountryIocCode," . " IndRank QualRank," . " IndRankFinal FinRank," . " QuScore QualScore," . "\tEvFinEnds, EvFinArrows, EvFinSO, EvElimEnds, EvElimArrows, EvElimSO, " . " FinWinLose Winner," . " FinScore Score," . " FinSetScore SetScore," . " FinSetPoints SetPoints," . " FinTie AS Tie," . " FinArrowstring ArrowString," . " FinTiebreak TieBreak," . " FinStatus Status, " . " FinLive LiveFlag " . "FROM " . " Finals " . "INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "INNER JOIN Events ON FinEvent=EvCode AND FinTournament=EvTournament AND EvTeamEvent=0 " . "INNER JOIN Targets ON EvFinalTargetType=TarId " . "LEFT JOIN Individuals ON FinAthlete=IndId AND FinEvent=IndEvent AND FinTournament=IndTournament " . "LEFT JOIN Entries ON FinAthlete=EnId AND FinTournament=EnTournament " . "LEFT JOIN Qualifications ON QuId=EnId " . "LEFT JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament " . "LEFT JOIN FinSchedule ON FinEvent=FSEvent AND FinMatchNo=FSMatchNo AND FinTournament=FSTournament AND FSTeamEvent='0' " . "WHERE FinMatchNo%2=0 " . " AND FinTournament = " . $this->tournament . " " . $filter . ") f1 " . "INNER JOIN (select" . " FinEvent OppEvent," . " FinTournament OppTournament," . " FinDateTime OppLastUpdated," . " FinMatchNo OppMatchNo," . " EnCode OppBib," . " EnId OppEnId," . " FsTarget OppTarget," . " concat(upper(EnFirstName), ' ', EnName) OppAthlete," . " EnFirstName OppFamilyName," . " upper(EnFirstName) OppFamilyNameUpper," . " IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition) OppPosition," . " EnName OppGivenName," . " CoId OppCountryId," . " CoCode OppCountryCode," . " CoName OppCountryName," . " CoIocCode OppCountryIocCode," . " IndRank OppQualRank," . " IndRankFinal OppFinRank," . " QuScore OppQualScore," . " FinWinLose OppWinner," . " FinScore OppScore," . " FinSetScore OppSetScore," . " FinSetPoints OppSetPoints," . " FinTie AS OppTie," . " FinArrowstring OppArrowString," . " FinTiebreak OppTieBreak, " . " FinStatus OppStatus " . "FROM " . " Finals " . "INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "INNER JOIN Events ON FinEvent=EvCode AND FinTournament=EvTournament AND EvTeamEvent=0 " . "LEFT JOIN Individuals ON FinAthlete=IndId AND FinEvent=IndEvent AND FinTournament=IndTournament " . "LEFT JOIN Entries ON FinAthlete=EnId AND FinTournament=EnTournament " . "LEFT JOIN Qualifications ON QuId=EnId " . "LEFT JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament " . "LEFT JOIN FinSchedule ON FinEvent=FSEvent AND FinMatchNo=FSMatchNo AND FinTournament=FSTournament AND FSTeamEvent='0' " . "WHERE FinMatchNo%2=1 " . " AND FinTournament = " . $this->tournament . " " . $filter . ") f2 on Tournament=OppTournament and Event=OppEvent and MatchNo=OppMatchNo-1 " . (empty($this->opts['enid']) ? '' : " where (EnId=" . intval($this->opts['enid']) . " or OppEnId=" . intval($this->opts['enid']) . ") ") . (empty($this->opts['coid']) ? '' : " where (CountryId=" . intval($this->opts['coid']) . " or OppCountryId=" . 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('BracketsInd'); $this->data['meta']['saved'] = get_text('Seeded16th'); $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'), 'countryId' => '', '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'), 'oppCountryId' => '', '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')); $this->data['sections'] = array(); 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])) { $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), '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] = array('meta' => array(), 'items' => array()); $this->data['sections'][$myRow->Event]['phases'][$myRow->Phase]['meta']['phaseName'] = get_text(namePhase($myRow->EvFinalFirstPhase, $myRow->Phase) . "_Phase"); } $tmpArr = array(); $oppArr = array(); if ($myRow->TieBreak) { for ($countArr = 0; $countArr < strlen(trim($myRow->TieBreak)); $countArr++) { $tmpArr[] = DecodeFromLetter(substr(trim($myRow->TieBreak), $countArr, 1)); } } if ($myRow->OppTieBreak) { for ($countArr = 0; $countArr < strlen(trim($myRow->OppTieBreak)); $countArr++) { $oppArr[] = DecodeFromLetter(substr(trim($myRow->OppTieBreak), $countArr, 1)); } } $this->data['sections'][$myRow->Event]['phases'][$myRow->Phase]['items'][] = array('liveFlag' => $myRow->LiveFlag, 'scheduledDate' => $myRow->ScheduledDate, 'scheduledTime' => $myRow->ScheduledTime, 'matchNo' => $myRow->MatchNo, 'bib' => $myRow->Bib, 'id' => $myRow->EnId, 'target' => $myRow->Target, 'athlete' => $myRow->Athlete, 'familyName' => $myRow->FamilyName, 'familyNameUpper' => $myRow->FamilyNameUpper, 'givenName' => $myRow->GivenName, 'countryId' => $myRow->CountryId, 'countryCode' => $myRow->CountryCode, 'countryName' => $myRow->CountryName, 'countryIocCode' => $myRow->CountryIocCode, 'qualRank' => $myRow->QualRank, 'finRank' => $myRow->FinRank, 'qualScore' => $myRow->QualScore, 'winner' => $myRow->Winner, 'score' => $myRow->Score, 'setScore' => $myRow->SetScore, 'setPoints' => $myRow->SetPoints, 'tie' => $myRow->Tie, 'arrowstring' => $myRow->ArrowString, 'tiebreak' => $myRow->TieBreak, 'tiebreakDecoded' => implode(',', $tmpArr), 'status' => $myRow->Status, 'position' => $myRow->QualRank ? $myRow->QualRank : $myRow->Position, 'saved' => $myRow->Position > 0 and $myRow->Position < 9 and $myRow->EvFinalFirstPhase != valueFirstPhase($myRow->EvFinalFirstPhase), 'oppMatchNo' => $myRow->OppMatchNo, 'oppBib' => $myRow->OppBib, 'oppId' => $myRow->OppEnId, 'oppTarget' => $myRow->OppTarget, 'oppAthlete' => $myRow->OppAthlete, 'oppFamilyName' => $myRow->OppFamilyName, 'oppFamilyNameUpper' => $myRow->OppFamilyNameUpper, 'oppGivenName' => $myRow->OppGivenName, 'oppCountryId' => $myRow->OppCountryId, 'oppCountryCode' => $myRow->OppCountryCode, 'oppCountryName' => $myRow->OppCountryName, 'oppCountryIocCode' => $myRow->OppCountryIocCode, 'oppQualRank' => $myRow->OppQualRank, 'oppFinRank' => $myRow->OppFinRank, 'oppQualScore' => $myRow->OppQualScore, 'oppWinner' => $myRow->OppWinner, 'oppScore' => $myRow->OppScore, 'oppSetScore' => $myRow->OppSetScore, 'oppSetPoints' => $myRow->OppSetPoints, 'oppTie' => $myRow->OppTie, 'oppArrowstring' => $myRow->OppArrowString, 'oppTiebreak' => $myRow->OppTieBreak, 'oppTiebreakDecoded' => implode(',', $oppArr), 'oppStatus' => $myRow->OppStatus, 'oppPosition' => $myRow->OppQualRank ? $myRow->OppQualRank : $myRow->OppPosition, 'oppSaved' => $myRow->OppPosition > 0 and $myRow->OppPosition < 9 and $myRow->EvFinalFirstPhase != valueFirstPhase($myRow->EvFinalFirstPhase)); $curEvent = ''; $curPhase = ''; $section = null; } }
$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>'; $ScoreDx .= '<td colspan="' . $nARR . '">'; $ScoreDx .= '<table class="Tabella">' . "\n"; $ScoreDx .= '<tr>'; for ($i = 0; $i < $nSO; ++$i) { $ScoreDx .= '<td style="font-size:180%; font-weight:bold; text-align:center;">' . DecodeFromLetter($TieDx[$i]) . ' </td>'; } $ScoreDx .= '</tr>' . "\n"; $ScoreDx .= '</table>' . "\n"; $ScoreDx .= '</td>'; $ScoreDx .= '<td> </td>'; if ($MyRowDx->MatchMode == 0) { $ScoreDx .= '<td style="font-size:180%; font-weight:bold; text-align:right;">' . $Tot . '</td>'; } else { $ScoreDx .= '<td colspan="2" style="font-size:180%; font-weight:bold; text-align:right;">' . $MyRowDx->FinalScore . '</td>'; } $ScoreDx .= '</tr>' . "\n"; $ScoreDx .= '</table>' . "\n"; if ($PosArrDx or $PosArrSx) { // semaforo dx $SemaforoDx = '<table class="Tabella">' . "\n";
} print '<tr class="' . $style . '">'; print '<th class="Title">'; print $item['rank'] . ' '; $endRank = $item['rankBeforeSO'] + $item['ct'] - 1; print '<select name="R[' . $section['meta']['event'] . '][' . $item['id'] . '_' . $item['subteam'] . ']">' . "\n"; for ($i = $item['rankBeforeSO']; $i <= $endRank; ++$i) { print '<option value="' . $i . '"' . ($i == $item['rank'] ? ' selected' : '') . '>' . $i . '</option>' . "\n"; } print '</select>' . "\n"; print '</th>'; print '<td width="10%" class="Center">' . $item['countryCode'] . '</td>'; print '<td width="30%">' . ($item['countryName'] != '' ? $item['countryName'] . (intval($item['subteam']) <= 1 ? '' : ' (' . $item['subteam'] . ')') : ' ') . '</td>'; print '<td class="Center">' . $item['score'] . '</td>'; print '<td class="Center">' . $item['gold'] . '</td>'; print '<td class="Center">' . $item['xnine'] . '</td>'; print '<td>'; for ($i = 0; $i < 9; ++$i) { print '<input type="text" maxlength="2" size="1" name="T[' . $section['meta']['event'] . '][' . $item['id'] . '_' . $item['subteam'] . '][' . $i . ']" value="' . (strlen($item['tiebreak']) > $i ? DecodeFromLetter($item['tiebreak'][$i]) : '') . '"> '; } print '</td>'; print '</tr>'; } print '<tr><td class="Center" colspan="' . $Colonne . '"><input type="hidden" name="Ok" value="OK"><input type="submit" value="' . get_text('CmdOk') . '"></td></tr>' . "\n"; print '</table>' . "\n"; print '<br>'; } print '</form>'; } } include 'Common/Templates/tail.php';
function ExportASC($Event = null, $IncludeZeroInfo = true) { $ToCode = ''; $ToType = 0; $NumDist = 0; $IocCode = ''; /*$Select = "SELECT ToCode, TtNumDist, ToType " . "FROM Tournament INNER JOIN Tournament*Type ON ToType=TtId " . "WHERE ToId=" . StrSafe_DB($_SESSION['TourId']) . " ";*/ $Select = "SELECT ToCode, ToNumDist AS TtNumDist, ToType, ToIocCode " . "FROM Tournament " . "WHERE ToId=" . StrSafe_DB($_SESSION['TourId']) . " "; $Rs = safe_r_sql($Select); if (safe_num_rows($Rs) == 1) { $row = safe_fetch($Rs); $ToCode = $row->ToCode; $ToType = $row->ToType; $NumDist = $row->TtNumDist; $IocCode = $row->ToIocCode; } if ($ToCode == '') { return array('', ''); } $StrData = ''; /* * Tipo 0: Informazioni varie sulla ver di ianseo usata * Versione - data aggiornamento archivio nomi */ if ($IncludeZeroInfo) { $r = safe_r_sql("\n\t\t\t\tSELECT\n\t\t\t\t\tgroup_concat( CONCAT( if( LupIocCode = '', '___', LupIocCode ) , '-', date_format( LupLastUpdate, '%Y%m%d%H%i%s' ) ) SEPARATOR ',' ) AS up\n\t\t\t\tFROM\n\t\t\t\t\tLookUpPaths\n\t\t\t"); $rowUp = safe_fetch($r); //$StrData.='0;' . ProgramVersion . ';' . ProgramRelease . ';' . (defined('ProgramBuild') ? ProgramBuild : '') . ';'. GetParameter('SwUpdate') . ';' . GetParameter('LueUpdat') . "\n"; $StrData .= '0;' . ProgramVersion . ';' . ProgramRelease . ';' . (defined('ProgramBuild') ? ProgramBuild : '') . ';' . GetParameter('SwUpdate') . ';' . $rowUp->up . "\n"; } /* * Tipo 1: Classifica di classe - Individuale * Matricola-Divisione-Classe-CognomeNome-Societa-AgeClass-Totale1-ori1-X1-Totale2-Ori2-X2-CodiceDiControllo-PosizioneClassificaIndividuale(999 se nn partecipa)-Status-Singole distanze * N.B. NON USO l'oggettone poichè ho bisogno di avere anche i non pertecipanti cl/div individuali */ $Query = "SELECT " . "'1' AS RowType,EnCode as Bib, EnDivision, EnClass," . "CONCAT(EnFirstName,' ',EnName) AS Name, CoCode,EnAgeClass, "; if ($ToType == 8) { $Query .= "(QuD1Score+QuD2Score) AS Score1, " . "(QuD1Gold+QuD2Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine) AS Xnine1, " . "(QuD3Score+QuD4Score) AS Score2, " . "(QuD3Gold+QuD4Gold) AS Gold2, " . "(QuD3Xnine+QuD4Xnine) AS Xnine2, "; } else { if ($ToType == 10 || $ToType == 12 || $ToType == 13) { $Query .= "(QuD1Score) AS Score1, " . "(QuD1Gold) AS Gold1, " . "(QuD1Xnine) AS Xnine1, " . "(QuD2Score) AS Score2, " . "(QuD2Gold) AS Gold2, " . "(QuD2Xnine) AS Xnine2, "; } else { $Query .= "(QuD1Score+QuD2Score+QuD3Score+QuD4Score) AS Score1, " . "(QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine) AS Xnine1, " . "(QuD5Score+QuD6Score+QuD7Score+QuD8Score) AS Score2, " . "(QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold) AS Gold2, " . "(QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine) AS Xnine2, "; } } $Query .= "IF(EnDob!='0000-00-000',CONCAT(EnDob,'|',EnSex),EnCtrlCode) AS EnCtrlCode, IF(EnIndClEvent=1,QuClRank,999) AS ClRank,EnStatus "; for ($i = 1; $i <= $NumDist; ++$i) { $Query .= ",QuD" . $i . "Score,QuD" . $i . "Gold,QuD" . $i . "Xnine "; } $Query .= ", if(EnIocCode!='', EnIocCode, '{$IocCode}') as IocCode "; $Query .= "FROM " . "Qualifications INNER JOIN Entries ON QuId=EnId AND EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EnAthlete=1 " . "INNER JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament " . "WHERE " . "EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EnStatus<=1 AND QuScore>0 " . "ORDER BY " . "EnCode ASC, CONCAT(EnDivision,EnClass) ASC "; //print $Query;exit; $Rs = safe_r_sql($Query); if (safe_num_rows($Rs) > 0) { while ($MyRow = safe_fetch($Rs)) { $cols = array(); foreach ($MyRow as $key => $val) { $cols[] = stripslashes($val); } $StrData .= implode(';', $cols) . "\n"; } } /* * Tipo 2: Finale Individuale * Matricola-Divisione-Classe-CognomeNome-Societa-Evento-PosPartenza|FaseIniziale-CodiceControllo-PosizioneClassificaAssoluta-Scores|SetPoints_arrostringDecodificata#tieArrowstringDecodificata */ // Carico le fasi in un array $myPhases = getPhaseArray(); /*print '<pre>'; print_r($myPhases); print '</pre>'; exit;*/ // Genero la query che mi ritorna tutti gli eventi individuali $MyQuery = "SELECT EvCode, EvFinalFirstPhase, EvEventName, EvFinalPrintHead,EvMatchMode,EvMatchArrowsNo "; $MyQuery .= "FROM Events "; $MyQuery .= "WHERE EvTournament = " . StrSafe_DB($_SESSION['TourId']) . " AND EvTeamEvent=0 "; if (!is_null($Event) && preg_match("/^[0-9A-Z]{1,4}\$/i", $Event)) { $MyQuery .= "AND EvCode LIKE '" . $Event . "' "; } $MyQuery .= "ORDER BY EvProgr ASC, EvCode "; $RsEv = safe_r_sql($MyQuery); if (safe_num_rows($RsEv) > 0) { $RsEvCounter = 0; while ($MyRowEv = safe_fetch($RsEv)) { //$target=$GLOBALS{GetTargetType($MyRowEv->EvCode,0)}; //print_r($target); $PhaseFields = array(); reset($myPhases); //Genero la query che mi da i risultati per ogni evento $MyQuery = "SELECT FinAthlete, CONCAT_WS(' ',EnFirstName, EnName) as Atleta, CoCode, CoName, "; $Tmp = ""; $NumPhases = 0; $NeedTitle = true; foreach ($myPhases as $Key => $Value) { //print $Value.'<br><br>'; if ($Key <= valueFirstPhase($MyRowEv->EvFinalFirstPhase)) { // mi servirà dopo nei calcoli dei campi! $PhaseFields[] = array("X_Phase" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Phase", "X_SetPoints" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_SetPoints", "X_Arrowstring" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Arrowstring", "X_TieArrowstring" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_TieArrowstring", "X_Tie" => $Value . "Tie", "X_Live" => $Value . "Live", "X_Matchno" => $Value . "Matchno", "X_PhaseNo" => namePhase($MyRowEv->EvFinalFirstPhase, $Key)); //print_r($PhaseFields); /*if($Key!=0) { $MyQuery .= "SUM(IF(GrPhase=" . $Key . ",IF(FinScore=0 && FinTie=2,(QuScore*10),FinScore),0)) as `" . $Key . "_Phase`, SUM(IF(GrPhase=" . $Key . ",FinTie,0)) as `" . $Value . "Tie`, SUM(IF(GrPhase=" . $Key . ",LENGTH(FinArrowstring),0)) as `" . $Value . "Live`, SUM(IF(GrPhase=" . $Key . ",FinMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC " . $Tmp; $NumPhases++; } else { $MyQuery .= "SUM(IF((GrPhase=0 OR GrPhase=1),FinScore,0)) as `" . $Key . "_Phase`, SUM(IF((GrPhase=0 OR GrPhase=1),FinTie,0)) as `" . $Value . "Tie`, SUM(IF((GrPhase=0 OR GrPhase=1),LENGTH(FinArrowstring),0)) as `" . $Value . "Live`, SUM(IF((GrPhase=0 OR GrPhase=1),FinMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC, `" . $Value . "Tie` DESC " . $Tmp; $NumPhases++; }*/ if ($Key != 0) { //$MyQuery .= "SUM(IF(GrPhase=" . $Key . ",IF(IF(EvMatchMode=0,FinScore,FinSetScore)=0 && FinTie=2,(QuScore*10),IF(EvMatchMode=0,FinScore,FinSetScore)),0)) as `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_Phase`, SUM(IF(GrPhase=" . $Key . ",FinTie,0)) as `" . $Value . "Tie`, MAX(IF(GrPhase=" . $Key . ",/*FinTieBreak*/'','')) as `" . $Value . "TieBreak`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinSetPoints,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_SetPoints`, SUM(IF(GrPhase=" . $Key . ",FinMatchNo,0)) as `" . $Value . "Matchno`, "; $MyQuery .= "SUM(IF(GrPhase=" . $Key . ",IF(IF(EvMatchMode=0,FinScore,FinSetScore)=0 && FinTie=2,(QuScore*10),IF(EvMatchMode=0,FinScore,FinSetScore)),0)) as `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Phase`, SUM(IF(GrPhase=" . $Key . ",FinTie,0)) as `" . $Value . "Tie`,GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinArrowstring,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Arrowstring`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinTieBreak,'') SEPARATOR '') as `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_TieArrowstring`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinSetPoints,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_SetPoints`, SUM(IF(GrPhase=" . $Key . ",FinMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Phase` DESC " . $Tmp; if ($Key == 4 && $MyRowEv->EvMatchMode != 0) { $MyQuery .= "SUM(IF(GrPhase=" . $Key . ",FinSetScore,0)) as `QuarterWinner`, SUM(IF(GrPhase=" . $Key . ",FinScore,0)) as `QuarterScore`, "; $Tmp = ", `QuarterWinner` DESC, `QuarterScore` DESC " . $Tmp; } $NumPhases++; } else { $MyQuery .= "SUM(IF((GrPhase=0 OR GrPhase=1),IF(EvMatchMode=0,FinScore,FinSetScore),0)) as `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Phase`, SUM(IF((GrPhase=0 OR GrPhase=1),FinTie,0)) as `" . $Value . "Tie`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),FinTieBreak,'') SEPARATOR '') as `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_TieArrowstring`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),FinSetPoints,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_SetPoints`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),FinArrowstring,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Arrowstring`,SUM(IF((GrPhase=0 OR GrPhase=1),FinMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC, `" . $Value . "Tie` DESC " . $Tmp; $NumPhases++; } } } $MyQuery .= "MIN(GrPhase) as LastPhase, ifnull(CurrentPhase,128) as CurrentPhase, QuScore, IndRank,IndRankFinal,EnCode,EnDivision,EnClass,FinEvent, "; $MyQuery .= "IF(LENGTH(EnCtrlCode)=16,EnCtrlCode,CONCAT(EnDob,'|',EnSex)) AS EnCtrlCode,EnCode "; $MyQuery .= ", if(EnIocCode!='', EnIocCode, '{$IocCode}') as IocCode "; $MyQuery .= "FROM Finals "; $MyQuery .= "INNER JOIN Events ON FinEvent=EvCode AND FinTournament=EvTournament AND EvTeamEvent=0 "; $MyQuery .= "INNER JOIN Grids ON FinMatchNo=GrMatchNo "; $MyQuery .= "INNER JOIN Entries ON FinAthlete=EnId AND FinTournament=EnTournament "; $MyQuery .= "INNER JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament "; $MyQuery .= "INNER JOIN Qualifications ON EnId=QuId "; $MyQuery .= "INNER JOIN Individuals ON IndId=FinAthlete AND IndEvent=FinEvent AND IndTournament=FinTournament "; $MyQuery .= "LEFT JOIN (SELECT min(GrPhase) AS CurrentPhase, FinTournament AS SqyTournament, FinEvent AS SqyEvent " . "FROM Finals INNER JOIN Grids ON FinMatchNo=GrMatchNo " . "WHERE FinScore<>0 GROUP BY SqyTournament, SqyEvent) AS Sqy ON SqyTournament=FinTournament AND SqyEvent=FinEvent "; $MyQuery .= "WHERE FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND FinEvent=" . StrSafe_DB($MyRowEv->EvCode) . " "; $MyQuery .= "GROUP BY FinAthlete, CONCAT_WS(' ', EnFirstName, EnName), CoCode, CoName "; $MyQuery .= "ORDER BY FinEvent, LastPhase ASC " . $Tmp . ", IndRank ASC"; ///*Debug*/echo $MyQuery. "<br> <br>"; //print '<br><br>'.$MyQuery.'<br><br>'; $Rs = safe_r_sql($MyQuery); $MyPos = 0; // $MyRank=0; //Se Esistono righe caricate.... if (safe_num_rows($Rs) > 0) { // $OldScore=-1; // $OldTie=-1; // $OldLastPhase=-1; // $OldRank=-1; $ActualScore = 0; $ActualTie = -1; while ($MyRow = safe_fetch($Rs)) { $TmpScores = array(); $cols = array(); $MyPos++; // Se non ho parimerito il ranking � uguale alla posizione if ($MyPos > $MyRow->CurrentPhase) { $TmpScores = array(); $ActualScore = 0; $ActualTie = -1; if ($MyRowEv->EvMatchMode == 0) { foreach ($PhaseFields as $i => $Val) { $ActualScore = $MyRow->{$Val['X_Phase']} != 0 ? $MyRow->{$Val['X_Phase']} : $ActualScore; $ActualTie = $MyRow->LastPhase < 2 ? $MyRow->{$Val['X_Tie']} : -1; $TmpScores[] = ($MyRow->{$Val["X_Phase"]} == $MyRow->QuScore * 10 ? 'bye' : $MyRow->{$Val["X_Phase"]}) . '|'; /*print '<pre>'; print_r($Val); print '</pre>';*/ list($tmpPhase, ) = explode('_', $Val['X_Phase']); //$x=DecodeArrowstring($MyRowEv->EvMatchMode,$MyRowEv->EvMatchArrowsNo,0,0,$tmpPhase,$MyRow->{$Val["X_Arrowstring"]},$target); //$x=DecodeArrowstring($MyRowEv->EvMatchMode,$MyRowEv->EvMatchArrowsNo,0,0,$tmpPhase,$MyRow->{$Val["X_Arrowstring"]}); $numRows = 0; $numCols = 0; $obj = getEventArrowsParams($MyRowEv->EvCode, $tmpPhase, 0); $numRows = $obj->ends; $numCols = $obj->arrows; $x = DecodeArrowstring($numRows, $numCols, $MyRow->{$Val["X_Arrowstring"]}); $TmpScores[count($TmpScores) - 1] .= '_' . $x; //$x=DecodeTieArrowstring($MyRow->{$Val['X_TieArrowstring']},$target); $x = DecodeTieArrowstring($MyRow->{$Val['X_TieArrowstring']}); $TmpScores[count($TmpScores) - 1] .= '#' . $x; //print $TmpScores[count($TmpScores)-1] . '<br>'; } // if ($OldScore!=$ActualScore || $OldTie!=$ActualTie || $OldLastPhase!=$MyRow->LastPhase) // $MyRank = $MyPos; } else { foreach ($PhaseFields as $i => $Val) { /*print '<pre>'; print_r($Val); print '</pre>';*/ $TmpScores[] = ($MyRow->{$Val["X_Phase"]} == $MyRow->QuScore * 10 ? 'bye' : $MyRow->{$Val["X_Phase"]}) . '|' . ($MyRowEv->EvMatchMode == 1 ? str_replace('|', ',', $MyRow->{$Val["X_SetPoints"]}) : ''); list($tmpPhase, ) = explode('_', $Val['X_Phase']); //$x=DecodeArrowstring($MyRowEv->EvMatchMode,$MyRowEv->EvMatchArrowsNo,0,0,$tmpPhase,$MyRow->{$Val["X_Arrowstring"]},$target); $numRows = 0; $numCols = 0; $obj = getEventArrowsParams($MyRowEv->EvCode, $tmpPhase, 0); $numRows = $obj->ends; $numCols = $obj->arrows; $x = DecodeArrowstring($numRows, $numCols, $MyRow->{$Val["X_Arrowstring"]}); $TmpScores[count($TmpScores) - 1] .= '_' . $x; //$x=DecodeTieArrowstring($MyRow->{$Val['X_TieArrowstring']},$target); $x = DecodeTieArrowstring($MyRow->{$Val['X_TieArrowstring']}); $TmpScores[count($TmpScores) - 1] .= '#' . $x; //print $TmpScores[count($TmpScores)-1] . '<br>'; } if ($MyRow->LastPhase >= 8) { //$MyRank=$MyRow->LastPhase+1; } elseif ($MyRow->LastPhase == 4) { $ActualScore = $MyRow->QuarterWinner; $ActualTie = $MyRow->QuarterScore; // if ($OldScore!=$ActualScore || $OldTie!=$ActualTie || $OldLastPhase!=$MyRow->LastPhase) // { // $MyRank = $MyPos; // } } } } //Per i primi 4 NON vale la regola sopra // if($MyPos<=4) // { // if($MyRow->CurrentPhase==1 && $MyRank>2) // $MyRank = $MyPos; // elseif($MyRow->CurrentPhase==0) // $MyRank = $MyPos; // } //Tolgo tutti Quelli da non scrivere //Salvo i valori attuali e risistemo i colori // $OldScore=$ActualScore; // $OldTie=$ActualTie; // $OldLastPhase=$MyRow->LastPhase; // $OldRank=$MyRank; $cols[] = 2; $cols[] = $MyRow->EnCode; $cols[] = $MyRow->EnDivision; $cols[] = $MyRow->EnClass; $cols[] = stripslashes($MyRow->Atleta); $cols[] = $MyRow->CoCode; $cols[] = $MyRow->FinEvent; $cols[] = $MyRow->IndRank . '|' . $MyRowEv->EvFinalFirstPhase; $cols[] = $MyRow->EnCtrlCode; //$cols[]=$MyRank; //print $MyRow->IndRankFinal.'<br>'; $cols[] = $MyRow->IndRankFinal; $cols[] = $MyRow->IocCode; $StrData .= join(';', $cols) . ';' . join(';', $TmpScores) . "\n"; } } } } //exit; /* * Tipo 3: Classifica di classe - Squadre * CodiceSocieta-Divisione-Classe-Totale1-ori1-X1-Totale2-Ori2-X2-PosizioneClassifica-MatricolaPartecipanti(in lista) */ $MyQuery = "SELECT TcOrder,CoCode, TeEvent,Quanti,EnCode, EnClass, EnDivision,EnAgeClass, "; if ($ToType == 8) { $MyQuery .= "(QuD1Score+QuD2Score) AS Score1, " . "(QuD1Gold+QuD2Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine) AS Xnine1, " . "(QuD3Score+QuD4Score) AS Score2, " . "(QuD3Gold+QuD4Gold) AS Gold2, " . "(QuD3Xnine+QuD4Xnine) AS Xnine2, "; } else { if ($ToType == 10 || $ToType == 12 || $ToType == 13) { $MyQuery .= "(QuD1Score) AS Score1, " . "(QuD1Gold) AS Gold1, " . "(QuD1Xnine) AS Xnine1, " . "(QuD2Score) AS Score2, " . "(QuD2Gold) AS Gold2, " . "(QuD2Xnine) AS Xnine2, "; } else { $MyQuery .= "(QuD1Score+QuD2Score+QuD3Score+QuD4Score) AS Score1, " . "(QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine) AS Xnine1, " . "(QuD5Score+QuD6Score+QuD7Score+QuD8Score) AS Score2, " . "(QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold) AS Gold2, " . "(QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine) AS Xnine2, "; } } $MyQuery .= "QuScore, QuGold,QuXnine,TeScore, TeRank, TeGold, TeXnine, ToGolds AS TtGolds, ToXNine AS TtXNine "; $MyQuery .= ", if(EnIocCode!='', EnIocCode, '{$IocCode}') as IocCode "; $MyQuery .= "FROM Tournament AS t "; $MyQuery .= "INNER JOIN Teams AS te ON t.ToId=te.TeTournament AND te.TeFinEvent=0 "; $MyQuery .= "INNER JOIN Countries AS c ON te.TeCoId=c.CoId AND te.TeTournament=c.CoTournament "; $MyQuery .= "INNER JOIN (SELECT TcCoId, TcSubTeam, TcEvent, TcFinEvent, COUNT(TcId) as Quanti FROM TeamComponent WHERE TcTournament=" . StrSafe_DB($_SESSION['TourId']) . " GROUP BY TcCoId, TcSubTeam, TcEvent, TcFinEvent ORDER BY TcOrder ASC) AS sq ON te.TeCoId=sq.TcCoId AND te.TeEvent=sq.TcEvent AND te.TeSubTeam=sq.TcSubTeam AND te.TeFinEvent=sq.TcFinEvent "; $MyQuery .= "INNER JOIN TeamComponent AS tc ON te.TeCoId=tc.TcCoId AND te.TeEvent=tc.TcEvent AND te.TeTournament=tc.TcTournament AND te.TeFinEvent=tc.TcFinEvent "; $MyQuery .= "INNER JOIN Entries AS en ON tc.TcId=en.EnId "; $MyQuery .= "INNER JOIN Qualifications AS q ON en.EnId=q.QuId "; $MyQuery .= "LEFT JOIN Classes AS cl ON en.EnClass=cl.ClId AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "LEFT JOIN Divisions AS d ON en.EnDivision=d.DivId AND DivTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "WHERE ToId = " . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "ORDER BY TeEvent, TeScore DESC, TeGold DESC, TeXnine DESC, CoCode,TcOrder"; //print $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if (safe_num_rows($Rs) > 0) { $CurEvent = ""; $CurTeam = ""; // Variabili per la gestione del ranking $MyRank = 1; $MyPos = 0; // Variabili che contengono i punti del precedente atleta per la gestione del rank $MyScoreOld = 0; $MyGoldOld = 0; $MyXNineOld = 0; $Score1 = 0; $Score2 = 0; $Gold1 = 0; $Gold2 = 0; $Xnine1 = 0; $Xnine2 = 0; $TmpMatr = ''; while ($MyRow = safe_fetch($Rs)) { if ($CurEvent != $MyRow->TeEvent) { // ultimo totale prima di cambiare evento if ($CurEvent != '') { $StrData .= $Score1 . ';' . $Gold1 . ';' . $Xnine1 . ';' . $Score2 . ';' . $Gold2 . ';' . $Xnine2 . ';' . $MyRank . ';' . substr($TmpMatr, 0, -1) . "\n"; } $TmpMatr = ''; $CurTeam = ""; $MyRank = 1; $MyPos = 0; $MyScoreOld = 0; $MyGoldOld = 0; $MyXNineOld = 0; $Score1 = 0; $Score2 = 0; $Gold1 = 0; $Gold2 = 0; $Xnine1 = 0; $Xnine2 = 0; } if ($CurTeam != $MyRow->CoCode) { if ($CurTeam != '') { $StrData .= $Score1 . ';' . $Gold1 . ';' . $Xnine1 . ';' . $Score2 . ';' . $Gold2 . ';' . $Xnine2 . ';' . $MyRank . ';' . substr($TmpMatr, 0, -1) . "\n"; $TmpMatr = ''; $Score1 = 0; $Score2 = 0; $Gold1 = 0; $Gold2 = 0; $Xnine1 = 0; $Xnine2 = 0; } $MyPos++; // Se non ho parimerito il ranking ? uguale alla posizione if (!($MyRow->TeScore == $MyScoreOld && $MyRow->TeGold == $MyGoldOld && $MyRow->TeXnine == $MyXNineOld)) { $MyRank = $MyPos; } $StrData .= '3;' . $MyRow->CoCode . ';' . substr($MyRow->TeEvent, 0, 2) . ';' . substr($MyRow->TeEvent, 2, 2) . ';'; } $Score1 += $MyRow->Score1; $Gold1 += $MyRow->Gold1; $Xnine1 += $MyRow->Xnine1; $Score2 += $MyRow->Score2; $Gold2 += $MyRow->Gold2; $Xnine2 += $MyRow->Xnine2; $TmpMatr .= $MyRow->EnCode . ';'; $CurEvent = $MyRow->TeEvent; $CurTeam = $MyRow->CoCode; $MyScoreOld = $MyRow->TeScore; $MyGoldOld = $MyRow->TeGold; $MyXNineOld = $MyRow->TeXnine; } // ultimissimo totale $StrData .= $Score1 . ';' . $Gold1 . ';' . $Xnine1 . ';' . $Score2 . ';' . $Gold2 . ';' . $Xnine2 . ';' . $MyRank . ';' . substr($TmpMatr, 0, -1) . "\n"; } //print $StrData;Exit; /* * Tipo 4: Finale a Squadre * CodiceSocieta-Evento-PosPartenza|FaseIniziale-PosizioneClassifica-ScoresDelleFasi */ //Carico le fasi in un array $myPhases = getPhaseArray(); //Genero la query che mi ritorna tutti gli eventi a squadre $MyQuery = "SELECT EvCode, EvFinalFirstPhase, EvEventName, EvFinalPrintHead,EvMatchMode,EvMatchArrowsNo,EvMixedTeam "; $MyQuery .= "FROM Events "; $MyQuery .= "WHERE EvTournament = " . StrSafe_DB($_SESSION['TourId']) . " AND EvTeamEvent=1 "; if (!is_null($Event) && preg_match("/^[0-9A-Z]{1,4}\$/i", $Event)) { $MyQuery .= "AND EvCode LIKE '" . $Event . "' "; } $MyQuery .= "ORDER BY EvProgr ASC, EvCode "; $RsEv = safe_r_sql($MyQuery); if (safe_num_rows($RsEv) > 0) { $RsEvCounter = 0; while ($MyRowEv = safe_fetch($RsEv)) { //$target=$GLOBALS{GetTargetType($MyRowEv->EvCode,1)}; $PhaseFields = array(); reset($myPhases); //Genero la query che mi da i risultati per ogni evento $MyQuery = "SELECT TfTeam, CoName, CoCode, TeRank,TeRankFinal, "; $Tmp = ""; $NumPhases = 0; $NeedTitle = true; while (list($Key, $Value) = each($myPhases)) { if ($Key <= valueFirstPhase($MyRowEv->EvFinalFirstPhase)) { // mi servirà dopo nei calcoli dei campi! $PhaseFields[] = array("X_Phase" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Phase", "X_SetPoints" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_SetPoints", "X_Arrowstring" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Arrowstring", "X_TieArrowstring" => namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_TieArrowstring", "X_Tie" => $Value . "Tie", "X_Live" => $Value . "Live", "X_Matchno" => $Value . "Matchno"); /*if($Key!=0) { $MyQuery .= "SUM(IF(GrPhase=" . $Key . ",IF(TfScore=0 && TfTie=2,(TeScore*10),TfScore),0)) as `" . $Key . "_Phase`, SUM(IF(GrPhase=" . $Key . ",TfTie,0)) as `" . $Value . "Tie`, SUM(IF(GrPhase=" . $Key . ",LENGTH(TfArrowstring),0)) as `" . $Value . "Live`, SUM(IF(GrPhase=" . $Key . ",TfMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC " . $Tmp; $NumPhases++; } else { $MyQuery .= "SUM(IF((GrPhase=0 OR GrPhase=1),TfScore,0)) as `" . $Key . "_Phase`, SUM(IF((GrPhase=0 OR GrPhase=1),TfTie,0)) as `" . $Value . "Tie`, SUM(IF((GrPhase=0 OR GrPhase=1),LENGTH(TfArrowstring),0)) as `" . $Value . "Live`, SUM(IF((GrPhase=0 OR GrPhase=1),TfMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC, `" . $Value . "Tie` DESC " . $Tmp; $NumPhases++; }*/ if ($Key != 0) { //$MyQuery .= "SUM(IF(GrPhase=" . $Key . ",IF(IF(EvMatchMode=0,FinScore,FinSetScore)=0 && FinTie=2,(QuScore*10),IF(EvMatchMode=0,FinScore,FinSetScore)),0)) as `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_Phase`, SUM(IF(GrPhase=" . $Key . ",FinTie,0)) as `" . $Value . "Tie`,GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinArrowstring,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_Arrowstring`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinTieBreak,'') SEPARATOR '') as `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_TieArrowstring`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",FinSetPoints,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_SetPoints`, SUM(IF(GrPhase=" . $Key . ",FinMatchNo,0)) as `" . $Value . "Matchno`, "; $MyQuery .= "SUM(IF(GrPhase=" . $Key . ",IF(TfScore=0 && TfTie=2,(TeScore*10),TfScore),0)) as `" . $Key . "_Phase`, SUM(IF(GrPhase=" . $Key . ",TfTie,0)) as `" . $Value . "Tie`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",TfTieBreak,'') SEPARATOR '') as `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_TieArrowstring`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",TfSetPoints,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_SetPoints`, GROUP_CONCAT(IF(GrPhase=" . $Key . ",TfArrowstring,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Arrowstring`, SUM(IF(GrPhase=" . $Key . ",TfMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC " . $Tmp; if ($Key == 4) { $MyQuery .= "SUM(IF(GrPhase=" . $Key . ",TfScore,0)) as `QuarterScore`, "; $Tmp = ", `QuarterScore` DESC " . $Tmp; } $NumPhases++; } else { //$MyQuery .= "SUM(IF((GrPhase=0 OR GrPhase=1),IF(EvMatchMode=0,FinScore,FinSetScore),0)) as `" . $Key . "_Phase`, SUM(IF((GrPhase=0 OR GrPhase=1),FinTie,0)) as `" . $Value . "Tie`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),FinTieBreak,'') SEPARATOR '') as `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key) . "_TieArrowstring`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),FinSetPoints,'') SEPARATOR '') AS `" . $Key. "_SetPoints`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),FinArrowstring,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase,$Key). "_Arrowstring`,SUM(IF((GrPhase=0 OR GrPhase=1),FinMatchNo,0)) as `" . $Value . "Matchno`, "; $MyQuery .= "SUM(IF((GrPhase=0 OR GrPhase=1),TfScore,0)) as `" . $Key . "_Phase`, SUM(IF((GrPhase=0 OR GrPhase=1),TfTie,0)) as `" . $Value . "Tie`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),TfTieBreak,'')) as `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_TieArrowstring`,GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),TfSetPoints,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_SetPoints`, GROUP_CONCAT(IF((GrPhase=0 OR GrPhase=1),TfArrowstring,'') SEPARATOR '') AS `" . namePhase($MyRowEv->EvFinalFirstPhase, $Key) . "_Arrowstring`, SUM(IF((GrPhase=0 OR GrPhase=1),TfMatchNo,0)) as `" . $Value . "Matchno`, "; $Tmp = ", `" . $Key . "_Phase` DESC, `" . $Value . "Tie` DESC " . $Tmp; $NumPhases++; } } } $MyQuery .= "MIN(GrPhase) as LastPhase, ifnull(CurrentPhase,128) as CurrentPhase, TeScore "; $MyQuery .= "FROM TeamFinals "; $MyQuery .= "INNER JOIN Events ON TfEvent=EvCode AND TfTournament=EvTournament AND EvTeamEvent=1 "; $MyQuery .= "INNER JOIN Grids ON TfMatchNo=GrMatchNo "; $MyQuery .= "INNER JOIN Countries ON TfTeam=CoId AND TfTournament=CoTournament "; $MyQuery .= "INNER JOIN Teams ON TfTeam=TeCoId AND TfEvent=TeEvent AND TfTournament=TeTournament AND TeFinEvent=1 "; $MyQuery .= "LEFT JOIN (SELECT min(GrPhase) AS CurrentPhase, TfTournament AS SqyTournament, TfEvent AS SqyEvent " . "FROM TeamFinals INNER JOIN Grids ON TfMatchNo=GrMatchNo " . "WHERE TfScore<>0 GROUP BY SqyTournament, SqyEvent) AS Sqy ON SqyTournament=TfTournament AND SqyEvent=TfEvent "; $MyQuery .= "WHERE TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND TfEvent=" . StrSafe_DB($MyRowEv->EvCode) . " "; $MyQuery .= "GROUP BY TfTeam, CoName, CoCode "; $MyQuery .= "ORDER BY TfEvent, LastPhase ASC " . $Tmp . ", TeRank ASC"; //print $MyQuery . "<br>"; $Rs = safe_r_sql($MyQuery); $MyPos = 0; // $MyRank=0; //Se Esistono righe caricate.... if (safe_num_rows($Rs) > 0) { // if($RsEvCounter++) // $pdf->AddPage(); // $pdf->SetXY(10,$pdf->GetY()+5); // $OldScore=-1; // $OldTie=-1; // $OldLastPhase=-1; $ActualScore = 0; $ActualTie = -1; $ActualMatch = 0; while ($MyRow = safe_fetch($Rs)) { $TmpScores = array(); $cols = array(); $MyPos++; // Se non ho parimerito il ranking � uguale alla posizione if ($MyPos > $MyRow->CurrentPhase) { $TmpScores = array(); $ActualScore = 0; $ActualMatch = 0; $ActualTie = -1; foreach ($PhaseFields as $Key => $Val) { $ActualScore = $MyRow->{$Val["X_Phase"]} != 0 ? $MyRow->{$Val["X_Phase"]} : $ActualScore; $ActualMatch = $MyRow->{$Val["X_Matchno"]} != 0 ? $MyRow->{$Val["X_Matchno"]} : $ActualMatch; $ActualTie = $MyRow->LastPhase < 2 ? $MyRow->{$Val["X_Tie"]} : -1; $TmpScores[] = ($MyRow->{$Val["X_Phase"]} == $MyRow->TeScore * 10 ? 'bye' : $MyRow->{$Val["X_Phase"]}) . '|'; list($tmpPhase, ) = explode('_', $Val['X_Phase']); //$x=DecodeArrowstring($MyRowEv->EvMatchMode,$MyRowEv->EvMatchArrowsNo,1,$MyRowEv->EvMixedTeam,$tmpPhase,$MyRow->{$Val["X_Arrowstring"]},$target); //$x=DecodeArrowstring($MyRowEv->EvMatchMode,$MyRowEv->EvMatchArrowsNo,1,$MyRowEv->EvMixedTeam,$tmpPhase,$MyRow->{$Val["X_Arrowstring"]}); $numRows = 0; $numCols = 0; $obj = getEventArrowsParams($MyRowEv->EvCode, $tmpPhase, 1); $numRows = $obj->ends; $numCols = $obj->arrows; $x = DecodeArrowstring($numRows, $numCols, $MyRow->{$Val["X_Arrowstring"]}); $TmpScores[count($TmpScores) - 1] .= '_' . $x; //$x=DecodeTieArrowstring($MyRow->{$Val['X_TieArrowstring']},$target); $x = DecodeTieArrowstring($MyRow->{$Val['X_TieArrowstring']}); $TmpScores[count($TmpScores) - 1] .= '#' . $x; } if ($MyRow->LastPhase >= 8) { // $MyRank=$MyRow->LastPhase+1; } elseif ($MyRow->LastPhase == 4) { $ActualScore = $MyRow->QuarterScore; $ActualTie = $MyRow->QuarterScore; // if ($OldScore!=$ActualScore || $OldTie!=$ActualTie || $OldLastPhase!=$MyRow->LastPhase) // { // $MyRank = $MyPos; // } } } // else // $MyRank = -1; //Per i primi 4 NON vale la regola sopra // if($MyPos<=4) // { // if($MyRow->CurrentPhase==1 && $MyRank>2) // $MyRank = $MyPos; // elseif($MyRow->CurrentPhase==0) // $MyRank = $MyPos; // // } //Tolgo tutti Quelli da non scrivere //Salvo i valori attuali e risistemo i colori // $OldScore=$ActualScore; // $OldTie=$ActualTie; // $OldLastPhase=$MyRow->LastPhase; // $OldMatch=$ActualMatch; $cols[] = '4'; $cols[] = $MyRow->CoCode; $cols[] = $MyRowEv->EvCode; $cols[] = $MyRow->TeRank . '|' . $MyRowEv->EvFinalFirstPhase; //$cols[]=$MyRank; $cols[] = $MyRow->TeRankFinal; $StrData .= join(';', $cols) . ';' . join(';', $TmpScores) . "\n"; } } } } /* * Tipo 5/6: Classifica eliminatorie, fase 1 e fase 2 * Matricola-Divisione-Classe-CognomeNome-Societa-Evento-Totale-Ori-X-CodiceFiscale-PosizioneClassifica * */ for ($tipo = 5; $tipo <= 6; ++$tipo) { $phase = $tipo - 5; $Query = "SELECT " . "'" . $tipo . "' AS RowType,EnCode as Bib, EnDivision, EnClass," . "CONCAT(EnFirstName,' ',EnName) AS Name, CoCode,ElEventCode, " . "ElScore,ElGold,ElXnine,EnCtrlCode,ElRank " . "FROM " . "Entries " . "INNER JOIN " . "Countries " . "ON EnCountry=CoId AND EnTournament=CoTournament " . "INNER JOIN " . "Eliminations " . "ON EnId=ElId AND EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND ElElimPhase=" . $phase . " " . "ORDER BY " . "ElEventCode ASC, (ElScore*1.0) DESC, ElRank ASC, ElGold DESC, ElXnine DESC "; //print $Query . '<br><br/>'; $Rs = safe_r_sql($Query); $CurEvent = ""; // Variabili per la gestione del ranking // $MyRank = 1; // $MyPos = 0; // Variabili che contengono i punti del precedente atleta per la gestione del rank // $MyScoreOld = 0; // $MyGoldOld = 0; // $MyXNineOld = 0; if (safe_num_rows($Rs) > 0) { while ($myRow = safe_fetch($Rs)) { // if ($CurEvent!=$myRow->ElEventCode) // { // // $MyRank = 1; // $MyPos = 0; // $MyScoreOld = 0; // $MyGoldOld = 0; // $MyXNineOld = 0; // } // // ++$MyPos; // if (!($myRow->ElScore==$MyScoreOld && $myRow->ElGold==$MyGoldOld && $myRow->ElXnine==$MyXNineOld)) // $MyRank = $MyPos; $StrData .= $myRow->RowType . ';' . $myRow->Bib . ';' . $myRow->EnDivision . ';' . $myRow->EnClass . ';' . $myRow->Name . ';' . $myRow->CoCode . ';' . $myRow->ElEventCode . ';' . $myRow->ElScore . ';' . $myRow->ElGold . ';' . $myRow->ElXnine . ';' . $myRow->EnCtrlCode . ';' . $myRow->ElRank . "\n"; // $MyScoreOld = $myRow->ElScore; // $MyGoldOld = $myRow->ElGold; // $MyXNineOld = $myRow->ElXnine; $CurEvent = $myRow->ElEventCode; } } } /* * Tipo 7: assoluti individuali * Matricola-Divisione-Classe-CognomeNome-Societa-CodiceEvento-Totale1-ori1-X1-Totale2-Ori2-X2-CodiceDiControllo-PosizioneClassificaIndividuale(999 se nn partecipa)-Status-Singole distanze-tiearrowstring */ $MyQuery = "SELECT EnCode as Bib, EnName AS Name, CONCAT(EnFirstName,' ',EnName) AS Name,SUBSTRING(QuTargetNo,1,1) AS Session, SUBSTRING(QuTargetNo,2) AS TargetNo, CoCode AS NationCode, CoName AS Nation, EnClass AS ClassCode, EnAgeClass as AgeClass, EnDivision AS DivCode, EvCode as EventCode, EvEventName as EventName, EvQualPrintHead,"; $MyQuery .= "IF(EvElim1=0 && EvElim2=0,(EvFinalFirstPhase*2),IF(EvElim1=0,EvElim2,EvElim1)) as QualifiedNo, "; $MyQuery .= "ToNumDist AS NumDist, Td1, Td2, Td3, Td4, Td5, Td6, Td7, Td8, "; for ($i = 1; $i <= $NumDist; ++$i) { $MyQuery .= "QuD" . $i . "Score,QuD" . $i . "Gold,QuD" . $i . "Xnine,QuD" . $i . "Arrowstring AS Arrowstring" . $i . ", "; } $MyQuery .= "QuScore, IndRank, QuGold, QuXnine, ToGolds AS TtGolds, ToXNine AS TtXNine, "; if ($ToType == 8) { $MyQuery .= "(QuD1Score+QuD2Score) AS Score1, " . "(QuD1Gold+QuD2Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine) AS Xnine1, " . "(QuD3Score+QuD4Score) AS Score2, " . "(QuD3Gold+QuD4Gold) AS Gold2, " . "(QuD3Xnine+QuD4Xnine) AS Xnine2, "; } else { if ($ToType == 10 || $ToType == 12 || $ToType == 13) { $MyQuery .= "(QuD1Score) AS Score1, " . "(QuD1Gold) AS Gold1, " . "(QuD1Xnine) AS Xnine1, " . "(QuD2Score) AS Score2, " . "(QuD2Gold) AS Gold2, " . "(QuD2Xnine) AS Xnine2, "; } else { $MyQuery .= "(QuD1Score+QuD2Score+QuD3Score+QuD4Score) AS Score1, " . "(QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine) AS Xnine1, " . "(QuD5Score+QuD6Score+QuD7Score+QuD8Score) AS Score2, " . "(QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold) AS Gold2, " . "(QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine) AS Xnine2, "; } } $MyQuery .= "QuTieBreak AS ArrowstringTie, "; $MyQuery .= "IF(LENGTH(EnCtrlCode)=16,EnCtrlCode,CONCAT(EnDob,'|',EnSex)) AS EnCtrlCode, IndRank, EnStatus "; $MyQuery .= "FROM Tournament AS t "; $MyQuery .= "INNER JOIN Entries AS e ON t.ToId=e.EnTournament "; $MyQuery .= "INNER JOIN Countries AS c ON e.EnCountry=c.CoId AND e.EnTournament=c.CoTournament "; $MyQuery .= "INNER JOIN Qualifications AS q ON e.EnId=q.QuId "; $MyQuery .= "INNER JOIN EventClass AS ec ON e.EnClass=ec.EcClass AND e.EnDivision=ec.EcDivision AND e.EnTournament=ec.EcTournament AND ec.EcTeamEvent=0 "; $MyQuery .= "INNER JOIN Events AS ev ON ev.EvCode=ec.EcCode AND ev.EvTeamEvent=ec.EcTeamEvent AND ev.EvTournament=ec.EcTournament "; $MyQuery .= "INNER JOIN Individuals i ON i.IndId=e.EnId AND i.IndEvent=ev.EvCode AND i.IndTournament=e.EnTournament "; $MyQuery .= "LEFT JOIN TournamentDistances AS td ON t.ToType=td.TdType and TdTournament=ToId AND CONCAT(TRIM(e.EnDivision),TRIM(e.EnClass)) LIKE TdClasses "; //Where Normale $MyQuery .= "WHERE EnAthlete=1 AND EnIndFEvent=1 AND EnStatus <= 1 AND QuScore<>'0' AND ToId = " . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "ORDER BY EvProgr, EvCode, QuScore DESC, IndRank ASC, QuGold DESC, QuXnine DESC, IndRank, EnFirstName,EnName "; //print $MyQuery;exit; $Rs = safe_r_sql($MyQuery); //$target=$GLOBALS['TrgOutdoor']; if ($Rs && safe_num_rows($Rs) > 0) { $CurGroup = "...."; // Variabili per la gestione del ranking $MyRank = 1; //$MyPos = 0; $EndQualified = false; // Variabili che contengono i punti del precedente atleta per la gestione del rank // $MyScoreOld = 0; // $MyGoldOld = 0; // $MyXNineOld = 0; $MyEndScore = -1; $MyGroupStartPos = 0; $CurrentRow = -1; while ($MyRow = safe_fetch($Rs)) { $CurrentRow++; if ($CurGroup != $MyRow->EventCode) { $CurGroup = $MyRow->EventCode; // $MyRank = 1; // $MyPos = 0; // $MyScoreOld = 0; // $MyGoldOld = 0; // $MyXNineOld = 0; $EndQualified = false; $MyGroupStartPos = $CurrentRow; //Carico l'ultimo punteggio per entrare // Vado a brancare la riga con l'ultimo Score buono if (safe_num_rows($Rs) > $MyGroupStartPos + $MyRow->QualifiedNo) { safe_data_seek($Rs, $MyGroupStartPos + $MyRow->QualifiedNo - 1); $tmpMyRow = safe_fetch($Rs); if ($CurGroup == $tmpMyRow->EventCode) { $MyEndScore = $tmpMyRow->QuScore; $tmpMyRow = safe_fetch($Rs); //Controllo se c'è parimerito per entrare if ($MyEndScore != $tmpMyRow->QuScore || $CurGroup != $tmpMyRow->EventCode) { $MyEndScore *= -1; } } else { $MyEndScore = -1; } $tmpMyRow = NULL; } else { safe_data_seek($Rs, safe_num_rows($Rs) - 1); $tmpMyRow = safe_fetch($Rs); $MyEndScore = -1; } safe_data_seek($Rs, $MyGroupStartPos + 1); } $MyRank = $MyRow->IndRank; //$MyPos++; // Se non ho parimerito il ranking è uguale alla posizione // if($MyEndScore == $MyRow->QuScore) //Spareggio // { // if ($MyRow->QuScore!=$MyScoreOld) // $MyRank = $MyPos; // } // else // { // if (!($MyRow->QuScore==$MyScoreOld && $MyRow->QuGold==$MyGoldOld && $MyRow->QuXnine==$MyXNineOld)) // $MyRank = $MyPos; // } if ($MyRank > $MyRow->QualifiedNo && !$EndQualified) { $EndQualified = true; } // $MyScoreOld = $MyRow->QuScore; // $MyGoldOld = $MyRow->QuGold; // $MyXNineOld = $MyRow->QuXnine; // qui butto fuori la riga $cols = array(); $cols[] = 7; $cols[] = $MyRow->Bib; $cols[] = $MyRow->DivCode; $cols[] = $MyRow->ClassCode; $cols[] = $MyRow->Name; $cols[] = $MyRow->NationCode; $cols[] = $MyRow->EventCode; $cols[] = $MyRow->Score1; $cols[] = $MyRow->Gold1; $cols[] = $MyRow->Xnine1; $cols[] = $MyRow->Score2; $cols[] = $MyRow->Gold2; $cols[] = $MyRow->Xnine2; $cols[] = $MyRow->EnCtrlCode; //$cols[]=($MyRow->IndRank==0 ? $MyRank : $MyRow->IndRank); $cols[] = $MyRank; $cols[] = $MyRow->EnStatus; for ($i = 1; $i <= $NumDist; ++$i) { $cols[] = $MyRow->{'QuD' . $i . 'Score'}; $cols[] = $MyRow->{'QuD' . $i . 'Gold'}; $cols[] = $MyRow->{'QuD' . $i . 'Xnine'}; $c = array(); $v = $MyRow->{'Arrowstring' . $i}; for ($k = 0; $k < strlen($v); ++$k) { $c[] = DecodeFromLetter($v[$k]); } $cols[] = implode(',', $c); } $c = array(); $v = $MyRow->ArrowstringTie; for ($k = 0; $k < strlen($v); ++$k) { $c[] = DecodeFromLetter($v[$k]); } $cols[] = implode(',', $c); $StrData .= join(';', $cols) . "\n"; } } /* * Tipo 8: Assoluti a squadre * CodiceSocieta-Evento-Totale1-ori1-X1-Totale2-Ori2-X2-PosizioneClassifica-MatricolaPartecipanti(in lista) */ /*$MyQuery = "SELECT EnCode,CoCode AS NationCode, TeSubTeam as SubTeam, CoName AS Nation, TeEvent, EvEventName, Quanti, EnFirstName as FirstName, EnName AS Name, EnClass AS ClassCode, EnDivision AS DivCode,EnAgeClass as AgeClass, EnSubClass as SubClass, sqY.QuantiPoss as NumGialli, (EvFinalFirstPhase*2) as QualifiedNo, EvQualPrintHead, "; $MyQuery.= "QuScore, TeScore, TeRank, TeGold, TeXnine, TtGolds, TtXNine, "; if ($ToType==8) { $MyQuery .= "(QuD1Score+QuD2Score) AS Score1, " . "(QuD1Gold+QuD2Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine) AS Xnine1, " . "(QuD3Score+QuD4Score) AS Score2, " . "(QuD3Gold+QuD4Gold) AS Gold2, " . "(QuD3Xnine+QuD4Xnine) AS Xnine2 "; } else if ($ToType==10 || $ToType==12 || $ToType==13) { $MyQuery .= "(QuD1Score) AS Score1, " . "(QuD1Gold) AS Gold1, " . "(QuD1Xnine) AS Xnine1, " . "(QuD2Score) AS Score2, " . "(QuD2Gold) AS Gold2, " . "(QuD2Xnine) AS Xnine2 "; } else { $MyQuery .= "(QuD1Score+QuD2Score+QuD3Score+QuD4Score) AS Score1, " . "(QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine) AS Xnine1, " . "(QuD5Score+QuD6Score+QuD7Score+QuD8Score) AS Score2, " . "(QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold) AS Gold2, " . "(QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine) AS Xnine2 "; } $MyQuery.= "FROM Tournament AS t "; $MyQuery.= "INNER JOIN Tournament*Type AS tt ON t.ToType=tt.TtId "; $MyQuery.= "INNER JOIN Teams AS te ON t.ToId=te.TeTournament AND te.TeFinEvent=1 "; $MyQuery.= "INNER JOIN Countries AS c ON te.TeCoId=c.CoId AND te.TeTournament=c.CoTournament "; $MyQuery.= "INNER JOIN Events AS ev ON te.TeEvent=ev.EvCode AND t.ToId=ev.EvTournament AND EvTeamEvent=1 "; $MyQuery.= "INNER JOIN (SELECT TcCoId, TcSubTeam, TcEvent, TcTournament, TcFinEvent, COUNT(TcId) as Quanti FROM TeamComponent GROUP BY TcCoId, TcSubTeam, TcEvent, TcTournament) AS sq ON te.TeCoId=sq.TcCoId AND te.TeSubTeam=sq.TcSubTeam AND te.TeEvent=sq.TcEvent AND te.TeTournament=sq.TcTournament AND te.TeFinEvent=sq.TcFinEvent "; $MyQuery.= "INNER JOIN TeamComponent AS tc ON te.TeCoId=tc.TcCoId AND te.TeSubTeam=tc.TcSubTeam AND te.TeEvent=tc.TcEvent AND te.TeTournament=tc.TcTournament AND te.TeFinEvent=tc.TcFinEvent "; $MyQuery.= "INNER JOIN Entries AS en ON tc.TcId=en.EnId "; $MyQuery.= "INNER JOIN Qualifications AS q ON en.EnId=q.QuId "; //Contatori per Coin toss & Spareggi $MyQuery .= "INNER JOIN (SELECT Count(*) as QuantiPoss, EvCode as SubCode, TeScore AS Score, TeGold AS Gold, TeXnine AS XNine " . "FROM Teams " . "INNER JOIN Events ON TeEvent=EvCode AND TeTournament=EvTournament AND EvTeamEvent=1 " . "WHERE TeTournament = " . StrSafe_DB($_SESSION['TourId']) . " " . "GROUP BY TeScore, EvCode, TeGold, TeXnine) AS sqY ON sqY.Score=te.TeScore AND sqY.Gold=te.TeGold AND sqY.Xnine=te.TeXnine AND ev.EvCode=sqY.SubCode "; //Where Normale $MyQuery.= "WHERE ToId = " . StrSafe_DB($_SESSION['TourId']) . " "; //if(isset($_REQUEST["Definition"])) // $MyQuery .= "AND te.TeEvent LIKE " . StrSafe_DB($_REQUEST["Definition"]) . " "; $MyQuery.= "ORDER BY EvProgr,TeEvent, TeScore DESC, TeGold DESC, TeXnine DESC, TeRank, NationCode, SubTeam, TcOrder ";*/ $MyQuery = "SELECT EnCode,CoCode AS NationCode, TeSubTeam as SubTeam, CoName AS Nation, TeEvent, EvEventName, Quanti, EnFirstName as FirstName, EnName AS Name, EnClass AS ClassCode, EnDivision AS DivCode,EnAgeClass as AgeClass, EnSubClass as SubClass, sqY.QuantiPoss as NumGialli, (EvFinalFirstPhase*2) as QualifiedNo, EvQualPrintHead, "; $MyQuery .= "QuScore, TeScore, TeRank, TeGold, TeXnine, ToGolds AS TtGolds, ToXNine AS TtXNine, "; if ($ToType == 8) { $MyQuery .= "(QuD1Score+QuD2Score) AS Score1, " . "(QuD1Gold+QuD2Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine) AS Xnine1, " . "(QuD3Score+QuD4Score) AS Score2, " . "(QuD3Gold+QuD4Gold) AS Gold2, " . "(QuD3Xnine+QuD4Xnine) AS Xnine2 "; } else { if ($ToType == 10 || $ToType == 12 || $ToType == 13) { $MyQuery .= "(QuD1Score) AS Score1, " . "(QuD1Gold) AS Gold1, " . "(QuD1Xnine) AS Xnine1, " . "(QuD2Score) AS Score2, " . "(QuD2Gold) AS Gold2, " . "(QuD2Xnine) AS Xnine2 "; } else { $MyQuery .= "(QuD1Score+QuD2Score+QuD3Score+QuD4Score) AS Score1, " . "(QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold) AS Gold1, " . "(QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine) AS Xnine1, " . "(QuD5Score+QuD6Score+QuD7Score+QuD8Score) AS Score2, " . "(QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold) AS Gold2, " . "(QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine) AS Xnine2 "; } } $MyQuery .= "FROM Tournament AS t "; $MyQuery .= "INNER JOIN Teams AS te ON t.ToId=te.TeTournament AND te.TeFinEvent=1 "; $MyQuery .= "INNER JOIN Countries AS c ON te.TeCoId=c.CoId AND te.TeTournament=c.CoTournament "; $MyQuery .= "INNER JOIN Events AS ev ON te.TeEvent=ev.EvCode AND t.ToId=ev.EvTournament AND EvTeamEvent=1 "; $MyQuery .= "INNER JOIN (SELECT TcCoId, TcSubTeam, TcEvent, TcTournament, TcFinEvent, COUNT(TcId) as Quanti FROM TeamComponent GROUP BY TcCoId, TcSubTeam, TcEvent, TcTournament) AS sq ON te.TeCoId=sq.TcCoId AND te.TeSubTeam=sq.TcSubTeam AND te.TeEvent=sq.TcEvent AND te.TeTournament=sq.TcTournament AND te.TeFinEvent=sq.TcFinEvent "; $MyQuery .= "INNER JOIN TeamComponent AS tc ON te.TeCoId=tc.TcCoId AND te.TeSubTeam=tc.TcSubTeam AND te.TeEvent=tc.TcEvent AND te.TeTournament=tc.TcTournament AND te.TeFinEvent=tc.TcFinEvent "; $MyQuery .= "INNER JOIN Entries AS en ON tc.TcId=en.EnId "; $MyQuery .= "INNER JOIN Qualifications AS q ON en.EnId=q.QuId "; //Contatori per Coin toss & Spareggi $MyQuery .= "INNER JOIN (SELECT Count(*) as QuantiPoss, EvCode as SubCode, TeScore AS Score, TeGold AS Gold, TeXnine AS XNine " . "FROM Teams " . "INNER JOIN Events ON TeEvent=EvCode AND TeTournament=EvTournament AND EvTeamEvent=1 " . "WHERE TeTournament = " . StrSafe_DB($_SESSION['TourId']) . " " . "GROUP BY TeScore, EvCode, TeGold, TeXnine) AS sqY ON sqY.Score=te.TeScore AND sqY.Gold=te.TeGold AND sqY.Xnine=te.TeXnine AND ev.EvCode=sqY.SubCode "; //Where Normale $MyQuery .= "WHERE ToId = " . StrSafe_DB($_SESSION['TourId']) . " "; //if(isset($_REQUEST["Definition"])) // $MyQuery .= "AND te.TeEvent LIKE " . StrSafe_DB($_REQUEST["Definition"]) . " "; $MyQuery .= "ORDER BY EvProgr,TeEvent, TeScore DESC, TeGold DESC, TeXnine DESC, TeRank, NationCode, SubTeam, TcOrder "; //print $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if ($Rs && safe_num_rows($Rs) > 0) { $CurGroup = "...."; $CurTeam = ""; // Variabili per la gestione del ranking //$MyRank = 1; //$MyPos = 0; $EndQualified = false; // Variabili che contengono i punti del precedente atleta per la gestione del rank // $MyScoreOld = 0; // $MyGoldOld = 0; // $MyXNineOld = 0; $MyEndScore = -1; $MyGroupStartPos = 0; $CurrentRow = -1; $cols = array(); $tmpMatr = array(); $score1 = 0; $score2 = 0; $gold1 = 0; $gold2 = 0; $x1 = 0; $x2 = 0; while ($MyRow = safe_fetch($Rs)) { $CurrentRow++; if ($CurGroup != $MyRow->TeEvent) { $CurGroup = $MyRow->TeEvent; // $MyRank = 1; // $MyPos = 0; // $MyScoreOld = 0; // $MyGoldOld = 0; // $MyXNineOld = 0; $EndQualified = false; $MyGroupStartPos = $CurrentRow; if (safe_num_rows($Rs) > $MyGroupStartPos + $MyRow->QualifiedNo * $MyRow->Quanti) { safe_data_seek($Rs, $MyGroupStartPos + ($MyRow->QualifiedNo - 1) * $MyRow->Quanti); $tmpMyRow = safe_fetch($Rs); if ($CurGroup == $tmpMyRow->TeEvent) { $MyEndScore = $tmpMyRow->TeScore; safe_data_seek($Rs, $MyGroupStartPos + $MyRow->QualifiedNo * $MyRow->Quanti); $tmpMyRow = safe_fetch($Rs); //Controllo se c'è parimerito per entrare if ($MyEndScore != $tmpMyRow->TeScore || $CurGroup != $tmpMyRow->TeEvent) { $MyEndScore *= -1; } } else { $MyEndScore = -1; } $tmpMyRow = NULL; } else { safe_data_seek($Rs, safe_num_rows($Rs) - 1); $tmpMyRow = safe_fetch($Rs); $MyEndScore = -1; } safe_data_seek($Rs, $MyGroupStartPos + 1); //$CurTeam = ""; } if ($CurTeam != $MyRow->NationCode . "|" . $MyRow->TeEvent) { if ($CurTeam != '') { // sostituisco i punti nelle colonne generate in (*) più sotto $cols[3] = $score1; $cols[4] = $gold1; $cols[5] = $x1; $cols[6] = $score2; $cols[7] = $gold2; $cols[8] = $x2; $StrData .= implode(';', $cols) . ';' . implode(';', $tmpMatr) . "\n"; /*print '<pre>'; print_r($cols); print_r($tmpMatr); print '</pre>';*/ $cols = array(); $tmpMatr = array(); $score1 = 0; $score2 = 0; $gold1 = 0; $gold2 = 0; $x1 = 0; $x2 = 0; } $MyPos++; $MyRank = $MyRow->TeRank; // Se non ho parimerito il ranking è uguale alla posizione // if($MyEndScore == $MyRow->TeScore) //Spareggio // { // if ($MyRow->QuScore!=$MyScoreOld) // $MyRank = $MyPos; // } // else // { // if (!($MyRow->TeScore==$MyScoreOld && $MyRow->TeGold==$MyGoldOld && $MyRow->TeXnine==$MyXNineOld)) // $MyRank = $MyPos; // } if ($MyRank > $MyRow->QualifiedNo && !$EndQualified) { $EndQualified = true; } $cols[] = 8; $cols[] = $MyRow->NationCode; $cols[] = $MyRow->TeEvent; // colonne (*) $cols[] = 0; $cols[] = 0; $cols[] = 0; $cols[] = 0; $cols[] = 0; $cols[] = 0; // fine colonne (*) //$cols[]=($MyRow->TeRank==0 ? $MyRank : $MyRow->TeRank); $cols[] = $MyRank; } $tmpMatr[] = $MyRow->EnCode; $score1 += $MyRow->Score1; $score2 += $MyRow->Score2; $gold1 += $MyRow->Gold1; $gold2 += $MyRow->Gold2; $x1 += $MyRow->Xnine1; $x2 += $MyRow->Xnine2; // $MyScoreOld = $MyRow->TeScore; // $MyGoldOld = $MyRow->TeGold; // $MyXNineOld = $MyRow->TeXnine; $CurTeam = $MyRow->NationCode . "|" . $MyRow->TeEvent; } // ultima $cols[3] = $score1; $cols[4] = $gold1; $cols[5] = $x1; $cols[6] = $score2; $cols[7] = $gold2; $cols[8] = $x2; $StrData .= implode(';', $cols) . ';' . implode(';', $tmpMatr) . "\n"; /*print '<pre>'; print_r($cols); print_r($tmpMatr); print '</pre>';*/ } /* * Tipo 99: Verbale arbitri * Domanda - Risposte */ /*$MyQuery = "SELECT '99' AS RowType, FraQuestion, REPLACE(FraAnswer,';','\";\"') AS Ans " . "FROM FinalReportQ " . "INNER JOIN Tournament ON ToId=" . StrSafe_DB($_SESSION['TourId']) . " " . "INNER JOIN Tournament*Type ON TtId=ToType " . "LEFT JOIN FinalReportA ON FrqId=FraQuestion AND FraTournament=ToId " . "WHERE (FrqStatus & TtCategory) > 0 AND FraQuestion IS NOT NULL " . "ORDER BY FrqId";*/ $MyQuery = "SELECT '99' AS RowType, FraQuestion, REPLACE(FraAnswer,';','\";\"') AS Ans " . "FROM FinalReportQ " . "INNER JOIN Tournament ON ToId=" . StrSafe_DB($_SESSION['TourId']) . " " . "LEFT JOIN FinalReportA ON FrqId=FraQuestion AND FraTournament=ToId " . "WHERE (FrqStatus & ToCategory) > 0 AND FraQuestion IS NOT NULL " . "ORDER BY FrqId"; //print $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if (safe_num_rows($Rs) > 0) { while ($MyRow = safe_fetch($Rs)) { $cols = array(); $cols[] = $MyRow->RowType; $cols[] = $MyRow->FraQuestion; $cols[] = $MyRow->Ans; $StrData .= join(';', $cols) . "\n"; } } //exit; return array($StrData, $ToCode); }
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); }
$arrG_N = array(); for ($i = 0; $i < count($arrG); ++$i) { //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 {
// i riferimenti verranno sostituiti dopo $out .= '<td class="Right Bold"><span id="sp_' . $coords . '">{sp_' . $m . '_' . $i . '}</span></td>'; $out .= '<td class="Right Bold"><span id="st_' . $coords . '">{st_' . $m . '_' . $i . '}</span></td>'; } $out .= '</tr>' . "\n"; } // riga degli so e dei totali $out .= '<tr>'; $out .= '<th>S.O.</th>'; $out .= '<td class="Center" colspan="' . $cols . '">'; for ($i = 0; $i < $so; ++$i) { /* * stesse considerazioni per le textbox dei punti */ $name = 't_' . $myRow->{'match' . $m} . '_' . $i; $out .= '<input type="text" id="' . $name . '" size="2" maxlength="3" value="' . (!empty($myRow->{'tiebreak' . $m}) ? DecodeFromLetter(substr($myRow->{'tiebreak' . $m}, $i, 1)) : '') . '" /> '; } $out .= '</td>'; $out .= '<td class="Right Bold">' . get_text('Total') . '</td>'; $out .= '<td class="Right Bold"><span id="tot_' . $myRow->{'match' . $m} . '">' . $totCum . '</span></td>'; if ($myRow->matchMode == 1) { $out .= '<td class="Right Bold">' . get_text('Total') . '</td>'; $out .= '<td class="Right Bold"><span id="totsets_' . $myRow->{'match' . $m} . '">{totsets_' . $m . '}</span></td>'; } $out .= '</tr>' . "\n"; } else { if ($chunkMode == 2) { $sql = "SELECT RevLanguage1, RevLanguage2 " . "FROM Reviews " . "WHERE RevEvent=" . StrSafe_DB($myRow->event) . " AND " . "RevMatchNo =" . $myRow->match1 . " AND " . "RevTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND " . "RevTeamEvent=" . StrSafe_DB($team); $rs = safe_r_sql($sql); if (safe_num_rows($rs) > 1) { exit;
print '<select name="R' . $nn . '">' . "\n"; for ($i = $item['rankBeforeSO']; $i <= $endRank; ++$i) { print '<option value="' . $i . '"' . ($i == $item['rank'] ? ' selected' : '') . '>' . $i . '</option>' . "\n"; } print '</select>' . "\n"; print '</th>'; print '<td>' . $item['athlete'] . '</td>'; print '<td width="5%" class="Center">' . $item['countryCode'] . '</td>'; print '<td width="15%">' . ($item['countryName'] != '' ? $item['countryName'] : ' ') . '</td>'; for ($i = 1; $i <= $NumDist; ++$i) { $tmp = explode('|', $item['dist_' . $i]); print '<td class="Center">' . $tmp[1] . '</td>'; } print '<td class="Center">' . $item['score'] . '</td>'; print '<td class="Center">' . $item['gold'] . '</td>'; print '<td class="Center">' . $item['xnine'] . '</td>'; print '<td>'; for ($i = 0; $i < 3; ++$i) { print '<input type="text" maxlength="3" size="1" name="T' . $nn . '[' . $i . ']" value="' . (strlen($item['tiebreak']) > $i ? DecodeFromLetter($item['tiebreak'][$i]) : '') . '"> '; } print '</td>'; print '</tr>' . "\n"; } print '<tr><td class="Center" colspan="' . $Colonne . '"><input type="hidden" name="Ok" value="OK"><input type="submit" value="' . get_text('CmdOk') . '"></td></tr>' . "\n"; print '</table>' . "\n"; print '<br>'; } print '</form>'; } } include 'Common/Templates/tail.php';
} $EnCours = false; $myRow = safe_fetch($rs); // debug_svela($myRow, true); // righe e colonne e so nel caso di individuali cumulativi $rows = 4; $cols = 3; $so = 1; list($rows, $cols, $so) = CalcScoreRowsColsSO($myRow, $TourId); // i due score da stampare a video $scores = array(1 => '', 2 => ''); for ($archer = 1; $archer < 3; $archer++) { for ($row = 0; $row < $rows; $row++) { for ($col = 0; $col < $cols; $col++) { $idx = $row * $cols + $col; $ArValue = empty($myRow->{'arrowString' . $archer}[$idx]) ? '' : DecodeFromLetter($myRow->{'arrowString' . $archer}[$idx]); if ($ArValue == '') { continue; } $scores[$archer][$row][] = $ArValue; } } } // Get the last filled $LastEnd = max(count($scores[1]), count($scores[2])) - 1; if (empty($scores[1][$LastEnd])) { $scores[1][$LastEnd] = array(); } if (empty($scores[2][$LastEnd])) { $scores[2][$LastEnd] = array(); }
$Tg->appendChild($XmlDoc->createCDATASection('')); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('photo2'); $Tg->appendChild($XmlDoc->createCDATASection('')); $Opp2->appendChild($Tg); // photo3 $Tg = $XmlDoc->createElement('photo3'); $Tg->appendChild($XmlDoc->createCDATASection('')); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('photo3'); $Tg->appendChild($XmlDoc->createCDATASection('')); $Opp2->appendChild($Tg); // all arrows for ($n = 0; $n < 15; $n++) { $a = DecodeFromLetter(substr($row->arrowstring1, $n, 1)); $b = DecodeFromLetter(substr($row->arrowstring2, $n, 1)); $Tg = $XmlDoc->createElement('a' . ($n + 1)); $Tg->appendChild($XmlDoc->createCDATASection($a)); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('a' . ($n + 1)); $Tg->appendChild($XmlDoc->createCDATASection($b)); $Opp2->appendChild($Tg); } $Tg = $XmlDoc->createElement('xtowin', ''); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('xtowin', ''); $Opp2->appendChild($Tg); $Tg = $XmlDoc->createElement('xtodescr', ''); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('xtodescr', ''); $Opp2->appendChild($Tg);
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 IndRankFinal<={$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 qualifiche, le posizioni finali e le eliminatorie (se ci sono) */ $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tEnId,EnCode, upper(EnIocCode) EnIocCode, EnName AS Name, EnFirstName AS FirstName, upper(EnFirstName) AS FirstNameUpper, CoId, CoCode, CoName,\r\n\t\t\t\t\tEvCode,EvEventName,EvProgr,\r\n\t\t\t\t\tEvFinalPrintHead as PrintHeader,\r\n\t\t\t\t\tEvFinalFirstPhase,\tEvElim1, \tEvElim2,EvMatchMode, EvMedals,\r\n\t\t\t\t\tIndRank as QualRank, IF(EvShootOff+EvE1ShootOff+EvE2ShootOff=0, IndRank, IndRankFinal) as FinalRank, QuScore AS QualScore,\r\n\t\t\t\t\te1.ElRank AS E1Rank,e1.ElScore AS E1Score,\r\n\t\t\t\t\te2.ElRank AS E2Rank,e2.ElScore AS E2Score,\r\n\t\t\t\t\tIndTimestamp,IndTimestampFinal\r\n\t\t\t\tFROM\r\n\t\t\t\t\tTournament\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEntries\r\n\t\t\t\t\tON ToId=EnTournament\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tCountries\r\n\t\t\t\t\tON EnCountry=CoId AND EnTournament=CoTournament AND EnTournament={$this->tournament}\r\n\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\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tIndividuals\r\n\t\t\t\t\tON EnTournament=IndTournament AND EnId=IndId\r\n\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEvents\r\n\t\t\t\t\tON EvCode=IndEvent AND EvTeamEvent=0 AND EvTournament=IndTournament\r\n\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tEliminations AS e1\r\n\t\t\t\t\tON IndId=e1.ElId AND IndTournament=e1.ElTournament AND IndEvent=e1.ElEventCode AND e1.ElElimPhase=0\r\n\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tEliminations AS e2\r\n\t\t\t\t\tON IndId=e2.ElId AND IndTournament=e2.ElTournament AND IndEvent=e2.ElEventCode AND e2.ElElimPhase=1\r\n\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tEnAthlete=1 AND EnIndFEvent=1 AND EnStatus <= 1 AND QuScore != 0 AND ToId = {$this->tournament}\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\t\t{$EnFilter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\t\tEvProgr, EvCode, IF(EvShootOff+EvE1ShootOff+EvE2ShootOff=0, IndRank, IndRankFinal) ASC, EnFirstName, EnName\r\n\t\t\t"; //print $q;exit; $r = safe_r_sql($q); $this->data['meta']['title'] = get_text('IndFinEvent', 'Tournament'); // $this->data['meta']['printHeader']=''; // $this->data['meta']['firstPhase']=-1; // $this->data['meta']['elim1']=-1; // $this->data['meta']['elim2']=-1; // $this->data['meta']['matchMode']=-1; $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00'; $this->data['sections'] = array(); if (safe_num_rows($r) > 0) { $curEvent = ''; $section = null; while ($myRow = safe_fetch($r)) { if ($curEvent != $myRow->EvCode) { /* * se non sono all'inizio, prima di iniziare una sezione devo prendere quella appena fatta * e accodarla alle altre */ if ($curEvent != '') { $this->data['sections'][$curEvent] = $section; $section = null; } // al cambio creo una nuova sezione $curEvent = $myRow->EvCode; $phases = getPhasesId($myRow->EvFinalFirstPhase); // qui ci sono le descrizioni dei campi $fields = array('id' => 'Id', 'bib' => get_text('Code', 'Tournament'), 'athlete' => get_text('Athlete'), 'familyname' => get_text('FamilyName', 'Tournament'), 'givenname' => get_text('Name', 'Tournament'), 'countryCode' => '', 'countryName' => get_text('Country'), 'countryIocCode' => '', 'qualRank' => get_text('RankScoreShort'), 'qualScore' => get_text('PositionShort'), 'rank' => get_text('PositionShort'), 'elims' => array('e1' => get_text('Eliminations_1'), 'e2' => get_text('Eliminations_2'), 'fields' => array('score' => get_text('Total'), 'rank' => get_text('PositionShort'))), 'finals' => array()); foreach ($phases as $k => $v) { if ($v <= valueFirstPhase($myRow->EvFinalFirstPhase)) { if (!($v == 32 && ($myRow->EvFinalFirstPhase == 24 || $myRow->EvFinalFirstPhase == 48))) { $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' => $curEvent, 'descr' => get_text($myRow->EvEventName, '', '', true), 'printHeader' => get_text($myRow->PrintHeader, '', '', true), 'firstPhase' => $myRow->EvFinalFirstPhase, 'elim1' => $myRow->EvElim1 != 0, 'elim2' => $myRow->EvElim2 != 0, 'matchMode' => $myRow->EvMatchMode, 'order' => $myRow->EvProgr, 'lastUpdate' => '0000-00-00 00:00:00', 'fields' => $fields, 'medals' => $myRow->EvMedals), 'items' => array()); } $item = array('id' => $myRow->EnId, 'bib' => $myRow->EnCode, 'athlete' => $myRow->FirstNameUpper . ' ' . $myRow->Name, 'familyname' => $myRow->FirstName, 'familynameUpper' => $myRow->FirstNameUpper, 'givenname' => $myRow->Name, 'countryId' => $myRow->CoId, 'countryCode' => $myRow->CoCode, 'countryIocCode' => $myRow->EnIocCode, 'countryName' => $myRow->CoName, 'qualScore' => $myRow->QualScore, 'qualRank' => $myRow->QualRank, 'rank' => $myRow->FinalRank == 9999 ? 'DSQ' : $myRow->FinalRank, 'preseed' => ($myRow->EvFinalFirstPhase == 48 or $myRow->EvFinalFirstPhase == 24) and $myRow->QualRank <= 8 ? '1' : '', 'elims' => array(), 'finals' => array()); if ($myRow->E1Rank !== null && $myRow->E1Score !== null) { $item['elims']['e1']['score'] = $myRow->E1Score; $item['elims']['e1']['rank'] = $myRow->E1Rank; } if ($myRow->E2Rank !== null && $myRow->E2Score !== null) { $item['elims']['e2']['score'] = $myRow->E2Score; $item['elims']['e2']['rank'] = $myRow->E2Rank; } $section['items'][$myRow->EnId] = $item; if ($myRow->IndTimestampFinal > $section['meta']['lastUpdate']) { $section['meta']['lastUpdate'] = $myRow->IndTimestampFinal; } if ($myRow->IndTimestampFinal > $this->data['meta']['lastUpdate']) { $this->data['meta']['lastUpdate'] = $myRow->IndTimestampFinal; } } // ultimo giro $this->data['sections'][$curEvent] = $section; } /* * A questo punto ho i nomi, le qualifiche,le eliminatorie (se ci sono) * e punti+rank delle precedenti. * Mi mancano le finali. Che prendo SOLO se lo shootoff è risolto * */ $q = "(\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tf1.FinEvent AS `event`,f1.FinAthlete AS `athlete`,f1.FinMatchNo AS `matchNo`,f1.FinScore AS `score`,f1.FinSetScore AS `setScore`,f1.FinSetPoints AS `setPoints`,f1.FinTie AS `tie`,f1.FinArrowstring AS `arrowstring`,f1.FinTiebreak AS `tiebreak`,\r\n\t\t\t\t\tf2.FinAthlete AS `oppAthlete`,f2.FinMatchNo AS `oppMatchNo`,f2.FinScore AS `oppScore`,f2.FinSetScore AS `oppSetScore`,f2.FinSetPoints AS `oppSetPoints`,f2.FinTie AS `oppTie`,f2.FinArrowstring AS `oppArrowstring`,f2.FinTiebreak AS `oppTiebreak`,\r\n\t\t\t\t\tGrPhase, EvProgr, IndRankFinal\r\n\t\t\t\t\tFROM Finals AS f1\r\n\t\t\t\t\tINNER JOIN Events\r\n\t\t\t\t\t\tON EvTournament=f1.FinTournament AND EvCode=f1.FinEvent AND EvTeamEvent=0 AND EvShootOff=1\r\n\t\t\t\t\tINNER JOIN Finals AS f2\r\n\t\t\t\t\t\tON f2.FinEvent=f1.FinEvent AND f2.FinTournament=f1.FinTournament AND f2.FinMatchNo=f1.FinMatchNo+1\r\n\t\t\t\t\tINNER JOIN Grids\r\n\t\t\t\t\t\tON GrMatchNo=f1.FinMatchNo\r\n\t\t\t\t\tINNER JOIN Individuals\r\n\t\t\t\t\t\tON IndTournament={$this->tournament} AND IndEvent=f1.FinEvent AND IndId=f1.FinAthlete\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tf1.FinTournament={$this->tournament} and f1.FinMatchNo%2=0\r\n\t\t\t\t\t\t{$filter}\r\n\t\t\t\t) union (\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tf1.FinEvent AS `event`,f1.FinAthlete AS `athlete`,f1.FinMatchNo AS `matchNo`,f1.FinScore AS `score`,f1.FinSetScore AS `setScore`,f1.FinSetPoints AS `setPoints`,f1.FinTie AS `tie`,f1.FinArrowstring AS `arrowstring`,f1.FinTiebreak AS `tiebreak`,\r\n\t\t\t\t\tf2.FinAthlete AS `oppAthlete`,f2.FinMatchNo AS `oppMatchNo`,f2.FinScore AS `oppScore`,f2.FinSetScore AS `oppSetScore`,f2.FinSetPoints AS `oppSetPoints`,f2.FinTie AS `oppTie`,f2.FinArrowstring AS `oppArrowstring`,f2.FinTiebreak AS `oppTiebreak`,\r\n\t\t\t\t\tGrPhase, EvProgr, IndRankFinal\r\n\t\t\t\t\tFROM Finals AS f1\r\n\t\t\t\t\tINNER JOIN Events\r\n\t\t\t\t\t\tON EvTournament=f1.FinTournament AND EvCode=f1.FinEvent AND EvTeamEvent=0 AND EvShootOff=1\r\n\t\t\t\t\tINNER JOIN Finals AS f2\r\n\t\t\t\t\t\tON f2.FinEvent=f1.FinEvent AND f2.FinTournament=f1.FinTournament AND f2.FinMatchNo=f1.FinMatchNo-1\r\n\t\t\t\t\tINNER JOIN Grids\r\n\t\t\t\t\t\tON GrMatchNo=f1.FinMatchNo\r\n\t\t\t\t\tINNER JOIN Individuals\r\n\t\t\t\t\t\tON IndTournament={$this->tournament} AND IndEvent=f1.FinEvent AND IndId=f1.FinAthlete\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\tf1.FinTournament={$this->tournament} and f1.FinMatchNo%2=1\r\n\t\t\t\t\t\t{$filter}\r\n \t\t\t\t)\r\n \t\t\t\tORDER BY\r\n \t\t\t\t\tEvProgr ASC, IndRankFinal ASC, GrPhase DESC\r\n\t\t\t"; //print $q;exit; //return; $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]); } } if (!empty($this->data['sections'][$row->event]['items'][$row->athlete])) { $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), 'oppAthlete' => $row->oppAthlete, 'oppScore' => $row->oppScore, 'oppSetScore' => $row->oppSetScore, 'oppSetPoints' => $row->oppSetPoints, 'oppTie' => $row->oppTie, 'oppArrowstring' => implode('|', $oppArrowstring), 'oppTiebreak' => implode('|', $oppTiebreak)); } } } }
/** * 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)); } } } }
$Tg->appendChild($XmlDoc->createCDATASection('')); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('photo2'); $Tg->appendChild($XmlDoc->createCDATASection('')); $Opp2->appendChild($Tg); // photo3 $Tg = $XmlDoc->createElement('photo3'); $Tg->appendChild($XmlDoc->createCDATASection('')); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('photo3'); $Tg->appendChild($XmlDoc->createCDATASection('')); $Opp2->appendChild($Tg); // all arrows for ($n = 0; $n < 15; $n++) { $a = DecodeFromLetter(substr($r['arrowstring'], $n, 1)); $b = DecodeFromLetter(substr($r['oppArrowstring'], $n, 1)); $Tg = $XmlDoc->createElement('a' . ($n + 1)); $Tg->appendChild($XmlDoc->createCDATASection($a)); $Opp1->appendChild($Tg); $Tg = $XmlDoc->createElement('a' . ($n + 1)); $Tg->appendChild($XmlDoc->createCDATASection($b)); $Opp2->appendChild($Tg); } } } } // debug_svela($r); if (empty($EXCLUDE_HEADER)) { header('Cache-Control: no-store, no-cache, must-revalidate'); header('Content-type: text/xml; charset=' . PageEncode); echo $XmlDoc->SaveXML();
$r = safe_r_sql($q); $tour = null; if (safe_num_rows($r) == 1) { $tour = safe_fetch($r); } if ($tour === null) { exit; } $goldsChars = array(); for ($i = 0; $i < strlen($tour->ToGoldsChars); ++$i) { $goldsChars[] = DecodeFromLetter($tour->ToGoldsChars[$i]); } $goldsChars = implode(',', $goldsChars); $xNineChars = array(); for ($i = 0; $i < strlen($tour->ToXNineChars); ++$i) { $xNineChars[] = DecodeFromLetter($tour->ToXNineChars[$i]); } $xNineChars = implode(',', $xNineChars); $categories = getTournamentCategories(); $comboCategory = comboFromRs($categories, 'key', 'descr', 1, $tour->ToCategory, null, 'd_ToCategory', 'd_ToCategory'); $elabMode = getElabTeamMode(); $comboElabTeam = comboFromRs($elabMode, 'key', 'descr', 1, $tour->ToElabTeam, null, 'd_ToElabTeam', 'd_ToElabTeam'); $comboElimination = comboFromRs(array(array('key' => '0', 'descr' => get_text('No')), array('key' => '1', 'descr' => get_text('Yes'))), 'key', 'descr', 1, $tour->ToElimination, null, 'd_ToElimination', 'd_ToElimination'); $comboDouble = comboFromRs(array(array('key' => '0', 'descr' => get_text('No')), array('key' => '1', 'descr' => get_text('Yes'))), 'key', 'descr', 1, $tour->ToDouble, null, 'd_ToDouble', 'd_ToDouble'); $JS_SCRIPT = array('<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Common/ColorPicker/302pop.js"></script>'); include 'Common/Templates/head.php'; ?> <div align="center"> <div class=""> <form name="frm" id="frm" method="post" action="<?php print $_SERVER['PHP_SELF'];
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(); }
function OtherColumns($PhaseCounter, $FinMatchNo, $FirstName, $Name, $Country, $FinScore, $FinTie, $FinTieBreak, $FinSetPoints, $OppScore, $OppTie, $TargetNo, $ScheduledDate, $ScheduledTime, $TargetType = '') { $this->SetLineWidth(0.1); $this->SetFont('', '', 8); $this->SetXY(90 + $PhaseCounter * $this->CellHSp, $this->lastY); mb_regex_encoding('UTF-8'); if (!is_null($FirstName)) { $this->Cell($this->CellHSp, $this->CellVSp, $FirstName . ' ' . $this->FirstLetters($Name) . " (" . $Country . ")", 0, 0, 'L'); } elseif ($OppTie == 2) { $this->Cell($this->CellHSp, $this->CellVSp, '-Bye-', 0, 0, 'L'); } else { $this->Cell($this->CellHSp, $this->CellVSp, '', 0, 0, 'L'); } $this->lastY += $this->CellVSp; $this->SetXY(90 + $PhaseCounter * $this->CellHSp, $this->lastY); //Punteggio $tmpScore = ""; if ($FinScore == 0 && $OppScore == 0) { if ($OppTie == 2 && !empty($FirstName)) { $tmpScore = '-Bye-'; } else { if ($FinTie == 2 || $OppTie == 2) { $tmpScore = ' '; } else { $tmpScore = $TargetNo != '' && $TargetNo != 0 ? 'T# ' . $TargetNo : ''; } } } else { $tmpScore = !empty($FirstName) ? $FinScore : ''; } //OLD $tmpScore=($OppTie==2 || ($FinScore==0 && $OppScore==0)) ? ($TargetNo != '' && $TargetNo != 0 ? 'T# ' . $TargetNo : '') : (!empty($FirstName) ? $FinScore : ''); //Gestisco cosa scrivere nel tie if (strlen(trim($FinTieBreak)) > 0) { $tmpArr = ""; for ($countArr = 0; $countArr < strlen(trim($FinTieBreak)); $countArr++) { $tmpArr .= DecodeFromLetter(substr(trim($FinTieBreak), $countArr, 1)) . ","; } $tmpScore .= " T." . substr($tmpArr, 0, -1); } else { if ($FinTie == 1) { $tmpScore .= " *"; } } //Punti dei Set, se presenti if (!empty($FinSetPoints)) { $tmpSetPoint = ""; foreach (explode("|", $FinSetPoints) as $spValue) { if ($spValue != 0) { $tmpSetPoint .= $spValue . ","; } } if (strlen($tmpSetPoint) > 0) { $tmpScore .= ' (' . substr($tmpSetPoint, 0, -1) . ')'; } } $this->Cell($this->CellHSp - 1, $this->CellVSp, $tmpScore, 0, 0, 'L'); $this->setX($this->getX() + 1); $this->Line(90 + $PhaseCounter * $this->CellHSp, $this->lastY, 90 + $PhaseCounter * $this->CellHSp + $this->CellHSp, $this->lastY); if ($FinMatchNo % 2 == 0) { $this->Line(90 + $PhaseCounter * $this->CellHSp + $this->CellHSp, $this->lastY, 90 + $PhaseCounter * $this->CellHSp + $this->CellHSp, $this->lastY + ($PhaseCounter == 1 ? 3 : ($PhaseCounter == 2 ? 6 : ($PhaseCounter == 3 ? 12 : 24))) * $this->CellVSp); if ($ScheduledDate != '' && $ScheduledTime != '') { $this->SetFont('', '', 6); $this->SetXY(90 + $PhaseCounter * $this->CellHSp, $this->getY() + ($PhaseCounter == 1 ? 3 : ($PhaseCounter == 2 ? 6 : ($PhaseCounter == 3 ? 12 : 24))) * $this->CellVSp / 2 - 0.6 * $this->CellVSp); $this->Cell($this->CellHSp, 0.6 * $this->CellVSp, $FinTie == 0 && $OppTie == 0 && $FinScore == 0 && $OppScore == 0 ? $ScheduledDate : '', 0, 0, 'R', 0); $this->SetXY(90 + $PhaseCounter * $this->CellHSp, $this->getY() + 0.6 * $this->CellVSp); $this->Cell($this->CellHSp, 0.6 * $this->CellVSp, $FinTie == 0 && $OppTie == 0 && $FinScore == 0 && $OppScore == 0 ? $ScheduledTime : '', 0, 0, 'R', 0); } } $this->lastY += ($PhaseCounter == 1 ? 2 : ($PhaseCounter == 2 ? 5 : ($PhaseCounter == 3 ? 11 : 23))) * $this->CellVSp; }
//print '<td class="Center"><input type="text" size="4" name="T_' . $MyRow->Event . '_' . $MyRow->MatchNo . '" value="' . $MyRow->tie . '"></td>'; print '<td class="Center">'; $ComboStyle = ''; if (array_search($MyRow->FinEvent . '_' . $MyRow->GrMatchNo, array_keys($Tie_Error)) !== false) { $ComboStyle = 'error'; } print '<select class="' . $ComboStyle . '" name="T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '" id="T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '">' . "\n"; print '<option value="0"' . ($ComboStyle == '' && $MyRow->FinTie == 0 || $ComboStyle != '' && $_REQUEST['T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo] == 0 ? ' selected' : '') . '>0 - ' . get_text('NoTie', 'Tournament') . '</option>' . "\n"; print '<option value="1"' . ($ComboStyle == '' && $MyRow->FinTie == 1 || $ComboStyle != '' && $_REQUEST['T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo] == 1 ? ' selected' : '') . '>1 - ' . get_text('TieWinner', 'Tournament') . '</option>' . "\n"; print '<option value="2"' . ($ComboStyle == '' && $MyRow->FinTie == 2 || $ComboStyle != '' && $_REQUEST['T_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo] == 2 ? ' selected' : '') . '>2 - ' . get_text('Bye') . '</option>' . "\n"; print '</select>' . "\n"; print '</td>'; print '<td id="Tie_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '">'; $TieBreak = str_pad($MyRow->FinTiebreak, $obj->so, ' ', STR_PAD_RIGHT); for ($i = 0; $i < $obj->so; ++$i) { print '<input type="text" name="t_' . $MyRow->FinEvent . '_' . $MyRow->GrMatchNo . '[]" size="2" maxlength="3" value="' . DecodeFromLetter($TieBreak[$i]) . '"> '; } print '</td>'; } print '</tr>' . "\n"; if (++$ii == 2) { $StileRiga = $StileRiga == "" ? $StileRiga = "warning" : ""; $ii = 0; } $MyEvent = $MyRow->FinEvent; } print '<tr><td colspan="' . (8 - $Cols2Remove) . '" class="Center"><input type="submit" value="' . get_text('CmdSave') . '" onclick="document.Frm.Command.value=\'SAVE\'"></td></tr>' . "\n"; } else { print '<tr>'; print '<td colspan="' . (8 - $Cols2Remove) . '">'; //$PrecPhase = ($_REQUEST['d_Phase']==0 ? 1 : ($_REQUEST['d_Phase']==32 ? 48 :$_REQUEST['d_Phase']*2));
$Element->setAttribute('Name', 'Total'); $Athlete->appendChild($Element); $Element = $XmlDoc->createElement('Item', $item['gold']); $Element->setAttribute('Name', 'Gold'); $Athlete->appendChild($Element); $Element = $XmlDoc->createElement('Item', $item['xnine']); $Element->setAttribute('Name', 'Xnine'); $Athlete->appendChild($Element); //Definizione dello spareggio/Sorteggio $so = ''; if ($item['so'] > 0) { $tmpArr = ""; if (strlen(trim($item['tiebreak']))) { $tmpArr = "-T."; for ($countArr = 0; $countArr < strlen(trim($item['tiebreak'])); $countArr++) { $tmpArr .= DecodeFromLetter(substr(trim($item['tiebreak']), $countArr, 1)) . ","; } $tmpArr = substr($tmpArr, 0, -1); } $so = get_text('ShotOffShort', 'Tournament') . $tmpArr; } elseif ($item['ct'] > 1) { $so = get_text('CoinTossShort', 'Tournament'); } $Element = $XmlDoc->createElement('Item', $so); $Element->setAttribute('Name', 'SO'); $Athlete->appendChild($Element); } } } if (is_null($ToFit)) { header('Cache-Control: no-store, no-cache, must-revalidate');
$Win2 = 1; } else { if ($MyRow->TfScore > $MyRow2->TfScore) { $Win = 1; $Win2 = 0; } elseif ($MyRow2->TfScore > $MyRow->TfScore) { $Win = 0; $Win2 = 1; } } $Tiebreak = array(); $Tiebreak2 = array(); if ($MyRow->TfTie == 1 || $MyRow2->TfTie) { for ($i = 0; $i < TieBreakArrows_Team; ++$i) { $Tiebreak[] = DecodeFromLetter($MyRow->TfTiebreak[$i]); $Tiebreak2[] = DecodeFromLetter($MyRow2->TfTiebreak[$i]); } } $Tiebreak = trim(join(' ', $Tiebreak)); if ($Tiebreak != '') { $Tiebreak = '(' . $Tiebreak . ')'; } $Tiebreak2 = trim(join(' ', $Tiebreak2)); if ($Tiebreak2 != '') { $Tiebreak2 = '(' . $Tiebreak2 . ')'; } // ath1 $XmlAthlete = $XmlDoc->createElement('Athlete'); $XmlAthlete->setAttribute('Win', $Win); $XmlAthlete->setAttribute('MatchNo', $MyRow->TfMatchNo); $XmlMatch->appendChild($XmlAthlete);
} } if ($Arrows == $MyRow->EvMaxTeamPerson) { $Arrows = 0; $tota = ''; $totb = ''; } } $Arrows = 0; $tota = ''; $totb = ''; for ($i = 0; $i < $obj->so; $i++) { $a = substr($MyRow->TbString, $i, 1); $b = substr($MyRow->OppTbString, $i, 1); $av = DecodeFromLetter($a); $bv = DecodeFromLetter($b); $tota .= trim($a); $totb .= trim($b); $xmlArrows .= '<t_' . $MyRow->MatchNo . '_' . $i . '>' . $av . '</t_' . $MyRow->MatchNo . '_' . $i . '>' . "\n"; $xmlArrows .= '<t_' . $MyRow->OppMatchNo . '_' . $i . '>' . $bv . '</t_' . $MyRow->OppMatchNo . '_' . $i . '>' . "\n"; $Arrows++; if ($NextArrow == '' and $Arrows == $MyRow->EvMaxTeamPerson) { if (!$tota and !$totb) { $NextArrow = 't_' . $matchfirst . '_' . ($i + 1 - $MyRow->EvMaxTeamPerson); } elseif (!$av and strlen($totb) == $MyRow->EvMaxTeamPerson) { $NextArrow = 't_' . $MyRow->MatchNo . '_' . ($i + 1 + strlen($tota) - $MyRow->EvMaxTeamPerson) . ''; } elseif (!$bv and strlen($tota) == $MyRow->EvMaxTeamPerson) { $NextArrow = 't_' . $MyRow->OppMatchNo . '_' . ($i + 1 + strlen($totb) - $MyRow->EvMaxTeamPerson) . ''; } elseif (!$av or !$bv) { $NextArrow = 't_' . $OrgMatch . '_' . ($i + 1 + strlen($MyRow->MatchNo == $OrgMatch ? $tota : $totb) - $MyRow->EvMaxTeamPerson) . ''; }
/** * read() * * @override * * (non-PHPdoc) * @see ianseo/Common/Rank/Obj_Rank#read() */ public function read() { if (!empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0) { $this->opts['dist'] = 0; } $dd = $this->opts['dist'] > 0 ? 'D' . $this->opts['dist'] : ''; $f = $this->safeFilter(); $filter = ""; if ($f !== false) { $filter = $f; } $EnFilter = empty($this->opts['enid']) ? '' : " AND EnId=" . intval($this->opts['enid']); $EnFilter .= empty($this->opts['coid']) ? '' : " AND EnCountry=" . intval($this->opts['coid']); if (array_key_exists('cutRank', $this->opts) && is_numeric($this->opts['cutRank']) && $this->opts['cutRank'] > 0) { $filter .= "AND Ind{$dd}Rank<={$this->opts['cutRank']} "; } $comparedTo = 0; if (!empty($this->opts["comparedTo"]) && is_numeric($this->opts["comparedTo"])) { $comparedTo = $this->opts["comparedTo"]; } if (!empty($this->opts['session']) and $ses = intval($this->opts['session'])) { $EnFilter .= " AND QuSession={$ses} "; } $tmp = null; if (empty($this->opts['runningDist']) || $this->opts['runningDist'] > 0) { $tmp = array(); foreach (range(1, empty($this->opts['runningDist']) ? 8 : $this->opts['runningDist']) as $n) { $tmp[] = 'QuD' . $n . 'Hits'; } $tmp = implode('+', $tmp); } elseif ($this->opts['dist']) { $tmp = 'QuD' . $this->opts['dist'] . 'Hits'; } else { $tmp = 'QuHits'; } $MyRank = "Ind{$dd}Rank"; $only4zero = ""; if ($this->opts['dist'] == 0 && empty($this->opts['runningDist'])) { $only4zero = ",IndTiebreak,(IndSO>0) as isSO, IFNULL(sqY.Quanti,1) AS `NumCT`,ABS(IndSO) AS RankBeforeSO "; } $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tEnId,EnCode, upper(EnIocCode) EnIocCode, EnName AS Name, EnFirstName AS FirstName, upper(EnFirstName) AS FirstNameUpper, SUBSTRING(QuTargetNo,1,1) AS Session,\r\n\t\t\t\t\tSUBSTRING(QuTargetNo,2) AS TargetNo, FlContAssoc,\r\n\t\t\t\t\tEvProgr, ToNumEnds,ToNumDist,ToMaxDistScore,\r\n\t\t\t\t\tCoId, CoCode, CoName, EnClass, EnDivision,EnAgeClass, EnSubClass,\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\tQuD1Score, IndD1Rank, QuD2Score, IndD2Rank, QuD3Score, IndD3Rank, QuD4Score, IndD4Rank,\r\n\t\t\t\t\tQuD5Score, IndD5Rank, QuD6Score, IndD6Rank, QuD7Score, IndD7Rank, QuD8Score, IndD8Rank,\r\n\t\t\t\t\tQuD1Gold, QuD2Gold, QuD3Gold, QuD4Gold, QuD5Gold, QuD6Gold, QuD7Gold, QuD8Gold,\r\n\t\t\t\t\tQuD1Xnine, QuD2Xnine, QuD3Xnine, QuD4Xnine, QuD5Xnine, QuD6Xnine, QuD7Xnine, QuD8Xnine,\r\n\t\t\t\t\tQuD1Arrowstring,QuD2Arrowstring,QuD3Arrowstring,QuD4Arrowstring,QuD5Arrowstring,QuD6Arrowstring,QuD7Arrowstring,QuD8Arrowstring,\r\n\t\t\t\t\tQuScore,\r\n\t\t\t\t\tIF(EvRunning=1,IFNULL(ROUND(QuScore/QuHits,3),0),0) as RunningScore,\r\n\t\t\t\t\tEvCode,EvEventName,EvRunning, EvFinalFirstPhase, EvElim1, EvElim2,\r\n\t\t\t\t\t{$tmp} AS Arrows_Shot,\r\n\t\t\t\t\tIF(EvElim1=0 && EvElim2=0, IF(EvFinalFirstPhase=48, 104, IF(EvFinalFirstPhase=24, 56, (EvFinalFirstPhase*2))) ,IF(EvElim1=0,EvElim2,EvElim1)) as QualifiedNo, EvQualPrintHead as PrintHeader,\r\n\t\t\t\t\t{$MyRank} AS Rank, " . (!empty($comparedTo) ? 'IFNULL(IopRank,0)' : '0') . " as OldRank, Qu{$dd}Score AS Score, Qu{$dd}Gold AS Gold,Qu{$dd}Xnine AS XNine, Qu{$dd}Hits AS Hits, "; if (!empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0) { for ($i = 1; $i <= $this->opts['runningDist']; $i++) { $q .= "QuD" . $i . "Score+"; } $q = substr($q, 0, -1) . " AS OrderScore, "; for ($i = 1; $i <= $this->opts['runningDist']; $i++) { $q .= "QuD" . $i . "Gold+"; } $q = substr($q, 0, -1) . " AS OrderGold, "; for ($i = 1; $i <= $this->opts['runningDist']; $i++) { $q .= "QuD" . $i . "XNine+"; } $q = substr($q, 0, -1) . " AS OrderXnine, "; } else { $q .= "0 AS OrderScore, 0 AS OrderGold, 0 AS OrderXnine, "; } $q .= "IndTimestamp,\r\n\t\t\t\t\tToGolds AS GoldLabel, ToXNine AS XNineLabel,\r\n\t\t\t\t\tToDouble, DiEnds, DiArrows\r\n\t\t\t\t\t{$only4zero}\r\n\t\t\t\tFROM Tournament\r\n\t\t\t\tINNER JOIN Entries ON ToId=EnTournament\r\n\t\t\t\tINNER JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament AND EnTournament={$this->tournament}\r\n\t\t\t\tINNER JOIN Qualifications ON EnId=QuId\r\n\t\t\t\tINNER JOIN EventClass ON EnClass=EcClass AND EnDivision=EcDivision AND EnTournament=EcTournament AND EcTeamEvent=0\r\n\t\t\t\tINNER JOIN Individuals ON EcTournament=IndTournament AND EcCode=IndEvent AND EnId=IndId\r\n\t\t\t\tINNER JOIN Events ON EvCode=EcCode AND EvTeamEvent=EcTeamEvent AND EvTournament=EcTournament\r\n\t\t\t\tLEFT JOIN TournamentDistances ON ToType=TdType AND TdTournament=ToId AND CONCAT(TRIM(EnDivision),TRIM(EnClass)) LIKE TdClasses\r\n\t\t\t\tleft join DistanceInformation on EnTournament=DiTournament and DiSession=1 and DiDistance=1 and DiType='Q' "; if (!empty($comparedTo)) { $q .= "LEFT JOIN IndOldPositions ON IopId=EnId AND IopEvent=EvCode AND IopTournament=EnTournament AND IopHits=" . ($comparedTo > 0 ? $comparedTo : "(SELECT MAX(IopHits) FROM IndOldPositions WHERE IopId=EnId AND IopEvent=EvCode AND IopTournament=EnTournament AND IopHits!=QuHits) ") . " "; } $q .= "LEFT JOIN Flags ON FlIocCode='FITA' and FlCode=CoCode and FlTournament=-1\r\n\r\n\t\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\tIndEvent,Count(*) as Quanti, IndSO as sqyRank, IndTournament\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tIndividuals INNER JOIN Events ON IndEvent=EvCode AND IndTournament=EvTournament AND EvTeamEvent=0\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tIndTournament = {$this->tournament} AND IndSO!=0 {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tIndSO, IndEvent,IndTournament\r\n\t\t\t\t\t\t) AS sqY\r\n\t\t\t\t\tON sqY.sqyRank=IndSO AND sqY.IndEvent=Individuals.IndEvent AND sqY.IndTournament=Individuals.IndTournament\r\n\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tEnAthlete=1 AND EnIndFEvent=1 AND EnStatus <= 1 " . (empty($this->opts['includeNullPoints']) ? " AND QuScore != 0 " : "") . " AND ToId = {$this->tournament}\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\t\t{$EnFilter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\t\tEvProgr, EvCode, "; if (!empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0) { $q .= "OrderScore DESC, OrderGold DESC, OrderXnine DESC, FirstName, Name "; } else { $q .= "RunningScore DESC, Ind{$dd}Rank ASC, FirstName, Name "; } //print $q;exit; $r = safe_r_sql($q); $this->data['meta']['title'] = get_text('ResultIndAbs', 'Tournament'); $this->data['meta']['distance'] = $this->opts['dist']; $this->data['meta']['numDist'] = -1; $this->data['meta']['double'] = -1; $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00'; $this->data['sections'] = array(); if ($r && safe_num_rows($r) > 0) { $curEvent = ''; $section = null; $runningOldScore = -1; $runningPos = 0; $runningRank = 0; $oldScore = -1; $oldGold = -1; $oldXnine = -1; $myPos = 0; $myRank = 0; while ($myRow = safe_fetch($r)) { if ($curEvent != $myRow->EvCode) { /* * se non sono all'inizio, prima di iniziare una sezione devo prendere quella appena fatta * e accodarla alle altre */ if ($curEvent != '') { foreach ($section["meta"]["arrowsShot"] as $k => $v) { if ($v) { $section["meta"]["sesArrows"][$k] = get_text('AfterXArrows', 'Common', $v); } } $this->data['sections'][$curEvent] = $section; $section = null; } // al cambio creo una nuova sezione $curEvent = $myRow->EvCode; // inizializzo i meta che son comuni a tutta la classifica if ($this->data['meta']['numDist'] == -1) { $this->data['meta']['numDist'] = $myRow->ToNumDist; $this->data['meta']['double'] = $myRow->ToDouble; } // qui ci sono le descrizioni dei campi $distFields = array(); $distValid = $myRow->ToNumDist; foreach (range(1, 8) as $n) { $distFields['dist_' . $n] = $myRow->{'Td' . $n}; if ($distFields['dist_' . $n] == '-') { $distValid--; } } $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('Class'), 'ageclass' => get_text('AgeCl'), 'subclass' => get_text('SubCl', 'Tournament'), 'countryId' => 'CoId', 'countryCode' => get_text('CountryCode'), 'countryName' => get_text('Country'), 'rank' => get_text('PositionShort'), 'oldRank' => '', 'rankBeforeSO' => '', 'score' => $myRow->EvRunning == 1 ? get_text('ArrowAverage') : get_text('TotalShort', 'Tournament'), 'completeScore' => get_text('TotalShort', 'Tournament'), 'gold' => $myRow->GoldLabel, 'xnine' => $myRow->XNineLabel, 'hits' => get_text('Arrows', 'Tournament')); if ($this->opts['dist'] == 0 && empty($this->opts['runningDist'])) { $fields = $fields + array('tiebreak' => get_text('TieArrows'), 'ct' => get_text('CoinTossShort', 'Tournament'), 'so' => get_text('ShotOffShort', 'Tournament')); } $fields = $fields + $distFields; $section = array('meta' => array('event' => $curEvent, 'firstPhase' => $myRow->EvFinalFirstPhase, 'elimination1' => $myRow->EvElim1, 'elimination2' => $myRow->EvElim2, 'descr' => get_text($myRow->EvEventName, '', '', true), 'numDist' => $distValid, 'qualifiedNo' => $myRow->QualifiedNo, 'printHeader' => !empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0 ? get_text('AfterXDistance', 'Tournament', $this->opts['runningDist']) : ($this->opts['dist'] > 0 ? get_text('AtXDistance', 'Tournament', $this->opts['dist']) : $myRow->PrintHeader), 'arrowsShot' => array(), 'maxScore' => $myRow->ToMaxDistScore, 'maxArrows' => $myRow->DiEnds ? $myRow->DiEnds * $myRow->DiArrows : $myRow->ToNumEnds * 3, 'sesArrows' => array(), 'running' => $myRow->EvRunning == 1 ? 1 : 0, 'order' => $myRow->EvProgr, 'fields' => $fields)); $oldScore = -1; $oldGold = -1; $oldXnine = -1; $myPos = 0; $myRank = 0; $runningOldScore = -1; $runningPos = 0; $runningRank = 0; } if ($myRow->EvRunning == 1) { $runningPos++; if ($runningOldScore != $myRow->RunningScore) { $runningRank = $runningPos; } $runningOldScore = $myRow->RunningScore; } $myPos++; if (!($oldScore == $myRow->OrderScore && $oldGold == $myRow->OrderGold && $oldXnine == $myRow->OrderXnine)) { $myRank = $myPos; } $oldScore = $myRow->OrderScore; $oldGold = $myRow->OrderGold; $oldXnine = $myRow->OrderXnine; // creo un elemento per la sezione $item = array('id' => $myRow->EnId, 'bib' => $myRow->EnCode, 'session' => $myRow->Session, 'target' => $myRow->TargetNo, 'athlete' => $myRow->FirstNameUpper . ' ' . $myRow->Name, 'familyname' => $myRow->FirstName, 'familynameUpper' => $myRow->FirstNameUpper, 'givenname' => $myRow->Name, 'div' => $myRow->EnDivision, 'class' => $myRow->EnClass, 'ageclass' => $myRow->EnAgeClass, 'subclass' => $myRow->EnSubClass, 'countryId' => $myRow->CoId, 'countryCode' => $myRow->CoCode, 'contAssoc' => $myRow->FlContAssoc, 'countryIocCode' => $myRow->EnIocCode, 'countryName' => $myRow->CoName, 'rank' => !empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0 ? $myRank : ($myRow->EvRunning == 1 ? $runningRank : $myRow->Rank), 'oldRank' => $myRow->OldRank, 'rankBeforeSO' => isset($myRow->RankBeforeSO) ? $myRow->RankBeforeSO : 0, 'score' => !empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0 ? $myRow->OrderScore : ($myRow->EvRunning == 1 ? $myRow->RunningScore : $myRow->Score), 'completeScore' => $myRow->Score, 'gold' => !empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0 ? $myRow->OrderGold : $myRow->Gold, 'xnine' => !empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0 ? $myRow->OrderXnine : $myRow->XNine, 'hits' => $myRow->Hits, 'recordGap' => $myRow->Arrows_Shot * 10 - $myRow->Score); if ($this->opts['dist'] == 0 && empty($this->opts['runningDist'])) { $tmpArr = ""; if ($myRow->IndTiebreak) { $tmpArr = "T."; for ($countArr = 0; $countArr < strlen(trim($myRow->IndTiebreak)); $countArr++) { $tmpArr .= DecodeFromLetter(substr(trim($myRow->IndTiebreak), $countArr, 1)) . ","; } $tmpArr = substr($tmpArr, 0, -1); } $item = $item + array('tiebreak' => $myRow->IndTiebreak, 'tiebreakDecoded' => $tmpArr, 'ct' => $myRow->NumCT, 'so' => $myRow->isSO); } $distFields = array(); foreach (range(1, 8) as $n) { if (!empty($this->opts['runningDist']) && $this->opts['runningDist'] > 0 && $n > $this->opts['runningDist'] || $this->opts['dist'] > 0 && $n != $this->opts['dist']) { $distFields['dist_' . $n] = '0|0|0|0'; } else { $distFields['dist_' . $n] = $myRow->{'IndD' . $n . 'Rank'} . '|' . $myRow->{'QuD' . $n . 'Score'} . '|' . $myRow->{'QuD' . $n . 'Gold'} . '|' . $myRow->{'QuD' . $n . 'Xnine'}; } $item["D{$n}Arrowstring"] = $myRow->{"QuD{$n}Arrowstring"}; } $item = $item + $distFields; //Gestisco il numero di frecce tirate per sessione if (empty($section["meta"]["arrowsShot"][$myRow->Session]) || $section["meta"]["arrowsShot"][$myRow->Session] <= $myRow->Arrows_Shot) { $section["meta"]["arrowsShot"][$myRow->Session] = $myRow->Arrows_Shot; } // e lo aggiungo alla sezione //print_r($item); $section['items'][] = $item; if ($myRow->IndTimestamp > $this->data['meta']['lastUpdate']) { $this->data['meta']['lastUpdate'] = $myRow->IndTimestamp; } } foreach ($section["meta"]["arrowsShot"] as $k => $v) { if ($v) { $section["meta"]["sesArrows"][$k] = get_text('AfterXArrows', 'Common', $v); } } // ultimo giro $this->data['sections'][$curEvent] = $section; } }
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(); }