From d5ee700ac56d20b6965e7ade4c9a8c8c57df57d6 Mon Sep 17 00:00:00 2001 From: mrothauer Date: Tue, 3 Dec 2024 17:24:20 +0100 Subject: [PATCH 1/9] add zuwendungsbestaetigung --- .../Migrations/20241203155342_Fundings6.php | 15 +++++++++ .../src/Controller/FundingsController.php | 13 ++++++++ plugins/Admin/templates/Fundings/edit.php | 17 ++++++++++ plugins/Admin/templates/Fundings/index.php | 1 + .../list/fundings/zuwendungsbestaetigung.php | 7 ++++ src/Model/Entity/Funding.php | 33 +++++++++++-------- src/Model/Entity/Fundingupload.php | 2 ++ src/Model/Table/FundingsTable.php | 13 ++++++-- .../status/zuwendungsbestaetigungStatus.php | 8 +++++ .../funding/zuwendungsbestaetigungInfo.php | 10 ++++-- .../zuwendungsbestaetigung_status_changed.php | 31 +++++++++++++++++ 11 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 config/Migrations/20241203155342_Fundings6.php create mode 100644 plugins/Admin/templates/element/list/fundings/zuwendungsbestaetigung.php create mode 100644 templates/element/funding/status/zuwendungsbestaetigungStatus.php create mode 100644 templates/email/html/fundings/zuwendungsbestaetigung_status_changed.php diff --git a/config/Migrations/20241203155342_Fundings6.php b/config/Migrations/20241203155342_Fundings6.php new file mode 100644 index 000000000..d6f90173c --- /dev/null +++ b/config/Migrations/20241203155342_Fundings6.php @@ -0,0 +1,15 @@ +execute($sql); + } +} diff --git a/plugins/Admin/src/Controller/FundingsController.php b/plugins/Admin/src/Controller/FundingsController.php index 915c40a81..f150d3404 100644 --- a/plugins/Admin/src/Controller/FundingsController.php +++ b/plugins/Admin/src/Controller/FundingsController.php @@ -107,6 +107,18 @@ private function sendEmails($funding) { ]); $email->addToQueue(); } + + if ($funding->isDirty('zuwendungsbestaetigung_status')) { + $email->viewBuilder()->setTemplate('fundings/zuwendungsbestaetigung_status_changed'); + $email->setSubject('Der Status deiner Zuwendungsbestätigung wurde geändert') + ->setTo($funding->owner_user->email) + ->setViewVars([ + 'funding' => $funding, + 'data' => $funding->owner_user, + ]); + $email->addToQueue(); + } + } public function index() @@ -124,6 +136,7 @@ public function index() 'Fundingsupporters', 'FundinguploadsActivityProofs', 'FundinguploadsFreistellungsbescheids', + 'FundinguploadsZuwendungsbestaetigungs', 'Fundingbudgetplans', ]); diff --git a/plugins/Admin/templates/Fundings/edit.php b/plugins/Admin/templates/Fundings/edit.php index 66c7e6025..aa546bcde 100644 --- a/plugins/Admin/templates/Fundings/edit.php +++ b/plugins/Admin/templates/Fundings/edit.php @@ -110,6 +110,23 @@ echo $this->element('funding/blocks/blockCheckboxes', ['funding' => $funding, 'disabled' => true]); + + if ($funding->is_submitted) { + echo $this->element('funding/fundingUploadsForm', [ + 'fundinguploads' => $funding->fundinguploads_zuwendungsbestaetigungs, + 'uploadType' => Fundingupload::TYPE_MAP[Fundingupload::TYPE_ZUWENDUNGSBESTAETIGUNG], + 'legend' => 'Upload Zuwendungsbestätigung', + ]); + + echo '
'; + echo 'Status Zuwendungsbestätigung'; + echo $this->element('funding/status/zuwendungsbestaetigungStatus', ['funding' => $funding, 'additionalTextBefore' => '', 'additionalTextAfter' => '']); + echo $this->Form->control('Fundings.zuwendungsbestaetigung_status', ['label' => 'Status', 'options' => Funding::STATUS_MAPPING_UPLOADS, 'disabled' => !$funding->is_submitted, 'class' => 'no-verify']); + echo $this->Form->control('Fundings.zuwendungsbestaetigung_comment', ['label' => 'Kommentar', 'disabled' => !$funding->is_submitted, 'class' => 'no-verify']); + echo '
'; + } + + echo ''; echo $this->element('cancelAndSaveButton', ['saveLabel' => 'Speichern']); diff --git a/plugins/Admin/templates/Fundings/index.php b/plugins/Admin/templates/Fundings/index.php index 603282d46..03dd5da79 100644 --- a/plugins/Admin/templates/Fundings/index.php +++ b/plugins/Admin/templates/Fundings/index.php @@ -15,6 +15,7 @@ ['name' => 'fundingsupporter.name', 'label' => 'Träger', 'sortable' => false], ['label' => 'Summe', 'template' => 'list/fundings/budgetplan', 'sortable' => false], ['label' => 'eingereicht', 'template' => 'list/fundings/submitInfo'], + ['label' => 'ZB', 'template' => 'list/fundings/zuwendungsbestaetigung'], ['name' => 'created', 'type' => 'datetime', 'label' => 'erstellt'], ['name' => 'modified', 'type' => 'datetime', 'label' => 'geändert'], ], diff --git a/plugins/Admin/templates/element/list/fundings/zuwendungsbestaetigung.php b/plugins/Admin/templates/element/list/fundings/zuwendungsbestaetigung.php new file mode 100644 index 000000000..2f1bc3661 --- /dev/null +++ b/plugins/Admin/templates/element/list/fundings/zuwendungsbestaetigung.php @@ -0,0 +1,7 @@ +is_submitted) { + return; +} +echo '
'; + echo $object->zuwendungsbestaetigungs_count . 'x'; +echo '
'; diff --git a/src/Model/Entity/Funding.php b/src/Model/Entity/Funding.php index d7c9296be..b9ae31d29 100644 --- a/src/Model/Entity/Funding.php +++ b/src/Model/Entity/Funding.php @@ -216,28 +216,25 @@ public function _getActivityProofStatusCssClass() { if (!empty($this->workshop) && !$this->workshop->funding_activity_proof_required) { return ''; } - - if ($this->activity_proof_status == self::STATUS_PENDING) { - return 'is-pending'; - } - if ($this->activity_proof_status == self::STATUS_VERIFIED_BY_ADMIN) { - return 'is-verified'; - } - if ($this->activity_proof_status == self::STATUS_REJECTED_BY_ADMIN) { - return 'is-rejected'; - } - return ''; + return $this->getAdminStatusCssClass('activity_proof_status'); } public function _getFreistellungsbescheidStatusCssClass() { + return $this->getAdminStatusCssClass('freistellungsbescheid_status'); + } + + public function _getZuwendungsbestaetigungStatusCssClass() { + return $this->getAdminStatusCssClass('zuwendungsbestaetigung_status'); + } - if ($this->freistellungsbescheid_status == self::STATUS_PENDING) { + private function getAdminStatusCssClass($statusField) { + if ($this->$statusField == self::STATUS_PENDING) { return 'is-pending'; } - if ($this->freistellungsbescheid_status == self::STATUS_VERIFIED_BY_ADMIN) { + if ($this->$statusField == self::STATUS_VERIFIED_BY_ADMIN) { return 'is-verified'; } - if ($this->freistellungsbescheid_status == self::STATUS_REJECTED_BY_ADMIN) { + if ($this->$statusField == self::STATUS_REJECTED_BY_ADMIN) { return 'is-rejected'; } return ''; @@ -273,6 +270,10 @@ public function _getFreistellungsbescheidStatusHumanReadable() { return self::STATUS_MAPPING_UPLOADS[$this->freistellungsbescheid_status]; } + public function _getZuwendungsbestaetigungStatusHumanReadable() { + return self::STATUS_MAPPING_UPLOADS[$this->zuwendungsbestaetigung_status]; + } + public static function getFieldsCount() { return count(self::FIELDS_WORKSHOP) + count(self::FIELDS_OWNER_USER) @@ -371,4 +372,8 @@ public function _getFreistellungsbescheidsCount(): int { return count($this->fundinguploads_freistellungsbescheids); } + public function _getZuwendungsbestaetigungsCount(): int { + return count($this->fundinguploads_zuwendungsbestaetigungs); + } + } \ No newline at end of file diff --git a/src/Model/Entity/Fundingupload.php b/src/Model/Entity/Fundingupload.php index 4d085c484..90dd1dab1 100644 --- a/src/Model/Entity/Fundingupload.php +++ b/src/Model/Entity/Fundingupload.php @@ -10,10 +10,12 @@ class Fundingupload extends Entity const TYPE_ACTIVITY_PROOF = 1; const TYPE_FREISTELLUNGSBESCHEID = 2; + const TYPE_ZUWENDUNGSBESTAETIGUNG = 3; const TYPE_MAP = [ self::TYPE_ACTIVITY_PROOF => 'activity_proofs', self::TYPE_FREISTELLUNGSBESCHEID => 'freistellungsbescheids', + self::TYPE_ZUWENDUNGSBESTAETIGUNG => 'zuwendungsbestaetigungs', ]; public function _getFullPath() { diff --git a/src/Model/Table/FundingsTable.php b/src/Model/Table/FundingsTable.php index 19b02a83d..89ee93725 100644 --- a/src/Model/Table/FundingsTable.php +++ b/src/Model/Table/FundingsTable.php @@ -36,7 +36,7 @@ public function initialize(array $config): void { 'className' => 'Fundinguploads', 'foreignKey' => 'funding_uid', 'conditions' => [ - 'FundinguploadsActivityProofs.type' => Fundingupload::TYPE_ACTIVITY_PROOF + 'FundinguploadsActivityProofs.type' => Fundingupload::TYPE_ACTIVITY_PROOF, ], 'dependent' => true, ]); @@ -44,7 +44,15 @@ public function initialize(array $config): void { 'className' => 'Fundinguploads', 'foreignKey' => 'funding_uid', 'conditions' => [ - 'FundinguploadsFreistellungsbescheids.type' => Fundingupload::TYPE_FREISTELLUNGSBESCHEID + 'FundinguploadsFreistellungsbescheids.type' => Fundingupload::TYPE_FREISTELLUNGSBESCHEID, + ], + 'dependent' => true, + ]); + $this->hasMany('FundinguploadsZuwendungsbestaetigungs', [ + 'className' => 'Fundinguploads', + 'foreignKey' => 'funding_uid', + 'conditions' => [ + 'FundinguploadsZuwendungsbestaetigungs.type' => Fundingupload::TYPE_ZUWENDUNGSBESTAETIGUNG, ], 'dependent' => true, ]); @@ -201,6 +209,7 @@ public function findOrCreateCustom($workshopUid) { 'Fundingsupporters', 'FundinguploadsActivityProofs', 'FundinguploadsFreistellungsbescheids', + 'FundinguploadsZuwendungsbestaetigungs', ])->first(); if (empty($funding->fundingbudgetplans)) { diff --git a/templates/element/funding/status/zuwendungsbestaetigungStatus.php b/templates/element/funding/status/zuwendungsbestaetigungStatus.php new file mode 100644 index 000000000..ae29bd00d --- /dev/null +++ b/templates/element/funding/status/zuwendungsbestaetigungStatus.php @@ -0,0 +1,8 @@ +zuwendungsbestaetigung_status_css_class . '">'; +echo '

' . $additionalTextBefore . $funding->zuwendungsbestaetigung_status_human_readable . $additionalTextAfter . '

'; + if ($funding->zuwendungsbestaetigung_comment != '') { + echo '

' . h($funding->zuwendungsbestaetigung_comment) . '

'; + } +echo ''; diff --git a/templates/element/funding/zuwendungsbestaetigungInfo.php b/templates/element/funding/zuwendungsbestaetigungInfo.php index 6f099a2d0..fdcc7447d 100644 --- a/templates/element/funding/zuwendungsbestaetigungInfo.php +++ b/templates/element/funding/zuwendungsbestaetigungInfo.php @@ -1,8 +1,12 @@ '; - echo 'Zuwendungsbestätigung: Bestätigung von Admin ausstehend (Der Upload wird in Kürze möglich sein)'; -echo ''; +echo $this->element('funding/status/zuwendungsbestaetigungStatus', [ + 'funding' => $funding, + 'additionalTextBefore' => 'Zuwendungsbestätigung: ', + 'additionalTextAfter' => ' - ' . $this->Html->link('Jetzt hochladen', [ + 'javascript:void(0)', + ]), +]); echo '