From 5299ca210319b324564a889dcb2d7b651117f7eb Mon Sep 17 00:00:00 2001 From: msquare Date: Tue, 15 Nov 2016 17:54:59 +0100 Subject: [PATCH] reduce complexity of shift view --- includes/view/EventConfig_view.php | 4 +- includes/view/Shifts_view.php | 83 ++++++++++++---------- locale/de_DE.UTF-8/LC_MESSAGES/default.mo | Bin 41201 -> 41205 bytes locale/de_DE.UTF-8/LC_MESSAGES/default.po | 8 +-- 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php index 7c369bb0..d184166f 100644 --- a/includes/view/EventConfig_view.php +++ b/includes/view/EventConfig_view.php @@ -48,7 +48,7 @@ function EventConfig_info($event_config) { // Event name, start+end date are set if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { - return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date("Y-m-d", $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date'])); + return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date'])); } // Event name, start date are set @@ -58,7 +58,7 @@ function EventConfig_info($event_config) { // Event start+end date are set if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { - return sprintf(_("Event from %s to %s"), date("Y-m-d", $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date'])); + return sprintf(_("Event from %s to %s"), date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date'])); } // Only event name is set diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index c53bf972..7ad580f4 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -45,40 +45,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts, $needed_angels = ''; foreach ($shift['NeedAngels'] as $needed_angeltype) { - $class = 'progress-bar-warning'; - if ($needed_angeltype['taken'] == 0) { - $class = 'progress-bar-danger'; - } - if ($needed_angeltype['taken'] >= $needed_angeltype['count']) { - $class = 'progress-bar-success'; - } - $needed_angels .= '
'; - - $needed_angels .= '
' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '
'; - - $needed_angels .= '

' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '

'; - $needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); - - $angels = []; - foreach ($shift['ShiftEntry'] as $shift_entry) { - if ($shift_entry['TID'] == $needed_angeltype['TID']) { - $entry = User_Nick_render(User($shift_entry['UID'])); - if ($shift_entry['freeloaded']) { - $entry = '' . $entry . ''; - } - if ($user_shift_admin) { - $entry .= '
'; - $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs'); - $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs'); - $entry .= '
'; - } - $angels[] = $entry; - } - } - - $needed_angels .= join(', ', $angels); - - $needed_angels .= '
'; + $needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin); } return page_with_title($shift['name'] . ' %c', [ @@ -99,7 +66,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts, div('col-sm-3 col-xs-6', [ '

' . _('Start') . '

', '

', - glyph('calendar') . date('Y-m-d', $shift['start']), + glyph('calendar') . date(_('Y-m-d'), $shift['start']), '
', glyph('time') . date('H:i', $shift['start']), '

' @@ -107,7 +74,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts, div('col-sm-3 col-xs-6', [ '

' . _('End') . '

', '

', - glyph('calendar') . date('Y-m-d', $shift['end']), + glyph('calendar') . date(_('Y-m-d'), $shift['end']), '
', glyph('time') . date('H:i', $shift['end']), '

' @@ -131,6 +98,50 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts, ]); } +function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin) { + $needed_angels = ''; + + $class = 'progress-bar-warning'; + if ($needed_angeltype['taken'] == 0) { + $class = 'progress-bar-danger'; + } + if ($needed_angeltype['taken'] >= $needed_angeltype['count']) { + $class = 'progress-bar-success'; + } + $needed_angels .= '
'; + + $needed_angels .= '
' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '
'; + + $needed_angels .= '

' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '

'; + $needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); + + $angels = []; + foreach ($shift['ShiftEntry'] as $shift_entry) { + if ($shift_entry['TID'] == $needed_angeltype['TID']) { + $angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin); + } + } + + $needed_angels .= join(', ', $angels); + $needed_angels .= '
'; + + return $needed_angels; +} + +function Shift_view_render_shift_entry($shift_entry, $user_shift_admin) { + $entry = User_Nick_render(User($shift_entry['UID'])); + if ($shift_entry['freeloaded']) { + $entry = '' . $entry . ''; + } + if ($user_shift_admin) { + $entry .= '
'; + $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs'); + $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs'); + $entry .= '
'; + } + return $entry; +} + /** * Calc shift length in format 12:23h. * diff --git a/locale/de_DE.UTF-8/LC_MESSAGES/default.mo b/locale/de_DE.UTF-8/LC_MESSAGES/default.mo index 5b99222242d71a147d4a15b79b2049bbbad996e9..7e98477ddc7420ba2a6c24b45e681296d650cfcd 100644 GIT binary patch delta 4190 zcmXZfc~I6x9LMn$JRS}O!81f25fnqrq!7^*k2Ji-F>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Vz*OWDQ-w*Gw%-0SPQ^mvH&D0hDo#f){3Bzi zhFO66AasNMAxT4>@|SQS7Gn|KMGY`(qrGkwsETaEIIKmL{v^iWEqoC}IUq{30DI#G z9HZlMghqEd!Z!1t3mkw?;#}08)?gYQK&|)=4#WOiY@$BYdz-N}?nLcv4YtECP+R#m zYO7A7&dzBJ)^WY$Ubux1@t}339UvMbh`YJ?3DiVGo#RnkG#NEf0jgpps6$+is?2)S zp{z!IzXOBu3rzE9G`NlyXWJ^9VWhK*GYOSoU(}%-i<&40wW53s#W|=Im!c;85cRwY zHSrEqh3YX;4-V3hM^PpE5w-GD=!Z9IOX4!0s;JCqTYEew(l4SQF3}g4`\n" "Language-Team: \n" "Language: de_DE\n" @@ -2027,7 +2027,7 @@ msgstr "Wir haben aktuell keine Informationen über das Event." #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:19 #, php-format msgid "from %s to %s" -msgstr "von %s bis %s" +msgstr "vom %s bis %s" #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:23 #, php-format @@ -2052,7 +2052,7 @@ msgstr "Abbau endet in %c" #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:51 #, php-format msgid "%s, from %s to %s" -msgstr "%s, von %s bis %s" +msgstr "%s, vom %s bis %s" #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:51 #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:56 @@ -2063,7 +2063,7 @@ msgstr "d.m.Y" #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:56 #, php-format msgid "%s, starting %s" -msgstr "%s, ab %s" +msgstr "%s, ab dem %s" #: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:61 #, php-format