} } safe_free_result($Rs); } //Parte per le premiazioni $Sql = "SELECT EnDivision as Divisione, EnClass as Classe, SUM(EnIndClEvent) as QuantiInd, IFNULL(numTeam,0) AS QuantiSq\r\n\tFROM Entries\r\n\tinner join Divisions on EnDivision=DivId and DivAthlete=1 and DivTournament=" . StrSafe_DB($_SESSION['TourId']) . "\r\n\tinner join Classes on EnClass=ClId and ClAthlete=1 and ClTournament=" . StrSafe_DB($_SESSION['TourId']) . "\r\n\tLEFT JOIN (\r\n\t SELECT sqDiv, sqCl, COUNT(sqQuanti) as numTeam\r\n\t FROM\r\n\t (SELECT EnDivision as sqDiv, EnClass as sqCl, COUNT(EnId) as sqQuanti\r\n\t FROM Entries\r\n\t WHERE EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND EnTeamClEvent=1\r\n\t GROUP BY EnDivision, EnClass, IF(EnCountry2=0,EnCountry,EnCountry2), EnSubTeam\r\n\t HAVING sqQuanti>=3) as sq\r\n\t GROUP BY sqDiv, sqCl\r\n\t) AS sqy ON EnDivision=sqDiv AND EnClass=sqCl\r\n\tWHERE EnTournament=" . StrSafe_DB($_SESSION['TourId']) . "\r\n\tGROUP BY EnDivision, EnClass, numTeam"; $Rs = safe_r_sql($Sql); if (safe_num_rows($Rs) > 0) { while ($MyRow = safe_fetch($Rs)) { $listClDiv[$MyRow->Classe][$MyRow->Divisione]["I"] = $MyRow->QuantiInd; $listClDiv[$MyRow->Classe][$MyRow->Divisione]["S"] = $MyRow->QuantiSq; } } //debug_svela($listClDiv); $FirstTime = true; $DivSize = ($pdf->getPageWidth() - 35) / count($DivArray); foreach ($listClDiv as $cl => $singleClass) { if ($FirstTime || !$pdf->SamePage(16)) { $TmpSegue = !$pdf->SamePage(16); if ($TmpSegue) { $pdf->AddPage(); } $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->SetXY(25, $pdf->GetY() + 5); $pdf->Cell($pdf->getPageWidth() - 35, 6, get_text('StatEvents', 'Tournament'), 1, 1, 'C', 1); if ($TmpSegue) { $pdf->SetXY($pdf->getPageWidth() - 40, $pdf->GetY() - 6); $pdf->SetFont($pdf->FontStd, 'I', 6); $pdf->Cell(30, 6, get_text('Continue'), 0, 1, 'R', 0); } $pdf->SetX(25);
$DivArray[] = trim($MyRow->EnDivision) != '' ? $MyRow->EnDivision : '--'; foreach ($SesArray as $Value) { $Sql .= "SUM(IF(TRIM(EnDivision)='" . trim($MyRow->EnDivision) . "' AND QuSession='" . $Value . "',1,0)) as `" . (trim($MyRow->EnDivision) != '' ? $MyRow->EnDivision : '--') . $Value . "`, "; $SesFields[] = (trim($MyRow->EnDivision) != '' ? $MyRow->EnDivision : '--') . $Value; } } safe_free_result($Rs); $SqlEmpty = $Sql; $Sql .= "ClId " . "FROM Classes " . "LEFT JOIN Entries ON TRIM(ClId) = TRIM(EnClass) AND ClTournament=EnTournament " . "LEFT JOIN Qualifications ON EnId = QuId " . "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " " . "GROUP BY ClId " . "ORDER BY ClViewOrder"; $SqlEmpty .= "'--' AS ClId " . "FROM Entries " . "LEFT JOIN Qualifications ON EnId = QuId " . "WHERE EnTournament = " . StrSafe_DB($_SESSION['TourId']) . " AND EnClass='' " . "GROUP BY EnClass "; $Rs = safe_r_sql($Sql); $RsEmpty = safe_r_sql($SqlEmpty); if ($Rs && count($DivArray) > 0) { $ShowStatusLegend = false; $FirstTime = true; $DivSize = ($pdf->getPageWidth() - 35) / count($DivArray); $SesSize = $DivSize / (count($SesArray) + 1); while ($MyRow = safe_fetch($Rs)) { if ($FirstTime || !$pdf->SamePage(16)) { $TmpSegue = !$pdf->SamePage(16); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->SetXY(25, $pdf->GetY() + 5); $pdf->Cell($pdf->getPageWidth() - 35, 6, get_text('StatClasses', 'Tournament'), 1, 1, 'C', 1); if ($TmpSegue) { $pdf->SetXY($pdf->getPageWidth() - 40, $pdf->GetY() - 6); $pdf->SetFont($pdf->FontStd, 'I', 6); $pdf->Cell(30, 6, get_text('Continue'), 0, 1, 'R', 0); } $pdf->SetX(25); $pdf->SetFont($pdf->FontStd, 'B', 10); foreach ($DivArray as $Value) {
} if ($OldDate != $MyRow->SchDate && $OldDate != '' || !$pdf->SamePage(RowH + 12 + $DistGap) || (!$pdf->SamePage(2 * RowH + 12 + $DistGap) and $MyRow->Warmup)) { // debug_svela($LastTarget-$FirstTarget); if ($LastTarget - $FirstTarget < 21) { $pdf->AddPage('P'); //Al cambio di data aggiungo una pagina } else { $pdf->AddPage('L'); //Al cambio di data aggiungo una pagina } $TopPos = 35; $DimTarget = min(10, ($pdf->getpagewidth() - 20 - ColName) / ($LastTarget - $FirstTarget + 1)); } else { if ($OldDate) { $pdf->SetLineStyle(array('width' => 0.5, 'color' => array(128))); $pdf->Line(10, $TopPos + RowH + $DistGap - 1, $pdf->getPageWidth() - 10, $TopPos + RowH + $DistGap - 1); $pdf->SetLineStyle(array('width' => 0.1, 'color' => array(0))); } $TopPos += RowH + $DistGap + 2; } $DistGap = 3; $pdf->SetTextColor(0); $pdf->SetXY(10, $TopPos - 1); $pdf->SetFont($pdf->FontStd, 'B', 14); $pdf->Cell(ColName, 3, isset($_REQUEST["HideTime"]) ? '' : $MyRow->SchTime, 0, 0, "C"); // data e ora $pdf->SetXY(10, $TopPos + ($MyRow->EvMatchArrowsNo == '--' ? 7 : 4)); $pdf->SetFont($pdf->FontStd, 'I', 8); //$pdf->Cell(ColName,5,date( get_text('DateFmt'), $MyRow->SchDate),0,0,"C"); $pdf->Cell(ColName, 5, dateRenderer($MyRow->FSScheduledDate, get_text('DateFmt')), 0, 0, "C"); if ($MyRow->EvMatchArrowsNo != '--') {