/** * read() * * @Override * * (non-PHPdoc) * @see ianseo/Common/Rank/Obj_Rank#calculate() */ public function read() { $f = $this->safeFilter(); $filter = $f !== false ? $f : ""; if (array_key_exists('cutRank', $this->opts) && is_numeric($this->opts['cutRank']) && $this->opts['cutRank'] > 0) { $filter .= "AND Teams.teRank<={$this->opts['cutRank']} "; } $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tTeTournament,CoId,TeSubTeam,CoCode,CoName, TeEvent,EvEventName,ToNumEnds,ToNumDist,ToMaxDistScore,FlContAssoc,\r\n\t\t\t\t\tEvMaxTeamPerson, EvProgr, EvFinalFirstPhase,\r\n\t\t\t\t\tClDescription, DivDescription,\r\n\t\t\t\t\tEnId,EnCode,EnFirstName,upper(EnFirstName) EnFirstNameUpper,EnName,EnClass,EnDivision,EnAgeClass,EnSubClass,\r\n\t\t\t\t\tIF(EvFinalFirstPhase=48, 104, IF(EvFinalFirstPhase=24, 56, (EvFinalFirstPhase*2))) AS QualifiedNo,\tEvQualPrintHead,\r\n\t\t\t\t\tSUBSTRING(QuTargetNo,1,1) AS Session, SUBSTRING(QuTargetNo,2) AS TargetNo,\r\n\t\t\t\t\tQuHits*EvMaxTeamPerson AS Arrows_Shot, QuScore, TeScore,TeRank, TeGold, TeXnine, ToGolds, ToXNine,TeHits,\r\n\t\t\t\t\tTeRank, EvRunning, IF(EvRunning=1,IFNULL(ROUND(TeScore/TeHits,3),0),0) as RunningScore,\r\n\t\t\t\t\tABS(TeSO) AS RankBeforeSO,\r\n\t\t\t\t\ttie.Quanti,\r\n\t\t\t\t\tTeTieBreak,(TeSO>0) AS isSO,IFNULL(sqY.Quanti,1) AS `NumCT`,\r\n\t\t\t\t\tIFNULL(Td1,'.1.') as Td1, IFNULL(Td2,'.2.') as Td2, IFNULL(Td3,'.3.') as Td3, IFNULL(Td4,'.4.') as Td4, IFNULL(Td5,'.5.') as Td5, IFNULL(Td6,'.6.') as Td6, IFNULL(Td7,'.7.') as Td7, IFNULL(Td8,'.8.') as Td8,\r\n\t\t\t\t\tTeTimeStamp, DiEnds, DiArrows\r\n\t\t\t\tFROM\r\n\t\t\t\t\tTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeams\r\n\t\t\t\t\tON ToId=TeTournament AND TeFinEvent=1\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tCountries\r\n\t\t\t\t\tON TeCoId=CoId AND TeTournament=CoTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEvents\r\n\t\t\t\t\tON TeEvent=EvCode AND ToId=EvTournament AND EvTeamEvent=1\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tTeEvent as tieEvent, TeFinEvent as tieFinEvent, TeTournament as tieTournament, TeScore as tieScore, Count(*) as Quanti\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tTeTournament = {$this->tournament} {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tTeEvent, TeFinEvent, TeTournament, TeScore\r\n\t\t\t\t\t\t) AS tie\r\n\t\t\t\t\tON Teams.TeEvent=tie.tieEvent AND Teams.TeTournament=tie.tieTournament AND Teams.TeFinEvent=tie.tieFinEvent AND Teams.TeScore=tie.tieScore\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tTeamComponent AS tc\r\n\t\t\t\t\tON Teams.TeCoId=tc.TcCoId AND Teams.TeSubTeam=tc.TcSubTeam AND Teams.TeEvent=tc.TcEvent AND Teams.TeTournament=tc.TcTournament AND Teams.TeFinEvent=tc.TcFinEvent\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tEntries\r\n\t\t\t\t\tON TcId=EnId\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tQualifications\r\n\t\t\t\t\tON EnId=QuId\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tDivisions\r\n\t\t\t\t\tON EnDivision=DivId AND EnTournament=DivTournament\r\n\t\t\t\t\tINNER JOIN\r\n\t\t\t\t\t\tClasses\r\n\t\t\t\t\tON EnClass=ClId AND EnTournament=ClTournament\r\n\t\t\t\t/* Contatori per CT (gialli)*/\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t\t\tTeEvent as sqyEvent,Count(*) as Quanti, TeSO as sqyRank, TeTournament as sqyTournament\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\tTeams\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tTeTournament = {$this->tournament} AND TeFinEvent=1 AND TeSO!=0 {$filter}\r\n\t\t\t\t\t\t\tGROUP BY\r\n\t\t\t\t\t\t\t\tTeSO, TeEvent, TeTournament\r\n\t\t\t\t\t\t) AS sqY\r\n\t\t\t\t\tON sqY.sqyRank=TeSO AND sqY.sqyEvent=Teams.TeEvent AND Teams.TeFinEvent=1 AND sqY.sqyTournament=Teams.TeTournament\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tTournamentDistances\r\n\t\t\t\t\tON ToType=TdType AND TdTournament=ToId AND TeEvent like TdClasses\r\n\t\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t\tFlags\r\n\t\t\t\t\t\tON FlIocCode='FITA' and FlCode=CoCode and FlTournament=-1\r\n\t\t\t\t\tleft join DistanceInformation on EnTournament=DiTournament and DiSession=1 and DiDistance=1 and DiType='Q'\r\n\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\tTeams.TeTournament={$this->tournament}\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tEvProgr,TeEvent, RunningScore DESC, TeRank ASC, TeGold DESC, TeXnine DESC, CoCode, TeSubTeam ,tc.TcOrder\r\n\t\t\t"; $r = safe_r_sql($q); $this->data['meta']['title'] = get_text('ResultSqAbs', 'Tournament'); $this->data['meta']['lastUpdate'] = '0000-00-00 00:00:00'; $this->data['sections'] = array(); $myEv = ''; $myTeam = ''; if (safe_num_rows($r) > 0) { $section = null; while ($row = safe_fetch($r)) { if ($myEv != $row->TeEvent) { if ($myEv != '') { foreach ($section["meta"]["arrowsShot"] as $k => $v) { if ($v) { $section["meta"]["sesArrows"][$k] = get_text('AfterXArrows', 'Common', $v); } } $this->data['sections'][$myEv] = $section; $section = null; } $myEv = $row->TeEvent; $fields = array('id' => 'Id', 'countryCode' => get_text('CountryCode'), 'countryName' => get_text('Country'), 'subteam' => get_text('PartialTeam'), 'athletes' => array('name' => get_text('Athletes'), 'fields' => array('id' => 'Id', 'bib' => get_text('Code', 'Tournament'), 'session' => get_text('Session'), 'target' => get_text('Target'), 'athlete' => get_text('Athlete'), 'familyname' => get_text('FamilyName', 'Tournament'), 'givenname' => get_text('Name', 'Tournament'), 'div' => get_text('Division'), 'class' => get_text('Cl'), 'ageclass' => get_text('AgeCl'), 'subclass' => get_text('SubCl', 'Tournament'), 'quscore' => get_text('TotaleScore'))), 'rank' => get_text('PositionShort'), 'rankBeforeSO' => '', 'score' => $row->EvRunning == 1 ? get_text('ArrowAverage') : get_text('TotaleScore'), 'gold' => $row->ToGolds, 'xnine' => $row->ToXNine, 'hits' => get_text('Arrows', 'Tournament'), 'tiebreak' => get_text('TieArrows'), 'tie' => get_text('Tie'), 'ct' => get_text('CoinTossShort', 'Tournament'), 'so' => get_text('ShotOffShort', 'Tournament')); $distFields = array(); $distValid = $row->ToNumDist; foreach (range(1, 8) as $n) { $distFields['dist_' . $n] = $row->{'Td' . $n}; if ($distFields['dist_' . $n] == '-') { $distValid--; } } $section = array('meta' => array('event' => $myEv, 'firstPhase' => $row->EvFinalFirstPhase, 'descr' => get_text($row->EvEventName, '', '', true), 'qualifiedNo' => $row->QualifiedNo, 'printHeader' => $row->EvQualPrintHead, 'order' => $row->EvProgr, 'numDist' => $distValid, 'maxScore' => $row->ToMaxDistScore * $row->EvMaxTeamPerson, 'maxArrows' => ($row->DiEnds ? $row->DiEnds * $row->DiArrows : $row->ToNumEnds * 3) * $row->EvMaxTeamPerson, 'arrowsShot' => array(), 'sesArrows' => array(), 'running' => $row->EvRunning == 1 ? 1 : 0, 'fields' => $fields), 'items' => array()); } if ($myTeam != $row->CoId . $row->TeSubTeam . $row->TeEvent) { $tmpArr = array(); for ($countArr = 0; $countArr < strlen(trim($row->TeTieBreak)); $countArr = $countArr + $row->EvMaxTeamPerson) { $tmpArr[] = ValutaArrowString(substr(trim($row->TeTieBreak), $countArr, $row->EvMaxTeamPerson)) . ","; } $item = array('id' => $row->CoId, 'countryCode' => $row->CoCode, 'contAssoc' => $row->FlContAssoc, 'countryName' => $row->CoName, 'subteam' => $row->TeSubTeam, 'athletes' => array(), 'rank' => $row->TeRank, 'rankBeforeSO' => $row->RankBeforeSO, 'score' => $row->EvRunning == 1 ? $row->RunningScore : $row->TeScore, 'gold' => $row->TeGold, 'xnine' => $row->TeXnine, 'hits' => $row->TeHits, 'recordGap' => $row->Arrows_Shot * 10 - $row->TeScore, 'tiebreak' => $row->TeTieBreak, 'tiebreakDecoded' => $row->TeTieBreak ? 'T.' . implode(',', $tmpArr) : '', 'ct' => $row->NumCT, 'tie' => $row->Quanti > 1, 'so' => $row->isSO); //Gestisco il numero di frecce tirate per sessione if (empty($section["meta"]["arrowsShot"][$row->Session]) || $section["meta"]["arrowsShot"][$row->Session] <= $row->Arrows_Shot) { $section["meta"]["arrowsShot"][$row->Session] = $row->Arrows_Shot; } $section['items'][] = $item; if ($row->TeTimeStamp > $this->data['meta']['lastUpdate']) { $this->data['meta']['lastUpdate'] = $row->TeTimeStamp; } $myTeam = $row->CoId . $row->TeSubTeam . $row->TeEvent; } if (!array_key_exists('components', $this->opts) || $this->opts['components']) { $athlete = array('id' => $row->EnId, 'bib' => $row->EnCode, 'session' => $row->Session, 'target' => $row->TargetNo, 'athlete' => $row->EnFirstNameUpper . ' ' . $row->EnName, 'familyname' => $row->EnFirstName, 'familynameUpper' => $row->EnFirstNameUpper, 'givenname' => $row->EnName, 'div' => $row->EnDivision, 'class' => $row->EnClass, 'ageclass' => $row->EnAgeClass, 'subclass' => $row->EnSubClass, 'quscore' => $row->QuScore); $section['items'][count($section['items']) - 1]['athletes'][] = $athlete; } } foreach ($section["meta"]["arrowsShot"] as $k => $v) { if ($v) { $section["meta"]["sesArrows"][$k] = str_replace("<br/>", " ", get_text('AfterXArrows', 'Common', $v)); } } // ultimo giro $this->data['sections'][$myEv] = $section; } }
function getStatEntriesByCountriesQuery($ORIS = false, $Athletes = false) { $Sql = ""; if ($ORIS) { $Sql = "SELECT SUM(IF((DivAthlete AND ClAthlete AND EnSex=0), 1,0)) as M, SUM(IF((DivAthlete AND ClAthlete AND EnSex=1), 1,0)) as W, SUM(IF((DivAthlete AND ClAthlete), 0,1)) as Of, "; $Sql .= "CoCode as NationCode, CoName as NationName "; $Sql .= "FROM Entries "; $Sql .= "INNER JOIN Countries ON EnCountry = CoId "; $Sql .= "LEFT JOIN Divisions ON EnDivision=DivId AND DivTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $Sql .= "LEFT JOIN Classes ON EnClass=ClId AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $Sql .= "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; $Sql .= "GROUP BY CoCode "; $Sql .= "ORDER BY CoCode "; } else { $Sql = "SELECT DISTINCT CONCAT(TRIM(EnDivision),'|',TRIM(EnClass)) as Id, (DivAthlete AND ClAthlete) as isAthlete " . "FROM Entries " . "LEFT JOIN Divisions ON EnDivision=DivId AND DivTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "LEFT JOIN Classes ON EnClass=ClId AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " " . ($Athletes ? 'AND DivAthlete=1 AND ClAthlete=1 ' : '') . "ORDER BY LENGTH(EnDivision) DESC, DivViewOrder, EnDivision, LENGTH(EnClass) DESC, ClViewOrder, EnClass"; $Rs = safe_r_sql($Sql); $Sql = "SELECT "; if (safe_num_rows($Rs) > 0) { while ($MyRow = safe_fetch($Rs)) { $Sql .= "SUM(IF(CONCAT(TRIM(EnDivision),'|',TRIM(EnClass))='" . $MyRow->Id . "',1,0)) as `" . $MyRow->Id . "`, "; } safe_free_result($Rs); } $Sql .= "CoCode as NationCode, CoName as NationName "; $Sql .= "FROM Entries "; $Sql .= "INNER JOIN Countries ON EnCountry = CoId "; $Sql .= "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; $Sql .= "GROUP BY CoCode "; $Sql .= "ORDER BY CoCode "; } return $Sql; }
function Get_Tournament_Option($key, $Ret = '', $TourId = 0) { if (!$TourId and !empty($_SESSION['TourId'])) { $TourId = $_SESSION['TourId']; } if (empty($TourId)) { return array(); } $q = safe_r_sql("select ToOptions from Tournament where ToId={$TourId}"); $r = safe_fetch($q); if ($r->ToOptions) { $ToOptions = unserialize($r->ToOptions); } if (!empty($ToOptions[$key])) { if (is_array($ToOptions[$key])) { if (empty($Ret)) { $Ret = array(); } foreach ($ToOptions[$key] as $k => $v) { $Ret[$k] = $v; } } elseif (is_object($ToOptions[$key])) { if (empty($Ret)) { $Ret = new StdClass(); } foreach ($ToOptions[$key] as $k => $v) { $Ret->{$k} = $v; } } else { $Ret = $ToOptions[$key]; } } return $Ret; }
function findOutOfRange() { global $flags; /* * Per ogni sessione eliminatoria con i parametri settati calcolo il range corretto dei suoi bersagli. * Poi tra le righe che agganciano una sessione controllo la bontà del target impostato */ $sessions = GetSessions('E'); $ranges = array(); foreach ($sessions as $s) { // se ogni parametro è >0 if ($s->SesTar4Session * $s->SesAth4Target * $s->SesFirstTarget > 0) { $range = array(); for ($tt = $s->SesFirstTarget; $tt < $s->SesTar4Session + $s->SesFirstTarget; ++$tt) { for ($aa = 1; $aa <= $s->SesAth4Target; ++$aa) { $range[] = str_pad($tt, TargetNoPadding, '0', STR_PAD_LEFT) . chr($aa + 64); } } $ranges[$s->SesOrder] = $range; } } // adesso controllo i bersagli $q = "\r\n\t\t\tSELECT CONCAT(ElElimPhase,'_',ElEventCode,'_',ElQualRank,'_',ElTournament) AS `Id`,ElSession,ElTargetNo\r\n\t\t\tFROM\r\n\t\t\t\tEliminations\r\n\t\t\tWHERE\r\n\t\t\t\tElTournament={$_SESSION['TourId']}\r\n\t\t"; $r = safe_r_sql($q); while ($MyRow = safe_fetch($r)) { if ($MyRow->ElSession != 0 && trim($MyRow->ElTargetNo) != '') { $flags[$MyRow->Id]['out'] = !in_array($MyRow->ElTargetNo, $ranges[$MyRow->ElSession]) ? 0 : 1; } } }
function GetParameter($ParameterName) { $TmpSql = "SELECT ParValue FROM Parameters WHERE ParId=" . StrSafe_DB($ParameterName); $Rs = safe_r_sql($TmpSql, false, true); if ($Rs and $TmpRow = safe_fetch($Rs)) { return $TmpRow->ParValue; } return ''; }
function __construct($TemplateID = 0) { parent::__construct('BackNumber'); $Select = "SELECT BackNumber.*, LENGTH(BnBackground) as ImgSize " . "FROM BackNumber " . "WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal in (0," . $TemplateID . ") order by BnFinal desc limit 1"; //print $Select;exit; $Rs = safe_r_sql($Select); if (safe_num_rows($Rs) == 1) { $this->RowBn = safe_fetch($Rs); } else { // fall back if no Backnumber creates from template! include_once 'Tournament/BackNumberEmpty.php'; $this->RowBn = emptyBackNumber(); } $this->Rotation = $this->RowBn->BnOffsetX != 0 || $this->RowBn->BnOffsetY != 0; $this->RotX = $this->RowBn->BnWidth / 2; $this->RotY = $this->RowBn->BnOffsetY / 2; // TargetNo Specs $this->TargetNoFont = ($this->RowBn->BnTargetNo & 4) == 4 ? $this->FontFix : (($this->RowBn->BnTargetNo & 2) == 2 ? 'dejavuserif' : $this->FontStd); $this->TargetNoStyle = ($this->RowBn->BnTargetNo & 8 ? 'B' : '') . ($this->RowBn->BnTargetNo & 16 ? 'I' : ''); $this->TargetNoColor = array(base_convert(substr($this->RowBn->BnTnoColor, 0, 2), 16, 10), base_convert(substr($this->RowBn->BnTnoColor, 2, 2), 16, 10), base_convert(substr($this->RowBn->BnTnoColor, 4, 2), 16, 10)); $this->TargetNoAlign = ($this->RowBn->BnTargetNo & 96) == 64 ? 'L' : (($this->RowBn->BnTargetNo & 96) == 32 ? 'R' : 'C'); // Athlete Specs $this->AthleteFont = ($this->RowBn->BnAthlete & 4) == 4 ? $this->FontFix : (($this->RowBn->BnAthlete & 2) == 2 ? 'dejavuserif' : $this->FontStd); $this->AthleteStyle = ($this->RowBn->BnAthlete & 8 ? 'B' : '') . ($this->RowBn->BnAthlete & 16 ? 'I' : ''); $this->AthleteColor = array(base_convert(substr($this->RowBn->BnAthColor, 0, 2), 16, 10), base_convert(substr($this->RowBn->BnAthColor, 2, 2), 16, 10), base_convert(substr($this->RowBn->BnAthColor, 4, 2), 16, 10)); $this->AthleteAlign = ($this->RowBn->BnAthlete & 96) == 64 ? 'L' : (($this->RowBn->BnAthlete & 96) == 32 ? 'R' : 'C'); if ($this->RowBn->BnCapitalFirstName) { $this->FirstNameAllCaps = true; } // Country Specs $this->CountryFont = ($this->RowBn->BnCountry & 4) == 4 ? $this->FontFix : (($this->RowBn->BnCountry & 2) == 2 ? 'dejavuserif' : $this->FontStd); $this->CountryStyle = ($this->RowBn->BnCountry & 8 ? 'B' : '') . ($this->RowBn->BnCountry & 16 ? 'I' : ''); $this->CountryColor = array(base_convert(substr($this->RowBn->BnCoColor, 0, 2), 16, 10), base_convert(substr($this->RowBn->BnCoColor, 2, 2), 16, 10), base_convert(substr($this->RowBn->BnCoColor, 4, 2), 16, 10)); $this->CountryAlign = ($this->RowBn->BnCountry & 96) == 64 ? 'L' : (($this->RowBn->BnCountry & 96) == 32 ? 'R' : 'C'); // background temp creation if ($this->RowBn->ImgSize) { $this->BackGroundFile = tempnam('/tmp', 'bgf'); $img = imagecreatefromstring($this->RowBn->BnBackground); if (!imagepng($img, $this->BackGroundFile)) { die('could not create image'); } } $Orientation = $this->RowBn->BnWidth > $this->RowBn->BnHeight ? 'L' : 'P'; $this->setPageOrientation($Orientation); $this->setPageFormat(array($this->RowBn->BnWidth, $this->RowBn->BnHeight), $Orientation); $this->SetFont($this->FontStd, '', 10); $this->AliasNbPages(); $this->setPrintHeader(false); $this->setPrintFooter(false); $this->SetMargins(10, 10, 10); $this->SetAutoPageBreak(false, 10); $this->SetAuthor('http://www.ianseo.net'); $this->SetCreator('Software Design by Ianseo'); $this->SetTitle('IANSEO - Integrated Result System (release ' . ProgramVersion . ')'); $this->SetSubject('BackNo'); }
function calculateAgeClass($dateOfBirth, $gender, $division = '') { $allowedClass = array(); $age = intval(substr($_SESSION['TourRealWhenTo'], 0, 4) - substr($dateOfBirth, 0, 4)); // get the classes based on the division selected $Select = "SELECT DISTINCT ClId " . "FROM Classes " . "INNER JOIN Divisions on DivTournament=ClTournament and DivAthlete=ClAthlete " . ($division ? "AND DivId='{$division}' " : '') . "WHERE ClTournament={$_SESSION['TourId']} " . "AND (ClDivisionsAllowed='' or find_in_set(DivId, ClDivisionsAllowed)) " . "AND ClSex in (-1, {$gender}) " . ($age ? "AND (ClAthlete!='1' or (ClAgeFrom<={$age} and ClAgeTo>={$age})) " : '') . "ORDER BY ClViewOrder, DivViewOrder "; $RsCl = safe_r_sql($Select); while ($MyRow = safe_fetch($RsCl)) { $allowedClass[] = $MyRow->ClId; } return $allowedClass; }
/** * create(). * Metodo statico per istanziare la classe corretta. * La classe corretta viene scelta in base al parametro $family e deve trovarsi * nella directory /Common/Rank. * * Il nome del file e il nome della classe stessa deve essere nella seguente forma: * Obj_Rank_<family>_<type>_<lang> * con <family> la famiglia, <type> il tipo gara e <lang> la regola localizzata con <type> e <lang> * opzionali. * * Il metodo cerca nella directory se esiste prima di tutto il file corretto nella sequenza: * 1) Obj_Rank_<family>_<type>_<lang> * 2) Obj_Rank_<family>_<lang> * 3) Obj_Rank_<family>_<type> * 4) Obj_Rank_<family> * * @static * * @param string $family: famiglia * Attualmente per convenzione abbiamo: * DivClass => classifica di Divisione/Classe individuale * SubClass => classifica di Categoria/Classe di merito individuale * Snapshot => classifica di Categoria/Classe o di Qualificazione basata sul metodo dell "Snapshot" * Abs => classifica di qualificazione assoluta * AbsTeam => classifica di qualificazione assoluta a squadre * ElimInd => classifica fase eliminatoria individuale * FinalInd => classifica finale individuale * DivClassTeam => classifica di Divisione/Classe s squadre * AbsTeam => classifica di qualificazione a squadre * FinalTeam => classifica finale a squadre * * @param mixed[] $opts: opzioni usate dai vari metodi write() e read() dalle classi. * A seconda della classe sarà inizializzato in un qualche modo. * Ogni classe commenta la forma di $opts * * @see Obj_Rank_* * * @return mixed: istanza della classe corretta per gestire la rank * */ public static function create($family, $opts = null) { /* * In base a $family, al tipo di torneo e alla localizzazione della regola * con cui il torneo è stato creato istanzio la classe giusta includendo quello che serve */ global $CFG; // torneo passato $tournament = array_key_exists('tournament', $opts) ? $opts['tournament'] : $_SESSION['TourId']; // tipo e localizzazione $q = safe_r_sql("select ToType, ToLocRule from Tournament where ToId={$tournament}"); $r = safe_fetch($q); $ToType = $r->ToType; $ToLocRule = $r->ToLocRule; // sicuramente includo la classe base if (!file_exists($CFG->DOCUMENT_PATH . 'Common/Rank/Obj_Rank.php')) { return null; } require_once 'Common/Rank/Obj_Rank.php'; /* * Adesso in base alla famiglia, al tipo e alla localizzazione * cerco il file in questa sequenza: * 1) Obj_Rank_<family>_<type>_<lang> * 2) Obj_Rank_<family>_<lang> * 3) Obj_Rank_<family>_<type> * 4) Obj_Rank_<family> * Se neppure (4) esiste termino con errore (null) perchè il default è la base della famiglia * e voglio che esista! */ //print $family.'<br/>'; $name = 'Obj_Rank_' . $family; $rootLoc = $CFG->DOCUMENT_PATH . "Modules/Sets/{$ToLocRule}/Rank/" . $name . "%s.php"; $rootGlobal = $CFG->DOCUMENT_PATH . "Common/Rank/" . $name . "%s.php"; if (file_exists($file = sprintf($rootLoc, "_{$ToType}")) or file_exists($file = sprintf($rootLoc, "")) or file_exists($file = sprintf($rootGlobal, "_{$ToType}")) or file_exists($file = sprintf($rootGlobal, ""))) { // first step is to include base class!!! require_once $file; $name = basename($file, ".php"); // check if the "calc" class exists if (file_exists($file = sprintf($rootLoc, "_{$ToType}_calc")) or file_exists($file = sprintf($rootLoc, "_calc")) or file_exists($file = sprintf($rootGlobal, "_{$ToType}_calc")) or file_exists($file = sprintf($rootGlobal, "_calc"))) { require_once $file; $name = basename($file, ".php"); } // returns the found class return new $name($opts); } else { // no class found! return null; } }
function getModuleParameter($module, $param, $defaultValue = '') { static $Parameters = array(); if (empty($Parameters[$module])) { $TmpSql = "SELECT MpValue, MpParameter\n\t\t\tFROM ModulesParameters\n\t\t\tWHERE MpModule=" . StrSafe_DB($module) . "\n\t\t\tAND MpTournament=" . StrSafe_DB($_SESSION['TourId']); $Rs = safe_r_sql($TmpSql); while ($r = safe_fetch($Rs)) { $Parameters[$module][$r->MpParameter] = $r->MpValue; } } if (isset($Parameters[$module][$param])) { return $Parameters[$module][$param]; } else { return $defaultValue; } }
function getGroupedTargets($TargetNo, $Session = 0, $SesType = 'Q', $SesPhase = '') { global $CompId; // get all targets associated/grouped together with the target requested $SubSelect = "select TgGroup, TgSession, TgSesType\n\t\tfrom TargetGroups\n\t\twhere TgTournament={$CompId}\n\t\tand TgTargetNo='{$TargetNo}'"; if ($SesType != 'Q') { $SubSelect .= " and TgSesType='{$SesType}{$SesPhase}'"; } $Tmp = array(); $q = safe_r_sql("Select TgTargetNo\n\t\tfrom TargetGroups\n\t\twhere TgTournament={$CompId}\n\t\tand (TgGroup, TgSession, TgSesType)=({$SubSelect}) order by TgTargetNo"); while ($r = safe_fetch($q)) { $Tmp[] = $r->TgTargetNo; } if ($Tmp) { $TargetNo = implode("','", $Tmp); } return $TargetNo; }
function SetElimArrowValue($Phase, $Event, $Target, $ArIndex, $ArSymbol, $Output = 'XML', $CompId = '') { require_once 'Common/Lib/Obj_RankFactory.php'; $JsonResult = array(); $JsonResult['error'] = 1; $JsonResult['qutarget'] = $_REQUEST['qutarget']; $JsonResult['distnum'] = $_REQUEST['distnum']; $JsonResult['arrowindex'] = $_REQUEST['arrowindex']; $JsonResult['arrowsymbol'] = ''; $JsonResult['curscore'] = ''; $JsonResult['curgold'] = ''; $JsonResult['curxnine'] = ''; $JsonResult['score'] = ''; $JsonResult['gold'] = ''; $JsonResult['xnine'] = ''; if (empty($CompId)) { $CompId = $_SESSION['TourId']; } $q = safe_r_sql("select * from Eliminations\r\n\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\tand ElEventCode='{$Event}'\r\n\t\tand ElTargetNo='{$Target}'\r\n\t\tand ElTournament={$CompId}\r\n\t\t"); if ($r = safe_fetch($q)) { $Arrowstring = str_pad($r->ElArrowString, $ArIndex + 1, ' ', STR_PAD_RIGHT); $xx = GetLetterFromPrint($ArSymbol); $Arrowstring[$ArIndex] = str_pad($xx, 1, ' ', STR_PAD_RIGHT); list($CurScore, $CurGold, $CurXNine) = ValutaArrowStringGX($Arrowstring); safe_w_sql("update Eliminations\r\n\t\t\tset ElArrowString='{$Arrowstring}',\r\n\t\t\tElScore={$CurScore},\r\n\t\t\tElGold={$CurGold},\r\n\t\t\tElXnine={$CurXNine}\r\n\t\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\t\tand ElEventCode='{$Event}'\r\n\t\t\tand ElTargetNo='{$Target}'\r\n\t\t\tand ElTournament={$CompId}"); if (safe_w_affected_rows()) { if ($Phase[1] == 1) { require_once 'Common/Fun_Sessions.inc.php'; ResetElimRows($Event, 2); } Obj_RankFactory::create('ElimInd', array('tournament' => $CompId, 'eventsC' => array($Event . '@' . $Phase[1])))->calculate(); } $JsonResult['error'] = 0; $JsonResult['arrowsymbol'] = $xx ? strtoupper($ArSymbol) : ''; $JsonResult['curscore'] = $CurScore; $JsonResult['curgold'] = $CurGold; $JsonResult['curxnine'] = $CurXNine; $JsonResult['score'] = $CurScore; $JsonResult['gold'] = $CurGold; $JsonResult['xnine'] = $CurXNine; } return $JsonResult; }
function getTargets($ByDiv = true) { $ar = array(); $MySql = "select" . " DivId" . ", ClId" . ", TfId " . ", TfName " . ", TfDefault " . "from" . " Divisions" . " inner join Classes on DivTournament=ClTournament and DivAthlete=ClAthlete" . " inner join TargetFaces Tf on DivTournament=TfTournament and if(TfRegExp>'', concat(trim(DivId),trim(ClId)) REGEXP TfRegExp, concat(trim(DivId),trim(ClId)) like TfClasses) " . "WHERE" . " DivTournament={$_SESSION['TourId']} " . " AND DivAthlete='1' " . " AND (ClDivisionsAllowed='' or find_in_set(DivId, ClDivisionsAllowed))" . "order by" . " DivViewOrder" . ", ClViewOrder" . ", TfDefault desc" . ", TfRegExp>'' desc" . ", concat(trim(DivId),trim(ClId)) = TfClasses desc" . ", left(TfClasses,1)!='_' and left(TfClasses,1)!='%' desc" . ", left(TfClasses,1)='_' desc" . ", TfClasses desc" . ", TfClasses='%' "; $q = safe_r_sql($MySql); if ($ByDiv) { while ($r = safe_fetch($q)) { if (!$r->TfDefault or empty($ar[$r->DivId][$r->ClId])) { $ar[$r->DivId][$r->ClId][$r->TfId] = get_text($r->TfName, 'Tournament', '', true); } } } else { $divs = array(); while ($r = safe_fetch($q)) { if (!$r->TfDefault or empty($divs[$r->DivId][$r->ClId])) { $ar[$r->TfId][$r->DivId][$r->ClId] = $r->TfDefault; $divs[$r->DivId][$r->ClId] = 'done'; } } } return $ar; }
public function __construct($tourId, $phase) { $this->setTourId($tourId); $this->setPhase($phase); // Estraggo le info del torneo /*$query = "SELECT " . "ToCode,ToName,IF(TtElabTeam=1 || TtElabTeam=2,'1',IF(INSTR(TtName,'Indoor')=0,'0','2' )) AS MyType " . "FROM " . "Tournament INNER JOIN Tournament*Type ON ToType=TtId " . "WHERE " . "ToId=" . $this->getTourId() . " ";*/ $query = "SELECT " . "ToCode,ToName,IF(ToElabTeam=1 || ToElabTeam=2,'1',IF(INSTR(ToTypeName,'Indoor')=0,'0','2' )) AS MyType " . "FROM " . "Tournament " . "WHERE " . "ToId=" . $this->getTourId() . " "; $rs = safe_r_sql($query); if (safe_num_rows($rs) == 1) { $myRow = safe_fetch($rs); $this->setTourCode($myRow->ToCode); $this->setTourName($myRow->ToName); $this->setType($myRow->MyType); } else { $this->setError(1); } }
/** * Cerca quale evento è live in questo momento * Se trova più eventi contemporanei ritorna i dati di quello con modifiche più recenti. * * @param Int $Team: vale 0 se l'evento è individuale e 1 se è a squadre. * * @return Array: Un vettore formato dall'Evento e dal MatchNo oppure false in caso di errore. * Se non ci sono eventi live viene ritornato array(NULL,NULL) */ function FindLive($Team = -1) { if ($Team == 0) { $Select = "SELECT" . " '0' Team" . " , FinDateTime DateTime" . " , FinEvent AS Event" . " , FinMatchNo AS MatchNo" . " FROM" . " Finals " . " WHERE" . " FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND FinLive='1' " . "ORDER BY" . " Team," . " DateTime DESC," . " Event ASC," . " MatchNo ASC "; } elseif ($Team == 1) { $Select = "SELECT" . " '1' Team " . " , TfDateTime DateTime" . " , TfEvent AS Event " . " , TfMatchNo AS MatchNo " . " FROM" . " TeamFinals " . " WHERE" . " TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND TfLive='1' " . "ORDER BY" . " Team," . " DateTime DESC," . " Event ASC," . " MatchNo ASC"; } elseif ($Team == -1) { $Select = "(SELECT" . " '0' Team" . " , FinDateTime DateTime" . " , FinEvent AS Event" . " , FinMatchNo AS MatchNo" . " FROM" . " Finals " . " WHERE" . " FinTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND FinLive='1') " . "UNION " . "(SELECT" . " '1' Team " . " , TfDateTime DateTime " . " , TfEvent AS Event " . " , TfMatchNo AS MatchNo " . " FROM" . " TeamFinals " . " WHERE" . " TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND TfLive='1') " . "ORDER BY" . " Team," . " DateTime DESC," . " Event ASC," . " MatchNo ASC "; } else { return ''; } $Rs = safe_r_sql($Select); // at least 2 rows because "live" is set on both opponents! if (safe_num_rows($Rs) < 2) { return ''; } $MyRow1 = safe_fetch($Rs); $MyRow2 = safe_fetch($Rs); // check if these are really 2 opponents in the same match!! if ($MyRow1->Event == $MyRow2->Event and $MyRow1->Team == $MyRow2->Team and ($MyRow1->MatchNo == $MyRow2->MatchNo - 1 or $MyRow1->MatchNo == $MyRow2->MatchNo + 1)) { return array($MyRow1->Event, min($MyRow1->MatchNo, $MyRow2->MatchNo), $MyRow1->Team); } return ''; }
$year = date('Y', $_SESSION['ToWhenFromUTS']) - $yy; // Estraggo l'ageclass dalla tabella $Select = "SELECT ClId,ClValidClass " . "FROM Classes " . "WHERE ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND ClAgeFrom<=" . StrSafe_DB($year) . " AND ClAgeTo>=" . StrSafe_DB($year) . " "; //. "AND ClSex = " . StrSafe_DB($Sex) . " "; $cond = "AND ClSex = " . StrSafe_DB($_REQUEST['d_e_EnSex']) . " "; $condUnisex = "AND ClSex = -1 "; $RsCl = safe_r_sql($Select . $cond); //print $Select.$cond;exit; if (safe_num_rows($RsCl) == 1) { $MyRow = safe_fetch($RsCl); $AgeClass = $MyRow->ClId; $Classes = $MyRow->ClValidClass; } elseif (safe_num_rows($RsCl) == 0) { $RsCl = safe_r_sql($Select . $condUnisex); if (safe_num_rows($RsCl) == 1) { $Row = safe_fetch($RsCl); $AgeClass = $Row->ClId; $Classes = $MyRow->ClValidClass; } } } } else { $Errore = 1; } if (!debug) { header('Content-Type: text/xml'); } print '<response>' . "\n"; print '<error>' . $Errore . '</error>' . "\n"; print '<ageclass><![CDATA[' . $AgeClass . ']]></ageclass>' . "\n"; print '<classes><![CDATA[' . $Classes . ']]></classes>' . "\n";
function getTeamBracketsQuery($ORIS = false, $EventRequested = '') { require_once 'Common/Lib/Fun_PrintOuts.php'; if (!$EventRequested and !empty($_REQUEST['Event'])) { $EventRequested = $_REQUEST['Event']; } if ($ORIS) { //Genero la Query dei Nomi $MyQueryNames = "SELECT TfcEvent, TfcCoId, TfcSubTeam, TfcOrder, EnFirstName, EnName, CONCAT(TeRank,CHAR(64+TfcOrder)) AS BackNo "; $MyQueryNames .= "FROM TeamFinComponent "; $MyQueryNames .= "INNER JOIN Entries ON TfcId=EnId AND TfcTournament=EnTournament "; $MyQueryNames .= "INNER JOIN Teams ON TfcCoId=TeCoId AND TfcSubTeam=TeSubTeam AND TfcEvent=TeEvent AND TfcTournament=TeTournament AND TeFinEvent=1 "; $MyQueryNames .= "WHERE TfcTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; //Genero la query Degli eventi $MyQuery = "SELECT f.TfTeam, f.TfSubTeam, f.TfEvent AS Event, EvEventName AS EventDescr, f.TfMatchNo, EvFinalFirstPhase, TeRank, TeScore, " . "IF(GrPhase!=0,GrPhase,1) as Phase, (GrPhase=1) as Finalina, " . "CONCAT(CoName, IF(f.TfSubTeam>'1',CONCAT(' (',f.TfSubTeam,')'),'')) as Team, CoCode as Country, IF(EvMatchMode=0,f.TfScore,f.TfSetScore) AS Score, f.TfTie, f.TfTieBreak, IF(EvMatchMode=0,f2.TfScore,f2.TfSetScore) as OppScore, f2.TfTie as OppTie, f.TfSetPoints as SetPoints, " . "IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition) GrPosition, EvFinalPrintHead, FSTarget, IFNULL(NComponenti,0) AS NumComponenti, DATE_FORMAT(FSScheduledDate,'" . get_text('DateFmtDB') . "') as ScheduledDate, DATE_FORMAT(FSScheduledTime,'" . get_text('TimeFmt') . "') AS ScheduledTime "; $MyQuery .= "FROM TeamFinals as f "; $MyQuery .= "INNER JOIN TeamFinals AS f2 ON f.TfEvent=f2.TfEvent AND f.TfMatchNo=IF((f.TfMatchNo % 2)=0,f2.TfMatchNo-1,f2.TfMatchNo+1) AND f.TfTournament=f2.TfTournament "; $MyQuery .= "INNER JOIN Events ON f.TfEvent=EvCode AND f.TfTournament=EvTournament AND EvTeamEvent=1 "; $MyQuery .= "INNER JOIN Grids ON f.TfMatchNo=GrMatchNo "; $MyQuery .= "LEFT JOIN Teams ON f.TfTeam=TeCoId AND f.TfSubTeam=TeSubTeam AND f.TfEvent=TeEvent AND f.TfTournament=TeTournament AND TeFinEvent=1 "; $MyQuery .= "LEFT JOIN Countries ON f.TfTeam=CoId AND f.TfTournament=CoTournament "; $MyQuery .= "LEFT JOIN FinSchedule ON f.TfEvent=FSEvent AND f.TfMatchNo=FSMatchNo AND f.TfTournament=FSTournament AND FSTeamEvent='1' "; $MyQuery .= "LEFT JOIN (SELECT TfcEvent AS Evento, Max(Quanti) AS NComponenti FROM ( "; $MyQuery .= "SELECT TfcEvent, Count( * ) AS Quanti FROM TeamFinComponent WHERE TfcTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "GROUP BY TfcEvent, TfcCoId, TfcSubTeam) AS Ssqy GROUP BY TfcEvent) as Sqy ON f.TfEvent=Evento "; $MyQuery .= "WHERE f.TfTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; if ($EventRequested) { $MyQuery .= CleanEvents($EventRequested, 'f.TfEvent'); $MyQueryNames .= CleanEvents($EventRequested, 'TfcEvent'); } $MyQuery .= "ORDER BY EvProgr ASC, EvCode, Phase DESC, f.TfMatchNo ASC "; $MyQueryNames .= "ORDER BY TfcEvent, TfcCoId, TfcSubTeam, TfcOrder "; //* DEBUG --> */ print $MyQuery; $ArrNames = array(); $RsNames = safe_r_sql($MyQueryNames); if (safe_num_rows($RsNames) > 0) { $arrKeys = array(); $arrValues = array(); while ($MyRow = safe_fetch($RsNames)) { $arrKeys[] = $MyRow->TfcEvent . "_" . $MyRow->TfcCoId . "_" . $MyRow->TfcSubTeam . "_" . $MyRow->TfcOrder; $arrValues[] = array($MyRow->BackNo, $MyRow->EnFirstName . ' ' . $MyRow->EnName); } $ArrNames = array_combine($arrKeys, $arrValues); } return array($MyQuery, $ArrNames); } //Genero la Query dei Nomi $MyQueryNames = "SELECT TfcEvent, TfcCoId, TfcSubTeam, TfcOrder, EnFirstName, EnName "; $MyQueryNames .= "FROM TeamFinComponent "; $MyQueryNames .= "INNER JOIN Entries ON TfcId=EnId AND TfcTournament=EnTournament "; $MyQueryNames .= "WHERE TfcTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; //Genero la query Degli eventi $MyQuery = "SELECT TfTeam, TfSubTeam, TfEvent AS Event, EvEventName AS EventDescr, TfMatchNo, EvFinalFirstPhase, " . "IF(GrPhase!=0,GrPhase,1) as Phase, (GrPhase=1) as finalina, " . "CONCAT(CoName, IF(TfSubTeam>'1',CONCAT(' (',TfSubTeam,')'),'')) as Team, CoCode as Country, IF(EvMatchMode=0,TfScore,TfSetScore) as Score, TfTie, TfTieBreak, " . "IF(EvFinalFirstPhase=48 || EvFinalFirstPhase=24,GrPosition2, GrPosition) GrPosition, EvFinalPrintHead, FSTarget, NumComponenti, DATE_FORMAT(FSScheduledDate,'" . get_text('DateFmtDB') . "') as ScheduledDate, DATE_FORMAT(FSScheduledTime,'" . get_text('TimeFmt') . "') AS ScheduledTime "; $MyQuery .= "FROM TeamFinals "; $MyQuery .= "INNER JOIN Events ON TfEvent=EvCode AND TfTournament=EvTournament AND EvTeamEvent=1 "; $MyQuery .= "INNER JOIN Grids ON TfMatchNo=GrMatchNo "; $MyQuery .= "LEFT JOIN Countries ON TfTeam=CoId AND TfTournament=CoTournament "; $MyQuery .= "LEFT JOIN FinSchedule ON TfEvent=FSEvent AND TfMatchNo=FSMatchNo AND TfTournament=FSTournament AND FSTeamEvent='1' "; $MyQuery .= "LEFT JOIN (SELECT TfcEvent AS Evento, Max( Quanti ) AS NumComponenti FROM ( "; $MyQuery .= "SELECT TfcEvent, Count( * ) AS Quanti FROM TeamFinComponent WHERE TfcTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "GROUP BY TfcEvent, TfcCoId, TfcSubTeam) AS Ssqy GROUP BY TfcEvent) as Sqy ON TfEvent=Evento "; $MyQuery .= "WHERE TfTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; if ($EventRequested) { $MyQuery .= CleanEvents($EventRequested, 'TfEvent'); $MyQueryNames .= CleanEvents($EventRequested, 'TfcEvent'); } $MyQuery .= "ORDER BY EvProgr ASC, EvCode, Phase DESC, TfMatchNo ASC "; $MyQueryNames .= "ORDER BY TfcEvent, TfcCoId, TfcSubTeam, TfcOrder "; //* DEBUG --> */ print $MyQueryNames; $ArrNames = array(); $RsNames = safe_r_sql($MyQueryNames); if (safe_num_rows($RsNames) > 0) { $arrKeys = array(); $arrValues = array(); while ($MyRow = safe_fetch($RsNames)) { $arrKeys[] = $MyRow->TfcEvent . "_" . $MyRow->TfcCoId . "_" . $MyRow->TfcSubTeam . "_" . $MyRow->TfcOrder; $arrValues[] = $MyRow->EnFirstName . ' ' . $MyRow->EnName; } $ArrNames = array_combine($arrKeys, $arrValues); } return array($MyQuery, $ArrNames); }
function getAbsTeamItems($Team) { global $TourId; $FeedItems = array(); // TEAM EVENTS $MyQuery = "SELECT CoCode AS NationCode, TeSubTeam as SubTeam, CoName AS Nation, TeEvent, EvEventName" . ", sqY.QuantiPoss as NumGialli, (EvFinalFirstPhase*2) as QualifiedNo, EvQualPrintHead, "; $MyQuery .= "TeScore, TeRank, TeGold, TeXnine, ToGolds AS TtGolds, ToXNine AS TtXNine "; $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 "; //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=TeFinEvent " . "WHERE TeTournament = {$TourId} AND EvTeamEvent=1 " . "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 = {$TourId} "; $MyQuery .= "AND te.TeEvent in ('" . implode("','", array_keys($Team)) . "') "; $MyQuery .= "ORDER BY EvProgr, TeEvent, TeScore DESC, TeGold DESC, TeXnine DESC, TeRank, NationCode, SubTeam"; //echo $MyQuery;exit(); $Rs = safe_r_sql($MyQuery); $CurGroup = "...."; $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; $txt = array(); while ($MyRow = safe_fetch($Rs)) { //se cambia classifica rifaccio l'header if ($CurGroup != $MyRow->TeEvent) { if ($txt) { // previous group teams $FeedItems['AT-' . $CurGroup]['text'] = implode(' - ', $txt); } $TmpTitle = get_text($MyRow->EvEventName, '', '', true); $FeedItems['AT-' . $MyRow->TeEvent]['title'] = get_text('ResultSqAbs', 'Tournament') . ': ' . $TmpTitle; $txt = array(); $MyRank = 1; $MyPos = 0; $MyScoreOld = 0; $MyGoldOld = 0; $MyXNineOld = 0; $CurTeam = ""; $CurGroup = $MyRow->TeEvent; } // Sicuramente devo incrementare la posizione $MyPos++; // Se non ho parimerito il ranking è uguale alla posizione if (!($MyRow->TeScore == $MyScoreOld && $MyRow->TeGold == $MyGoldOld && $MyRow->TeXnine == $MyXNineOld)) { $MyRank = $MyPos; } if ($MyRank <= $Team[$MyRow->TeEvent] and count($txt) <= $Team[$MyRow->TeEvent]) { $txt[] = sprintf("%s) %s: %s", $MyRank, $MyRow->NationCode . '-' . $MyRow->Nation, $MyRow->TeScore); } } if ($txt) { // previous group teams $FeedItems['AT-' . $CurGroup]['text'] = implode(' - ', $txt); } return $FeedItems; }
} // Mi serve la sessione attuale del tizio $query = "SELECT " . "QuSession " . "FROM " . "Qualifications " . "WHERE QuId=" . StrSafe_DB($id) . " "; $rs = safe_r_sql($query); $old = 0; if ($rs) { if (safe_num_rows($rs) == 1) { $myRow = safe_fetch($rs); $old = $myRow->QuSession; if ($session != 0 && $session != $old) { // conto gli arcieri di $session sessione $query = "SELECT " . "COUNT(QuId) AS HowMany " . "FROM " . "Qualifications INNER JOIN Entries ON QuId=EnId AND EnTournament=" . $tourId . " " . "WHERE QuSession=" . StrSafe_DB($session) . " "; $rs = safe_r_sql($query); if ($rs) { if (safe_num_rows($rs) == 1) { $myRow = safe_fetch($rs); if ($num4session < $myRow->HowMany + 1) { $tooMany = 1; $msg = get_text('NoMoreAth4Session', 'Tournament'); } } } } if ($tooMany == 0) { $query = "UPDATE " . "Qualifications " . "SET " . "QuSession=" . StrSafe_DB($session) . " " . "WHERE " . "QuId=" . StrSafe_DB($id) . " "; $rs = safe_w_sql($query); // se la riga è stata aggiornata significa che la session è cambiata quindi annullo il target if (safe_w_affected_rows() == 1) { $query = "UPDATE " . "Qualifications " . "SET " . "QuTargetNo='', QuBacknoPrinted=0 " . "WHERE " . "QuId=" . StrSafe_DB($id) . " "; $rs = safe_w_sql($query); $resetTarget = 1;
$Select = "SELECT ToCode " . "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; } if ($ToCode == '') { exit; } // Cerco gli eventi delle finali $FinEventInd = 0; $FinEventTeam = 0; $Select = "SELECT COUNT(EvCode) AS Quanti,EvTeamEvent FROM Events " . "WHERE EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EvShootOff=1 " . "GROUP BY EvTeamEvent "; $Rs = safe_r_sql($Select); if ($Rs) { while ($RowEv = safe_fetch($Rs)) { if ($RowEv->EvTeamEvent == '0') { $FinEventInd = $RowEv->Quanti; } elseif ($RowEv->EvTeamEvent == '1') { $FinEventTeam = $RowEv->Quanti; } } } // Cerco gli eventi delle eliminatorie $ElimEvent = array(1 => 0, 2 => 0); for ($i = 1; $i <= 2; ++$i) { $Select = "SELECT EvCode FROM Events " . "WHERE EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EvElim" . $i . ">0 AND EvE" . $i . "ShootOff=1 "; $Rs = safe_r_sql($Select); if ($Rs && safe_num_rows($Rs) > 0) { $ElimEvent[$i] = safe_num_rows($Rs); }
<?php require_once './config.php'; require_once 'Common/Fun_FormatText.inc.php'; require_once 'Common/Lib/Fun_Scheduler.php'; // require_once('Common/Lib/ArrTargets.inc.php'); // require_once('Common/Fun_Phases.inc.php'); //require_once('Common/Fun_Phases.inc.php'); $q = safe_r_sql("select * from BoinxSchedule where BsTournament={$TourId} and BsType='Qua_Ind'"); if ($r = safe_fetch($q)) { $SQL = "select substr(QuTargetNo, 2) Bib\n\t\t, concat(EnName, ' ', upper(EnFirstName)) Name\n\t\t, concat(CoCode, '-', CoName) Country\n\t\t, QuScore, QuClRank QuRank, IndRank\n\t\t, concat(DivDescription, ' ', ClDescription) CategoryLong\n\t\t, concat(DivId, ClId) CategoryShort\n\t\t, EvCode EventShort, EvEventName EventLong\n\t\t, EnId, CoCode\n\t\tfrom Entries\n\t\tinner join Qualifications on EnId=QuId\n\t\tinner join Countries on EnCountry=CoId\n\t\tinner join Divisions on EnDivision=DivId and EnTournament=DivTournament\n\t\tinner join Classes on EnClass=ClId and EnTournament=ClTournament\n\t\tleft join Individuals on IndId=EnId\n\t\tleft join Events on IndEvent=EvCode and EnTournament=EvTournament\n\t\twhere QuTargetNo='{$r->BsExtra}' and EnTournament={$TourId}\n\t\t"; $q = safe_r_sql($SQL); $ENTRY = safe_fetch($q); } // debug_svela($SQL); if (!$ENTRY) { $ENTRY = new StdClass(); $ENTRY->EnId = ''; $ENTRY->CoCode = ''; $ENTRY->Bib = ''; $ENTRY->Name = ''; $ENTRY->Country = ''; $ENTRY->QuScore = ''; $ENTRY->QuRank = ''; $ENTRY->IndRank = ''; $ENTRY->CategoryLong = ''; $ENTRY->CategoryShort = ''; $ENTRY->EventShort = ''; $ENTRY->EventLong = ''; } $fotodir = 'http://' . $_SERVER['HTTP_HOST'] . $CFG->ROOT_DIR . 'TV/Photos/' . $TourCodeSafe . '-%s-%s.jpg';
/** * calculate() * * @Override * * (non-PHPdoc) * @see ianseo/Common/Rank/Obj_Rank#calculate() */ public function calculate() { $f = $this->safeFilter(); $filter = $f !== false ? $f : ""; $orderBy = "TeEvent, TeScore DESC, TeGold DESC, TeXnine DESC, TeSubTeam "; $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tTeTournament,TeCoId,TeSubTeam,TeEvent,\r\n\t\t\t\t\tIFNULL(IF(EvRunning=1, TeScore/TeHits,TeScore),0) as TeScore, TeGold, TeXnine,\r\n\t\t\t\t\tIF(EvFinalFirstPhase=0,9999,IF(EvFinalFirstPhase=48, 104, IF(EvFinalFirstPhase=24, 56, (EvFinalFirstPhase*2)))) AS QualifiedNo,\r\n\t\t\t\t\tTeRank AS ActualRank\r\n\t\t\t\t FROM\r\n\t\t\t\t \tTeams\r\n\t\t\t\t \tINNER JOIN\r\n\t\t\t\t \t\tEvents\r\n\t\t\t\t \tON TeEvent=EvCode AND TeTournament=EvTournament AND EvTeamEvent=1\r\n\t\t\t\t WHERE\r\n\t\t\t\t \tTeTournament={$this->tournament} AND TeFinEvent=1 AND TeScore<>'0'\r\n\t\t\t\t \t{$filter}\r\n\t\t\t\t ORDER BY\r\n\t\t\t\t \t{$orderBy}\r\n\t\t\t"; //print $q;exit; $r = safe_r_sql($q); if (!$r) { return false; } if (safe_num_rows($r) > 0) { $curGroup = ""; $myRank = 1; $myPos = 0; $endQualified = false; $myScoreOld = 0; $myGoldOld = 0; $myXNineOld = 0; $myEndScore = -1; $myGroupStartPos = 0; $currentRow = -1; while ($myRow = safe_fetch($r)) { ++$currentRow; if ($curGroup != $myRow->TeEvent) { $curGroup = $myRow->TeEvent; $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($r) > $myGroupStartPos + $myRow->QualifiedNo) { safe_data_seek($r, $myGroupStartPos + $myRow->QualifiedNo - 1); $tmpMyRow = safe_fetch($r); if ($curGroup == $tmpMyRow->TeEvent) { $myEndScore = $tmpMyRow->TeScore; $tmpMyRow = safe_fetch($r); //Controllo se c'è parimerito per entrare if ($myEndScore != $tmpMyRow->TeScore || $curGroup != $tmpMyRow->TeEvent) { $myEndScore *= -1; } } else { $myEndScore = -1; } $tmpMyRow = NULL; } else { safe_data_seek($r, safe_num_rows($r) - 1); $tmpMyRow = safe_fetch($r); $myEndScore = -1; } safe_data_seek($r, $myGroupStartPos + 1); } ++$myPos; $so = -1; // Se non ho parimerito il ranking è uguale alla posizione if ($myEndScore == $myRow->TeScore) { if ($myRow->TeScore != $myScoreOld) { $myRank = $myPos; } $so = 1; // rosso } else { if (!($myRow->TeScore == $myScoreOld && $myRow->TeGold == $myGoldOld && $myRow->TeXnine == $myXNineOld)) { $myRank = $myPos; } } if ($myRank > $myRow->QualifiedNo) { $so = 0; } $myScoreOld = $myRow->TeScore; $myGoldOld = $myRow->TeGold; $myXNineOld = $myRow->TeXnine; $x = false; if ($myRow->ActualRank != 0 && array_key_exists('skipExisting', $this->opts) && $this->opts['skipExisting'] == 1) { $x = $this->setRow(array(array('team' => $myRow->TeCoId, 'subteam' => $myRow->TeSubTeam, 'event' => $myRow->TeEvent, 'so' => $so * $myRank))); } else { $x = $this->setRow(array(array('team' => $myRow->TeCoId, 'subteam' => $myRow->TeSubTeam, 'event' => $myRow->TeEvent, 'so' => $so * $myRank, 'rank' => $myRank, 'tiebreak' => ''))); } //print '..'.$x.'<br>'; if ($x === false) { return false; } } } // debug_svela($tmpChris); return true; }
//print '<input type="checkbox" name="New_EcDivision[]" id="New_EcDivision_' . $MyRow->DivId .'" value="1">' . $MyRow->DivId . '<br>'; $ComboDiv .= '<option value="' . $Row->DivId . '">' . $Row->DivId . '</option>' . "\n"; } } $ComboDiv .= '</select>' . "\n"; print $ComboDiv; print '<br><br><a class="Link" href="javascript:SelectAllOpt(\'New_EcDivision\');">' . get_text('SelectAll') . '</a>'; ?> </td> <td width="25%" class="Center" valign="top"> <?php $ComboCl = '<select name="New_EcClass" id="New_EcClass" multiple="multiple">' . "\n"; $Select = "SELECT * " . "FROM Classes " . "WHERE ClTournament = " . StrSafe_DB($_SESSION['TourId']) . " AND ClAthlete=1 " . "ORDER BY ClViewOrder ASC "; $RsSel = safe_r_sql($Select); if (safe_num_rows($RsSel) > 0) { while ($Row = safe_fetch($RsSel)) { //print '<input type="checkbox" name="New_EcClass[]" id="New_EcClass_' . $MyRow->ClId .'" value="1">' . $MyRow->ClId . '<br>'; $ComboCl .= '<option value="' . $Row->ClId . '">' . $Row->ClId . '</option>' . "\n"; } } $ComboCl .= '</select>' . "\n"; print $ComboCl; print '<br><br><a class="Link" href="javascript:SelectAllOpt(\'New_EcClass\');">' . get_text('SelectAll') . '</a>'; ?> </td> <td width="25%" class="Center" valign="top"> <input type="button" name="Command" id="Command" value="<?php print get_text('CmdSave'); ?> " onclick="javascript:AddEventRule('<?php print $RowEv->EvCode;
} //Adesso aggiorno lo status $query = "UPDATE " . "Entries " . "SET " . "EnStatus=" . StrSafe_DB($status) . " " . "WHERE " . "EnId=" . StrSafe_DB($id) . " "; $rs = safe_w_sql($query); if (!$rs) { $error = 1; } if ($recalc) { // ricalcolo il vecchio e il nuovo if (!is_null($indFEvent)) { RecalculateShootoffAndTeams($indFEvent, $teamFEvent, $country, $div, $cl, $zero); } // rank di classe x tutte le distanze $q = "SELECT ToNumDist FROM Tournament WHERE ToId={$_SESSION['TourId']}"; $r = safe_r_sql($q); $tmpRow = safe_fetch($r); for ($i = 0; $i < $tmpRow->ToNumDist; ++$i) { if (!is_null($indFEvent)) { CalcQualRank($i, $div . $cl); } } MakeIndAbs(); } } else { $error = 1; } /****** End Controller ******/ /****** Output ******/ $xmlDoc = new DOMDocument('1.0', PageEncode); $xmlRoot = $xmlDoc->createElement('response'); $xmlDoc->appendChild($xmlRoot);
<?php require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; CheckTourSession(true); print_r($_COOKIE); $JS_SCRIPT = array('<script type="text/javascript" src="Fun_AJAX_GetImage.js"></script>', '<script type="text/javascript" src="../Fun_JS.js"></script>'); $txtHeader = ""; $athId = empty($_REQUEST['AthId']) || $_REQUEST['AthId'] == 0 ? null : $_REQUEST['AthId']; $sql = "SELECT EnCode, EnFirstName, EnName FROM Entries WHERE EnId=" . StrSafe_DB($athId) . " AND EnTournament=" . StrSafe_DB($_SESSION['TourId']); $Rs = safe_r_sql($sql); if (safe_num_rows($Rs) == 1) { $MyRow = safe_fetch($Rs); $txtHeader = $MyRow->EnCode . " - " . $MyRow->EnFirstName . " " . $MyRow->EnName; } $x = 168; $y = 78; $w = 300; $camurl = empty($_REQUEST['CamUrl']) ? "" : urldecode($_REQUEST['CamUrl']); if (!$camurl) { $camurl = $_COOKIE['CamUrl']; } $boundary = "\n--"; $f = @fopen($camurl, "r"); if ($camurl and $f) { $r = ""; $im = null; if (preg_match('/\\.jpg$/i', $camurl) != 0) { while (!feof($f)) { $r .= fread($f, 4096); } $im = imagecreatefromstring($r);
/** * @param string $pdf * If empty creates and returns a pdf, otherwise adds page to an existant pdf * @return tcpdf object * * */ function getSchedulePDF(&$pdf = '') { if (empty($pdf)) { require_once 'Common/pdf/IanseoPdf.php'; $pdf = new IanseoPdf('Scheduler'); $pdf->startPageGroup(); $pdf->AddPage(); } else { $pdf->AddPage(); } $Start = true; $StartX = $pdf->getX(); $FontAdjust = 1; $TimingWidth = 20; $DelayWidth = 10; $descrSize = $pdf->getPageWidth() - 40; $CellHeight = 5; if ($this->DayByDay) { $FontAdjust = 2; $TimingWidth = 30; $StartX += 10; $CellHeight = 8; } else { $StartX += 20; } foreach ($this->GetSchedule() as $Date => $Times) { if (!$Start and ($this->DayByDay or !$pdf->SamePage(55))) { $pdf->AddPage(); } elseif (!$Start) { $pdf->dy(2 * $FontAdjust); } $Start = false; // DAY $pdf->SetFont($pdf->FontStd, 'B', 8 * $FontAdjust); $pdf->Cell(0, $CellHeight, formatTextDate($Date), 0, 1, 'L', 1); $OldTitle = ''; $OldSubTitle = ''; $OldType = ''; $OldStart = ''; $OldEnd = ''; $IsTitle = false; $OldComment = ''; ksort($Times); // debug_svela($Times); foreach ($Times as $Time => $Sessions) { foreach ($Sessions as $Session => $Distances) { foreach ($Distances as $Distance => $Items) { foreach ($Items as $k => $Item) { if (!$pdf->SamePage(15)) { $pdf->AddPage(); // Day... $pdf->SetFont($pdf->FontStd, 'B', 8 * $FontAdjust); $pdf->Cell(0, $CellHeight, formatTextDate($Date) . ' (' . get_text('Continue') . ')', 0, 1, 'L', 1); // maybe the session title? if ($Item->Type != 'Z' and $OldTitle == $Item->Title and $OldTitle) { $pdf->SetFont($pdf->FontStd, 'B', 8 * $FontAdjust); $pdf->SetX($StartX + $TimingWidth); $pdf->Cell($descrSize, $CellHeight, $Item->Title . ' (' . get_text('Continue') . ')', 0, 1, 'L', 0); } $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); } $timingDelayed = ''; $timing = ''; if ($Item->Type == 'Z') { // free text $timing = $Item->Start . ($Item->Duration ? '-' . addMinutes($Item->Start, $Item->Duration) : ''); if ($Item->Shift) { $timingDelayed = '+' . $Item->Shift; } if ($OldTitle != $Item->Title and $Item->Title) { if (!$IsTitle) { $pdf->SetX($StartX); // prints timing only if alone if (!$Item->SubTitle and !$Item->Text) { if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $timing = ''; } else { $pdf->Cell($TimingWidth, $CellHeight, ' ', 0, 0); } $pdf->SetFont($pdf->FontStd, 'B', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $Item->Title, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); } $OldTitle = $Item->Title; $OldSubTitle = ''; $IsTitle = true; } if ($OldSubTitle != $Item->SubTitle and $Item->SubTitle) { $pdf->SetX($StartX); if (!$Item->Text) { if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $timing = ''; } else { $pdf->Cell($TimingWidth, $CellHeight, ' ', 0, 0); } $pdf->SetFont($pdf->FontStd, 'BI', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $Item->SubTitle, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); $OldSubTitle = $Item->SubTitle; $IsTitle = false; } if ($Item->Text) { $pdf->SetX($StartX); if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); $pdf->Line($StartX, $y = $pdf->GetY() + $CellHeight / 2, $StartX + $TimingWidth - $FontAdjust, $y); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $Item->Text, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); $timing = ''; $IsTitle = false; } $OldStart = $Item->Start; $OldEnd = $Item->Duration; $OldComment = ''; } else { // all other kind of texts have a title and the items if ($OldTitle != $Item->Title) { // Title if (!$IsTitle) { $pdf->SetX($StartX); $pdf->Cell($TimingWidth, $CellHeight, ' ', 0, 0); $pdf->SetFont($pdf->FontStd, 'B', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $Item->Title, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); } $OldTitle = $Item->Title; $OldSubTitle = ''; $IsTitle = true; } if ($OldSubTitle != $Item->SubTitle) { // SubTitle $pdf->SetX($StartX); $pdf->Cell($TimingWidth, $CellHeight, ' ', 0, 0); $pdf->SetFont($pdf->FontStd, 'BI', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $Item->SubTitle, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); $OldSubTitle = $Item->SubTitle; $IsTitle = false; } $timing = ''; if ($OldStart != $Item->Start or $OldEnd != $Item->Duration) { $timing = $Item->Start . ($Item->Duration ? '-' . addMinutes($Item->Start, $Item->Duration) : ''); $OldStart = $Item->Start; $OldEnd = $Item->Duration; if ($Item->Shift) { $timingDelayed = '+' . $Item->Shift; } } $lnk = $Item->Text; if (!$Item->Warmup) { // not warmup! $OldComment = ''; switch ($Item->Type) { case 'Q': case 'E': $t = safe_r_SQL("select distinct EcCode, EcTeamEvent from Entries\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN Qualifications on QuId=EnId and QuSession={$Item->Session}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN EventClass ON EcClass=EnClass AND EcDivision=EnDivision AND EcTournament=EnTournament\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN Events on EvCode=EcCode AND EvTeamEvent=IF(EcTeamEvent!=0, 1,0) AND EvTournament=EcTournament\n\t\t\t\t\t\t\t\t\t\t\t\twhere EnTournament={$this->TourId}\n\t\t\t\t\t\t\t\t\t\t\t\torder by EvTeamEvent, EvProgr"); $Link = array(); $lnk = ''; if ($Item->Comments) { $pdf->SetX($StartX); if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $pdf->SetFont($pdf->FontStd, 'I', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $Item->Comments, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); $timing = ''; } if (count($this->Groups[$Item->Type][$Session]) == 1) { $txt = $Item->Text . $lnk; } elseif ($Item == @end(end(end(end($this->Groups[$Item->Type][$Session]))))) { $txt = get_text('Distance', 'Tournament') . ' ' . $Distance . $lnk; } else { $txt = get_text('Distance', 'Tournament') . ' ' . $Distance; // more distances defined so format is different... } $pdf->SetX($StartX); if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $pdf->Cell($descrSize, $CellHeight, $txt, 0, 1, 'L', 0); $IsTitle = false; break; case 'I': case 'T': $lnk = $Item->Text . ': ' . $Item->Events; $pdf->SetX($StartX); if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $pdf->Cell($descrSize, $CellHeight, $lnk, 0, 1, 'L', 0); $IsTitle = false; if ($this->Finalists && $Item->Session <= 1) { // Bronze or Gold Finals if ($Item->Type == 'I') { $SQL = "select concat(upper(e1.EnFirstname), ' ', e1.EnName, ' (', c1.CoCode, ')') LeftSide,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconcat('(', c2.CoCode, ') ', upper(e2.EnFirstname), ' ', e2.EnName) RightSide\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom Finals tf1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Finals tf2 on tf1.FinEvent=tf2.FinEvent and tf1.FinTournament=tf2.FinTournament and tf2.FinMatchNo=tf1.FinMatchNo+1 and tf2.FinMatchNo%2=1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Entries e1 on e1.EnId=tf1.FinAthlete and tf1.FinEvent IN ('{$Item->Event}')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Entries e2 on e2.EnId=tf2.FinAthlete and tf2.FinEvent IN ('{$Item->Event}')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Countries c1 on e1.EnCountry=c1.CoId and c1.CoTournament={$this->TourId}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Countries c2 on e2.EnCountry=c2.CoId and c2.CoTournament={$this->TourId}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Grids on tf1.FinMatchNo=GrMatchNo and GrPhase={$Item->Session}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere tf1.FinTournament={$this->TourId}"; } else { $SQL = "select concat(c1.CoName, ' (', c1.CoCode, ')') LeftSide,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconcat('(', c2.CoCode, ') ', c2.CoName) RightSide\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom TeamFinals tf1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join TeamFinals tf2 on tf1.TfEvent=tf2.TfEvent and tf1.TfTournament=tf2.TfTournament and tf2.TfMatchNo=tf1.TfMatchNo+1 and tf2.TfMatchNo%2=1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Countries c1 on c1.CoId=tf1.TfTeam and tf1.TfEvent IN ('{$Item->Event}')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Countries c2 on c2.CoId=tf2.TfTeam and tf2.TfEvent IN ('{$Item->Event}')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Grids on tf1.TfMatchNo=GrMatchNo and GrPhase={$Item->Session}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere tf1.TfTournament={$this->TourId}"; } // debug_svela($SQL); $q = safe_r_SQL($SQL); if ($r = safe_fetch($q) and trim($r->LeftSide) and trim($r->RightSide)) { $pdf->SetXY($StartX + $TimingWidth, $pdf->getY() - 1.5); $pdf->Cell($descrSize, $CellHeight, $r->LeftSide . ' - ' . $r->RightSide, 0, 1, 'L', 0); } } break; case 'R': $lnk = $Item->Text . ': ' . $Item->Events; $pdf->SetX($StartX); if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $pdf->Cell($descrSize, $CellHeight, $lnk, 0, 1, 'L', 0); $IsTitle = false; if ($this->Finalists) { list($Phase, $Round, $Group) = explode('-', $Item->Session); $SQL = "select concat(upper(e1.EnFirstname), ' ', e1.EnName, ' (', c1.CoCode, ')') LeftSide,\n\t\t\t\t\t\t\t\t\t\t\t\t\tconcat('(', c2.CoCode, ') ', upper(e2.EnFirstname), ' ', e2.EnName) RightSide\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom F2FGrid g\n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join F2FFinal tf1 on g.F2FTournament=tf1.F2FTournament and g.F2FPhase=tf1.F2FPhase and g.F2FRound=tf1.F2FRound and g.F2FGroup=tf1.F2FGroup and g.F2FMatchNo1=tf1.F2FMatchNo\n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join F2FFinal tf2 on g.F2FTournament=tf2.F2FTournament and g.F2FPhase=tf2.F2FPhase and g.F2FRound=tf2.F2FRound and g.F2FGroup=tf2.F2FGroup and g.F2FMatchNo2=tf2.F2FMatchNo and tf1.F2FEvent=tf2.F2FEvent\n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Entries e1 on e1.EnId=tf1.F2FEnId and tf1.F2FEvent IN ('{$Item->Event}')\n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Entries e2 on e2.EnId=tf2.F2FEnId and tf2.F2FEvent IN ('{$Item->Event}')\n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Countries c1 on e1.EnCountry=c1.CoId and c1.CoTournament={$this->TourId}\n\t\t\t\t\t\t\t\t\t\t\t\t\tinner join Countries c2 on e2.EnCountry=c2.CoId and c2.CoTournament={$this->TourId}\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere g.F2FTournament={$this->TourId} and tf1.F2FSchedule='{$Date} {$Time}'"; $q = safe_r_SQL($SQL); while ($r = safe_fetch($q) and trim($r->LeftSide) and trim($r->RightSide)) { $pdf->SetXY($StartX + $TimingWidth, $pdf->getY() - 1.5); $pdf->Cell($descrSize, $CellHeight, $r->LeftSide . ' - ' . $r->RightSide, 0, 1, 'L', 0); } } break; default: debug_svela($Item); } } else { if ($Item->Comments) { $lnk = $Item->Comments; } else { switch ($Item->Type) { case 'I': case 'T': $lnk = $Item->Text . ': ' . $Item->Events . ' ' . 'warmup'; break; default: $lnk .= ' Warmup'; } } if ($OldComment == $lnk) { continue; } $OldComment = $lnk; $pdf->SetX($StartX); if ($Item->Shift and $timing) { $pdf->SetX($StartX - $DelayWidth); $pdf->Cell($DelayWidth, $CellHeight, $timingDelayed, 0, 0); $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } else { $pdf->Cell($TimingWidth, $CellHeight, $timing, 0, 0); } $pdf->SetFont($pdf->FontStd, 'I', 8 * $FontAdjust); $pdf->Cell($descrSize, $CellHeight, $lnk, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8 * $FontAdjust); $IsTitle = false; } } } } } } } return $pdf; }
/** * calculate(). * La classifica abs viene calcolata quando si calcola quella di classe e l'evento * prevede la div/cl della persona coinvolta * e quando si fanno gli spareggi per passare alle eliminatorie o alle finali. * Nel primo caso questo è il metodo da chiamare perchè calcolerà l'IndRank o l'IndD[1-8]Rank lavorando su tutto l'evento * (utilizza setRow()) altrimenti occorre usare setRow() direttamente. * * @override * * (non-PHPdoc) * @see ianseo/Common/Rank/Obj_Rank#calculate() */ public function calculate() { $dd = $this->opts['dist'] > 0 ? 'D' . $this->opts['dist'] : ''; $f = $this->safeFilter(); $filter = $f !== false ? $f : ""; $q = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tIndId AS `athId`,IndEvent AS `EventCode`,\r\n\t\t\t\t\tQu{$dd}Score AS Score,Qu{$dd}Gold AS Gold,Qu{$dd}Xnine AS XNine, Qu{$dd}Hits AS Hits, IndRank as actualRank,\r\n\t\t\t\t\tEvFinalFirstPhase, EvElim1, EvElim2,\r\n\t\t\t\t\tIF(EvFinalFirstPhase=0,9999,IF(EvElim1=0 && EvElim2=0, IF(EvFinalFirstPhase=48, 104, IF(EvFinalFirstPhase=24, 56, (EvFinalFirstPhase*2))) ,IF(EvElim1=0,EvElim2,EvElim1))) as QualifiedNo\r\n\t\t\t\tFROM\r\n\t\t\t\t\tEvents\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 EvCode=IndEvent AND EvTournament=IndTournament AND EvTeamEvent=0\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 IndId=QuId\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tIndTournament={$this->tournament}\r\n\t\t\t" . (empty($this->opts['includeNullPoints']) ? " AND QuScore != 0 " : "") . "\r\n\t\t\t\t\t{$filter}\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tIndEvent,Qu{$dd}Score DESC,Qu{$dd}Gold DESC,Qu{$dd}Xnine DESC\r\n\t\t\t"; //print $q.'<br><br>'; $r = safe_r_sql($q); if (!$r) { return false; } if (safe_num_rows($r) > 0) { $curGroup = ""; $myRank = 1; $myPos = 0; $endQualified = false; $myScoreOld = 0; $myGoldOld = 0; $myXNineOld = 0; $mySoScore = array(); $myGroupStartPos = 0; $currentRow = -1; while ($myRow = safe_fetch($r)) { ++$currentRow; if ($curGroup != $myRow->EventCode) { $curGroup = $myRow->EventCode; $myRank = 1; $myPos = 0; $myScoreOld = 0; $myGoldOld = 0; $myXNineOld = 0; $mySoScore = array(); $endQualified = false; $myGroupStartPos = $currentRow; /* * If starting phase is 1/48 or 1/24, I check the 8th position for shootoff, */ if (($myRow->EvFinalFirstPhase == 48 || $myRow->EvFinalFirstPhase == 24) && $myRow->EvElim1 == 0 && $myRow->EvElim2 == 0) { if (safe_num_rows($r) > $myGroupStartPos + 8) { safe_data_seek($r, $myGroupStartPos + 8 - 1); $tmpMyRow = safe_fetch($r); if ($curGroup == $tmpMyRow->EventCode) { $tmpScore = $tmpMyRow->Score; $tmpMyRow = safe_fetch($r); //Controllo se c'è parimerito per entrare if ($tmpScore == $tmpMyRow->Score && $curGroup == $tmpMyRow->EventCode) { $mySoScore[] = $tmpScore; } } $tmpMyRow = NULL; } safe_data_seek($r, $myGroupStartPos + 1); } /* * Carico l'ultimo punteggio per entrare. * Vado a prendere la riga con l'ultimo Score buono */ if (safe_num_rows($r) > $myGroupStartPos + $myRow->QualifiedNo) { safe_data_seek($r, $myGroupStartPos + $myRow->QualifiedNo - 1); $tmpMyRow = safe_fetch($r); if ($curGroup == $tmpMyRow->EventCode) { $tmpScore = $tmpMyRow->Score; $tmpMyRow = safe_fetch($r); //Controllo se c'è parimerito per entrare if ($tmpScore == $tmpMyRow->Score && $curGroup == $tmpMyRow->EventCode) { $mySoScore[] = $tmpScore; } } $tmpMyRow = NULL; } safe_data_seek($r, $myGroupStartPos + 1); } ++$myPos; $so = -1; // Se non ho parimerito il ranking è uguale alla posizione if (in_array($myRow->Score, $mySoScore)) { if ($myRow->Score != $myScoreOld) { $myRank = $myPos; } $so = 1; // rosso } else { if (!($myRow->Score == $myScoreOld && $myRow->Gold == $myGoldOld && $myRow->XNine == $myXNineOld)) { $myRank = $myPos; } } if ($myRank > $myRow->QualifiedNo) { $so = 0; } $myScoreOld = $myRow->Score; $myGoldOld = $myRow->Gold; $myXNineOld = $myRow->XNine; $x = false; if ($this->opts['dist'] == 0 && $myRow->actualRank != 0 && array_key_exists('skipExisting', $this->opts) && $this->opts['skipExisting'] == 1) { $x = $this->setRow(array(array('ath' => $myRow->athId, 'event' => $myRow->EventCode, 'dist' => $this->opts['dist'], 'hits' => $myRow->Hits, 'so' => $so * $myRank))); } else { $x = $this->setRow(array(array('ath' => $myRow->athId, 'event' => $myRow->EventCode, 'dist' => $this->opts['dist'], 'hits' => $myRow->Hits, 'rank' => $myRank, 'tiebreak' => '', 'so' => $so * $myRank))); } //print '..'.$x.'<br>'; if ($x === false) { return false; } } } return true; }
$NumCol = $NumColBase + $NumColDist; if ($section['meta']['arrowsShot']) { // Records handling $RecTot = array(); $RecordCut = array(); $RecTitle = ''; $RecCut = 0; $RecXNine = 0; $RecCols = array(); if ($section['meta']['arrowsShot']) { // Records handling $MaxScore = $section['meta']['numDist'] * $section['meta']['maxScore']; $sql = "select RtRecType, RtRecCode, RtRecDistance, RtRecTotal, RtRecXNine, TrColor,\n\t\t\t\t\tfind_in_set('bar', TrFlags) TrBars,\n\t\t\t\t\tfind_in_set('gap', TrFlags) TrGaps\n\t\t\t\tfrom RecTournament\n\t\t\t\tinner join TourRecords on TrTournament=RtTournament and TrRecType=RtRecType and TrRecCode=RtRecCode and TrRecTeam=RtRecTeam and TrRecPara=RtRecPara\n\t\t\t\tinner join Events on RtTournament=EvTournament and EvRecCategory=RtRecCategory and EvCode='{$IdEvent}' and EvTournament={$TourId} and RtRecTeam=EvTeamEvent and EvTeamEvent=0\n\t\t\t\twhere RtRecDistance='Total'\n\t\t\t\torder by RtRecTotal desc "; // for now we only do on totals $q = safe_r_sql($sql); while ($r = safe_fetch($q)) { $RecTot[$r->RtRecType][$r->RtRecCode]['tot'] = $MaxScore - $r->RtRecTotal; $RecTot[$r->RtRecType][$r->RtRecCode]['gap'] = $r->TrGaps; // no X9 checks now... // $RecTot[$r->RtRecType][$r->RtRecCode]['X9']=$MaxScore-$r->RtRecTotal; // $JS_SCRIPT[]='.Rec-'.$r->RtRecType.' {color:#'.$r->TrColor.';font-weight:bold;}'; if ($r->TrGaps) { $RecTitle .= ' <span class="piccolo" style="color:#' . $r->TrColor . '">' . get_text('RecordAverage', 'Tournament', get_text($r->RtRecType . '-short', 'Tournament')) . '</span>'; } $RecCut = max($RecCut, $RecTot[$r->RtRecType][$r->RtRecCode]['tot']); $rec = round($r->RtRecTotal * array_sum($section['meta']['arrowsShot']) / ($section['meta']['numDist'] * $section['meta']['maxArrows']), 1); // no X9 checks now... if ($r->TrBars) { $RecordCut["{$rec}"][] = '<tr class="Record_' . $r->RtRecType . '_' . $r->RtRecCode . '"><th colspan="%s">' . get_text('Record-' . $r->RtRecType . '-' . $r->RtRecCode . '-avg', 'InfoSystem') . '</th> <td class="NumberAlign Grassetto">' . number_format($rec, 1) . '</td> ' . ($View10s ? '<td> </td>' : '') . '
* LEGGERE NOTA PIU' SOTTO RIGUARDO ALLA VISIBILITA' DELLE FRECCE (riga 163) * * * * Aggiunta per il calcolo della freccia X to win * * aggiunti 4 campi XML: * - xtowin: valore della freccia (e quindi della zona da non scurire). Se 1000 ignorare * - totieset: indica se il valore indicato è per vincere o pareggiare il set * - towinmatch: indica se il valore indicato è per vincere il match * - totiematch: indica se il valore indicato è per pareggiare il match * * */ $SQL = "SELECT " . " f.FinEvent Event, " . " EvMatchArrowsNo, EvMixedTeam, EvTeamEvent, EvEventName, " . " GrPhase Phase, " . " f.FinVxF," . " IF(f.FinDateTime>=f2.FinDateTime, f.FinDateTime, f2.FinDateTime) AS DateTime," . " TIMESTAMPDIFF(SECOND, IF(f.FinDateTime>=f2.FinDateTime, f.FinDateTime, f2.FinDateTime), now())>90 AS TooOld," . " f.FinMatchNo as MatchNo," . " fs1.FsTarget Target, " . " fs2.FsTarget OppTarget, " . " f2.FinMatchNo as OppMatchNo," . " EvMatchMode!=0 as SetMode, " . " e1.EnId," . " e1.EnFirstName AS AthleteFirstName," . " e1.EnName as AthleteName," . " e1.EnCode as AthleteBib," . " c1.CoCode as CoCode, " . " c1.CoName as CoName, " . " IF(EvMatchMode=0,f.FinScore,f.FinSetScore) AS Score," . " f.FinSetPoints SetPoints," . " f.FinTie as Tie," . " f.FinTieBreak as TieBreak," . " f.FinArrowString as ArrowString, " . " e2.EnId OppEnId," . " e2.EnFirstName AS OpponentFirstName," . " e2.EnName as OpponentName," . " e2.EnCode as OpponentBib," . " c2.CoCode as OppCoCode, " . " c2.CoName as OppCoName, " . " IF(EvMatchMode=0,f2.FinScore,f2.FinSetScore) as OppScore," . " f2.FinSetPoints OppSetPoints," . " f2.FinTie as OppTie," . " f2.FinTieBreak as OppTieBreak," . " f2.FinArrowString as OppArrowString " . "FROM Finals AS f " . "INNER JOIN Finals AS f2 ON f.FinEvent=f2.FinEvent AND f.FinMatchNo=f2.FinMatchNo-1 AND f.FinTournament=f2.FinTournament " . "LEFT JOIN Entries e1 on f.FinAthlete=e1.EnId " . "LEFT JOIN Entries e2 on f2.FinAthlete=e2.EnId " . "LEFT JOIN Countries c1 on e1.EnCountry=c1.CoId " . "LEFT JOIN Countries c2 on e2.EnCountry=c2.CoId " . "LEFT JOIN FinSchedule fs1 on fs1.FSEvent=f.FinEvent and fs1.FSTeamEvent='0' and fs1.FSMatchNo=f.FinMatchNo and f.FinTournament=fs1.FSTournament " . "LEFT JOIN FinSchedule fs2 on fs2.FSEvent=f2.FinEvent and fs2.FSTeamEvent='0' and fs2.FSMatchNo=f2.FinMatchNo and f2.FinTournament=fs2.FSTournament " . "INNER JOIN Events ON f.FinEvent=EvCode AND f.FinTournament=EvTournament AND EvTeamEvent=0 " . "INNER JOIN Grids ON f.FinMatchNo=GrMatchNo " . "WHERE f.FinTournament={$TourId} AND (f.FinMatchNo % 2)=0" . " AND f.FinLive='1' "; $q = safe_r_sql($SQL); $r = safe_fetch($q); $NumArrows = 3; // Numero di frecce if (($r->EvMatchArrowsNo & ($r->Phase > 0 ? 2 * bitwisePhaseId($r->Phase) : 1)) !== 0) { $NumArrows = 6; // Numero di frecce } // if($r->EvMixedTeam) $nARR='2x2'; // elseif($r->EvTeamEvent) $nARR='3x2'; //$Target=${GetTargetType($r->Event, 0, $TourId)}; $XmlDoc = new DOMDocument('1.0', 'UTF-8'); $XmlRoot = $XmlDoc->createElement('archeryscores'); $XmlDoc->appendChild($XmlRoot); //$Header = $XmlDoc->createElement('header', get_text($r->Event, null, null, true) . ' - ' . get_text('IndFinEvent', 'Tournament') . ' - ' . get_text($r->Phase.'_Phase')); $Header = $XmlDoc->createElement('header'); $Header->appendChild($XmlDoc->createCDATASection(get_text($r->EvEventName, null, null, true)));
</th> </tr> <?php $Select = "SELECT TVRId, TVRTournament, TVRName, ToCode, ToName, ToWhere, "; $Select .= "date_format(ToWhenFrom, '" . get_text('DateFmtDB') . "') as ToFrom, "; $Select .= "date_format(ToWhenTo, '" . get_text('DateFmtDB') . "') as ToTo "; $Select .= "FROM TVRules inner join Tournament on ToId=TVRTournament "; if ($TourId) { $Select .= "where TVRTournament={$TourId} "; } $Select .= "order by ToWhenFrom desc, ToCode"; $riga = 1; $Rs = safe_r_sql($Select); if (safe_num_rows($Rs) > 0) { $old_code = ''; while ($MyRow = safe_fetch($Rs)) { if ($MyRow->ToCode != $old_code) { $riga = 1 - $riga; $old_code = $MyRow->ToCode; } print '<tr' . ($riga ? ' class="alt"' : '') . ' style="height:3em">'; print "<td>{$MyRow->ToCode}</td>"; print "<td>{$MyRow->ToName}</td>"; print "<td>{$MyRow->ToWhere}</td>"; if ($MyRow->ToFrom != $MyRow->ToTo) { print "<td>" . get_text('DateFmtMoreDays', '', array($MyRow->ToFrom, $MyRow->ToTo)) . "</td>"; } else { print "<td>{$MyRow->ToFrom}</td>"; } print '<td class="Left"><a target="_blank" class="Link" href="Rotation.php?Rule=' . $MyRow->TVRId . '&Tour=' . $MyRow->ToCode . '">' . ManageHTML($MyRow->TVRName) . '</a></td>'; print '<td class="Left">[ <a target="_blank" class="Link" href="LightRot.php?Rule=' . $MyRow->TVRId . '&Tour=' . $MyRow->ToCode . '">' . get_text('TvLightPage', 'Tournament') . '</a> ]</td>';
$_REQUEST['Id'] = $ArrowSearch->QuId; $_REQUEST['Point'] = $_REQUEST['arrowsymbol']; $BlockApi = false; require_once 'Qualification/UpdateArrow.php'; if (!$BlockApi and !$JsonResult['error']) { useArrowsSnapshot($ArrowSearch->QuSession, $_REQUEST['distnum'], substr($_REQUEST['qutarget'], 1, -1), substr($_REQUEST['qutarget'], 1, -1), $_REQUEST['arrowindex'] + 1); recalSnapshot($ArrowSearch->QuSession, $_REQUEST['distnum'], substr($_REQUEST['qutarget'], 1, -1), substr($_REQUEST['qutarget'], 1, -1)); } } } else { require_once 'Final/Fun_MatchTotal.inc.php'; $tgtType = 0; $Error = 1; $SQL = "SELECT EvFinalTargetType FROM Events WHERE EvCode='" . $Event . "' AND EvTeamEvent={$EventType} AND EvTournament={$CompId}"; $Rs = safe_r_sql($SQL); if ($r = safe_fetch($Rs)) { $tgtType = $r->EvFinalTargetType; $Error = 0; } $arrowIndex = $_REQUEST['arrowindex'] + 1; if (empty($_REQUEST['arrowsymbol'])) { $tmpLetter = ' '; } else { $tmpLetter = GetLetterFromPrint($_REQUEST['arrowsymbol'], 'T', $tgtType); if ($tmpLetter == ' ') { $Error = 1; } } if (!$Error) { UpdateArrowString($MatchNo, $Event, $EventType, $tmpLetter, $arrowIndex, $arrowIndex); }