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; $pdf->SetXY(10, $pdf->GetY() + 5); $pdf->SetFont($pdf->FontStd, '', 8); $pdf->Cell($pdf->GetStringWidth(get_text('Country')) + 5, 10, get_text('Country'), 0, 0, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 12); $pdf->Cell(15, 10, $MyRow->NationCode, 0, 0, 'C', 0); $pdf->Cell(50, 10, $MyRow->Nation, 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 8); $pdf->Cell(19, 10, get_text('Partecipants'), 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 7); $pdf->Cell(10, 4, '', 0, 0, 'C', 0); $pdf->Cell(10, 4, get_text('SessionShort', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(15, 4, get_text('Target'), 1, 0, 'C', 1); $pdf->Cell(10, 4, get_text('Code', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(45, 4, get_text('Athlete'), 1, 0, 'L', 1); $pdf->Cell(15, 4, get_text('AgeCl'), 1, 0, 'C', 1); $pdf->Cell(10, 4, get_text('SubCl', 'Tournament'), 1, 0, 'C', 1);
$WhereY = $WhereStartY; //Intestazione Atleta $pdf->SetY($pdf->GetPageHeight() * 0.2 - 23); $pdf->SetFont($pdf->FontStd, '', 10); $pdf->Cell($pdf->GetPageWidth() * 0.1, 6, get_text('Athlete') . ': ', 'TL', 0, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell($pdf->GetPageWidth() * 0.8 - 20, 6, $MyRow->Athlete, 'T', 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 10); $pdf->Cell($pdf->GetPageWidth() * 0.1, 6, get_text('Country') . ': ', 'L', 0, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell($pdf->GetPageWidth() * 0.8 - 20, 6, $MyRow->CoName . (strlen($MyRow->CoCode) > 0 ? ' (' . $MyRow->CoCode . ')' : ''), 0, 1, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 10); $pdf->Cell($pdf->GetPageWidth() * 0.1, 6, get_text('DivisionClass') . ': ', 'LB', 0, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell($pdf->GetPageWidth() * 0.8 - 20, 6, get_text($MyRow->EvEventName, '', '', true), 'B', 1, 'L', 0); $pdf->SetXY($pdf->GetPageWidth() * 0.9 - 10, $pdf->GetY() - 18); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell($pdf->GetPageWidth() * 0.1, 6, get_text('Rank'), 'TLR', 1, 'C', 1); $pdf->SetXY($pdf->GetPageWidth() * 0.9 - 10, $pdf->GetY()); $pdf->SetFont($pdf->FontStd, 'B', 25); $pdf->Cell($pdf->GetPageWidth() * 0.1, 12, $MyRow->GrPosition, 'BLR', 1, 'C', 1); $WhichScoreEnd = 7; if ($MyRow->EvFinalFirstPhase == 64 || $MyRow->EvFinalFirstPhase == 48) { $WhichScoreEnd = 6; } for ($WhichScore = $Start2FirstPhase[$MyRow->EvFinalFirstPhase]; $WhichScore < $WhichScoreEnd; $WhichScore++) { DrawScore($pdf, $MyRow, $WhichScore, $WhereX[$WhichScore - $Start2FirstPhase[$MyRow->EvFinalFirstPhase]], $WhereY[$WhichScore - $Start2FirstPhase[$MyRow->EvFinalFirstPhase]], $WhichScore == $WhichScoreEnd - 1); } } safe_free_result($Rs); }
$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); } $pdf->SetFont($pdf->FontStd, 'B', 7); $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(44, 4, get_text('Athlete'), 1, 0, 'L', 1); $pdf->Cell(16, 4, get_text('Country'), 1, 0, 'L', 1); if (!HideCols) {
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); $pdf->SetX(25); $pdf->SetFont($pdf->FontStd, 'B', 8); for ($i = 0; $i < count($DivArray); $i++) {
$pdf->SetFont($pdf->FontStd, '', 10); $pdf->Cell(40, 7, get_text('TourCommitee', 'Tournament') . ": ", 'L', 0, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(150, 7, $RowTournament->ToCommitee . " - " . $RowTournament->ToComDescr, 'R', 1, 'L', 0); //Luogo e data di Svolgimento $pdf->SetFont($pdf->FontStd, '', 10); $pdf->Cell(40, 7, get_text('TourWhen', 'Tournament') . ": ", 'L', 0, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(50, 7, TournamentDate2String($RowTournament->DtFrom, $RowTournament->DtTo), 0, 0, 'L', 0); $pdf->SetFont($pdf->FontStd, '', 10); $pdf->Cell(30, 7, get_text('TourWhere', 'Tournament') . ": ", 0, 0, 'R', 0); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(70, 7, $RowTournament->ToWhere, 'R', 1, 'L', 0); $pdf->SetFont($pdf->FontStd, 'B', 1); $pdf->Cell(190, 0.5, '', 1, 1, 'L', 1); $pdf->SetXY($pdf->GetX(), $pdf->GetY() + 5); //Parte di Report vera e propria /*$MySql = "SELECT FrqId, FrqStatus, FrqQuestion, FrqTip, FrqType, FrqOptions, TtCategory " . "FROM FinalReportQ " . "INNER JOIN Tournament ON ToId=" . StrSafe_DB($_SESSION['TourId']) . " " . "INNER JOIN Tournament*Type ON TtId=ToType "; if($AllQuestions) $MySql .= "WHERE FrqStatus > 0 "; else $MySql .= "WHERE (FrqStatus & TtCategory) > 0 "; $MySql .= "ORDER BY FrqId";*/ $MySql = "SELECT FrqId, FrqStatus, FrqQuestion, FrqTip, FrqType, FrqOptions, ToCategory AS TtCategory " . "FROM FinalReportQ " . "INNER JOIN Tournament ON ToId=" . StrSafe_DB($_SESSION['TourId']) . " "; if ($AllQuestions) { $MySql .= "WHERE FrqStatus > 0 "; } else { $MySql .= "WHERE (FrqStatus & ToCategory) > 0 ";
$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); for ($n = 1; $n <= $SesRow->ToNumDist; $n++) { // gets the different distances for each Event and target type $Sql = "select distinct cast(substr(QuTargetNo,2) as unsigned) TargetNo, IFNULL(Td{$n},'.{$n}.') as Distance, TarDescr, TarDim from\r\nEntries\r\ninner join Qualifications on EnId=QuId\r\nleft join TournamentDistances on concat(trim(EnDivision),trim(EnClass)) like TdClasses and EnTournament=TdTournament\r\nleft join (select TfId, TarDescr, TfW{$n} as TarDim, TfTournament from TargetFaces inner join Targets on TfT{$n}=TarId) tf on TfTournament=EnTournament and TfId=EnTargetFace\r\nwhere EnTournament={$_SESSION['TourId']} and QuSession={$SesRow->QuSession}\r\norder by Distance desc, TargetNo, TarDescr, TarDim"; $Rows = array(); $OldDist = 0; $OldTarg = 0; $OldDim = 0; $q = safe_r_sql($Sql); while ($r = safe_fetch($q)) { if ($r->Distance == '-') {
if (isset($_REQUEST["Session"]) && is_numeric($_REQUEST["Session"])) { $MyQuery .= "AND QuSession = " . StrSafe_DB($_REQUEST["Session"]) . " "; } $MyQuery .= "ORDER BY Name, FirstName, TargetNo "; $Rs = safe_r_sql($MyQuery); if ($Rs) { $ShowStatusLegend = false; $FirstTime = true; while ($MyRow = safe_fetch($Rs)) { if ($FirstTime || !$pdf->SamePage(4)) { $TmpSegue = !$pdf->SamePage(4); $StartLetter = substr($MyRow->Name, 0, 1); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(190, 6, get_text('PartecipantListError', '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); } $pdf->SetFont($pdf->FontStd, 'B', 7); $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(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(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->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 != '--') { // numero frecce $nARR = $MyRow->arrows . 'x' . $MyRow->ends; // Numero di frecce if ($MyRow->EvMaxTeamPerson > 1) { $nARR = "(" . $MyRow->EvMaxTeamPerson . 'x' . $MyRow->arrows / $MyRow->EvMaxTeamPerson . ")x" . $MyRow->ends; } $pdf->SetXY(10, $TopPos + 7);
$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; $OldDiv = '#@#@#'; } //Cambio di divisione if ($OldDiv != $MyRow->DivCode) { $RowX = 15; $pdf->SetXY($RowX, $pdf->GetY() + 10); $pdf->SetFont($pdf->FontStd, 'B', 10); $pdf->Cell(185, 7, $MyRow->DivDescription, 0, 1, 'L', 0);
$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); $pdf->SetFillColor(240); for ($i = $FirstTarget; $i <= $LastTarget; $i++) { $pdf->Cell($DimTarget, 4, $i, 'LRB', 0, "C", 1); } $OldSession = $MyRow->Session . $MyRow->Dist; $OldDist = ''; $OldTarget = '';