Merge branch 'ConstructionConsent/add-owner-number' into 'master'

Added new ConstructionConsent Features

See merge request fronk/thetool!1101
This commit is contained in:
Luca Haid
2025-03-11 13:37:55 +00:00
4 changed files with 101 additions and 67 deletions

View File

@@ -1,8 +1,9 @@
<?php
//die(json_encode($owners));
/**
* @var string $ressourcePathPrefix
* @var array $owners
* @var object $consent
* @var object $owner->consent
*/
?>
<html lang="de">
@@ -254,7 +255,7 @@
</p>
<ul style="margin-top: 0;">
<li>
<strong>Zustimmungserklärung inkl. Planskizze:</strong> Bitte unterschreiben und an uns zurücksenden (per Rücksendekuvert oder an <span class="no-word-break"><?=$consent->project->email?></span>).<br />
<strong>Zustimmungserklärung inkl. Planskizze:</strong> Bitte unterschreiben und an uns zurücksenden (per Rücksendekuvert oder an <span class="no-word-break"><?=$owner->consent->project->email?></span>).<br />
<em>(Hinweis: Die Planskizze zeigt eine vorläufige Darstellung des Trassenverlaufs auf Ihrem Grundstück. Der genaue Trassenverlauf wird erst vor Ort
im Rahmen der Detailplanung festgelegt. Alle erforderlichen Grab- und Wiederherstellungsarbeiten werden selbstverständlich kostenlos von der
Energie Steiermark Breitband GmbH durchgeführt.)</em>
@@ -262,7 +263,7 @@
</ul>
<p>Wir bedanken uns schon jetzt herzlich für Ihre Unterstützung bei diesem wichtigen Projekt!</p>
<p>Für Fragen oder weitere Informationen stehen wir Ihnen gerne unter <span class="no-word-break"><?=$consent->project->phone?></span> oder per E-Mail an <span class="no-word-break"><?=$consent->project->email?></span> zur Verfügung.</p>
<p>Für Fragen oder weitere Informationen stehen wir Ihnen gerne unter <span class="no-word-break"><?=$owner->consent->project->phone?></span> oder per E-Mail an <span class="no-word-break"><?=$owner->consent->project->email?></span> zur Verfügung.</p>
<p>Mit freundlichen Grüßen</p>
@@ -313,7 +314,7 @@
<li>eine Mitbenutzung von Anlagen, Leitungen oder sonstigen Einrichtungen nach § 60 64 nicht möglich oder nicht tunlich ist.</li>
</ol>
<p>Die BB beabsichtigt für das Projekt <?=$consent->name?> in Ausübung dieses Rechtes auf dem(n) Grundstück(en)</p>
<p>Die BB beabsichtigt für das Projekt <?=$owner->consent->name?> in Ausübung dieses Rechtes auf dem(n) Grundstück(en)</p>
<table class="consent-table">
<tr>
@@ -323,10 +324,10 @@
<th>LWL-Leerrohre und/oder LWL-Kabel (Künette, Inhouse etc.)</th>
</tr>
<tr>
<td><?=$consent->gst?></td>
<td><?=$consent->kg?></td>
<td><?=$consent->ez?></td>
<td>ca. <?=$consent->usage_length?> lfm (exkl. Beigest. LWL-Wohnungsverkabelung)</td>
<td><?=$owner->consent->gst?></td>
<td><?=$owner->consent->kg?></td>
<td><?=$owner->consent->ez?></td>
<td>ca. <?=$owner->consent->usage_length?> lfm (exkl. Beigest. LWL-Wohnungsverkabelung)</td>
</tr>
</table>
@@ -334,13 +335,13 @@
<table class="options-table">
<tr>
<td class="bullet"><?=($consent->usage_pipe_on_plot) ? "&#x2612;" : "&#x2610;"?></td>
<td class="bullet"><?=($owner->consent->usage_pipe_on_plot) ? "&#x2612;" : "&#x2610;"?></td>
<td>Verlegung von Rohren und Lichtwellenleitern am Grundstück</td>
</tr><tr>
<td class="bullet"><?=($consent->usage_pipe_in_building) ? "&#x2612;" : "&#x2610;"?></td>
<td class="bullet"><?=($owner->consent->usage_pipe_in_building) ? "&#x2612;" : "&#x2610;"?></td>
<td>Verlegung von Rohren und Lichtwellenleitern in den darauf befindlichen Gebäuden</td>
</tr><tr>
<td class="bullet"><?=($consent->usage_manhole) ? "&#x2612;" : "&#x2610;"?></td>
<td class="bullet"><?=($owner->consent->usage_manhole) ? "&#x2612;" : "&#x2610;"?></td>
<td>Errichtung eines Schachtes/einer Kabelmontagegrube und/oder eines LWL-Verteilschrankes/einer LWL-Abschlussbox.</td>
</tr>
@@ -353,7 +354,7 @@
<table class="options-table">
<tr>
<td class="bullet"><?=($consent->usage_owner) ? "&#x2612;" : "&#x2610;"?></td>
<td class="bullet"><?=($owner->consent->usage_owner) ? "&#x2612;" : "&#x2610;"?></td>
<td>Die Nutzung der Liegenschaft seitens BB dient der Eigenversorgung der GE und/oder dessen Nutzer(in) und wird dieser entgeltlos zugestimmt.</td>
</tr>
</table>
@@ -412,8 +413,8 @@
<div class="borderpoint">
<h3>Übersichtsplan / Planskizze</h3>
<?php if($consent->file && $consent->file->file_id && $consent->file->file->fileExists()): ?>
<img src="<?=$consent->file->file->asDataUrl()?>" style="max-width: 640px; max-height: 640px; border: 1px solid #000" />
<?php if($owner->consent->file && $owner->consent->file->file_id && $owner->consent->file->file->fileExists()): ?>
<img src="<?=$owner->consent->file->file->asDataUrl()?>" style="max-width: 640px; max-height: 640px; border: 1px solid #000" />
<?php endif; ?>
</div>

