WIP ConstructionConsent 2025-01-13

This commit is contained in:
Frank Schubert
2025-01-13 16:28:56 +01:00
parent 5f752da41f
commit 15bfe7c734
11 changed files with 541 additions and 22 deletions
@@ -130,6 +130,49 @@ class ConstructionConsentController extends mfBaseController {
$this->addAction();
}
protected function download() {
//var_dump($r->get());exit;
$owner_id = $this->request->owner_id;
if (!is_numeric($owner_id) || $owner_id < 1) {
$this->layout()->setFlash("Besitzer nicht gefunden", "error");
$this->redirect("ConstructionConsent");
}
$owner = new ConstructionConsentOwner($owner_id);
if (!$owner->id) {
$this->layout()->setFlash("Besitzer nicht gefunden", "error");
$this->redirect("ConstructionConsent");
}
$cc = $owner->consent;
if(!$cc) {
$this->layout()->setFlash("Zustimmungserklärung nicht gefunden.", "error");
$this->redirect("ConstructionConsent");
}
$this->layout()->setTemplate("ConstructionConsent/Consentform.pdf");
$this->layout()->set("ressourcePathPrefix", MFFANCYBASEURL);
$this->layout()->set("owners", [$owner]);
$this->layout()->set("consent", $cc);
//return true;
$filename = $cc->createConsentFormPdf();
if(!$filename) {
$this->layout()->setFlash("Beim Erstellen des PDFs ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.", "error");
$this->redirect("ConstructionConsent", "View", ["id" => $cc->id]);
}
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename="Zustimmungserklärung-'.$cc->id.'-'.$owner_id.'.pdf"');
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: ' . mime_content_type($filename));
header("Content-Length: " . filesize($filename));
readfile($filename);
exit;
}
protected function saveAction() {
$r = $this->request;
//var_dump($r->get());exit;