fix bad html at user_shifts

main
Philip Häusler 12 years ago
parent 7fa2353c38
commit 1cf84a87be

@ -483,72 +483,82 @@ function view_user_shifts() {
} }
$shifts_table.="</table>"; $shifts_table.="</table>";
// qqq // qqq
} else foreach ($shifts as $shift) { } else {
$info = array (); $shifts_table = array();
if (count($_SESSION['user_shifts']['days']) > 1) foreach ($shifts as $shift) {
$info[] = date("Y-m-d", $shift['start']); $info = array ();
$info[] = date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']); if (count($_SESSION['user_shifts']['days']) > 1)
if (count($_SESSION['user_shifts']['rooms']) > 1) $info[] = date("Y-m-d", $shift['start']);
$info[] = $shift['room_name']; $info[] = date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']);
$shift_row = '<tr><td>' . join('<br />', $info) . '</td>'; if (count($_SESSION['user_shifts']['rooms']) > 1)
$shift_row .= '<td>' . $shift['name']; $info[] = $shift['room_name'];
if (in_array('admin_shifts', $privileges)) $shift_row = array(
$shift_row .= ' <a href="?p=user_shifts&edit_shift=' . $shift['SID'] . '">[edit]</a> <a href="?p=user_shifts&delete_shift=' . $shift['SID'] . '">[x]</a>'; 'info' => join('<br />', $info),
$shift_row .= '<br />'; 'entries' => $shift['name']
$is_free = false; );
$shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
$query = "SELECT * if (in_array('admin_shifts', $privileges))
FROM `NeededAngelTypes` $shift_row['entries'] .= ' <a href="?p=user_shifts&edit_shift=' . $shift['SID'] . '">[edit]</a> <a href="?p=user_shifts&delete_shift=' . $shift['SID'] . '">[x]</a>';
JOIN `AngelTypes` $shift_row['entries'] .= '<br />';
ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) $is_free = false;
WHERE "; $shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
if ($shift_has_special_needs) $query = "SELECT *
$query .= "`shift_id` = " . sql_escape($shift['SID']); FROM `NeededAngelTypes`
else JOIN `AngelTypes`
$query .= "`room_id` = " . sql_escape($shift['RID']); ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)
$query .= " AND `count` > 0 "; WHERE ";
if (!empty($_SESSION['user_shifts']['types'])) if ($shift_has_special_needs)
$query .= "AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") "; $query .= "`shift_id` = " . sql_escape($shift['SID']);
$query .= "ORDER BY `AngelTypes`.`name`"; else
$angeltypes = sql_select($query); $query .= "`room_id` = " . sql_escape($shift['RID']);
$query .= " AND `count` > 0 ";
if (count($angeltypes) > 0) { if (!empty($_SESSION['user_shifts']['types']))
$my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0; $query .= "AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") ";
foreach ($angeltypes as $angeltype) { $query .= "ORDER BY `AngelTypes`.`name`";
$entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['id']) . " ORDER BY `Nick`"); $angeltypes = sql_select($query);
$entry_list = array ();
foreach ($entries as $entry) { if (count($angeltypes) > 0) {
if (in_array('user_shifts_admin', $privileges)) $my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0;
$entry_list[] = '<a href="' . page_link_to('user_myshifts') . '&id=' . $entry['UID'] . '">' . $entry['Nick'] . '</a> <a href="' . page_link_to('user_shifts') . '&entry_id=' . $entry['id'] . '">[x]</a>'; foreach ($angeltypes as $angeltype) {
else $entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['id']) . " ORDER BY `Nick`");
$entry_list[] = $entry['Nick']; $entry_list = array ();
foreach ($entries as $entry) {
if (in_array('user_shifts_admin', $privileges))
$entry_list[] = '<a href="' . page_link_to('user_myshifts') . '&id=' . $entry['UID'] . '">' . $entry['Nick'] . '</a> <a href="' . page_link_to('user_shifts') . '&entry_id=' . $entry['id'] . '">[x]</a>';
else
$entry_list[] = $entry['Nick'];
}
// do we need more angles of this type?
if ($angeltype['count'] - count($entries) > 0) {
$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?
if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges))
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . $inner_text . ' &raquo;</a>';
else
$entry_list[] = $inner_text;
unset($inner_text);
$is_free = true;
}
$shift_row['entries'] .= '<b>' . $angeltype['name'] . ':</b> ';
$shift_row['entries'] .= join(", ", $entry_list);
$shift_row['entries'] .= '<br />';
} }
// do we need more angles of this type? if (in_array('user_shifts_admin', $privileges)) {
if ($angeltype['count'] - count($entries) > 0) { $shift_row['entries'] .= '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">Weitere Helfer eintragen &raquo;</a>';
$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? if (($is_free && in_array(0, $_SESSION['user_shifts']['filled'])) || (!$is_free && in_array(1, $_SESSION['user_shifts']['filled']))) {
if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges)) $shifts_table[] = $shift_row;
$entry_list[] = '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . $inner_text . ' &raquo;</a>'; $row_count++;
else $ical_shifts[] = $shift;
$entry_list[] = $inner_text;
unset($inner_text);
$is_free = true;
} }
$shift_row .= '<b>' . $angeltype['name'] . ':</b> ';
$shift_row .= join(", ", $entry_list);
$shift_row .= '<br />';
}
if (in_array('user_shifts_admin', $privileges)) {
$shift_row .= '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">Weitere Helfer eintragen &raquo;</a>';
}
if (($is_free && in_array(0, $_SESSION['user_shifts']['filled'])) || (!$is_free && in_array(1, $_SESSION['user_shifts']['filled']))) {
$shifts_table .= $shift_row . '</td></tr>';
$row_count++;
$ical_shifts[] = $shift;
} }
} }
$shifts_table = table(array(
'info' => ucfirst(Get_Text("time")) . "/" . ucfirst(Get_Text("room")),
'entries' => ucfirst(Get_Text("entries"))
), $shifts_table);
} }
if ($user['ical_key'] == "") if ($user['ical_key'] == "")
@ -562,8 +572,6 @@ function view_user_shifts() {
'task_notice' => '<sup>1</sup>' . Get_Text("pub_schichtplan_tasks_notice"), 'task_notice' => '<sup>1</sup>' . Get_Text("pub_schichtplan_tasks_notice"),
'shifts_table' => $shifts_table, 'shifts_table' => $shifts_table,
'ical_text' => sprintf(Get_Text('inc_schicht_ical_text'), make_user_shifts_ical_link($user['ical_key']), page_link_to('user_myshifts') . '&reset'), 'ical_text' => sprintf(Get_Text('inc_schicht_ical_text'), make_user_shifts_ical_link($user['ical_key']), page_link_to('user_myshifts') . '&reset'),
'header1' => ucfirst(Get_Text("time")) . "/" . ucfirst(Get_Text("room")),
'header2' => ucfirst(Get_Text("entries")),
'filter' => ucfirst(Get_Text("to_filter")), 'filter' => ucfirst(Get_Text("to_filter")),
)); ));
} }

@ -10,21 +10,8 @@
</fieldset> </fieldset>
</form> </form>
<table> %shifts_table%
<thead>
<tr>
<th>
%header1%
</th>
<th>
%header2%
</th>
</tr>
</thead>
<tbody>
%shifts_table%
</tbody>
</table>
<h2>iCal Export</h2> <h2>iCal Export</h2>
<p> <p>
%ical_text% %ical_text%

Loading…
Cancel
Save