<?php
/*
* ConPortal - Pomona College ITS scheduling appplication
* Copyright (C) 2005-2008 Pomona College & Bucknell University
*
* 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 getDifferentialShifts()
{
$result = safeQuery("SELECT pid, start_d_o_w, start_time, end_d_o_w, end_time FROM
differentials ORDER BY pid");
$a = array();
while ($row = mysql_fetch_assoc($result))
{
$a[] = $row;
}
return $a;
}
function getDifferentialShiftsNumeric()
{
$result = safeQuery("SELECT pid, start_d_o_w, start_time, end_d_o_w, end_time FROM
differentials ORDER BY pid");
$a = array();
while ($row = mysql_fetch_assoc($result))
{
$row['start_d_o_w'] = d_o_w_to_number($row['start_d_o_w']);
$row['end_d_o_w'] = d_o_w_to_number($row['end_d_o_w']);
$a[] = $row;
}
return $a;
}
function d_o_w_to_number($day)
{
if($day == "Monday")
return 1;
if($day == "Tuesday")
return 2;
if($day == "Wednesday")
return 3;
if($day == "Thursday")
return 4;
if($day == "Friday")
return 5;
if($day == "Saturday")
return 6;
else
return 7;
}
function getDifferentialShiftByPid($pid)
{
$result = safeQuery("SELECT * FROM differentials WHERE pid = " . $pid ."");
$row = array();
$row = mysql_fetch_assoc($result);
return $row;
}
function deleteDifferentialByPid($pid)
{
$result = safeQuery("DELETE FROM differentials WHERE pid = \"" . $pid ."\"");
return $result;
}
function addDifferential($start_day, $start_time, $end_day, $end_time)
{
$result = safeQuery("INSERT INTO differentials (start_d_o_w, start_time, end_d_o_w, end_time)
VALUES (\"" . $start_day . "\",\"" . $start_time . "\",\"" . $end_day . "\",\"" . $end_time . "\")");
return $result;
}
?>