/** * 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 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 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 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 Get_Image($IocCode = null, $Section = null, $Reference = null, $Type = null, $Tourid = 0) { if (empty($Tourid)) { $Tourid = $_SESSION['TourId']; } $SQL = "select * from Images where ImTournament={$Tourid}"; if (!isnull($IocCode)) { $SQL .= " and ImIocCode='{$IocCode}'"; } if (!isnull($Section)) { $SQL .= " and ImSection='{$Section}'"; } if (!isnull($Reference)) { $SQL .= " and ImReference='{$Reference}'"; } if (!isnull($Type)) { $SQL .= " and ImType='{$Type}'"; } $q = safe_r_sql($SQL); }
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 ''; }
function SetAccreditation($Id, $SetRap = 0, $return = 'RicaricaOpener', $TourId = 0, $AccOp = 0) { $RicaricaOpener = false; if (!$TourId) { $TourId = $_SESSION['TourId']; } if (!$AccOp) { $AccOp = $_SESSION['AccOp']; } /* * Devo prevenire l'insert se l'id è in stato 7. * Per farlo cerco lo stato del tizio. * Se è 7 vuol dire che uno ha cliccato sul bottone dopo aver aperto il popup e io non scrivo in db */ $Select = "SELECT EnId FROM Entries\n\t\tWHERE EnId=" . StrSafe_DB($Id) . " AND EnTournament={$TourId} AND EnStatus='7' "; $Rs = safe_r_sql($Select); //TODO Patchare la query per supportare bene IpV6 if (safe_num_rows($Rs) == 0) { $Insert = "INSERT INTO AccEntries\n\t\t\t(AEId,AEOperation,AETournament,AEWhen,AEFromIp,AERapp)\n\t\t\tVALUES(\n\t\t\t\t{$Id}," . StrSafe_DB($AccOp) . "," . StrSafe_DB($TourId) . "," . StrSafe_DB(date('Y-m-d H:i')) . "," . "INET_ATON('" . ($_SERVER['REMOTE_ADDR'] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1') . "'), " . StrSafe_DB($SetRap) . "" . ") ON DUPLICATE KEY UPDATE " . "AEWhen=" . StrSafe_DB(date('Y-m-d H:i')) . "," . "AEFromIp=INET_ATON('" . ($_SERVER['REMOTE_ADDR'] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1') . "') "; $RsIns = safe_w_sql($Insert); $RicaricaOpener = $return == 'RicaricaOpener' ? true : (safe_w_affected_rows() ? 'AccreditationOK' : 'AccreditationTwice'); } return $RicaricaOpener; }
$MyQuery .= "FROM Entries AS e "; $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 AccEntries AS ae ON e.EnId=ae.AEId AND e.EnTournament=ae.AETournament "; $MyQuery .= "AND ae.AEOperation=(SELECT AOTId FROM AccOperationType WHERE AOTDescr=" . StrSafe_DB($OpDetails) . ") "; $MyQuery .= "INNER JOIN AccPrice AS ap ON CONCAT(EnDivision,EnClass) LIKE ap.APDivClass AND e.EnTournament=ap.APTournament "; $MyQuery .= "WHERE EnAthlete=1 AND EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; if (isset($_REQUEST["Session"]) && is_numeric($_REQUEST["Session"])) { $MyQuery .= "AND QuSession = " . StrSafe_DB($_REQUEST["Session"]) . " "; } if ($TmpWhere != "") { $MyQuery .= "AND (" . $TmpWhere . ")"; } $MyQuery .= "ORDER BY CoCode, Name, CoName, FirstName, TargetNo "; //echo $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if ($Rs) { $ShowStatusLegend = false; $OldTeam = '#@#@#'; $isFirstTime = true; $TotalPrice = 0; while ($MyRow = safe_fetch($Rs)) { if ($OldTeam != $MyRow->NationCode) { if (!$isFirstTime) { $pdf->SetFont($pdf->FontStd, '', 8); $pdf->Cell(165, 15, get_text('Cash', 'Tournament') . ":", 0, 0, 'R', 0); $pdf->SetFont($pdf->FontStd, 'B', 12); $pdf->Cell(25, 15, NumFormat($TotalPrice, 2) . " " . $pdf->writeCurrency(), 0, 1, 'R', 0); $pdf->AddPage(); } $isFirstTime = false;
$NumColDist = $ViewDists ? $rankData['meta']['numDist'] : 0; $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>
if (safe_num_rows($RsSel) > 0) { while ($Row = safe_fetch($RsSel)) { //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'); ?>
echo get_text('IndFinal'); echo '</a></td>'; echo '<td class="Center" width="40%" rowspan="2">'; $t = safe_r_sql("SELECT * FROM BackNumber WHERE BnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND BnFinal in (0,1) order by BnFinal desc"); if (safe_num_rows($t)) { echo '<img src="../../Tournament/ImgBackNumber.php?IdTpl=1"><br/><br/>'; } echo '<input type="button" value="' . get_text('BackNoEdit', 'BackNumbers') . '" onClick="document.location=\'' . $CFG->ROOT_DIR . 'Tournament/BackNumber.php?BackNo=1\'">' . '<br /><input type="button" value="' . get_text('BackNoExportLayout', 'BackNumbers') . '" onClick="document.location=\'' . $CFG->ROOT_DIR . 'Tournament/BackNumbersExport.php?BackNo=1\'">' . '<form id="PrnParameters" action="" method="post" enctype="multipart/form-data"><br /><input type="file" name="ImportBackNumbers" /> ' . '<input name="Submit" type="submit" value="' . get_text('BackNoImportLayout', 'BackNumbers') . '"></form></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="Center" width="60%"><div align="center"><br>'; echo '<table class="Tabella" style="width:80%">'; echo '<tr>'; //Eventi $MySql = "SELECT EvCode, EvEventName FROM Events WHERE EvTeamEvent='0' AND EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EvFinalFirstPhase!=0 ORDER BY EvProgr"; $Rs = safe_r_sql($MySql); if (safe_num_rows($Rs) > 0) { $TmpCnt = 0; while ($MyRow = safe_fetch($Rs)) { if ($TmpCnt++ % 2 == 0 && $TmpCnt != 1) { echo '</tr><tr>'; } echo '<td class="Center" width="50%"><a href="PDFBackNumber.php?Event=' . $MyRow->EvCode . '" class="Link" target="PrintOut">'; echo '<img src="../../Common/Images/pdf_small.gif" alt="' . $MyRow->EvCode . '" border="0"><br>'; echo $MyRow->EvCode . ' - ' . get_text($MyRow->EvEventName, '', '', true); echo '</a></td>'; } if ($TmpCnt % 2 != 0) { echo '<td> </td>'; } safe_free_result($Rs);
?> </th> <th class="Title" width="10%" nowrap="nowrap"><?php print get_text('TourWhen', 'Tournament'); ?> </th> <th class="Title" width="30%"><?php print get_text('TourWhere', 'Tournament'); ?> </th> <th class="Title" width="50%"><?php print get_text('TourName', 'Tournament'); ?> </th> </tr> <?php $q = safe_r_sql("select ToCode, ToName, ToWhere, DATE_FORMAT(ToWhenFrom,'" . get_text('DateFmtDB') . "') AS DtFrom, " . "DATE_FORMAT(ToWhenTo,'" . get_text('DateFmtDB') . "') AS DtTo from Tournament order by ToWhenTo desc, ToWhenFrom desc"); while ($r = safe_fetch($q)) { echo '<tr>'; echo '<td><a href="?ToCode=' . $r->ToCode . '">' . get_text('Download', 'Boinx') . '</a></td>'; print '<td>' . $r->ToCode . '</td>'; print '<td nowrap="nowrap">' . get_text('From', 'Tournament') . ' ' . $r->DtFrom . ' ' . get_text('To', 'Tournament') . ' ' . $r->DtTo . '</td>'; print '<td>' . ManageHTML($r->ToWhere) . '</td>'; print '<td>' . ManageHTML($r->ToName) . '</td>'; echo '</tr>'; } ?> </table> <?php include 'Common/Templates/tail.php';
} } //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');
<?php $BadgePerPage = 4; $format = array(210, 297); $q = safe_r_sql("select ToPrintPaper from Tournament where ToId='{$_SESSION['TourId']}'"); if ($r = safe_fetch($q) and $r->ToPrintPaper == '1') { $format = array(215.9, 279.4); } $pdf->SetAutoPageBreak(false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $cntPass = 0; $AccH = $pdf->getPageHeight() / 2 - 4; $AccW = $pdf->getPageWidth() / 2 - 4; while ($MyRow = safe_fetch($Rs)) { $pdf->SetDefaultColor(); $PosX = $cntPass % 2 == 0 ? 2 : $pdf->getPageWidth() / 2 + 2; $PosY = $cntPass % 4 < 2 ? 2 : $pdf->getPageHeight() / 2 + 2; $AccColor = array(255, 255, 255); if (!is_null($MyRow->AcColor)) { $AccColor = array(base_convert(substr($MyRow->AcColor, 0, 2), 16, 10), base_convert(substr($MyRow->AcColor, 2, 2), 16, 10), base_convert(substr($MyRow->AcColor, 4, 2), 16, 10)); } //Every 4 Accreditation I change page if ($cntPass % $BadgePerPage == 0) { $pdf->AddPage(); } //Put their image as background $pdf->SetXY($PosX, $PosY); $pdf->Image($_SESSION["TourCode"] . ".jpg", $PosX, $PosY, $AccW, $AccH, 'JPEG', '', 'T', 2, 300); //Banda Colorata $pdf->Rect($PosX, $PosY + 33, $AccW, 40, 'F', array(), $AccColor);
if ($session > 0) { $ses = GetSessions('Q', false, array($session . '_Q')); $num4session = $ses[0]->SesTar4Session * $ses[0]->SesAth4Target; } // 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) {
"></td> </tr> <tr> <th class="TitleLeft"><?php print get_text('OlympicFont-use', 'InfoSystem'); ?> </th> <td><input type="checkbox" name="OlympicFont-use"<?php echo empty($_SESSION['OlympicFont-use']) ? '' : ' checked="checked"'; ?> ></td> </tr> <?php // get the records type in the DB $q = safe_r_sql("select distinct\r\n\t\tReType,\r\n\t\tReCode,\r\n\t\tTrColor,\r\n\t\tTrTournament is not null as ReInserted ,\r\n\t\tfind_in_set('bar', TrFlags) TrBars,\r\n\t\tfind_in_set('gap', TrFlags) TrGaps from Records\r\n\tleft join TourRecords\r\n\t\ton ReType=TrRecType\r\n\t\tand ReCode=TrRecCode\r\n\t\tand ReTeam=TrRecTeam\r\n\t\tand RePara=TrRecPara\r\n\t\tand TrTournament={$_SESSION['TourId']}\r\n\tWHERE RePara=" . ($_SESSION['TourLocRule'] == 'PAR' ? '1' : '0') . "\r\n\t\t"); while ($r = safe_fetch($q)) { echo '<tr> <th class="TitleLeft">' . get_text($r->ReType . '-Record', 'Tournament') . '</th> <td><input type="checkbox" name="Records[]" value="' . $r->ReType . '"' . ($r->ReInserted ? ' checked="checked"' : '') . '> <input type="text" name="RecColor[' . $r->ReType . ']" id="BnTnoColor_' . $r->ReType . '" size="6" maxlength="7" value="#' . $r->TrColor . '"> <input type="text" id="Ex_BnTnoColor_' . $r->ReType . '" size="1" style="background-color:#' . $r->TrColor . '" readonly> <img src="../Common/Images/sel.gif" onclick="javascript:pickerPopup302(\'BnTnoColor_' . $r->ReType . '\',\'Ex_BnTnoColor_' . $r->ReType . '\');"> - ' . get_text('BarRecord', 'InfoSystem') . '<input type="checkbox" name="RecBar[' . $r->ReType . ']"' . ($r->TrBars ? ' checked="checked"' : '') . '> - ' . get_text('GapRecord', 'InfoSystem') . '<input type="checkbox" name="RecGap[' . $r->ReType . ']"' . ($r->TrGaps ? ' checked="checked"' : '') . '> </td> </tr>'; } ?> <tr> <td class="Center" colspan="2"> <input type="hidden" name="command" value="SAVE"/> <input type="button" value="<?php
/** * 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; }
<?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';
$yy = intval($yy__ . $__yy); //$year = date('Y') - $yy; $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";
<?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);
<th class="Title" colspan="4"><?php print get_text('TVOutRules', 'Tournament'); ?> </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>";
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); }