simplified shift view
This commit is contained in:
parent
5c8290d880
commit
62e72eda93
|
@ -182,7 +182,7 @@ function user_settings() {
|
||||||
form_text('jabber', "Jabber", $jabber),
|
form_text('jabber', "Jabber", $jabber),
|
||||||
form_text('hometown', Get_Text("makeuser_Hometown"), $hometown),
|
form_text('hometown', Get_Text("makeuser_Hometown"), $hometown),
|
||||||
$enable_tshirt_size ? form_select('tshirt_size', Get_Text("makeuser_T-Shirt"), $tshirt_sizes, $tshirt_size) : '',
|
$enable_tshirt_size ? form_select('tshirt_size', Get_Text("makeuser_T-Shirt"), $tshirt_sizes, $tshirt_size) : '',
|
||||||
form_checkboxes('angel_types', "What do you want to do?<br>(<a href=\"https://events.ccc.de/congress/2012/wiki/Volunteers#What_kind_of_volunteers_are_needed.3F\">Description of job types</a>)", $angel_types, $selected_angel_types),
|
form_checkboxes('angel_types', "<span id=\"angel_types_anchor\">What do you want to do?</span><br>(<a href=\"https://events.ccc.de/congress/2012/wiki/Volunteers#What_kind_of_volunteers_are_needed.3F\">Description of job types</a>)", $angel_types, $selected_angel_types),
|
||||||
form_submit('submit', Get_Text("save"))
|
form_submit('submit', Get_Text("save"))
|
||||||
)),
|
)),
|
||||||
form(array (
|
form(array (
|
||||||
|
|
|
@ -282,10 +282,11 @@ function view_user_shifts() {
|
||||||
$ical_shifts = array ();
|
$ical_shifts = array ();
|
||||||
$days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` ORDER BY `start`");
|
$days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` ORDER BY `start`");
|
||||||
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
||||||
if (in_array('admin_shifts', $privileges))
|
|
||||||
|
if(in_array('user_shifts_admin', $privileges))
|
||||||
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `AngelTypes`.`name`");
|
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `AngelTypes`.`name`");
|
||||||
else
|
else
|
||||||
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name` FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `UserAngelTypes`.`user_id` = " . sql_escape($user['UID']) . " AND (`AngelTypes`.`restricted` = 0 OR NOT `UserAngelTypes`.`confirm_user_id` IS NULL) ORDER BY `AngelTypes`.`name`");
|
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR NOT `UserAngelTypes`.`confirm_user_id` IS NULL) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . ") ORDER BY `AngelTypes`.`name`");
|
||||||
if (empty($types))
|
if (empty($types))
|
||||||
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
|
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
|
||||||
$filled = array (
|
$filled = array (
|
||||||
|
@ -420,9 +421,9 @@ function view_user_shifts() {
|
||||||
$query .= "`shift_id` = " . sql_escape($shift['SID']);
|
$query .= "`shift_id` = " . sql_escape($shift['SID']);
|
||||||
else
|
else
|
||||||
$query .= "`room_id` = " . sql_escape($shift['RID']);
|
$query .= "`room_id` = " . sql_escape($shift['RID']);
|
||||||
$query .= " AND `count` > 0
|
$query .= " AND `count` > 0 ";
|
||||||
AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ")
|
$query .= " AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ")";
|
||||||
ORDER BY `AngelTypes`.`name`";
|
$query .= "ORDER BY `AngelTypes`.`name`";
|
||||||
$angeltypes = sql_select($query);
|
$angeltypes = sql_select($query);
|
||||||
|
|
||||||
if (count($angeltypes) > 0) {
|
if (count($angeltypes) > 0) {
|
||||||
|
@ -441,10 +442,29 @@ function view_user_shifts() {
|
||||||
$entry_list[] = "<span style=\"$style\">" . $entry['Nick']."</span>";
|
$entry_list[] = "<span style=\"$style\">" . $entry['Nick']."</span>";
|
||||||
}
|
}
|
||||||
if ($angeltype['count'] - count($entries) > 0) {
|
if ($angeltype['count'] - count($entries) > 0) {
|
||||||
if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges)) {
|
// is the shift still running or alternatively is the user shift admin?
|
||||||
|
$user_may_join_shift = true;
|
||||||
|
|
||||||
|
/* you cannot join if user already joined this shift */
|
||||||
|
$user_may_join_shift &= !$my_shift;
|
||||||
|
|
||||||
|
// you cannot join if user is not of this angel type
|
||||||
|
$user_may_join_shift &= in_array($angeltype['id'], $_SESSION['user_shifts']['types']);
|
||||||
|
|
||||||
|
// you can only join if the shift is in future or running
|
||||||
|
$user_may_join_shift &= time() < $shift['end'];
|
||||||
|
|
||||||
|
// User shift admins may join anybody in every shift
|
||||||
|
$user_may_join_shift |= in_array('user_shifts_admin', $privileges);
|
||||||
|
|
||||||
|
if ($user_may_join_shift) {
|
||||||
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »</a>';
|
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »</a>';
|
||||||
} else {
|
} else {
|
||||||
$entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht';
|
if(!in_array('user_shifts_admin', $privileges) && $angeltype['restricted'] == 1 && !isset($angeltype['confirm_user_id'])) {
|
||||||
|
$entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht' . ' <img src="pic/lock.png" alt="unconfirmed" title="Du bist für diesen Engeltyp noch nicht freigeschaltet." />';
|
||||||
|
} else {
|
||||||
|
$entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht' . ' <a href="' . page_link_to('user_settings') . '#angel_types_anchor">(Werde ' . $angeltype['name'] .')</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$is_free = true;
|
$is_free = true;
|
||||||
}
|
}
|
||||||
|
@ -505,8 +525,8 @@ function view_user_shifts() {
|
||||||
$shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
|
$shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
|
||||||
$query = "SELECT *
|
$query = "SELECT *
|
||||||
FROM `NeededAngelTypes`
|
FROM `NeededAngelTypes`
|
||||||
JOIN `AngelTypes`
|
JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)
|
||||||
ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)
|
LEFT JOIN `UserAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `UserAngelTypes`.`angeltype_id` AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . ")
|
||||||
WHERE ";
|
WHERE ";
|
||||||
if ($shift_has_special_needs)
|
if ($shift_has_special_needs)
|
||||||
$query .= "`shift_id` = " . sql_escape($shift['SID']);
|
$query .= "`shift_id` = " . sql_escape($shift['SID']);
|
||||||
|
@ -533,10 +553,30 @@ function view_user_shifts() {
|
||||||
if ($angeltype['count'] - count($entries) > 0) {
|
if ($angeltype['count'] - count($entries) > 0) {
|
||||||
$inner_text = ($angeltype['count'] - count($entries)) . ' ' . Get_Text($angeltype['count'] - count($entries) == 1 ? 'helper' : 'helpers') . ' ' . Get_Text('needed');
|
$inner_text = ($angeltype['count'] - count($entries)) . ' ' . Get_Text($angeltype['count'] - count($entries) == 1 ? 'helper' : 'helpers') . ' ' . Get_Text('needed');
|
||||||
// is the shift still running or alternatively is the user shift admin?
|
// is the shift still running or alternatively is the user shift admin?
|
||||||
if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges))
|
$user_may_join_shift = true;
|
||||||
|
|
||||||
|
/* you cannot join if user already joined this shift */
|
||||||
|
$user_may_join_shift &= !$my_shift;
|
||||||
|
|
||||||
|
// you cannot join if user is not of this angel type
|
||||||
|
$user_may_join_shift &= in_array($angeltype['id'], $_SESSION['user_shifts']['types']);
|
||||||
|
|
||||||
|
// you can only join if the shift is in future or running
|
||||||
|
$user_may_join_shift &= time() < $shift['end'];
|
||||||
|
|
||||||
|
// User shift admins may join anybody in every shift
|
||||||
|
$user_may_join_shift |= in_array('user_shifts_admin', $privileges);
|
||||||
|
|
||||||
|
if ($user_may_join_shift)
|
||||||
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . $inner_text . ' »</a>';
|
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . $inner_text . ' »</a>';
|
||||||
else
|
else {
|
||||||
$entry_list[] = $inner_text;
|
if(!in_array('user_shifts_admin', $privileges) && $angeltype['restricted'] == 1 && !isset($angeltype['confirm_user_id'])) {
|
||||||
|
$entry_list[] = $inner_text . ' <img src="pic/lock.png" alt="unconfirmed" title="Du bist für diesen Engeltyp noch nicht freigeschaltet." />';
|
||||||
|
} else {
|
||||||
|
$entry_list[] = $inner_text . ' <a href="' . page_link_to('user_settings') . '#angel_types_anchor">(Werde ' . $angeltype['name'] .')</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unset($inner_text);
|
unset($inner_text);
|
||||||
$is_free = true;
|
$is_free = true;
|
||||||
}
|
}
|
||||||
|
@ -599,7 +639,7 @@ function make_select($items, $selected, $name, $title = null) {
|
||||||
$html_items[] = '<li class="heading">' . $title . '</li>' . "\n";
|
$html_items[] = '<li class="heading">' . $title . '</li>' . "\n";
|
||||||
|
|
||||||
foreach ($items as $i)
|
foreach ($items as $i)
|
||||||
$html_items[] = '<li><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label></li>';
|
$html_items[] = '<li><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label>' . (!isset($i['enabled']) || $i['enabled'] ? '' : ' <img src="pic/lock.png" alt="unconfirmed" title="Du bist für diesen Engeltyp noch nicht freigeschaltet." />') . '</li>';
|
||||||
$html = '<div class="selection ' . $name . '">' . "\n";
|
$html = '<div class="selection ' . $name . '">' . "\n";
|
||||||
$html .= '<ul id="selection_' . $name . '">' . "\n";
|
$html .= '<ul id="selection_' . $name . '">' . "\n";
|
||||||
$html .= implode("\n", $html_items);
|
$html .= implode("\n", $html_items);
|
||||||
|
|
|
@ -389,3 +389,7 @@ tr:hover .hidden {
|
||||||
#filter {
|
#filter {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td .entries img {
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ function check_all(id) {
|
||||||
var obj = document.getElementById(id);
|
var obj = document.getElementById(id);
|
||||||
var boxes = obj.getElementsByTagName("input");
|
var boxes = obj.getElementsByTagName("input");
|
||||||
for(var i = 0; i < boxes.length; i++) {
|
for(var i = 0; i < boxes.length; i++) {
|
||||||
if(boxes[i].type == "checkbox")
|
if(boxes[i].type == "checkbox" && !boxes[i].disabled)
|
||||||
boxes[i].checked = true;
|
boxes[i].checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 749 B |
Loading…
Reference in New Issue