Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mrothauer committed Dec 5, 2024
1 parent a374bad commit 2349528
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions plugins/Admin/src/Controller/FundingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Services\PdfWriter\FoerderbewilligungPdfWriterService;
use Cake\I18n\DateTime;
use App\Services\PdfWriter\FoerderantragPdfWriterService;
use League\Csv\Writer;

class FundingsController extends AdminAppController
{
Expand Down Expand Up @@ -38,6 +39,57 @@ public function foerderantragPdf($fundingUid) {
die($pdfWriterService->writeInline());
}

public function bankExport() {

$fundingsTable = $this->getTableLocator()->get('Fundings');

$fundings = $fundingsTable->find('all',
conditions: $this->conditions,
contain: [
'OwnerUsers',
'Fundingsupporters',
'Fundingbudgetplans',
])->toArray();

$validFundings = [];
foreach($fundings as $funding) {

if (!$funding->is_submitted) {
continue;
}

if ($funding->owner_user) {
$funding->owner_user->revertPrivatizeData();
}

$validFundings[] = $funding;

}

$writer = Writer::createFromString();

//Währung;VorzBetrag;RechNr;Belegdatum;InterneRechNr;KundeName;KundeOrt;KundeKonto;BU;Konto;Kontobezeichnung;Ware/Leistung;Fällig_am;gezahlt_am;UStSatz;USt-IdNr.Kunde;Kunden-Nr.;KOST1;KOST2;KOSTmenge;Kurs;Skonto;Nachricht;Skto_Fällig_am;BankKonto;BankBlz;Bankname;BankIban;BankBic;Skto_Proz

/*
$writer->insertOne(['VorzBetrag']);
foreach($validFundings as &$record) {
$record['VorzBetrag'] = $record->budgetplan_total_with_limit;
}
$writer->insertAll($records);
$this->disableAutoRender();
pr($writer->toString());
exit;
*/

$response = $this->response;
$response = $response->withStringBody($writer->toString());
$response = $response->withCharset('UTF-8');
$response = $response->withDownload('bankexport' . DateTime::now()->i18nFormat('yyyyMMdd_HHmmss') . '.csv');

}

public function edit($uid)
{

Expand Down

0 comments on commit 2349528

Please sign in to comment.