if ($TmpWhere != "") { $MyQuery .= "AND (" . $TmpWhere . ")"; } if ($NoPhoto) { $MyQuery .= "AND (length(PhPhoto)='' or PhPhoto is null) "; } $MyQuery .= "ORDER BY CoCode, Name, CoName, FirstName, TargetNo "; //debug_svela($MyQuery); $Rs = safe_r_sql($MyQuery); if ($Rs) { $ShowStatusLegend = false; $FirstTime = true; $OldTeam = '#@#@#'; while ($MyRow = safe_fetch($Rs)) { $pdf->SetDefaultColor(); if ($FirstTime || !$pdf->SamePage(4)) { $pdf->SetFont($pdf->FontStd, 'B', 7); $pdf->Cell(54, 4, get_text('Country'), 1, 0, 'L', 1); $pdf->Cell(7, 4, get_text('SessionShort', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(11, 4, get_text('Target'), 1, 0, 'C', 1); $pdf->Cell(10, 4, get_text('Code', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(41, 4, get_text('Athlete'), 1, 0, 'L', 1); $pdf->Cell(11, 4, get_text('AgeCl'), 1, 0, 'C', 1); $pdf->Cell(8, 4, get_text('SubCl', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(12, 4, get_text('Division'), 1, 0, 'C', 1); $pdf->Cell(12, 4, get_text('Cl'), 1, 0, 'C', 1); //Disegna i Pallini $pdf->DrawParticipantHeader(); $pdf->SetFont($pdf->FontStd, 'B', 7); $pdf->Cell(10, 4, get_text('Status', 'Tournament'), 1, 1, 'C', 1); $OldTeam = '';
$MyQuery .= "INNER JOIN Entries AS e ON t.ToId=e.EnTournament "; $MyQuery .= "INNER JOIN Countries AS c ON e.EnCountry=c.CoId AND e.EnTournament=c.CoTournament "; $MyQuery .= "INNER JOIN Qualifications AS q ON e.EnId=q.QuId "; $MyQuery .= "INNER JOIN Classes AS cl ON e.EnClass=cl.ClId AND ClTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "INNER JOIN Divisions AS d ON e.EnDivision=d.DivId AND DivTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "WHERE EnAthlete=1 AND ToId = " . StrSafe_DB($_SESSION['TourId']) . " "; $MyQuery .= "AND QuSession = " . StrSafe_DB($_REQUEST["Session"]) . " "; $MyQuery .= "ORDER BY QuTargetNo, CoCode, Name, CoName, FirstName "; //*DEBUG*/echo $MyQuery;exit(); $Rs = safe_r_sql($MyQuery); if ($Rs) { $ShowStatusLegend = false; $CurSession = -1; $OldTarget = ''; while ($MyRow = safe_fetch($Rs)) { if ($CurSession != $MyRow->Session || !$pdf->SamePage(4) || $MyRow->TargetLetter == 'A' && !$pdf->SamePage(16)) { $TmpSegue = !$pdf->SamePage(4); if ($MyRow->TargetLetter == 'A' && !$pdf->SamePage(16)) { $TmpSegue = true; $pdf->AddPage(); } elseif ($CurSession != -1) { $pdf->SetXY(10, $pdf->GetY() + 5); } $CurSession = $MyRow->Session; $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(190, 6, get_text('Session') . " " . $CurSession . " - " . get_text('Distance', 'HTT') . " " . $_REQUEST["Distance"], 1, 1, 'C', 1); if ($TmpSegue) { $pdf->SetXY(170, $pdf->GetY() - 6); $pdf->SetFont($pdf->FontStd, 'I', 6); $pdf->Cell(30, 6, get_text('Continue'), 0, 1, 'R', 0); }
//debug_svela($MyQuery); //echo $MyQuery;exit(); $Rs = safe_r_sql($MyQuery); if ($Rs) { $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; while ($MyRow = safe_fetch($Rs)) { //se cambia classifica rifaccio l'header if ($CurGroup != $MyRow->TeEvent || !$pdf->SamePage(4) || $CurTeam != $MyRow->NationCode && !$pdf->SamePage(4 * $MyRow->Quanti + 16)) { $TmpSegue = !$pdf->SamePage(4); if ($CurTeam != $MyRow->NationCode && !$pdf->SamePage(4 * 3 * $MyRow->Quanti + 16)) { $TmpSegue = true; $pdf->AddPage(); } else { if ($CurGroup != "....") { $pdf->SetXY(10, $pdf->GetY() + 5); } } if ($CurGroup != $MyRow->TeEvent) { $TmpSegue = false; } $CurGroup = $MyRow->TeEvent; $pdf->SetFont($pdf->FontStd, 'B', 10); $TmpTitle;
$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) { $pdf->Cell($DivSize, 6, $Value, 1, 0, 'C', 1); } $pdf->Cell(0.1, 6, '', 0, 1, 'C', 0);
$OldDist = ''; $OldTarget = ''; $TmpColor = array(255, 255, 255); $SecondaryDistance = 0; $TgText = ''; $TgFirst = 0; $TgNo = 0; $TgTop = 0; $TopPos = 35 - RowH; // select already assigned number of sessions with min and max target $SesSql = safe_r_sql("select QuSession, min(cast( substr(QuTargetNo,2) as unsigned)) TargetMin, max(cast( substr(QuTargetNo,2) as unsigned)) TargetMax, ToNumDist from Qualifications inner join Entries on EnId=QuId inner join Tournament on EnTournament=ToId where EnTournament={$_SESSION['TourId']} and cast( substr(QuTargetNo,2) as unsigned)>0 group by QuSession"); while ($SesRow = safe_fetch($SesSql)) { // set the target dimention $DimTarget = min(10, ($pdf->GetPageWidth() - 20 - ColName) / ($SesRow->TargetMax - $SesRow->TargetMin + 1)); // checks if there is enough space for at least 1 distance if (!$pdf->SamePage(RowH + 25)) { $pdf->AddPage(); //Al cambio di data aggiungo una pagina $TopPos = 35; } else { $TopPos += RowH; } // prints the session $pdf->SetFillColor(0); $pdf->SetTextColor(255); $pdf->SetXY(10, $TopPos); $pdf->SetFont($pdf->FontStd, 'B', 14); $pdf->Cell($pdf->GetPageWidth() - 20, 8, get_text('Session') . ": " . $SesRow->QuSession, 0, 0, "C", 1); $TopPos += 8; $pdf->SetFillColor(240); $pdf->SetTextColor(0);
$MyQuery .= "LEFT JOIN AccEntries AS ae ON Sq.EnId=ae.AEId AND at.AtTournament=ae.AETournament "; $MyQuery .= "AND ae.AEOperation=(SELECT AOTId FROM AccOperationType WHERE AOTDescr=" . StrSafe_DB($OpDetails) . ") "; $MyQuery .= "WHERE AtTournament = " . StrSafe_DB($_SESSION['TourId']) . " "; if (isset($_REQUEST["Session"]) && is_numeric($_REQUEST["Session"])) { $MyQuery .= "AND SUBSTRING(AtTargetNo,1,1) = " . StrSafe_DB($_REQUEST["Session"]) . " "; } $MyQuery .= "ORDER BY AtTargetNo, CoCode, Name, CoName, FirstName "; //echo $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if ($Rs) { $ShowStatusLegend = false; $CurSession = -1; $OldTarget = ''; while ($MyRow = safe_fetch($Rs)) { $pdf->SetDefaultColor(); if ($CurSession != $MyRow->Session || !$pdf->SamePage(4) || strtoupper(substr($MyRow->TargetNo, -1, 1)) == 'A' && !$pdf->SamePage(16)) { $TmpSegue = !$pdf->SamePage(4); if (strtoupper(substr($MyRow->TargetNo, -1, 1)) == 'A' && !$pdf->SamePage(16)) { $TmpSegue = true; $pdf->AddPage(); } elseif ($CurSession != -1) { $pdf->SetXY(10, $pdf->GetY() + 5); } $CurSession = $MyRow->Session; $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(190, 6, get_text('Session') . " " . $CurSession . " (" . get_text($OpDetails, 'Tournament') . ")", 1, 1, 'C', 1); if ($TmpSegue) { $pdf->SetXY(170, $pdf->GetY() - 6); $pdf->SetFont($pdf->FontStd, 'I', 6); $pdf->Cell(30, 6, get_text('Continue'), 0, 1, 'R', 0); }
$MyQuery .= "LEFT 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 .= "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 FirstName, Name, TargetNo "; $Rs = safe_r_sql($MyQuery); if ($Rs) { $StartLetter = "."; $ShowStatusLegend = false; while ($MyRow = safe_fetch($Rs)) { if ($StartLetter != $MyRow->Initial || !$pdf->SamePage(4)) { $TmpSegue = !$pdf->SamePage(4); if ($StartLetter != $MyRow->Initial && !$pdf->SamePage(20)) { $TmpSegue = false; $pdf->AddPage(); } elseif ($StartLetter != ".") { $pdf->SetY($pdf->GetY() + 5); } $StartLetter = $MyRow->Initial; $pdf->SetDefaultColor(); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(190, 6, $StartLetter, 1, 1, 'C', 1); if ($TmpSegue) { $pdf->SetXY(170, $pdf->GetY() - 6); $pdf->SetFont($pdf->FontStd, 'I', 6); $pdf->Cell(30, 6, get_text('Continue'), 0, 1, 'R', 0);
$rankData = $rank->getData(); if (count($rankData['sections'])) { $DistSize = 12; $AddSize = 0; $pdf->setDocUpdate($rankData['meta']['lastUpdate']); foreach ($rankData['sections'] as $section) { //Calcolo Le Misure per i Campi if ($rankData['meta']['numDist'] >= 4 && !$rankData['meta']['double']) { $DistSize = 48 / $rankData['meta']['numDist']; } elseif ($rankData['meta']['numDist'] >= 4 && $rankData['meta']['double']) { $DistSize = 48 / ($rankData['meta']['numDist'] / 2 + 1); } else { $AddSize = (48 - $rankData['meta']['numDist'] * 12) / 2; } //Verifico se l'header e qualche riga ci stanno nella stessa pagina altrimenti salto alla prosisma if (!$pdf->SamePage(28)) { $pdf->AddPage(); } writeGroupHeader($pdf, $section['meta'], $DistSize, $AddSize, $rankData['meta']['numDist'], $rankData['meta']['double'], false); foreach ($section['items'] as $item) { writeDataRow($pdf, $item, $DistSize, $AddSize, $rankData['meta']['numDist'], $rankData['meta']['double']); if (!$pdf->SamePage(4 * ($rankData['meta']['double'] ? 2 : 1))) { $pdf->AddPage(); writeGroupHeader($pdf, $section['meta'], $DistSize, $AddSize, $rankData['meta']['numDist'], $rankData['meta']['double'], true); } } $pdf->SetY($pdf->GetY() + 5); } } if (!isset($isCompleteResultBook)) { $pdf->Output();
$TgTop = 0; $TopPos = 35 - RowH; $MyRow = safe_fetch($Rs); $TimeEvents = array(); $DistGap = 0; while ($MyRow) { // check distances! $CurDistGap = ($MyRow->EvDistance ? 3 : 0) + ($MaxDist - $MyRow->EvDistance) / 5; $DistGap = max($DistGap, $CurDistGap); //Cambio di Orario e/o data if ($OldSched != $MyRow->SchDate . $MyRow->SchTime) { if (!empty($DayLastTargets[$MyRow->FSScheduledDate])) { $FirstTarget = $DayFirstTargets[$MyRow->FSScheduledDate]; $LastTarget = $DayLastTargets[$MyRow->FSScheduledDate]; } 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)));
$MyQuery .= "AND (" . $TmpWhere . ")"; } $MyQuery .= "ORDER BY CoCode, DivViewOrder, FirstName, Name"; //*DEBUG*/echo $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if (safe_num_rows($Rs) > 0) { $FirstTime = true; $OldTeam = '#@#@#'; $OldDiv = '#@#@#'; $ColNo = 0; $RowY = 0; $RowX = 0; $MaxHeight = 0; // $pdf->SetAutoPageBreak(false); while ($MyRow = safe_fetch($Rs)) { if ($OldDiv != $MyRow->DivCode && !$pdf->SamePage($MaxHeight + 20)) { $OldTeam = '#@#@#'; } //Cambio di Squadra if ($OldTeam != $MyRow->NationCode) { if (!$FirstTime) { $pdf->AddPage(); } $pdf->SetXY(10, $pdf->GetY() + 5); $pdf->SetFont($pdf->FontStd, 'B', 20); $pdf->Cell(190, 8, $MyRow->Nation . ' (' . $MyRow->NationCode . ')', 0, 0, 'L', 1); $FirstTime = false; $RowNo = 0; $ColNo = 0; $MaxHeight = 0; $OldTeam = $MyRow->NationCode;
$SecondaryDistance = 0; $TgText = ''; $TgFirst = 0; $TgNo = 0; $TgTop = 0; $OldTrueSession = ''; $TopPos = 35 - RowH; $MyRow = safe_fetch($Rs); while ($MyRow) { //Cambio di Sessione e/o Distanza if ($MyRow->Dist == '-') { $MyRow = safe_fetch($Rs); continue; } if ($OldSession != $MyRow->Session . $MyRow->Dist) { if (!$pdf->SamePage(RowH + 5) or $OldTrueSession != $MyRow->Session and !$pdf->SamePage(2 * RowH + 15)) { $pdf->AddPage(); //Al cambio di data aggiungo una pagina $TopPos = 35; } else { $TopPos += RowH; } $pdf->SetXY(10, $TopPos + 3); $pdf->SetFont($pdf->FontStd, 'B', 14); $pdf->Cell(ColName, 8, $MyRow->Dist, 0, 0, "C"); $pdf->SetXY(10, $TopPos + 9); $pdf->SetFont($pdf->FontStd, 'I', 8); $pdf->Cell(ColName, 5, get_text('Session') . ": " . $MyRow->Session, 0, 0, "C"); $pdf->SetTextColor(0); $pdf->SetXY(10 + ColName, $TopPos + 2); $pdf->SetFont($pdf->FontFix, 'B', 7);