reduce complexity of shift view

main
msquare 8 years ago
parent 5a93050a06
commit 5299ca2103

@ -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

@ -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 .= '<div class="list-group-item">';
$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']);
$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 = '<strike>' . $entry . '</strike>';
}
if ($user_shift_admin) {
$entry .= ' <div class="btn-group">';
$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 .= '</div>';
}
$angels[] = $entry;
}
}
$needed_angels .= join(', ', $angels);
$needed_angels .= '</div>';
$needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
}
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
@ -99,7 +66,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts,
div('col-sm-3 col-xs-6', [
'<h4>' . _('Start') . '</h4>',
'<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
glyph('calendar') . date('Y-m-d', $shift['start']),
glyph('calendar') . date(_('Y-m-d'), $shift['start']),
'<br />',
glyph('time') . date('H:i', $shift['start']),
'</p>'
@ -107,7 +74,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts,
div('col-sm-3 col-xs-6', [
'<h4>' . _('End') . '</h4>',
'<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
glyph('calendar') . date('Y-m-d', $shift['end']),
glyph('calendar') . date(_('Y-m-d'), $shift['end']),
'<br />',
glyph('time') . date('H:i', $shift['end']),
'</p>'
@ -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 .= '<div class="list-group-item">';
$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']);
$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 .= '</div>';
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 = '<strike>' . $entry . '</strike>';
}
if ($user_shift_admin) {
$entry .= ' <div class="btn-group">';
$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 .= '</div>';
}
return $entry;
}
/**
* Calc shift length in format 12:23h.
*

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Engelsystem 2.0\n"
"POT-Creation-Date: 2016-11-15 17:40+0100\n"
"PO-Revision-Date: 2016-11-15 17:40+0100\n"
"PO-Revision-Date: 2016-11-15 17:49+0100\n"
"Last-Translator: msquare <msquare@notrademark.de>\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

Loading…
Cancel
Save