added php download of membershipments

This commit is contained in:
Torsten Schulz
2023-12-27 10:40:24 +01:00
parent ea29b477f6
commit c622398357
2571 changed files with 350456 additions and 15 deletions

View File

@@ -0,0 +1,64 @@
<?php
include 'renderer.php';
require 'vendor/autoload.php'; // Stelle sicher, dass der Autoloader für PhpSpreadsheet geladen wird
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class Projectsmanagement 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);
$result = [];
while ($row = mysqli_fetch_assoc($result)) {
$result[] = [
'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 $result;
}
}