<?php
/*
* ITMS ValleyData source file version 1.0 May 11, 2001
*
* This is included on every ITMS page, defines the contents of the top portion of each page
* Expected input:
* $title
*
*
* Internet Task Management System: An online system used for recording information about and assigning tasks and processes.
* Copyright (C) 2001 ValleyData Programming Group
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* See file named "gpl.txt" included with source code or
* visit http://www.gnu.org/copyleft/gpl.txt on the internet.
*/
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
//header ("Expires: ". gmdate("D, d M Y H:i:s") . " GMT", time() + 20); // Date now plus 20 sec
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
include("config.php");
include("toolbox.php");
include("error_handler.php");
include("db_tools.php");
include("login.php");
$PAGE = strrchr($PHP_SELF, "/");
$PAGE = strtok($PAGE, "?");
$PAGE = substr($PAGE, 1);
if(isset($save)) //to update the status table immediately
{
setcookie("num_pending");
unset($num_pending);
setcookie("num_assigned");
unset($num_assigned);
db_open();
db_use();
$query = "SELECT PT.date_assigned, PT.period, PT.period_unit, PT.due_date, ".
"PT.tid, PT.title, PT.notify, PT.info, ".
"U1.name AS assigner, U2.name AS assignedTo, U1.email, U1.html FROM pending_tasks PT, ".
"users U1, users U2 WHERE PT.uid = '$uid' AND PT.assigner = U1.uid AND PT.uid = U2.uid";
$result = db_query($query);
$assignedBy_email = get_user_email($uid);
while($row = db_fetch_row($result))
{
$tid = $row["tid"];
$cbdone = "done$tid";
if(isset($$cbdone))
{
if($row["notify"] == 1)
{
//send notification
if(isset($row["email"]))
{
notifyComplete(
$row["title"],
$row["email"],
$row["assignedTo"],
$assignedBy_email,
$row["info"],
$row["due_date"],
get_priority_string($row["priority"]),
$row["html"]);
}
}
if($row["period"] != "0" && $row["period"] != "")
{
$due_date = $row["due_date"];//sample: 2001-03-11 18:59:56
$due_year = substr($due_date, 0, 4);
$due_month = substr($due_date, 5, 2);
$due_day = substr($due_date, 8, 2);
$due_hour = substr($due_date, 11, 2);
$due_min = substr($due_date, 14, 2);
$assigned_day = substr($row["date_assigned"], 8, 2);
switch($row["period_unit"])
{
case "0"://days
$due_day += $row["period"];
break;
case "1"://weeks
$due_day += ($row["period"] * 7);
break;
case "2"://months
$month_num = $due_month + $row["period"];
$days_to_add = get_days_in_month(mktime($due_hour, $due_min, 0, $due_month, $due_day, $due_year));
/*
$next_month_days = get_days_in_month(mktime($due_hour, $due_min, 0, $due_month + 1, 1, $due_year));
if($days_to_add > $next_month_days)
$days_to_add = $next_month_days;
*/
($assigned_day > $due_day) ? $max_day = $assigned_day : $max_day = $due_day;
for($i = $due_month+1; $i <= $month_num; $i++)
{
$curr_day = date('d', mktime($due_hour, $due_min, 0, $month_num-1, $days_to_add, $due_year));
$next_month_days = get_days_in_month(mktime($due_hour, $due_min, 0, $i, 1, $due_year));
if($max_day > $curr_day)
{
$curr_day = $max_day;
}
if($curr_day > $next_month_days)
{
$curr_day = $next_month_days;
}
$days_to_add += $curr_day;
}
$due_day = $days_to_add;
break;
}
$new_due = mktime($due_hour, $due_min, 0, $due_month, $due_day, $due_year);
$new_due = date('Y-m-d H:i:s', $new_due);
$query = "UPDATE pending_tasks SET date_assigned = '$due_date', due_date='$new_due' WHERE tid = '$tid'";
}
else
{
$query = "DELETE FROM pending_tasks WHERE tid = '$tid'";
}
db_query($query);
}
}
}
else if(isset($unassign)) //to update the status table immediately
{
setcookie("num_pending");
unset($num_pending);
setcookie("num_assigned");
unset($num_assigned);
$assignedBy_email = get_user_email($uid);
db_open();
db_use();
$query = "SELECT PT.date_assigned, PT.period, PT.period_unit, PT.due_date, ".
"PT.tid, PT.title, PT.notify, PT.info, ".
"U1.name AS assignedTo, U2.name AS assigner, U1.email, U1.html FROM pending_tasks PT, ".
"users U1, users U2 WHERE PT.uid=U1.uid AND PT.assigner=U2.uid";
$result = db_query($query);
while($row = db_fetch_row($result))
{
$tid = $row["tid"];
$cbunassign = "unassign$tid";
if(isset($$cbunassign))
{
//send notification
notifyUnassigned(
$row["title"],
$row["email"],
$row["assignedTo"],
$user,
$assignedBy_email,
$row["info"],
$row["due_date"],
get_priority_string($row["priority"]),
$row["html"]);
$query = "DELETE FROM pending_tasks WHERE tid = '$tid'";
db_query($query);
}
}
}
if(isset($password_change)) //if they are making a password change (in myprefs.php)
{
$oldpassword = make_clean($oldpassword);
$newpassword = make_clean($newpassword);
$newconfirm_password = make_clean($newconfirm_password);
if($ENABLE_LDAP == "true")
{
if(!ldap_is_user($user, $oldpassword))
{
message_box("Invalid Current Password, try again", "error");
}
else if($newpassword != $newconfirm_password)
{
message_box("Your two new passwords didn't match, try again", "warning");
}
else
{
//set new cookies so that the user doesn't have to re-login with new password
($SECURE_COOKIES == "true")? $SSL=1: $SSL=0;
setcookie("user", $user, 0, "", "", $SSL);
setcookie("pass", $newpassword, 0, "", "", $SSL);
setcookie("isAdmin", $isAdmin, 0, "", "", $SSL);
setcookie("uid", $uid, 0, "", "", $SSL);
setcookie("hash", md5($user.$uid.$isAdmin.$newpassword."alk4d"), 0, "", "", $SSL);
$pass = $newpassword;
$hash = md5($user.$uid.$isAdmin.$newpassword."alk4d");
ldap_update_password($user, $newpassword); //update password in ldap
}
}//end if($ENABLE_LDAP == "true")
else //if LDAP is disabled
{
if(!db_is_user($user, $oldpassword))
{
message_box("Invalid Current Password, try again", "error");
}
else if($newpassword != $newconfirm_password)
{
message_box("Your two new passwords didn't match, try again", "warning");
}
else
{
//set new cookies so that the user doesn't have to re-login with new password
($SECURE_COOKIES == "true")? $SSL=1: $SSL=0;
setcookie("user", $user, 0, "", "", $SSL);
setcookie("pass", $newpassword, 0, "", "", $SSL);
setcookie("isAdmin", $isAdmin, 0, "", "", $SSL);
setcookie("uid", $uid, 0, "", "", $SSL);
setcookie("hash", md5($user.$uid.$isAdmin.$newpassword."alk4d"), 0, "", "", $SSL);
$pass = $newpassword;
$hash = md5($user.$uid.$isAdmin.$newpassword."alk4d");
db_update_password($user, $newpassword); //update password in DB
}
}//end else if($ENABLE_LDAP == "false")
}//end if(isset($password_change))
if(isset($num_pending))
{
setcookie("num_pending", $num_pending);
}
if(isset($num_assigned))
{
setcookie("num_assigned", $num_assigned);
}
?>
<html>
<head>
<title><?php print($title); ?></title>
<META HTTP-EQUIV="Refresh" content="<?php print($EXPIRE_INTERVAL) ?>;URL=logout.php">
<link rel="stylesheet" type="text/css" href="itms.css" title="Default">
<META NAME="description" CONTENT="This site was created with ITMS.">
<META NAME="author" CONTENT="ValleyData Programming Group">
<?php print_js(); ?>
</head>
<body>
<table>
<tr>
<FORM>
<td colspan="2">
<IMG src="images/itms_header.jpg" WIDTH="<?php print($LOGO_WIDTH_HEADER); ?>" HEIGHT="<?php print($LOGO_HEIGHT_HEADER); ?>" border=0 alt="ITMS">
</td>
<td valign="top" align="left">
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR>
<TD class="table-separator-odd">
<?php
//tell the user who they are logged in as
print("Welcome to ITMS: $user");
?>
</TD>
</TR>
<TR>
<TD class="table-separator-even"><?php
//tell the user which groups they belong to
$groups = get_user_groups($uid);
$size = count($groups);
if($size == 0)
print("You belong to no");
else
print("You are in the ");
$curr = 0;
foreach($groups as $group)
{
$curr++;
if($size == 1)
print(get_group_name($group["gid"]));
else if($curr == $size)
print("and " . get_group_name($group["gid"]));
else
print(get_group_name($group["gid"]) . ", ");
}
print(" groups.");
?>
</TD>
</TR>
<TR>
<TD class="table-separator-odd"><?php
//tell the user how many tasks they have been assigned
if(!isset($num_pending))
{
$num_pending = 0;
db_open();
db_use();
$query = "SELECT * FROM pending_tasks WHERE uid = '$uid' ORDER BY due_date";
$result = db_query($query);
while($row = db_fetch_row($result))
{
$num_pending++;
}
}
print("You have $num_pending Pending Tasks.");
?>
</TD>
</TR>
<TR>
<TD class="table-separator-even"><?php
//tell the user how many tasks have been assigned to them
if(!isset($num_assigned))
{
$num_assigned = 0;
db_open();
db_use();
$query = "SELECT * FROM pending_tasks WHERE assigner = '$uid' ORDER BY due_date";
$result = db_query($query);
while($row = db_fetch_row($result))
{
$num_assigned++;
}
}
print("You have $num_assigned Assigned Tasks.");
?>
</TD>
</TR>
</TABLE>
</td>
<td valign="top" align="left">
<iframe HEIGHT="<?php print($LOGO_HEIGHT_HEADER); ?>" WIDTH="300" frameborder="1" src="help.php<?php print("#" . $PAGE); ?>" name="instant_help">
<B>Click the Help button for help on using ITMS</B>
</iframe>
</td>
<td valign="top" align="left">
<INPUT TYPE="button" value="Help" onClick="window.open('help_system.php?topic=<?php print($PAGE); ?>', 'help', 'height=400,innerHeight=400,width=400,innerWidth=400')">
</td>
</FORM>
</tr>
<tr>
<td valign="top"><?php include("menu.php") ?></td>
<td valign="top" colspan="4">