<?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
*/
/* form handling code for appointment stuff */
require_once('../standard.php');
check_auth();
if (isset($_POST['refer']))
{
// The refer string indicates which action to take
switch ($_POST['refer'])
{
case "create_appt":
// Make sure ticket number and description are present
if (!isset($_POST['ticket']) or intval($_POST['ticket']) <= 0)
die("You did not enter a ticket number!");
if (!isset($_POST['desc']) or strlen($_POST['desc']) == 0)
die("You did not enter a description!");
// Assemble start timestamp from currently selected date and user-selected time
$start_time = strtotime(sprintf('Today %d:%02d:00', intval($_POST['hour']), intval($_POST['minute'])),
$_SESSION['shift_timestamp']);
// sanitize description string for database
$desc = mysql_real_escape_string($_POST['desc']);
if (isAppointmentValid($start_time, intval($_POST['position'])) or
(isset($_POST['appointment_override']) and checkPerm($_SESSION, "appointments")))
{
// Send to database
createAppointment($start_time, intval($_POST['position']), intval($_POST['ticket']), $desc, $_SESSION['pid']);
}
break;
case "set_status":
// sanitize status string for database
updateAppointmentStatus(intval($_POST['pid']), mysql_real_escape_string($_POST['status']));
break;
default:
die("Error in /redirects/appointments.php: unknown refer '{$_POST['refer']}'");
}
header("Location: " . BASE_URL . "show_shifts.php");
}
else
die("Error in /redirects/appointments.php: refer not set");
?>