From fedfaac61d5e8d615be418ed5a5fa28a09d80d36 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Wed, 18 Jun 2025 14:09:59 +0200 Subject: [PATCH] added new file upload and bug fix --- Layout/default/ConstructionConsent/View.php | 22 +++++++++++++--- .../ConstructionConsentJournal.php | 2 +- .../ConstructionConsentJournalController.php | 11 ++++++++ ...133701_constr_consent_add_journal_file.php | 25 +++++++++++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 db/migrations/20250618133701_constr_consent_add_journal_file.php diff --git a/Layout/default/ConstructionConsent/View.php b/Layout/default/ConstructionConsent/View.php index 804ae4a22..8cb43e73c 100644 --- a/Layout/default/ConstructionConsent/View.php +++ b/Layout/default/ConstructionConsent/View.php @@ -437,9 +437,10 @@ $pagination_entity_name = "Adressen";
@@ -452,6 +453,19 @@ $pagination_entity_name = "Adressen"; create)?> (creator?>) text)?> + file_id): ?> + $j->file_id])?>" class="ml-2"> + file_id); + if ($file->fileExists()) { + echo $file->filename; + } else { + echo "Datei nicht gefunden"; + } + ?> + + + @@ -1161,8 +1175,8 @@ $pagination_entity_name = "Adressen"; notify("error", "Begründung muss mindestens 3 Zeichen lang sein"); $(this).prop("checked", false); switcheries.forEach(s => s.setPosition()); - ret - if (reason != null) { + return; + } if (true) { $.post("", { consent_id: id?>, text: `Genehmigung überschreiben wurde ${$(this).prop("checked") ? "aktiviert" : "deaktiviert"} | Begründung: ${reason}` @@ -1191,7 +1205,7 @@ $pagination_entity_name = "Adressen"; } }, 'json'); } - }}); + }); // do the same for prioritize $("#prioritize").on("change", function() { diff --git a/application/ConstructionConsentJournal/ConstructionConsentJournal.php b/application/ConstructionConsentJournal/ConstructionConsentJournal.php index 19da43bc6..b32d1e29d 100644 --- a/application/ConstructionConsentJournal/ConstructionConsentJournal.php +++ b/application/ConstructionConsentJournal/ConstructionConsentJournal.php @@ -65,7 +65,7 @@ class ConstructionConsentJournal extends mfBaseModel { $model = new ConstructionConsentJournal(); $table_fields = [ - "constructionconsent_id", "text", + "constructionconsent_id", "text", "file_id", "create_by","edit_by","create","edit" ]; diff --git a/application/ConstructionConsentJournal/ConstructionConsentJournalController.php b/application/ConstructionConsentJournal/ConstructionConsentJournalController.php index c1b8566ca..eb7997513 100644 --- a/application/ConstructionConsentJournal/ConstructionConsentJournalController.php +++ b/application/ConstructionConsentJournal/ConstructionConsentJournalController.php @@ -44,8 +44,19 @@ class ConstructionConsentJournalController extends mfBaseController { } + try { + $uploaded = mfUpload::handleFormUpload("file", false, "/ConstructionConsentJournal"); + } catch (Exception $e) { + var_dump($e->getMessage()); + die(); + $this->layout()->setFlash("Fehler beim speichern!", "error"); + $this->redirect("ConstructionConsent", "View", ["id" => $consent->id]); + } + + $journal = ConstructionConsentJournal::create([ "constructionconsent_id" => $consent->id, + "file_id" => $uploaded->id, "text" => $text ]); diff --git a/db/migrations/20250618133701_constr_consent_add_journal_file.php b/db/migrations/20250618133701_constr_consent_add_journal_file.php new file mode 100644 index 000000000..aa92d3083 --- /dev/null +++ b/db/migrations/20250618133701_constr_consent_add_journal_file.php @@ -0,0 +1,25 @@ +getEnvironment() == "thetool") { + $table = $this->table('ConstructionConsentJournal'); + $table->addColumn('file_id', 'integer', ['null' => true, 'after' => 'text']) + ->save(); + } + } + + public function down(): void + { + if ($this->getEnvironment() == "thetool") { + $table = $this->table('ConstructionConsentJournal'); + $table->removeColumn('file_id') + ->save(); + } + } +} \ No newline at end of file