<?php
/*
* ConPortal - Pomona College ITS scheduling appplication
* Copyright (C) 2005-2006 Pomona College
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
function index_people_on_duty ()
{
?>
<div id="index_people_on_duty" class="index_box">
<h4>Current Shifts</h4>
<?php
$shifts_now = sortShiftsByTime(getShiftDetailsForArray(getShiftsForTime(time())));
if (count($shifts_now) > 0)
{
echo "<ul>\n";
foreach ($shifts_now as $row)
{
//get the data for the current shift and then the people on that shift
$status = getShiftStaffingStatus($row['pid']);
$position = getPositionDetails($row['position']);
switch ($status)
{
case STATUS_PERM_OPEN:
echo "<li>The shift from " . date("g:ia", $row['start_time']) .
" to " . date("g:ia", $row['end_time']) .
" has not been taken.</li>\n";
break;
case STATUS_TEMP_OPEN:
$temp_dropper = getNameForUser($row['dropper']);
echo "<li>The shift from " . date("g:ia", $row['start_time']) .
" to " . date("g:ia", $row['end_time']) .
" has been temporarily dropped by $temp_dropper.</li>\n";
break;
default:
echo "<li>" . getNameForUser($row['owner']) . INDEX_WORKING_STRING .
date("g:ia", $row['start_time']) . " to " . date("g:ia", $row['end_time']) .
" at " . $position['name'] . ".</li>\n";
}
}
echo "</ul>\n";
}
else
{
echo "<p>There are no shifts right now.</p>";
}
?>
</div>
<?php
}
function index_quick_punch ()
{
?>
<div id="index_quick_punch" class="index_box">
<h4>Quickpunch!</h4>
<?php
//set ipOK to true; if punch in returns false, set it to false and display warning
$ipOK = true;
$posted = false;
if($_SERVER['REQUEST_METHOD']=='POST')
$posted = true;
$punched = isPunchedIn($_SESSION['pid']);
//George sez: not sure that this code does the right thing. How about if I just not display punch buttons
//at all if user isn't in a good place?
//if login isn't ok, display error message
if(isset($_SESSION['ipOK']) && $_SESSION['ipOK']==FALSE)
{
echo "Sorry, but you can't punch in/out if you're not at work.";
}
//reset value
$_SESSION['ipOK']==TRUE;
//new code, 11-18-08
if(checkIP())
{
?>
<br>
<form method='post' action='redirects/punch_in_out.php'><center> <?
if($punched)
{
echo "<input type='submit' value='" . INDEX_PUNCH_OUT . "' /> <br><br>";
}
else if(!$punched)
{
echo "<input type='submit' value='" . INDEX_PUNCH_IN . "' /> <br><br>";
}
?>
<input type='hidden' name='fromWhere' value='QuickPunch'>
</form>
<br>
<form method='post' action='redirects/punch_in_out.php'><center> <?
if($punched)
{
echo "<input type='submit' value='" . INDEX_PUNCH_OUT_LOG_OUT . "' /> <br><br>";
}
else if(!$punched)
{
echo "<input type='submit' value='" . INDEX_PUNCH_IN_LOG_OUT . "' /> <br><br>";
}
?>
<input type='hidden' name='fromWhere' value='ThenLogout'>
</form>
</div><?
}
else
{
echo INDEX_INVALID_IP_FOR_QUICKPUNCH;
//The things I do to pacify co-workers...
if(QUICKPUNCH_NOTIFY_BUTTON == TRUE)
{
echo "<form method='post' action='redirects/generic_emailer.php'>
<input type='hidden' id='source' name='source'
value='quickpunch_notify'><br /> To request that the location you
are at be added as an acceptable location to punch in and out from,
please type a brief description of your location and click Submit.<br />";
echo "<input type='text' size='20' id='comp_description' name='comp_description'><br />";
echo "<input type='submit' value='Submit'><br />";
}
echo "</div>";
}
}
function index_my_shifts ()
{
?>
<div id="index_my_shifts" class="index_box">
<h4>My Shifts</h4>
<?php
// Get all the information for all the shifts we are interested in
$shifts = sortShiftsByDateTime(getShiftDetailsForArray(getShiftsForUserIncludingDropped($_SESSION['pid'])));
$shift_flag = false;
foreach ($shifts as $row)
{
// Don't display a shift whose last occurrence is in the past.
list(,$realEndDate) = xlate_shiftdate($row['day_of_week'], $row['start_date'], $row['end_date']);
if ($realEndDate + time_part($row['end_time']) < time())
continue;
$shift_flag = true;
$nicerow = getShiftDetailsHumanReadable($row['pid']);
$output = "<div class=\"index_perm_shift\">" .
$nicerow['day_of_week'] . " " . $nicerow['start_time'] . " - " . $nicerow['end_time'] . "\n";
switch(getShiftStaffingStatus($row['pid']))
{
case STATUS_PERM_TAKEN:
$output .= "<p class=\"small\">Shift runs from " .
$nicerow['start_date'] . " to " . $nicerow['end_date'] . " in " . $nicerow['position'] . ".</p>\n";
break;
case STATUS_TEMP_TAKEN:
if ($row['dropper'] and $row['dropper'] != $_SESSION['pid'])
{
// A shift that someone else dropped and this user picked up
$output .= "<p class=\"note\">Temp shift filling in for " .
$nicerow['dropper'] . " on " . $nicerow['start_date'] . " in " . $nicerow['position'] . ".</p>\n";
}
else
{
// A shift that wasn't dropped
$output .= "<p class=\"note\">Temp shift on " . $nicerow['start_date'] . ".</p>\n";
}
break;
case STATUS_PERM_OPEN:
// A shift that this user has perm-dropped. Don't show.
continue 2;
case STATUS_TEMP_OPEN:
$output .= "<p class=\"warn\">You have temp dropped this shift for " .
$nicerow['start_date'] . ", but it has not been taken. " .
INDEX_DROPPER_WARN . "<p>\n";
break;
}
$output .= "</div>";
echo $output;
}
if (!$shift_flag)
{
echo "<p>You currently have no shifts.</p>";
}
?>
</div>
<?php
}
function index_appointments ()
{
?>
<div id="index_appointments" class="index_box">
<h4>My Appointments</h4>
<?php
$appt_flag = false;
for ($i = 0; $i < 7; ++$i)
{
$timestamp = date_part(strtotime("+$i days"));
$shifts = getShiftsForDayAndUser($_SESSION['pid'], $timestamp);
foreach ($shifts as $shiftPid)
{
$appointments = getUncancelledAppointmentsForShift($shiftPid, $timestamp);
foreach ($appointments as $apptPid)
{
$appt_flag = true;
$appt = getAppointmentDetails($apptPid);
?>
<div class="index_appt">
<?= date("l n/j g:ia", $appt['start_time']) ?> -
<?= $appt['ticket_number'] ?> - <?= $appt['description'] ?>
<p class="small">Scheduled by <?= getNameForUser($appt['author']) ?> on
<?= date("n/j g:ia", $appt['author_datetime']) ?></p>
</div>
<?php
}
}
}
if (!$appt_flag)
echo "<p>You have no appointments in the next seven days.</p>\n";
?>
</div>
<?php
}
function index_announcements ()
{
?>
<div id="index_announcements" class="index_box">
<h4>Announcements</h4>
<?php
$announcements = array();
$groups = array_merge(array(getPrimaryGroupForUser($_SESSION['pid'])),
getGroupsForUser($_SESSION['pid']));
foreach ($groups as $tempGroup)
{
$tempAnnouncements = getUnexpiredAnnouncmentsForGroup($tempGroup);
$announcements = array_merge($announcements,$tempAnnouncements);
}
if (count($announcements) > 0)
{
echo '<ul>';
foreach ($announcements as $announcement)
{
$tempAnnouncement = getAnnouncmentDetails($announcement);
echo '<li><span class="announcementSubject">'.
$tempAnnouncement['subject'].'</span>'.
' (<span class="announcementDate">'.
date("n/j/Y", $tempAnnouncement['publishDate']).'</span>'.
') <span class="announcementMessage">'.
$tempAnnouncement['message'].'</span></li>';
}
echo '</ul>';
}
else
{
echo '<p>No current announcements.</p>'."\n";
}
echo '</div>';
}
function index_upcoming_events()
{
?>
<div id="index_upcoming_events" class="index_box">
<h4>Upcoming Meetings</h4>
<?php
$meetings = getUpcomingMeetingDetails();
// Remove meetings too far ahead
foreach ($meetings as $i => $meeting)
{
if ($meeting['date'] > strtotime("+7 days"))
unset($meetings[$i]);
}
if (count($meetings) > 0)
{
echo "<ul>\n";
foreach ($meetings as $meeting)
{
$type = getNameForMeetingType($meeting['type']);
echo "<li>There will be a";
$firstChar = ucfirst($type[0]);
if ($firstChar == 'A' or $firstChar == 'E' or $firstChar == 'I' or $firstChar == 'O' or $firstChar == 'U')
echo "n";
echo " $type meeting on " . date("l n/j/Y", $meeting['date']) . " in {$meeting['location']}.</li>\n";
}
echo "</ul>\n";
}
else
{
echo "<p>No events are scheduled in the next seven days.</p>";
}
?>
</div>
<?php
}
function index_shift_changelog()
{
?>
<div id="index_shift_changelog" class="index_box">
<h4>Shift Changelog</h4>
<?php
display_shift_changelog();
?>
</div>
<?php
}
///////////////////////////////////////////////////////////////
/// Custom homepage functions used for the ITS HelpDesk ///
/// -John Duprey ///
///////////////////////////////////////////////////////////////
function index_hd_links() { // links from the HD Panel grabbed out of the database *note* db functions located in links/db.php
?>
<div align=center id="index_link_list" class="index_box">
<h4>HelpDesk Links</h4>
<script type="text/javascript">
var myMenu;
window.onload = function() {
myMenu = new SDMenu("hd_menu");
myMenu.init();
};
</script>
<div id="hd_menu" class="sdmenu">
<?php
$groups = getLinkGroups();
foreach ($groups as $g) {
if ($g['id'] == 1) {
$links = getPopularLinks();
}
else {
$links = getLinkList($g['id']);
}
if (sizeof($links) == 0) { }
else {
echo "<div>\n<span>" . $g['name'] . "</span>\n";
foreach ($links as $l) {
echo "<a href=\"" . $l['link'] . "\" onclick=\"popUpdate(". $l['id'] .")\" target=blank >" . $l['title'] . "</a>\n";
}
echo " </div>\n";
}
}
?>
</div>
</div>
<?
}
function index_search_box() {
?>
<div id="index_search_box" class="index_box">
<h4>Search AskIT</h4>
<form method="get" class="confluence-searchbox marginlessForm "action="https://wiki.albany.edu/dosearchsite.action" target="_blank">
<input type="hidden" name="searchQuery.spaceKey" value="KB"/>
<input type="text" name="searchQuery.queryString" id="Text1"/>
<input type="submit" value="Search" />
</form>
</div>
<?
}
function index_clocked_in() {
$punchedin = getPunchedIn();
?>
<div id="index_punched_in" class="index_box">
<h4>Punched In Users</h4>
<ul>
<?
foreach($punchedin as $_) {
echo "<li>" . $_['first'] . " " . $_['last'] . " punched in at " . $_['time_in'] . " from " . $_['description'] . "</li>\n";
}
?>
</ul></div>
<?
}
?>