kompass/modules/event-participants/Controllers/class-printparticipantlistinvoicepdf.php

65 lines
2.8 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Reqeust\AnwesenheitRequest;
class PrintParticipantListInvoicePdfController {
private function get_table_header(string $event_name) : string {
return '<h1>Teili-Liste für ' . $event_name . '</h1><br /><br /><br /><br /><table style="border-spacing: 0; width: 100%;page-break-after: always">' .
'<tr>' .
'<td>Vorname</td>' .
'<td>Nachname</td>' .
'<td>Teili-Gruppe</td>' .
'<td>Stamm</td>' .
'<td>Geburtsdatum</td>' .
'<td>Beitrag</td>' .
'<td>Tage</td>' .
'<td>Notizen</td>';
}
public function __construct() {
global $_POST, $_REQUEST, $dbHandler;
$group_name = ['participant' => 'Teili', 'volunteer' => 'Teami', 'other' => 'Sonstige'];
$event = Event::loadById( $_REQUEST['event-id'] );
$output = '';
$i = 0;
foreach ( $event->tribes as $tribe => $participants ) {
if ( count( $participants ) == 0 ) {
continue;
}
foreach ( $participants as $participant ) {
if ($participant->beitrag == 0) {
continue;
}
if ( $i == 0 ) {
$output .= $this->get_table_header( $event->event_name );
}
$i ++;
$output .= '<tr style="min-height: 80px; height: 80px; border-style: solid; border-width: 1px;">' .
'<td style="min-height: 40px; height: 40px; width: 150px; border-style: solid; border-width: 1px;">' . $participant->vorname .
('' != $participant->pfadiname ? '<br /> (' . $participant->pfadiname . ')' : '') . '</td>' .
'<td style="width: 150px; border-style: solid; border-width: 1px;">' . $participant->nachname . '</td>' .
'<td style="padding-right: 100px; border-style: solid; border-width: 1px;">' . $group_name[$participant->teilnahme] . '</td>' .
'<td style="padding-right: 100px; border-style: solid; border-width: 1px;">' . $tribe . '</td>' .
'<td style="padding-right: 50px; border-style: solid; border-width: 1px;">' . \DateTime::createFromFormat( 'Y-m-d', $participant->geburtsdatum )->format( 'd.m.Y' ) . '</td>' .
'<td style="padding-right: 50px; border-style: solid; border-width: 1px;">' . str_replace('.', ',', $participant->beitrag) . ' Euro</td>' .
'<td style="border-style: solid; border-width: 1px;">' . AnwesenheitRequest::send($participant) . '</td>' .
'<td style="padding-right: 150px; border-style: solid; border-width: 1px;"></td></tr>';
if ( $i == 12 ) {
$output .= '</table>';
$i = 0;
}
}
}
$output .= '</table></body></html>';
kompass_create_pdf($output,$event->event_name . ' Beitragsliste.pdf', 'landscape');
}
}