diff --git a/db/migrations/2021_10_12_000000_add_shifts_description.php b/db/migrations/2021_10_12_000000_add_shifts_description.php new file mode 100644 index 00000000..15faeb97 --- /dev/null +++ b/db/migrations/2021_10_12_000000_add_shifts_description.php @@ -0,0 +1,37 @@ +schema->table( + 'Shifts', + function (Blueprint $table) { + $table->text('description')->nullable()->after('shifttype_id'); + } + ); + } + + /** + * Reverse the migration + */ + public function down() + { + $this->schema->table( + 'Shifts', + function (Blueprint $table) { + $table->dropColumn('description'); + } + ); + } +} diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php index 8036a537..bd3dcdc0 100644 --- a/includes/controller/shifts_controller.php +++ b/includes/controller/shifts_controller.php @@ -86,6 +86,7 @@ function shift_edit_controller() $shifttype_id = $shift['shifttype_id']; $title = $shift['title']; + $description = $shift['description']; $rid = $shift['RID']; $start = $shift['start']; $end = $shift['end']; @@ -93,6 +94,7 @@ function shift_edit_controller() if ($request->hasPostData('submit')) { // Name/Bezeichnung der Schicht, darf leer sein $title = strip_request_item('title'); + $description = strip_request_item('description'); // Auswahl der sichtbaren Locations für die Schichten if ( @@ -152,6 +154,7 @@ function shift_edit_controller() if ($valid) { $shift['shifttype_id'] = $shifttype_id; $shift['title'] = $title; + $shift['description'] = $description; $shift['RID'] = $rid; $shift['start'] = $start; $shift['end'] = $end; @@ -171,6 +174,7 @@ function shift_edit_controller() . '\' from ' . date('Y-m-d H:i', $start) . ' to ' . date('Y-m-d H:i', $end) . ' with angel types ' . join(', ', $needed_angel_types_info) + . ' and description ' . $description ); success(__('Shift updated.')); @@ -199,6 +203,8 @@ function shift_edit_controller() form_select('rid', __('Room:'), $rooms, $rid), form_text('start', __('Start:'), date('Y-m-d H:i', $start)), form_text('end', __('End:'), date('Y-m-d H:i', $end)), + form_textarea('description', __('Additional description'), $description), + __('This description is for single shifts, otherwise please use the description in shift type.'), '

' . __('Needed angels') . '

', $angel_types_spinner, form_submit('submit', __('Save')) diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 96ec0033..b071a069 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -535,6 +535,7 @@ function Shift_update($shift) `end` = ?, `RID` = ?, `title` = ?, + `description` = ?, `URL` = ?, `edited_by_user_id` = ?, `edited_at_timestamp` = ? @@ -546,6 +547,7 @@ function Shift_update($shift) $shift['end'], $shift['RID'], $shift['title'], + $shift['description'], $shift['URL'], $user->id, time(), @@ -569,12 +571,13 @@ function Shift_create($shift) `end`, `RID`, `title`, + `description`, `URL`, `created_by_user_id`, `edited_at_timestamp`, `created_at_timestamp` ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ', [ $shift['shifttype_id'], @@ -582,6 +585,7 @@ function Shift_create($shift) $shift['end'], $shift['RID'], $shift['title'], + $shift['description'], $shift['URL'], auth()->user()->id, time(), diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index cf5ed47b..bc3414fe 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -29,6 +29,7 @@ function admin_shifts() $change_hours = []; $title = ''; $shifttype_id = null; + $description = null; // When true: creates a shift beginning at the last shift change hour and ending at the first shift change hour $shift_over_midnight = true; @@ -70,6 +71,9 @@ function admin_shifts() // Name/Bezeichnung der Schicht, darf leer sein $title = strip_request_item('title'); + // Beschreibung der Schicht, darf leer sein + $description = strip_request_item('description'); + // Auswahl der sichtbaren Locations für die Schichten if ( $request->has('rid') @@ -194,7 +198,8 @@ function admin_shifts() 'end' => $end, 'RID' => $rid, 'title' => $title, - 'shifttype_id' => $shifttype_id + 'shifttype_id' => $shifttype_id, + 'description' => $description, ]; } elseif ($mode == 'multi') { $shift_start = (int)$start; @@ -213,7 +218,8 @@ function admin_shifts() 'end' => $shift_end, 'RID' => $rid, 'title' => $title, - 'shifttype_id' => $shifttype_id + 'shifttype_id' => $shifttype_id, + 'description' => $description, ]; $shift_start = $shift_end; @@ -323,6 +329,7 @@ function admin_shifts() form([ $hidden_types, form_hidden('shifttype_id', $shifttype_id), + form_hidden('description', $description), form_hidden('title', $title), form_hidden('rid', $rid), form_hidden('start', date('Y-m-d H:i', $start)), @@ -357,6 +364,7 @@ function admin_shifts() engelsystem_log( 'Shift created: ' . $shifttypes[$shift['shifttype_id']] . ' with title ' . $shift['title'] + . ' with description ' . $shift['description'] . ' from ' . date('Y-m-d H:i', $shift['start']) . ' to ' . date('Y-m-d H:i', $shift['end']) ); @@ -413,9 +421,17 @@ function admin_shifts() return page_with_title(admin_shifts_title(), [ msg(), form([ - form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id), - form_text('title', __('Title'), $title), - form_select('rid', __('Room'), $room_array, $rid), + div('row',[ + div('col-md-6', [ + form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id), + form_text('title', __('Title'), $title), + form_select('rid', __('Room'), $room_array, $rid), + ]), + div('col-md-6', [ + form_textarea('description', __('Additional description'), $description), + __('This description is for single shifts, otherwise please use the description in shift type.'), + ]), + ]), div('row', [ div('col-md-6', [ form_datetime('start', __('Start'), $start), diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 4313ca14..e4a2df6c 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -176,7 +176,8 @@ function Shift_view($shift, $shifttype, Room $room, $angeltypes_source, ShiftSig ]), div('col-sm-6', [ '

' . __('Description') . '

', - $parsedown->parse($shifttype['description']) + $parsedown->parse($shifttype['description']), + $parsedown->parse($shift['description']), ]) ]); diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index f2b1ac63..e9312809 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -1418,6 +1418,13 @@ msgstr "Karte" msgid "Create shifts" msgstr "Schichten erstellen" +#: includes/pages/admin_shifts.php +msgid "Additional description" +msgstr "Zusätzliche Beschreibung" + +msgid "This description is for single shifts, otherwise please use the description in shift type." +msgstr "Diese Beschreibung ist für einzelne Schichten, ansonsten nutze bitte die Beschreibung im Schichttyp." + #: includes/pages/admin_shifts.php:82 msgid "Please select a location." msgstr "Bitte einen Ort auswählen."