View File

@@ -146,6 +146,10 @@ $pagination_entity_name = "Zustimmungserklärungen";
<button type="submit" class="btn btn-primary"><i class="far fa-search fa-fw"></i> Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("ConstructionConsent", "", ["resetFilter" => 1, "filter" => ["project_id" => (is_array($filter) && array_key_exists("project_id", $filter) ? $filter["project_id"] : "")]])?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
</div>
<!-- create a div that is on the right side of the row-->
<div class="col text-right">
<a class="btn btn-success" href="<?=self::getUrl("ConstructionConsent", "downloadMultiple", ["filter" => $filter])?>"><i class="fas fa-download"></i> Zustimmungserklärungen herunterladen</a>
</div>
</div>
</form>
@@ -321,6 +325,7 @@ $pagination_entity_name = "Zustimmungserklärungen";
<th>Objektadresse</th>
<th>GST-Nr.</th>
<th>Einlagezahl</th>
<th class="text-center">Anzahl Eigentümer</th>
<th>Anfragestatus</th>
<th>Anfrageresultat</th>
<th></th>
@@ -343,6 +348,18 @@ $pagination_entity_name = "Zustimmungserklärungen";
</td>
<td><?=$item->gst?></td>
<td><?=$item->ez?></td>
<td class="text-center">
<?php
if ($item->owners !== null) {
$owners = $item->owners;
$owner_count = count($owners);
?>
<?=$owner_count?>
<?php } ?>
</td>
<td><?=($item->status) ? __($item->status,"consent") : ""?></td>
<td>
<?php

View File

