$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; $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);
$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))); } $TopPos += RowH + $DistGap + 2; }