<?php
/*
* ConPortal - Pomona College ITS & Bucknell University ISR scheduling appplication
* Copyright (C) 2005-2007 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
*/
require_once('../standard.php');
$super_name = getNameForUser($_SESSION['pid']);
//build timestamps
$timeIn = return_ymd_timestamp_string($_POST['year_in'], $_POST['month_in'], $_POST['day_in']) . " " .
return_hm_timestamp_string($_POST['hour_in'], $_POST['min_in'], $_POST['AMPM_in']);
$timeOut = return_ymd_timestamp_string($_POST['year_out'], $_POST['month_out'], $_POST['day_out']) . " " .
return_hm_timestamp_string($_POST['hour_out'], $_POST['min_out'], $_POST['AMPM_out']);
//make sure those timestamps built above are actually valid...
if( is_valid_timestamp_string($timeIn) && is_valid_timestamp_string($timeOut) )
{
//first case: if it's a plain add for a user that has been picked from a list
if(isset($_POST['pid']))
{
//if box is checked, set time_out to all 0s to let the database function know
//that it should only set time in, regardless of what's in time_out
if($_POST['leave_logged_in'])
{
addPunchForUser($_POST['pid'], $timeIn, "0000-00-00 00:00:00");
}
else
{
addPunchForUser($_POST['pid'], $timeIn, $timeOut);
}
header("Location: " . BASE_URL . "punch_tracking.php");
}
//second case: we're modifing a punch that was picked from edit_punch.php
else if(isset($_POST['punch_pid']))
{
//same logic as above
if($_POST['leave_logged_in'])
{
modifyPunchForUser($_POST['punch_pid'], $timeIn, "0000-00-00 00:00:00");
}
else
{
modifyPunchForUser($_POST['punch_pid'], $timeIn, $timeOut);
}
header("Location: " . BASE_URL . "punch_tracking.php");
}
else //if neither pid nor punch_pid were set...
{
error("Something wasn't filled out properly! Now I am sad!");
display_errors();
}
}
//if timeIn & timeOut were not good, somehow...
else
{
$errStr = "timeIn and/or timeOut did not have sensible values - " . $timeIn . " and " . $timeOut;
error($errStr);
display_errors();
}
?>