From db8b6b25202efb2011d15afc28d748177b2bc819 Mon Sep 17 00:00:00 2001 From: msquare Date: Sat, 16 Sep 2017 17:14:45 +0200 Subject: change shift renderer global add user link --- includes/controller/shift_entries_controller.php | 11 ++++++++--- includes/view/ShiftCalendarShiftRenderer.php | 14 ++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'includes') diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php index 150db2e9..15aeaab1 100644 --- a/includes/controller/shift_entries_controller.php +++ b/includes/controller/shift_entries_controller.php @@ -32,14 +32,19 @@ function shift_entry_add_controller() } $shift['Name'] = $room_array[$shift['RID']]; - $type_id = 0; + $type_id = null; if ($request->has('type_id') && preg_match('/^\d+$/', $request->input('type_id'))) { $type_id = $request->input('type_id'); - } else { - redirect(page_link_to('user_shifts')); } if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) { + if($type_id == null) { + // If no angeltype id is given, then select first existing angeltype. + $needed_angeltypes = NeededAngelTypes_by_shift($shift_id); + if(count($needed_angeltypes) > 0) { + $type_id = $needed_angeltypes[0]['id']; + } + } $type = AngelType($type_id); } else { // TODO: Move queries to model diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 0e5fc8c3..3e59d61a 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -124,14 +124,12 @@ class ShiftCalendarShiftRenderer } if (in_array('user_shifts_admin', $privileges)) { - $html .= '
  • ' . _('Add more angels') . ':'; - foreach ($needed_angeltypes as $angeltype) { - $html .= ' ' . button( - page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]), - $angeltype['name'], - 'btn-xs' - ); - } + $html .= '
  • '; + $html .= button( + page_link_to('user_shifts', ['shift_id' => $shift['SID']]), + glyph('plus') . _('Add more angels'), + 'btn-xs' + ); $html .= '
  • '; } if ($html != '') { -- cgit v1.2.3-54-g00ecf