} $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);
$MyQuery = 'SELECT DATE_FORMAT(AEWhen,\'' . get_text('DateFmtDB') . '\') as Data, QuSession as Turno, COUNT(EnId) as Accreditati, IF(EnPays=0,"NoPay",ifnull(APPrice,0)) as Prezzo, SUM(IF(EnPays=1,APPrice,0)) as Totale' . ' FROM AccEntries' . ' INNER JOIN Entries ON AEId=EnId /*AND EnPays=1*/ AND AETournament = EnTournament' . ' INNER JOIN Qualifications ON EnId=QuId' . ' LEFT JOIN AccPrice ON EnTournament=APTournament AND CONCAT(EnDivision,EnClass) LIKE APDivClass' . ' WHERE AETournament = ' . StrSafe_DB($_SESSION['TourId']) . ' AND AEOperation = (SELECT AOTId FROM AccOperationType WHERE AOTDescr=' . StrSafe_DB($OpDetails) . ')' . ' GROUP BY QuSession, EnPays, IF(EnPays=0,"NoPay",ifnull(APPrice,0)), DATE_FORMAT(AEWhen,\'' . get_text('DateFmtDB') . '\')' . ' ORDER BY Data ASC, Turno ASC, EnPays DESC, APPrice DESC'; //echo $MyQuery;exit; $Rs = safe_r_sql($MyQuery); if ($Rs) { $TotalDay = 0; $Total = 0; $OldDate = ''; $isFirstTime = true; while ($MyRow = safe_fetch($Rs)) { if ($OldDate != $MyRow->Data) { if ($OldDate != '') { $pdf->SetFont($pdf->FontStd, '', 8); $pdf->Cell(30, 6, '', 0, 0, 'L', 0); $pdf->Cell(115, 6, get_text('Total') . " " . $OldDate, 0, 0, 'R', 0); $pdf->SetFont($pdf->FontStd, 'B', 8); $pdf->Cell(45, 6, NumFormat($TotalDay, 2) . " " . $pdf->writeCurrency(), 1, 1, 'R', 0); } $isFirstTime = true; $pdf->SetY($pdf->GetY() + 5); $pdf->SetFont($pdf->FontStd, 'B', 8); $pdf->Cell(30, 7, '', 0, 0, 'C', 0); $pdf->Cell(30, 7, get_text('TourWhen', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(25, 7, get_text('SessionShort', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(30, 7, get_text('Number'), 1, 0, 'C', 1); $pdf->Cell(30, 7, get_text('Price', 'Tournament'), 1, 0, 'C', 1); $pdf->Cell(45, 7, get_text('Total'), 1, 1, 'C', 1); $pdf->SetFont($pdf->FontStd, '', 1); $pdf->Cell(190, 0.5, '', 0, 1, 'C', 0); $OldDate = $MyRow->Data; $TotalDay = 0; }