include("include.php");
include("datefunctions.php");
$pageName= "calendar.php";
if ( !$userLoggedIn )
{
header( "location: login.php");
exit;
}
else
{
$usUserName = $userLoggedIn;
}
if ( count($HTTP_POST_VARS) )
{
if ( $submit == "Add New Item" )
{
$sql = "
INSERT INTO
tasks ( taskName, taskTargetDate, taskTargetTime, taskOwner,
taskPopupWarning, taskWarningDays )
VALUES
( '$newTaskName', '$newTaskTargetDate', '$newTaskTargetTime',
'$usUserName', '$newTaskPopupWarning', '$newTaskWarningDays' )
";
if ( !($result = mysql_query($sql,$conn)) ) DBErr($sql, $conn);
}
else
if ( $submit == "Delete Checked Items" && is_array( $deleteList ) )
{
while ( list( $taskId, $data ) = each ( $deleteList ) )
{
if ( $data == "Y" ) // this should always be true...just checking.
{
$sql = "
DELETE FROM
tasks
WHERE
taskId = '$taskId'
";
if ( !($result = mysql_query($sql,$conn)) ) DBErr($sql, $conn);
}
}
}
}
?>
InnerAthlete™ - Free Training Log and Fitness Portal: running, cycling, triathlons, adventure racing.
|
| Calendar |
|
// If a month and year haven't been explicitly chosen use current
if ($year=='')
$year=date(Y,time());
if ($month=='')
$month=date(m,time());
ShowMonthYearSelection( "calendar.php" );
GetTaskList( $month, $year, $monthList, $fullList );
ShowCalendarMonth( $monthList, $month, $year );
ShowTaskList( $usUserName, $fullList );
?>
|
|
| Copyright©
1999-2007 InnerAthlete™ All rights reserved.
|
|
|
|
// Fetches a list of tasks for the specified month.
function GetTaskList( $month, $year, &$monthList, &$fullList )
{
global $conn, $usUserName;
$startDate = $year . "-" . $month . "-" . "01";
$nextmonth = $month+1;
$lastday = mktime(0,0,0,$nextmonth,0,$year);
$lastday = date(d,$lastday);
$endDate = $year . "-" . $month . "-" . $lastday;
// fetch all tasks for given month year
$sql = "
SELECT
taskId, taskName, taskTargetDate, taskTargetTime
FROM
tasks
WHERE
taskOwner='$usUserName'
ORDER BY
taskTargetDate, taskTargetTime
";
// TO_DAYS( taskTargetDate ) BETWEEN TO_DAYS( '$startDate' ) AND TO_DAYS( '$endDate' )
// echo("sql - $sql
" );
if ( !($result = mysql_query($sql,$conn)) ) DBErr($sql, $conn);
while ( list( $taskId, $taskName, $taskDate, $taskTargetTime ) = mysql_fetch_row($result) )
{
$dateArray = explode( "-", $taskDate );
$day = intval( $dateArray[2] );
$taskMonth = intval( $dateArray[1] );
$fullList[$taskId]["DATE"] = $taskDate;
$fullList[$taskId]["DAY"] = $day;
$fullList[$taskId]["NAME"] = $taskName;
$fullList[$taskId]["TIME"] = $taskTargetTime;
if ( $taskMonth == $month )
{
$monthList[$day] = "$taskName";
if ( $taskTargetTime ) $monthList[$day].=", $taskTargetTime";
$monthList[$day].="
";
}
}
return( $taskList );
} // function GetTaskList
/****************************************************************************
*/
function ShowTaskList( $usUserName, $taskList )
{
global $conn;
echo("
\n
");
} // function ShowTaskList()