WIP ConstructionConsent 2025-01-13
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user