@@ -84,42 +84,34 @@ class ConstructionConsent extends mfBaseModel {
} catch(Exception $e) {
$this->log->debug($e->getTraceAsString());
}
return true;
}
public function createConsentFormPdf(ConstructionConsentOwner $owner = null) : ?string {
if($owner) {
$owners = [$owner];
} else {
if(!is_array($this->getProperty("owners")) || !count($this->getProperty("owners"))) {
return null;
}
$owners = $this->owners;
}
$pdf_vars = [
"consent" => $this,
"owners" => $owners
];
$footer_text = $this->footer_text;
$footer_font = $this->footer_font;
$footer_size = $this->footer_size;
$pdf = new PdfForm("ConstructionConsent/Consentform.pdf", $pdf_vars);
//$wkOpts = "--footer-center '$footer_text' --footer-font-name '$footer_font' --footer-font-size '$footer_size'";
$wkOpts = "--footer-html '".$_SERVER["HTTP_HOST"].MFFANCYBASEURL."/assets/pdf/ConstructionConsent/Consentform.footer.html' --margin-bottom 15mm --margin-top 10mm";
$filename = $pdf->render($wkOpts);
if(!file_exists($filename) || !is_file($filename)) {
public function createConsentFormPdf(array $owners): ?string
{
if (empty($owners)) {
return null;
}
return $filename;
$pdf = new PdfForm("ConstructionConsent/Consentform.pdf", [
'consent' => $this,
'owners' => $owners
]);
$footerFile = BASEDIR . "/public/assets/pdf/ConstructionConsent/Consentform.footer.html";
$wkOpts = sprintf(
"--footer-html '%s' --margin-bottom 15mm --margin-top 10mm --margin-bottom 15mm --margin-top 10mm",
$footerFile
);
$filename = $pdf->render($wkOpts);
return @is_file($filename) ? $filename : null;
}
public function getProperty($name) {
if($this->$name == null) {

View File

@@ -140,45 +140,69 @@ class ConstructionConsentController extends mfBaseController {
$this->addAction();
}
protected function download() {
//var_dump($r->get());exit;
protected function generatePdf(array $owners, ConstructionConsent $consent): ?string
{
if (empty($owners)) return null;
$this->layout()->setTemplate("ConstructionConsent/Consentform.pdf");
$this->layout()->set("ressourcePathPrefix", MFFANCYBASEURL);
$this->layout()->set("owners", $owners);
$this->layout()->set("consent", $consent);
return $consent->createConsentFormPdf($owners); // Might need adjustment for multiple
}
protected function downloadAction()
{
$owner_id = $this->request->owner_id;
if (!is_numeric($owner_id) || $owner_id < 1) {
if (!is_numeric($owner_id) || $owner_id < 1 || !($owner = new ConstructionConsentOwner($owner_id))->id) {
$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) {
if (!($cc = $owner->consent)) {
$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($owner);
if(!$filename) {
$this->layout()->setFlash("Beim Erstellen des PDFs ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.", "error");
if (!($filename = $this->generatePdf([$owner], $cc))) {
$this->layout()->setFlash("PDF-Erstellung fehlgeschlagen", "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));
$this->sendPdfResponse($filename, "Zustimmungserklärung-{$cc->id}-{$owner_id}.pdf");
}
protected function downloadMultipleAction()
{
// Reuse index filter logic
$filter = $this->getPreparedFilter($this->request->filter);
$owners = [];
foreach (ConstructionConsent::search($filter, []) as $consent) {
$owners = array_merge($owners, $consent->owners ?: []);
}
if (empty($owners)) {
$this->layout()->setFlash("Keine Besitzer gefunden", "error");
$this->redirect("ConstructionConsent");
}
// Use first consent as base - might need adjustment for your use case
if (!($filename = $this->generatePdf($owners, $owners[0]->consent))) {
$this->layout()->setFlash("PDF-Erstellung fehlgeschlagen", "error");
$this->redirect("ConstructionConsent");
}
$this->sendPdfResponse($filename, "Zustimmungserklärungen-".date('Y-m-d').".pdf");
}
private function sendPdfResponse(string $filename, string $downloadName): void
{
header('Content-Type: ' . mime_content_type($filename));
header('Content-disposition: attachment; filename="' . $downloadName . '"');
header('Content-Length: ' . filesize($filename));
readfile($filename);
exit;
}