summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php35
-rw-r--r--includes/view/Rooms_view.php2
-rw-r--r--includes/view/Shifts_view.php19
-rw-r--r--includes/view/User_view.php51
4 files changed, 72 insertions, 35 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 78563c0b..ce38a096 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -103,23 +103,25 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
foreach ($members as $member) {
$member['Nick'] = User_Nick_render($member);
if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
- $member['actions'] = join(" ", array(
- '<a href="' . page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="ok">' . _("confirm") . '</a>',
- '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("deny") . '</a>'
- ));
+ $member['actions'] = table_buttons([
+ button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], _("confirm"), 'btn-xs'),
+ button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("deny"), 'btn-xs')
+ ]);
$members_unconfirmed[] = $member;
} elseif ($member['coordinator']) {
if ($admin_angeltypes)
- $member['actions'] = '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0" class="cancel">' . _("Remove coordinator rights") . '</a>';
+ $member['actions'] = table_buttons([
+ button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0', _("Remove coordinator rights"), 'btn-xs')
+ ]);
else
$member['actions'] = '';
$coordinators[] = $member;
} else {
if ($admin_user_angeltypes)
- $member['actions'] = join(" ", array(
- $admin_angeltypes ? '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1" class="add">' . _("Add coordinator rights") . '</a>' : '',
- '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("remove") . '</a>'
- ));
+ $member['actions'] = table_buttons([
+ $admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1', _("Add coordinator rights"), 'btn-xs') : '',
+ button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')
+ ]);
$members_confirmed[] = $member;
}
}
@@ -131,6 +133,21 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
'actions' => ""
), $coordinators);
}
+
+ if (count($members_confirmed) > 0)
+ $members_confirmed[] = [
+ 'Nick' => _('Sum'),
+ 'DECT' => count($members_confirmed),
+ 'actions' => ''
+ ];
+
+ if (count($members_unconfirmed) > 0)
+ $members_unconfirmed[] = [
+ 'Nick' => _('Sum'),
+ 'DECT' => count($members_unconfirmed),
+ 'actions' => ''
+ ];
+
$page[] = '<h3>' . _("Members") . '</h3>';
if ($admin_user_angeltypes)
$page[] = buttons(array(
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index bb41a4d3..e1d411cb 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -4,7 +4,7 @@ function Room_name_render($room) {
global $privileges;
if (in_array('admin_rooms', $privileges))
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
- return $room['Name'];
+ return glyph('map-marker') . $room['Name'];
}
?> \ No newline at end of file
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 00c18572..b0628a3b 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -1,5 +1,14 @@
<?php
+function Shift_editor_info_render($shift) {
+ $info = [];
+ if ($shift['created_by_user_id'] != null)
+ $info[] = sprintf(glyph('plus') . _("created at %s by %s"), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id'])));
+ if ($shift['edited_by_user_id'] != null)
+ $info[] = sprintf(glyph('pencil') . _("edited at %s by %s"), date('Y-m-d H:i', $shift['edited_at_timestamp']), User_Nick_render(User($shift['edited_by_user_id'])));
+ return join('<br />', $info);
+}
+
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, $user_shifts = null) {
global $user;
@@ -12,7 +21,7 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null,
if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts))
return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
elseif ($user_angeltype == null)
- return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf('Become %s', $angeltype['name']));
+ return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']));
else
return '';
}
@@ -36,7 +45,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
$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'], $needed_angeltype['taken'], $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
+ $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) {
@@ -46,7 +55,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
$entry = '<strike>' . $entry . '</strike>';
if ($user_shift_admin) {
$entry .= ' <div class="btn-group">';
- $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift['SID'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs');
+ $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>';
}
@@ -60,6 +69,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
}
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
+
msg(),
Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '',
$signed_up ? info(_('You are signed up for this shift.'), true) : '',
@@ -104,7 +114,8 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
'<h2>' . _('Description') . '</h2>',
$parsedown->parse($shifttype['description'])
])
- ])
+ ]),
+ $shift_admin ? Shift_editor_info_render($shift) : ''
]);
}
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index a7d77b19..3ab5f816 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -19,10 +19,27 @@ $tshirt_sizes = array(
'XL-G' => "XL Girl"
);
-function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count) {
+/**
+ * View for editing the number of given vouchers
+ */
+function User_edit_vouchers_view($user) {
+ return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
+ msg(),
+ buttons([
+ button(user_link($user), glyph('chevron-left') . _("back"))
+ ]),
+ form([
+ form_spinner('vouchers', _("Number of vouchers"), $user['got_voucher']),
+ form_submit('submit', _("Save"))
+ ], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID'])
+ ]);
+}
+
+function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
foreach ($users as &$user) {
$user['Nick'] = User_Nick_render($user);
$user['Gekommen'] = glyph_bool($user['Gekommen']);
+ $user['got_voucher'] = $user['got_voucher'];
$user['Aktiv'] = glyph_bool($user['Aktiv']);
$user['force_active'] = glyph_bool($user['force_active']);
$user['Tshirt'] = glyph_bool($user['Tshirt']);
@@ -34,6 +51,7 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
$users[] = array(
'Nick' => '<strong>' . _('Sum') . '</strong>',
'Gekommen' => $arrived_count,
+ 'got_voucher' => $voucher_count,
'Aktiv' => $active_count,
'force_active' => $force_active_count,
'freeloads' => $freeloads_count,
@@ -52,6 +70,7 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
'Name' => Users_table_header_link('Name', _('Name'), $order_by),
'DECT' => Users_table_header_link('DECT', _('DECT'), $order_by),
'Gekommen' => Users_table_header_link('Gekommen', _('Arrived'), $order_by),
+ 'got_voucher' => Users_table_header_link('got_voucher', _('Voucher'), $order_by),
'freeloads' => _('Freeloads'),
'Aktiv' => Users_table_header_link('Aktiv', _('Active'), $order_by),
'force_active' => Users_table_header_link('force_active', _('Forced'), $order_by),
@@ -106,10 +125,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$shift_entries = array();
foreach ($needed_angel_type['users'] as $user_shift) {
- if ($its_me)
- $member = '<strong>' . User_Nick_render($user_shift) . '</strong>';
- else
- $member = User_Nick_render($user_shift);
+ $member = User_Nick_render($user_shift);
if ($user_shift['freeloaded'])
$member = '<strike>' . $member . '</strike>';
@@ -143,15 +159,15 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$myshift['actions'] = table_buttons($myshift['actions']);
if ($shift['freeloaded'])
- $timesum += - 2 * ($shift['end'] - $shift['start']);
+ $timesum += (- 2 * ($shift['end'] - $shift['start']));
else
- $timesum += $shift['end'] - $shift['start'];
+ $timesum += ($shift['end'] - $shift['start']);
$myshifts_table[] = $myshift;
}
if (count($myshifts_table) > 0)
$myshifts_table[] = array(
'date' => '<b>' . _("Sum:") . '</b>',
- 'time' => "<b>" . round($timesum / (60 * 60), 1) . " h</b>",
+ 'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
'room' => "",
'shift_info' => "",
'comment' => "",
@@ -171,7 +187,8 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'<h4>' . _("User state") . '</h4>',
($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
$user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
- ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
+ $admin_user_privilege || $its_me ? ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '</span>' : '<span class="text-danger">' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '</span>') : ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
+ $admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '<br /><span class="text-success">' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '</span><br />' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />') : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
)),
@@ -189,6 +206,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
buttons(array(
$admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '',
($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '',
+ $admin_user_privilege ? button(page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], glyph('cutlery') . _('Edit vouchers')) : '',
$its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '',
$its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '',
$its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '',
@@ -205,6 +223,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'comment' => _("Comment"),
'actions' => _("Action")
), $myshifts_table) : '',
+ $its_me ? info(glyph('info-sign') . _("Your night shifts between 2 and 8 am count twice."), true) : '',
$its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : ''
));
}
@@ -249,7 +268,7 @@ function User_angeltypes_render($user_angeltypes) {
$class = 'text-warning';
else
$class = 'text-success';
- $output[] = '<span class="' . $class . '">' . ($angeltype['coordinator'] ? '<span class="glyphicon glyphicon-certificate"></span> ' : '') . $angeltype['name'] . '</span>';
+ $output[] = '<span class="' . $class . '">' . ($angeltype['coordinator'] ? glyph('education') : '') . $angeltype['name'] . '</span>';
}
return join('<br />', $output);
}
@@ -263,23 +282,13 @@ function User_groups_render($user_groups) {
}
/**
- * Render a users avatar.
- *
- * @param User $user
- * @return string
- */
-function User_Avatar_render($user) {
- return '<div class="avatar">&nbsp;<img src="pic/avatar/avatar' . $user['Avatar'] . '.gif"></div>';
-}
-
-/**
* Render a user nickname.
*
* @param User $user_source
* @return string
*/
function User_Nick_render($user_source) {
- return '<a href="' . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
+ return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
}
?>