diff options
author | Philip Häusler <msquare@notrademark.de> | 2012-12-30 18:23:10 +0100 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2012-12-30 18:23:10 +0100 |
commit | 8fd5ffb3352f28557187ae16aaabb4b245a22941 (patch) | |
tree | a4429fb800bc0dc0a2b0076596389cec58c85048 | |
parent | f5f698a2a5a5c6b667c075469063882daf2a3ba0 (diff) |
cleanup user myshifts
-rw-r--r-- | includes/pages/user_myshifts.php | 66 | ||||
-rw-r--r-- | templates/user_myshifts.html | 46 |
2 files changed, 32 insertions, 80 deletions
diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 08e8e77f..346a74c0 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -15,12 +15,6 @@ function user_myshifts() { list ($shifts_user) = sql_select("SELECT * FROM `User` WHERE `UID`=" . sql_escape($id) . " LIMIT 1"); - if ($id != $user['UID']) { - $msg .= info(sprintf("You are viewing %s's shifts.", $shifts_user['Nick']), true); - if(in_array('admin_user', $privileges)) - $msg .= buttons(array(button(page_link_to('admin_user') . '&id=' . $shifts_user['UID'], "Edit " . $shifts_user['Nick'], 'edit'))); - } - if (isset ($_REQUEST['reset'])) { if ($_REQUEST['reset'] == "ack") { user_reset_ical_key($user); @@ -70,21 +64,14 @@ function user_myshifts() { } $shifts = sql_select("SELECT * FROM `ShiftEntry` JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `UID`=" . sql_escape($shifts_user['UID']) . " ORDER BY `start`"); + $myshifts_table = array(); $html = ""; $timesum = 0; foreach ($shifts as $shift) { - if (time() > $shift['end']) - $html .= '<tr class="done">'; - else - $html .= '<tr>'; - $html .= '<td>' . date("Y-m-d", $shift['start']) . '</td>'; - $html .= '<td>' . date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '</td>'; - $html .= '<td>' . $shift['Name'] . '</td>'; - $html .= '<td>' . $shift['name']; - + $shift_info = $shift['name']; $needed_angel_types_source = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`=" . sql_escape($shift['SID']) . " ORDER BY `AngelTypes`.`name`"); foreach($needed_angel_types_source as $needed_angel_type) { - $html .= '<br><b>' . $needed_angel_type['name'] . ':</b> '; + $shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> '; $users_source = sql_select("SELECT `User`.* FROM `ShiftEntry` JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` WHERE `ShiftEntry`.`SID`=" . sql_escape($shift['SID']) . " AND `ShiftEntry`.`TID`=" . sql_escape($needed_angel_type['id'])); $shift_entries = array(); @@ -94,33 +81,44 @@ function user_myshifts() { else $shift_entries[] = User_Nick_render($user_source); } - $html .= join(", ", $shift_entries); + $shift_info .= join(", ", $shift_entries); } - $html .= '</td>'; - $html .= '<td>' . $shift['Comment'] . '</td>'; - $html .= '<td>'; + $myshift = array( + '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'] + ); + + $myshift['actions'] = ""; if ($id == $user['UID']) - $html .= img_button(page_link_to('user_myshifts') . '&edit=' . $shift['id'], 'pencil', 'edit'); + $myshift['actions'] .= img_button(page_link_to('user_myshifts') . '&edit=' . $shift['id'], 'pencil', 'edit'); if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) - $html .= img_button(page_link_to('user_myshifts') . (($id != $user['UID'])? '&id=' . $id : '') . '&cancel=' . $shift['id'], 'cross', 'sign_off'); - $html .= '</td>'; - $html .= '</tr>'; + $myshift['actions'] .= img_button(page_link_to('user_myshifts') . (($id != $user['UID'])? '&id=' . $id : '') . '&cancel=' . $shift['id'], 'cross', 'sign_off'); $timesum += $shift['end'] - $shift['start']; + $myshifts_table[] = $myshift; } - if ($html == "") + if (count($shifts) == 0) $html = '<tr><td>' . ucfirst(Get_Text('none')) . '...</td><td></td><td></td><td></td><td></td><td>' . sprintf(Get_Text('pub_myshifts_goto_shifts'), page_link_to('user_shifts')) . '</td></tr>'; - - return msg().template_render('../templates/user_myshifts.html', array ( - 'intro' => sprintf(Get_Text('pub_myshifts_intro'), $LETZTES_AUSTRAGEN), - 'shifts' => $html, - 'time_sum' => round($timesum / (60*60), 1), - 'msg' => $msg, - 'ical_text' => sprintf(Get_Text('inc_schicht_ical_text'), - page_link_to_absolute('ical') . '&key=' . $shifts_user['ical_key'], - page_link_to('user_myshifts') . '&reset'), + return page(array( + msg(), + $id == $user['UID'] ? sprintf(Get_Text('pub_myshifts_intro'), $LETZTES_AUSTRAGEN) : '', + $id != $user['UID'] ? info(sprintf("You are viewing %s's shifts.", $shifts_user['Nick']), true) : '', + $id != $user['UID'] ? buttons(array(button(page_link_to('admin_user') . '&id=' . $shifts_user['UID'], "Edit " . $shifts_user['Nick'], 'edit'))) : '', + table(array( + 'date' => "Tag", + 'time' => "Zeit", + 'room' => "Ort", + 'shift_info' => "Name & Kollegen", + 'comment' => "Kommentar", + 'actions' => "Aktion" + ), $myshifts_table), + $id == $user['UID'] && count($shifts) == 0 ? error(sprintf(Get_Text('pub_myshifts_goto_shifts'), page_link_to('user_shifts')), true) : '', + "<h2>iCal Export</h2>" . sprintf(Get_Text('inc_schicht_ical_text'), page_link_to_absolute('ical') . '&key=' . $shifts_user['ical_key'], page_link_to('user_myshifts') . '&reset') )); } ?> diff --git a/templates/user_myshifts.html b/templates/user_myshifts.html deleted file mode 100644 index fdb1631a..00000000 --- a/templates/user_myshifts.html +++ /dev/null @@ -1,46 +0,0 @@ -<p> -%intro% -</p> -%msg% -<table> - <thead> - <tr> - <th> - Tag - </th> - <th> - Zeit - </th> - <th> - Ort - </th> - <th> - Name & Kollegen - </th> - <th> - Kommentar - </th> - <th> - Aktion - </th> - </tr> - </thead> - <tbody> - %shifts% - </tbody> - <tfoot> - <tr> - <th>Summe</th> - <th>%time_sum% Stunden</th> - <th></th> - <th></th> - <th></th> - <th></th> - </tr> - </tfoot> -</table> -<hr /> -<h2>iCal Export</h2> -<p> - %ical_text% -</p> |