66 lines
3.3 KiB
PHP
66 lines
3.3 KiB
PHP
<?php
|
|
include 'renderer.php';
|
|
include '../vendor/autoload.php'; // Stelle sicher, dass der Autoloader für PhpSpreadsheet geladen wird
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
class Memberlistdownload extends Renderer {
|
|
public function render(): void {
|
|
$members = $this->loadMembers();
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$columnHeaders = [];
|
|
$sheet->fromArray([$columnHeaders], null, 'A1');
|
|
$sheet->fromArray($dataArray, null, 'A2');
|
|
$writer = new Xlsx($spreadsheet);
|
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
header('Content-Disposition: attachment;filename="excel_file.xlsx"');
|
|
header('Cache-Control: max-age=0');
|
|
$writer->save('php://output');
|
|
}
|
|
|
|
private function loadMembers(): array {
|
|
$query = <<<queryend
|
|
SELECT c.first_name, c.last_name , c.street , c.zip , c.town, c.birthdate, c.phone, c.email, c.child_name,
|
|
c.child_street, c.subscription, c.bank_name, c.iban, c.bic, c.account_member_name, c.membership_status, c.salt, c.membership_start,
|
|
cs.`status_text`, (SELECT ph.`payment_date` FROM `paying_history` ph WHERE ph.`clubmember_id` = c.`id` ORDER BY `payment_date` DESC LIMIT 1) as last_payment,
|
|
cp.description
|
|
FROM `clubmember` c
|
|
JOIN `clubmember_status` cs
|
|
ON cs.`id` = c.`membership_status`
|
|
LEFT JOIN `clubmember_position` cp
|
|
ON cp.id = c.position_id
|
|
WHERE cs.`status_text` NOT IN ("Mitgliedschaft abgelehnt", "Mitgliedschaft gekündigt")
|
|
queryend;
|
|
$result = mysqli_query($this->dbConnection, $query);
|
|
$entries = [];
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
var_dump($row);
|
|
$entries[] = [
|
|
'first_name' => $this->decode($row['first_name'], $row['salt']),
|
|
'last_name' => $this->decode($row['last_name'], $row['salt']),
|
|
'street' => $this->decode($row['street'], $row['salt']),
|
|
'zip' => $this->decode($row['zip'], $row['salt']),
|
|
'town' => $this->decode($row['town'], $row['salt']),
|
|
'birthdate' => $this->decode($row['birthdate'], $row['salt']),
|
|
'phone' => $this->decode($row['phone'], $row['salt']),
|
|
'email' => $this->decode($row['email'], $row['salt']),
|
|
'child_name' => $this->decode($row['child_name'], $row['salt']),
|
|
'child_street' => $this->decode($row['child_street'], $row['salt']),
|
|
'subscription' => $this->decode($row['subscription'], $row['salt']),
|
|
'iban' => $this->decode($row['iban'], $row['salt']),
|
|
'bank_name' => $this->decode($row['bank_name'], $row['salt']),
|
|
'bic' => $this->decode($row['bic'], $row['salt']),
|
|
'account_member_name' => $this->decode($row['account_member_name'], $row['salt']),
|
|
'membership_status' => $row['membership_status'],
|
|
'membership_start' => $row['membership_start'],
|
|
'status_text' => $row['status_text'],
|
|
'last_payment' => $row['last_payment'],
|
|
'description' => $row['description'],
|
|
];
|
|
}
|
|
return $entries;
|
|
}
|
|
}
|