<?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
*/
require_once('standard.php');
// Check if there are any changes requested
$found = false;
foreach ($_POST as $key => $value)
{
if (intval($value) != 0)
{
$found = true;
break;
}
}
if (!$found)
{
error("No changes requested.");
header("Location: " . $_SERVER['HTTP_REFERER']);
exit;
}
xhtml_header('Confirm Shift Changes');
?>
<form action="redirects/shifts.php" method="post">
<p>You have requested the following changes in the shift schedule:</p>
<ul>
<?php
// Reiterate all selected changes
foreach ($_POST as $key => $value)
{
$arr = explode('_', $key);
$shiftPid = intval($arr[0]);
$timestamp = intval($arr[1]);
$action = intval($value);
$actionNamesLookup = array("Nothing ", "Perm take ", "Temp take ", "Perm drop ", "Temp drop ");
$actionName = $actionNamesLookup[$action];
if ($shiftPid != 0 and $timestamp != 0 and $action != 0)
{
// Get shift information
$shift_data = getShiftDetails($shiftPid);
$startTime = $shift_data['start_time'];
$endTime = $shift_data['end_time'];
// Print notice of change
echo "<li>$actionName" . date("g:ia", $startTime) . "-" . date("g:ia", $endTime);
// Print day of week if perm take/drop, full date if temp take/drop
if ($action == ACTION_PERM_TAKE or $action == ACTION_PERM_DROP)
echo " on " . date("l", $timestamp) . "s";
else
echo " on " . date("l, M d", $timestamp);
// Print select box of users if taking shift, and the person has the appropriate permission
if ($action == ACTION_PERM_TAKE or $action == ACTION_TEMP_TAKE)
{
if (checkPerm($_SESSION, "shifts"))
{
echo " on behalf of <select name=\"{$shiftPid}_user\">\n";
$users = sortUsersByName(getAllUserDetails());
foreach ($users as $i => $user)
{
if (checkUserCanTakeShift($user['pid'], $shiftPid, $timestamp))
{
if (intval($user['pid']) == $_SESSION['pid'])
echo "<option value=\"{$user['pid']}\" selected='selected'>{$user['name']}</option>\n";
else
echo "<option value=\"{$user['pid']}\">{$user['name']}</option>\n";
}
}
echo "</select>";
}
}
echo "</li>\n";
// Hidden form variable to transfer the action through
echo "<input type=\"hidden\" name=\"$key\" value=\"$value\" />\n";
}
}
?>
</ul>
<p>Message to be included in Usercons email:</p>
<p><textarea name="email_message" rows="10" cols="50"></textarea></p>
<p><input type="submit" value="Confirm Changes..." /></p>
</form>
<?php
xhtml_footer();
?>