Merge branch 'fronkdev' into 'master'

ConstructionConsent: Owners editable & status/result stats

See merge request fronk/thetool!952
This commit is contained in:
Frank Schubert
2025-01-27 14:40:50 +00:00
3 changed files with 118 additions and 2 deletions

View File

@@ -16,6 +16,8 @@ class ConstructionConsent extends mfBaseModel {
private $history;
private $inspection_protocol_planner;
private $inspection_protocol_electrician;
private $owner_result_counts;
private $owner_status_counts;
private $footer_text = "Energie Steiermark Breitband GmbH, A-8010 Graz, Leonhardgürtel 10, Telefon +43 (0)316 9000-0\nSitz Graz, FN 576705x, Landesgericht für ZRS Graz, ATU 77949678, breitband@e-steiermark.com, www.e-steiermark.com";
private $footer_font = "ITC Officina Sans Std";
@@ -204,6 +206,34 @@ class ConstructionConsent extends mfBaseModel {
return $this->inspection_protocol_electrician;
}
if($name == "owner_result_counts") {
$counts = [];
$owners = $this->getProperty("owners");
foreach($owners as $owner) {
if(!array_key_exists($owner->result, $counts)) {
$counts[$owner->result] = 0;
}
$counts[$owner->result]++;
}
$this->owner_result_counts = $counts;
return $this->owner_result_counts;
}
if($name == "owner_status_counts") {
$counts = [];
$owners = $this->getProperty("owners");
foreach($owners as $owner) {
if(!array_key_exists($owner->status, $counts)) {
$counts[$owner->status] = 0;
}
$counts[$owner->status]++;
}
$this->owner_status_counts = $counts;
return $this->owner_status_counts;
}
if($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {

View File

@@ -106,6 +106,29 @@ class ConstructionConsentOwnerController extends mfBaseController
}
protected function deleteAction() {
$id = $this->request->id;
$owner = new ConstructionConsentOwner($id);
if(!$owner->id) {
$this->layout()->setFlash("Besitzer nicht gefunden!", "error");
$this->redirect("ConstructionConsent");
}
$consent = $owner->consent;
foreach($owner->files as $file) {
$file->file->delete();
$file->delete();
}
$owner->delete();
$this->layout()->setFlash("Besitzer gelöscht!", "success");
$this->redirect("ConstructionConsent", "View", ["id" => $consent->id]);
}
protected function apiAction() {
if(!$this->me->is(["Admin"])) {
$this->redirect("Dashboard");