<?
include("connect.inc");
include("reqlogin.inc");
include("userprefs.inc");
// get today's date for _updated fields
include("getcurrdate.inc");
$error_message = "";
//take care of any special characters entered by user
$Information = addslashes($Information);
if (!(checkdate($SelMon, $SelDay, $SelYear)) and ($SelMon)) {
$error_message = "Invalid Date";
}
elseif ($Update) {
if (!($Complete)) {
$UpdToDoSQL = "UPDATE todo SET owner = '$NewSysID', month = '$SelMon', day = '$SelDay', year = '$SelYear', priority = '$NewPriority', information = '$Information', month_updated = '$MonthNum', day_updated = '$DayNum', year_updated = '$YearNum', updated_user = '$UserID' WHERE todo_id = '$id'";
include("updtodoxproj.inc");
}
elseif ($Complete = "Y" and $Update = "Y") {
$UpdToDoSQL = "UPDATE todo SET complete = '$Complete', completed_mon = '$Mon', completed_day = '$Day', completed_year = '$Year' WHERE todo_id = '$id'";
}
else {
$UpdToDoSQL = "UPDATE todo SET owner = '$NewSysID', month = '$SelMon', day = '$SelDay', year = '$SelYear', priority = '$NewPriority', information = '$Information', complete = '$Complete', completed_mon = '$Mon', completed_day = '$Day', completed_year = '$Year' WHERE todo_id = '$id'";
include("updtodoxproj.inc");
}
$UpdToDo = mysql_query($UpdToDoSQL);
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno == 0) {
$Message = "To Do Updated Successfully";
}
else {
$Message = "Error $errno: $error";
}
include("calendar.php");
exit;
}
// read todo
$GetToDoSQL = "SELECT owner, month, day, year, priority, information, complete FROM todo WHERE todo_id = '$id'";
$GetToDo = mysql_query($GetToDoSQL);
$gettodo = mysql_fetch_array($GetToDo);
// read users
include("getallusers.inc");
?>
<html>
<title>Mozart: Update To Do</title>
<body bgcolor=<? echo $bgcolor ?> text=<? echo $txtcolor ?>>
<?
include("links.inc");
?>
<form action="updtodo.php" method="post">
Change to user:<select name="NewSysID">
<?
while ($ownerdata = mysql_fetch_array($OwnerData)) {
if ($ownerdata["user_id"] == $gettodo["owner"]) {
$selected = " selected";
$selected_user = $ownerdata["user_id"];
}
else {
$selected = "";
}
printf("<option value=%s %s>%s", $ownerdata["user_id"], $selected, $ownerdata["system_id"]);
}
?>
</select>
Month: <select name=SelMon>
<?
$x = 1;
while ($x <= 12) {
if ($x == $gettodo["month"]) {
$selected = " selected";
}
else {
$selected = "";
}
printf ("<option%s>%s", $selected, $x);
$x++;
}
?>
</select>
Day: <select name=SelDay>
<?
$x = 1;
while ($x <= 31) {
if ($x == $gettodo["day"]) {
$selected = " selected";
}
else {
$selected = "";
}
printf ("<option%s>%s", $selected, $x);
$x++;
}
?>
</select>
Year: <select name=SelYear>
<?
$current_date = getdate();
$curryear = $current_date["year"];
$x = 1;
while ($x <= 10) {
if ($curryear == $gettodo["year"]) {
$selected = " selected";
}
else {
$selected = "";
}
printf ("<option%s>%s", $selected, $curryear);
$x++;
$curryear++;
}
?>
</select>
<br>
Priority:<select name=NewPriority>
<?
$x = 1;
while ($x <= 3) {
if ($x == $gettodo["priority"]) {
$selected = " selected";
}
else {
$selected = "";
}
printf("<option%s>%s", $selected, $x);
$x++;
}
?>
</select>
Mark Complete <input type=checkbox name=Complete>
<br>
To Do Details:<br><textarea cols=50 rows=10 wrap="hard" name=Information value=$getappt["information"]><? echo $gettodo["information"]?></textarea>
<br>
<?
// get associated project if applicable
$TodoXProjSQL = "SELECT xproj_id FROM todoxproj WHERE xtodo_id=$id";
$TodoXProj = mysql_query($TodoXProjSQL);
$todoxproj = mysql_fetch_array($TodoXProj);
$ProjID = $todoxproj["xproj_id"];
// get all projects for user
$ProjDataSQL = "SELECT proj_id, name FROM project, userxproj WHERE proj_id = xproj_id AND xuser_id = '$selected_user' ORDER BY name";
$ProjData = mysql_query($ProjDataSQL);
print ("Associate with project: <select name=\"ForProject\">");
print ("<option value=0>None");
while ($projdata = mysql_fetch_array($ProjData)) {
if ($projdata["proj_id"] == $ProjID) {
$selected = " selected";
}
else {
$selected = "";
}
printf("<option value=%s%s>%s", $projdata["proj_id"], $selected, $projdata["name"]);
}
print("</select>");
?>
<br>
<input type=submit name=Update value="Update To Do">
<input type=reset value="Reset">
<input type=hidden name=id value=<? echo $id ?>>
<input type=hidden name=Mon value=<? echo $Mon ?>>
<input type=hidden name=Day value=<? echo $Day ?>>
<input type=hidden name=Year value=<? echo $Year ?>>
</form>
<?
include("links.inc");
?>
</body>
</html>