From 089bb95715723ffd0ab8708e5716c0f2c0afa460 Mon Sep 17 00:00:00 2001
From: Thomas Hackl <hackl@data-quest.de>
Date: Thu, 7 Oct 2021 09:19:02 +0000
Subject: [PATCH] TIC 11447 Freitext Raumbelegungsplan

---
 app/controllers/resources/admin.php           |  4 +++
 app/controllers/resources/print.php           |  4 +++
 app/views/resources/admin/configuration.php   |  6 +++++
 app/views/resources/print/clipboard_rooms.php |  6 +++++
 .../20210421_freetext_in_room_export.php      | 27 +++++++++++++++++++
 5 files changed, 47 insertions(+)
 create mode 100644 db/migrations/20210421_freetext_in_room_export.php

diff --git a/app/controllers/resources/admin.php b/app/controllers/resources/admin.php
index 0ce8d41fc20..80a6c26e8fb 100644
--- a/app/controllers/resources/admin.php
+++ b/app/controllers/resources/admin.php
@@ -1209,6 +1209,10 @@ class Resources_AdminController extends AuthenticatedController
                 'RESOURCES_BOOKING_PLAN_END_HOUR',
                 $this->resources_booking_plan_end_hour
             );
+            $this->config->store(
+                'RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT',
+                Studip\Markup::purifyHtml(Request::get('additional_text'))
+            );
 
             $this->config->store(
                 'RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT',
diff --git a/app/controllers/resources/print.php b/app/controllers/resources/print.php
index a21db5e847f..292f8b80814 100644
--- a/app/controllers/resources/print.php
+++ b/app/controllers/resources/print.php
@@ -142,6 +142,10 @@ class Resources_PrintController extends AuthenticatedController
             2 => _('Sperrbuchung'),
             3 => _('Planungsbuchung')
         ];
+
+        // Get additional text to print
+        $this->additional_text = Config::get()->RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT;
+
         if (!$this->clipboard_selected && !$this->print_schedules) {
             //We have to load all selectable clipboards of the current user:
             $this->available_clipboards = Clipboard::getClipboardsForUser(
diff --git a/app/views/resources/admin/configuration.php b/app/views/resources/admin/configuration.php
index 62c1d886bbc..23ade8d19c0 100644
--- a/app/views/resources/admin/configuration.php
+++ b/app/views/resources/admin/configuration.php
@@ -128,6 +128,12 @@
                 <? endforeach ?>
             </select>
         </label>
+        <label>
+            <?= _('Zusatztext, der beim Seriendruck unter jedem Raumplan angezeigt werden soll') ?>
+            <textarea class="add_toolbar wysiwyg" name="additional_text" cols="75" rows="4">
+                <?= wysiwygReady($config->RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT) ?>
+            </textarea>
+        </label>
     </fieldset>
     <?= \Studip\Button::create(_('Speichern'), 'save') ?>
 </form>
diff --git a/app/views/resources/print/clipboard_rooms.php b/app/views/resources/print/clipboard_rooms.php
index 0cba520d95d..320280905e6 100644
--- a/app/views/resources/print/clipboard_rooms.php
+++ b/app/views/resources/print/clipboard_rooms.php
@@ -177,6 +177,12 @@
                 ],
                 ['class' => 'resource-plan']
             ) ?>
+            <? if ($additional_text != '') : ?>
+                <div>
+                    <br>
+                    <?= formatReady($additional_text) ?>
+                </div>
+            <? endif ?>
         </section>
     <? endforeach ?>
 <? endif ?>
diff --git a/db/migrations/20210421_freetext_in_room_export.php b/db/migrations/20210421_freetext_in_room_export.php
new file mode 100644
index 00000000000..f978a237fba
--- /dev/null
+++ b/db/migrations/20210421_freetext_in_room_export.php
@@ -0,0 +1,27 @@
+<?php
+class FreetextInRoomExport extends Migration
+{
+    public function description()
+    {
+        return 'Adds a global freetext for placing in room exports';
+    }
+
+    protected function up()
+    {
+        $query = "INSERT IGNORE INTO `config` (
+                `field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`
+            ) VALUES (
+                'RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT', '', 'string', 'global', 'resources', UNIX_TIMESTAMP(),
+                UNIX_TIMESTAMP(), 'Zusatztext, der beim Seriendruck unter jedem Raumplan angezeigt werden soll'
+            )";
+        DBManager::get()->exec($query);
+    }
+
+    protected function down()
+    {
+        $query = "DELETE FROM `config` WHERE `field` = 'RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT'";
+        DBManager::get()->exec($query);
+        $query = "DELETE FROM `config_values` WHERE `field` = 'RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT'";
+        DBManager::get()->exec($query);
+    }
+}
-- 
GitLab