Optional description for shifts

This commit is contained in:
xuwhite 2021-11-27 11:34:20 +01:00 committed by GitHub
parent 6c783e7faa
commit a1f5454bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 7 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddShiftsDescription extends Migration
{
use Reference;
/**
* Run the migration
*/
public function up()
{
$this->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');
}
);
}
}

View File

@ -86,6 +86,7 @@ function shift_edit_controller()
$shifttype_id = $shift['shifttype_id']; $shifttype_id = $shift['shifttype_id'];
$title = $shift['title']; $title = $shift['title'];
$description = $shift['description'];
$rid = $shift['RID']; $rid = $shift['RID'];
$start = $shift['start']; $start = $shift['start'];
$end = $shift['end']; $end = $shift['end'];
@ -93,6 +94,7 @@ function shift_edit_controller()
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
// Name/Bezeichnung der Schicht, darf leer sein // Name/Bezeichnung der Schicht, darf leer sein
$title = strip_request_item('title'); $title = strip_request_item('title');
$description = strip_request_item('description');
// Auswahl der sichtbaren Locations für die Schichten // Auswahl der sichtbaren Locations für die Schichten
if ( if (
@ -152,6 +154,7 @@ function shift_edit_controller()
if ($valid) { if ($valid) {
$shift['shifttype_id'] = $shifttype_id; $shift['shifttype_id'] = $shifttype_id;
$shift['title'] = $title; $shift['title'] = $title;
$shift['description'] = $description;
$shift['RID'] = $rid; $shift['RID'] = $rid;
$shift['start'] = $start; $shift['start'] = $start;
$shift['end'] = $end; $shift['end'] = $end;
@ -171,6 +174,7 @@ function shift_edit_controller()
. '\' from ' . date('Y-m-d H:i', $start) . '\' from ' . date('Y-m-d H:i', $start)
. ' to ' . date('Y-m-d H:i', $end) . ' to ' . date('Y-m-d H:i', $end)
. ' with angel types ' . join(', ', $needed_angel_types_info) . ' with angel types ' . join(', ', $needed_angel_types_info)
. ' and description ' . $description
); );
success(__('Shift updated.')); success(__('Shift updated.'));
@ -199,6 +203,8 @@ function shift_edit_controller()
form_select('rid', __('Room:'), $rooms, $rid), form_select('rid', __('Room:'), $rooms, $rid),
form_text('start', __('Start:'), date('Y-m-d H:i', $start)), form_text('start', __('Start:'), date('Y-m-d H:i', $start)),
form_text('end', __('End:'), date('Y-m-d H:i', $end)), 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.'),
'<h2>' . __('Needed angels') . '</h2>', '<h2>' . __('Needed angels') . '</h2>',
$angel_types_spinner, $angel_types_spinner,
form_submit('submit', __('Save')) form_submit('submit', __('Save'))

View File

@ -535,6 +535,7 @@ function Shift_update($shift)
`end` = ?, `end` = ?,
`RID` = ?, `RID` = ?,
`title` = ?, `title` = ?,
`description` = ?,
`URL` = ?, `URL` = ?,
`edited_by_user_id` = ?, `edited_by_user_id` = ?,
`edited_at_timestamp` = ? `edited_at_timestamp` = ?
@ -546,6 +547,7 @@ function Shift_update($shift)
$shift['end'], $shift['end'],
$shift['RID'], $shift['RID'],
$shift['title'], $shift['title'],
$shift['description'],
$shift['URL'], $shift['URL'],
$user->id, $user->id,
time(), time(),
@ -569,12 +571,13 @@ function Shift_create($shift)
`end`, `end`,
`RID`, `RID`,
`title`, `title`,
`description`,
`URL`, `URL`,
`created_by_user_id`, `created_by_user_id`,
`edited_at_timestamp`, `edited_at_timestamp`,
`created_at_timestamp` `created_at_timestamp`
) )
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
', ',
[ [
$shift['shifttype_id'], $shift['shifttype_id'],
@ -582,6 +585,7 @@ function Shift_create($shift)
$shift['end'], $shift['end'],
$shift['RID'], $shift['RID'],
$shift['title'], $shift['title'],
$shift['description'],
$shift['URL'], $shift['URL'],
auth()->user()->id, auth()->user()->id,
time(), time(),

View File

@ -29,6 +29,7 @@ function admin_shifts()
$change_hours = []; $change_hours = [];
$title = ''; $title = '';
$shifttype_id = null; $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 // When true: creates a shift beginning at the last shift change hour and ending at the first shift change hour
$shift_over_midnight = true; $shift_over_midnight = true;
@ -70,6 +71,9 @@ function admin_shifts()
// Name/Bezeichnung der Schicht, darf leer sein // Name/Bezeichnung der Schicht, darf leer sein
$title = strip_request_item('title'); $title = strip_request_item('title');
// Beschreibung der Schicht, darf leer sein
$description = strip_request_item('description');
// Auswahl der sichtbaren Locations für die Schichten // Auswahl der sichtbaren Locations für die Schichten
if ( if (
$request->has('rid') $request->has('rid')
@ -194,7 +198,8 @@ function admin_shifts()
'end' => $end, 'end' => $end,
'RID' => $rid, 'RID' => $rid,
'title' => $title, 'title' => $title,
'shifttype_id' => $shifttype_id 'shifttype_id' => $shifttype_id,
'description' => $description,
]; ];
} elseif ($mode == 'multi') { } elseif ($mode == 'multi') {
$shift_start = (int)$start; $shift_start = (int)$start;
@ -213,7 +218,8 @@ function admin_shifts()
'end' => $shift_end, 'end' => $shift_end,
'RID' => $rid, 'RID' => $rid,
'title' => $title, 'title' => $title,
'shifttype_id' => $shifttype_id 'shifttype_id' => $shifttype_id,
'description' => $description,
]; ];
$shift_start = $shift_end; $shift_start = $shift_end;
@ -323,6 +329,7 @@ function admin_shifts()
form([ form([
$hidden_types, $hidden_types,
form_hidden('shifttype_id', $shifttype_id), form_hidden('shifttype_id', $shifttype_id),
form_hidden('description', $description),
form_hidden('title', $title), form_hidden('title', $title),
form_hidden('rid', $rid), form_hidden('rid', $rid),
form_hidden('start', date('Y-m-d H:i', $start)), form_hidden('start', date('Y-m-d H:i', $start)),
@ -357,6 +364,7 @@ function admin_shifts()
engelsystem_log( engelsystem_log(
'Shift created: ' . $shifttypes[$shift['shifttype_id']] 'Shift created: ' . $shifttypes[$shift['shifttype_id']]
. ' with title ' . $shift['title'] . ' with title ' . $shift['title']
. ' with description ' . $shift['description']
. ' from ' . date('Y-m-d H:i', $shift['start']) . ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end']) . ' to ' . date('Y-m-d H:i', $shift['end'])
); );
@ -413,9 +421,17 @@ function admin_shifts()
return page_with_title(admin_shifts_title(), [ return page_with_title(admin_shifts_title(), [
msg(), msg(),
form([ form([
div('row',[
div('col-md-6', [
form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id), form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id),
form_text('title', __('Title'), $title), form_text('title', __('Title'), $title),
form_select('rid', __('Room'), $room_array, $rid), 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('row', [
div('col-md-6', [ div('col-md-6', [
form_datetime('start', __('Start'), $start), form_datetime('start', __('Start'), $start),

View File

@ -176,7 +176,8 @@ function Shift_view($shift, $shifttype, Room $room, $angeltypes_source, ShiftSig
]), ]),
div('col-sm-6', [ div('col-sm-6', [
'<h2>' . __('Description') . '</h2>', '<h2>' . __('Description') . '</h2>',
$parsedown->parse($shifttype['description']) $parsedown->parse($shifttype['description']),
$parsedown->parse($shift['description']),
]) ])
]); ]);

View File

@ -1418,6 +1418,13 @@ msgstr "Karte"
msgid "Create shifts" msgid "Create shifts"
msgstr "Schichten erstellen" 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 #: includes/pages/admin_shifts.php:82
msgid "Please select a location." msgid "Please select a location."
msgstr "Bitte einen Ort auswählen." msgstr "Bitte einen Ort auswählen."