diff options
author | jwacalex <aboehm@dompfaffenweg.de> | 2016-11-30 23:23:49 +0100 |
---|---|---|
committer | jwacalex <aboehm@dompfaffenweg.de> | 2016-11-30 23:23:49 +0100 |
commit | 45cda10479a16c237f917b69dc24ab3f31bffa89 (patch) | |
tree | 5aa98a6504d7558b56b7777f04b87a3b976bbedf /includes/view | |
parent | 79b9f9448e4f3ad7abb8d795c1404b3221c95bf9 (diff) | |
parent | 53e12065c76af4e5a0a2690e92e6724eed9f2895 (diff) |
merged master and issue
Diffstat (limited to 'includes/view')
-rw-r--r-- | includes/view/AngelTypes_view.php | 12 | ||||
-rw-r--r-- | includes/view/EventConfig_view.php | 40 | ||||
-rw-r--r-- | includes/view/Questions_view.php | 2 | ||||
-rw-r--r-- | includes/view/ShiftTypes_view.php | 1 | ||||
-rw-r--r-- | includes/view/Shifts_view.php | 6 | ||||
-rw-r--r-- | includes/view/User_view.php | 121 |
6 files changed, 111 insertions, 71 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index 77e2fbb6..ce316bb7 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -49,7 +49,7 @@ function AngelType_delete_view($angeltype) { /** * Render angeltype edit form. - * + * * @param Angeltype $angeltype * The angeltype to edit * @param boolean $supporter_mode @@ -66,8 +66,7 @@ function AngelType_edit_view($angeltype, $supporter_mode) { $supporter_mode ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']), $supporter_mode ? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No")) : form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']), $supporter_mode ? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $angeltype['requires_driver_license']), - form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")), - form_info("", _("Disabled Self Sign Up prevents angels form self assigning to a shift. They have to been added by coordinator.")), + form_info("", _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")), form_textarea('description', _("Description"), $angeltype['description']), form_info("", _("Please use markdown for the description.")), form_submit('submit', _("Save")) @@ -195,8 +194,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes) */ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) { $page = [ - msg(), - AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user) + AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user), + msg() ]; $page[] = '<h3>' . _("Description") . '</h3>'; @@ -292,9 +291,6 @@ function AngelTypes_about_view_angeltype($angeltype) { if ($angeltype['restricted']) { $html .= info(_("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."), true); } - if ($angeltype['no_self_signup']) { - $html .= info(_("This angeltype is unable to self sign up for shifts. Please show up at the according introduction meetings."), true); - } if ($angeltype['description'] != "") { $html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; } diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php index d184166f..37a19839 100644 --- a/includes/view/EventConfig_view.php +++ b/includes/view/EventConfig_view.php @@ -6,33 +6,49 @@ */ function EventConfig_countdown_page($event_config) { if ($event_config == null) { - return info(_("We got no information about the event right now."), true); + return div('col-md-12 text-center', [ + heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2) + ]); } $elements = []; if ($event_config['event_name'] != null) { - $elements[] = heading($event_config['event_name'], 2); - } - - if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { - $elements[] = sprintf(_("from %s to %s"), date("Y-m-d", $event_config['event_start_date']), date("Y-m-d", $event_config['event_end_date'])); + $elements[] = div('col-sm-12 text-center', [ + heading(sprintf(_("Welcome to the %s!"), $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'), 2) + ]); } if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) { - $elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['buildup_start_date'] . '">' . _("Buildup starts in %c") . '</h2>'; + $elements[] = div('col-sm-3 text-center hidden-xs', [ + heading(_("Buildup starts"), 4), + '<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>', + '<small>' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '</small>' + ]); } if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) { - $elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['event_start_date'] . '">' . _("Event starts in %c") . '</h2>'; + $elements[] = div('col-sm-3 text-center hidden-xs', [ + heading(_("Event starts"), 4), + '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>', + '<small>' . date(_("Y-m-d"), $event_config['event_start_date']) . '</small>' + ]); } - if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date'] && ($event_config['event_start_date'] == null || time() > $event_config['event_start_date'])) { - $elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['event_end_date'] . '">' . _("Event ends in %c") . '</h2>'; + if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) { + $elements[] = div('col-sm-3 text-center hidden-xs', [ + heading(_("Event ends"), 4), + '<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>', + '<small>' . date(_("Y-m-d"), $event_config['event_end_date']) . '</small>' + ]); } - if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date'] && ($event_config['event_start_date'] == null || time() > $event_config['event_start_date'])) { - $elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['teardown_end_date'] . '">' . _("Teardown ends in %c") . '</h2>'; + if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) { + $elements[] = div('col-sm-3 text-center hidden-xs', [ + heading(_("Teardown ends"), 4), + '<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>', + '<small>' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '</small>' + ]); } return join("", $elements); diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php index bdcb8a86..a44a29d1 100644 --- a/includes/view/Questions_view.php +++ b/includes/view/Questions_view.php @@ -26,7 +26,7 @@ function Questions_view($open_questions, $answered_questions, $ask_action) { 'Answer' => _("Answer"), 'actions' => "" ], $answered_questions), - heading(_("Ask an archangel"), 2), + heading(_("Ask the Heaven"), 2), form([ form_textarea('question', _("Your Question:"), ""), form_submit('submit', _("Save")) diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php index 163d6646..3e4cccc6 100644 --- a/includes/view/ShiftTypes_view.php +++ b/includes/view/ShiftTypes_view.php @@ -55,6 +55,7 @@ function ShiftType_view($shifttype, $angeltype) { button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'), button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete') ]), + heading(_("Description"), 2), $parsedown->parse($shifttype['description']) ]); } diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 885d1ad9..fbd71d54 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -81,7 +81,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt ]), div('col-sm-3 col-xs-6', [ '<h4>' . _('Location') . '</h4>', - '<p class="lead">' . glyph('map-marker') . $room['Name'] . '</p>' + '<p class="lead">' . Room_name_render($room) . '</p>' ]) ]), div('row', [ @@ -113,7 +113,9 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>'; $needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>'; - $needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); + $bar_max = max($needed_angeltype['count']*10, $needed_angeltype['taken']*10, 10); + $bar_value = max(1, $needed_angeltype['taken'] * 10); + $needed_angels .= progress_bar(0, $bar_max, $bar_value, $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); $angels = []; foreach ($shift['ShiftEntry'] as $shift_entry) { diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 09509c3d..65cb36b3 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -223,67 +223,83 @@ function User_shift_state_render($user) { return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>'; } -function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) { +function User_view_shiftentries($needed_angel_type) { + $shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> '; + + $shift_entries = []; + foreach ($needed_angel_type['users'] as $user_shift) { + $member = User_Nick_render($user_shift); + if ($user_shift['freeloaded']) { + $member = '<strike>' . $member . '</strike>'; + } + + $shift_entries[] = $member; + } + $shift_info .= join(", ", $shift_entries); + + return $shift_info; +} + +/** + * Helper that renders a shift line for user view + */ +function User_view_myshift($shift, $user_source, $its_me) { global $LETZTES_AUSTRAGEN, $privileges; - $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); + $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>'; + if ($shift['title']) { + $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>'; + } + foreach ($shift['needed_angeltypes'] as $needed_angel_type) { + $shift_info .= User_view_shiftentries($needed_angel_type); + } + + $myshift = [ + 'date' => date("Y-m-d", $shift['start']), + 'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']), + 'room' => $shift['Name'], + 'shift_info' => $shift_info, + 'comment' => $shift['Comment'] + ]; + + if ($shift['freeloaded']) { + if (in_array("user_shifts_admin", $privileges)) { + $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>'; + } else { + $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>'; + } + } + + $myshift['actions'] = [ + button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs') + ]; + if ($its_me || in_array('user_shifts_admin', $privileges)) { + $myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs'); + } + if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) { + $myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs'); + } + $myshift['actions'] = table_buttons($myshift['actions']); + return $myshift; +} + +/** + * Helper that prepares the shift table for user view + */ +function User_view_myshifts($shifts, $user_source, $its_me) { $myshifts_table = []; $timesum = 0; foreach ($shifts as $shift) { - $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>'; - if ($shift['title']) { - $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>'; - } - foreach ($shift['needed_angeltypes'] as $needed_angel_type) { - $shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> '; - - $shift_entries = []; - foreach ($needed_angel_type['users'] as $user_shift) { - $member = User_Nick_render($user_shift); - if ($user_shift['freeloaded']) { - $member = '<strike>' . $member . '</strike>'; - } - - $shift_entries[] = $member; - } - $shift_info .= join(", ", $shift_entries); - } - - $myshift = [ - 'date' => date("Y-m-d", $shift['start']), - 'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']), - 'room' => $shift['Name'], - 'shift_info' => $shift_info, - 'comment' => $shift['Comment'] - ]; - - if ($shift['freeloaded']) { - if (in_array("user_shifts_admin", $privileges)) { - $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>'; - } else { - $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>'; - } - } - - $myshift['actions'] = [ - button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs') - ]; - if ($its_me || in_array('user_shifts_admin', $privileges)) { - $myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs'); - } - if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) { - $myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs'); - } - $myshift['actions'] = table_buttons($myshift['actions']); + $myshifts_table[] = User_view_myshift($shift, $user_source, $its_me); if ($shift['freeloaded']) { $timesum += (- 2 * ($shift['end'] - $shift['start'])); } else { $timesum += ($shift['end'] - $shift['start']); } - $myshifts_table[] = $myshift; } + if (count($myshifts_table) > 0) { $myshifts_table[] = [ 'date' => '<b>' . _("Sum:") . '</b>', @@ -294,6 +310,15 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel 'actions' => "" ]; } + return $myshifts_table; +} + +/** + * Renders view for a single user + */ +function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) { + $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); + $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me); return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', [ msg(), |