<?php
/*
* ITMS ValleyData source file version 1.0 May 11, 2001
*
* This is editing a pending task that the current user has assigned
*
*
* 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.
*/
$title="Edit Pending Task";
include("header.php");
print("<h2>Edit Pending Task: $edit_pending_name</h2>\n");
$done_button_text = "Cancel";
if($edit_now == "true") // If they have hit the 'save changes' button
{
$done_button_text = "Finished";
$notify = isset($notify) ? "1" : "0";
if($hour == 12) //Special Noon/Midnight Logic
{
$hour = ($am_pm == "1") ? 12: 0;
}
else if($am_pm == "1")
{
$hour += 12;
}
$task_due_date = "$year-$month-$day $hour:$min:00";
$edit_pending_name = trim(make_clean($edit_pending_name));
$task_info = trim(make_clean($task_info));
$repeat_amt = (int)$repeat_amt;
$cc = trim($cc);
if($edit_pending_name != "")
{
db_open();
db_use();
$query2 = "SELECT original_id FROM pending_tasks WHERE tid='$edit_pending'";
$row = db_fetch_row(db_query($query2));
$original = $row["original_id"];
//message_box("SELECT original_id FROM pending_tasks WHERE tid='$edit_pending'");
db_open();
db_use();
$query = "UPDATE pending_tasks SET title='$edit_pending_name', uid='$assign_to', info='$task_info', " .
"due_date='$task_due_date', notify='$notify', priority='$priority', period='$repeat_amt', " . "period_unit='$repeat_unit' WHERE tid='$edit_pending'";
$default_user = "UPDATE task_types SET default_user='$assign_to' WHERE ttid='$original'";
$assigner_name = get_user_name($uid);
$assigner_email = get_user_email($uid);
$email_to = get_user_email($assign_to);
$priority = get_priority_string($priority);
if(db_query($query) && db_query($default_user)) // Update pending task details and reset default user
{
message_box("Task Modified Successfully<br>\n");
notifyUpdate($task_name, $email_to, $assigner_name, $assigner_email, $task_info, $task_due_date, $priority);
}
else
{
message_box("Task Modification Unsuccessful<br>\n", "warning");
}
}
else
{
message_box("Name cannot be blank. Pending task not changed.<br>\n", "error");
}
}
db_open();
db_use();
$query = "SELECT * FROM pending_tasks WHERE tid='$edit_pending'";
$query_task_type = "SELECT owner, group_owned FROM pending_tasks, task_types WHERE tid='$edit_pending' AND ttid=original_id";//Get Task Types attached to the task we are edditing
$row_task_type = db_fetch_row(db_query($query_task_type)); // Get all task type info from the pending task ID
$row = db_fetch_row(db_query($query)); // Get all pending task info from pending task ID
$info = $row["info"];
$notify = "";
if($row["notify"] == "1")
$notify = "checked";
$priority = $row["priority"];
$period = $row["period"];
$period_unit = $row["period_unit"];
$assigned_to = $row["uid"];
$assigned_to_name = get_user_name($assigned_to);
print("Currently assigned to: $assigned_to_name");
$due_date = $row["due_date"];//sample: 2001-03-11 18:59:56
$curr_year = substr($due_date, 0, 4);
$curr_month = substr($due_date, 5, 2);
$curr_day = substr($due_date, 8, 2);
$curr_hour = substr($due_date, 11, 2);
$curr_minute = substr($due_date, 14, 2);
$am_select = "selected";
$pm_select = "";
if($curr_hour == 0) //12 AM (Midnight)
{
$curr_hour = 12;
}
else if($curr_hour == 12) //12 PM (Noon)
{
$am_select = "";
$pm_select = "selected";
}
else if($curr_hour > 12)
{
$am_select = "";
$pm_select = "selected";
$curr_hour = $curr_hour - 12;
if($curr_hour < 10)
$curr_hour = "0" . $curr_hour;
}
?>
<FORM METHOD=POST ACTION="task_pending_edit.php" name="tpe_form">
<table>
<tr>
<td>Name:<INPUT TYPE="text" NAME="edit_pending_name" value="<?php print($edit_pending_name); ?>"></td>
</tr>
<tr>
<td>
<TEXTAREA NAME="task_info" ROWS="10" COLS="30"><?php print($info); ?></TEXTAREA>
</td>
</tr>
<tr>
<td>
Assign to: <SELECT NAME="assign_to">
<?php
if($row_task_type["group_owned"] == "1")
{
$groupnum = $row_task_type["owner"];
$users = get_users_in_group($groupnum);
}
else
{
$users = get_users_in_groups($uid);
}
$i = 0;
foreach($users as $u) // Show all relevant users in list box
{
$i++;
$assigned_to == $u["uid"] ? $selected = "selected" : $selected = "";
print("<option $selected value=\"" . $u["uid"] . "\">" . $u["name"] . "</option>\n");
}
if($i == 0)
{
print("<option value=\"" . $uid . "\">" . $user . "</option>\n");
}
//db_close();
?>
</SELECT>
</td>
</tr>
<tr>
<td>
Priority:
<SELECT NAME="priority">
<option <?php if($priority == "0")print("selected"); ?> value="0">Low</option>
<option <?php if($priority == "1")print("selected"); ?> value="1">Medium</option>
<option <?php if($priority == "2")print("selected"); ?> value="2">High</option>
<option <?php if($priority == "3")print("selected"); ?> value="3">ASAP!!!</option>
</SELECT>
</td>
</tr>
<tr>
<td>
Date: <INPUT TYPE="text" NAME="month" value="<?php print($curr_month); ?>" size="2" onblur="verify_int(this); verify_date(this, document.tpe_form.year.value, document.tpe_form.month.value, document.tpe_form.day.value, document.tpe_form.hour.value, document.tpe_form.min.value)">/<INPUT TYPE="text" NAME="day" value="<?php print($curr_day); ?>" size="2" onblur="verify_int(this); verify_date(this, document.tpe_form.year.value, document.tpe_form.month.value, document.tpe_form.day.value, document.tpe_form.hour.value, document.tpe_form.min.value)">/<INPUT TYPE="text" NAME="year" value="<?php print($curr_year); ?>" size="4" onblur="verify_int(this); verify_date(this, document.tpe_form.year.value, document.tpe_form.month.value, document.tpe_form.day.value, document.tpe_form.hour.value, document.tpe_form.min.value)">
Time: <INPUT TYPE="text" NAME="hour" value="<?php print($curr_hour); ?>" size="2" onblur="verify_int(this); verify_date(this, document.tpe_form.year.value, document.tpe_form.month.value, document.tpe_form.day.value, document.tpe_form.hour.value, document.tpe_form.min.value)">:<INPUT TYPE="text" NAME="min" value="<?php print($curr_minute); ?>" size="2" onblur="verify_int(this); verify_date(this, document.tpe_form.year.value, document.tpe_form.month.value, document.tpe_form.day.value, document.tpe_form.hour.value, document.tpe_form.min.value)"><SELECT NAME="am_pm"><option value="0" <?php print($am_select); ?>>AM</option><option value="1" <?php print($pm_select); ?>>PM</option></SELECT>
</td>
</tr>
<tr>
<td>
<INPUT TYPE="checkbox" NAME="notify" <?php print($notify); ?>>Notify me when task is completed
</td>
</tr>
<TR>
<TD>Repeat every:
<INPUT TYPE="text" NAME="repeat_amt" size="4" value="<?php print($period); ?>" onblur="verify_int(this)">
<SELECT NAME="repeat_unit">
<option value="0" <?php if($period_unit == "0")print("selected"); ?>>days</option>
<option value="1" <?php if($period_unit == "1")print("selected"); ?>>weeks</option>
<option value="2" <?php if($period_unit == "2")print("selected"); ?>>months</option>
</SELECT>
</TD>
</TR>
<tr>
<td colspan="2">
<INPUT TYPE="hidden" name="edit_pending" value="<?php print($edit_pending); ?>">
<INPUT TYPE="hidden" name="edit_now" value="true">
<INPUT TYPE="submit" value="Save Changes">
<INPUT TYPE="button" value="<?php print($done_button_text); ?>" onClick="location='index.php'">
</td>
</tr>
</table>
</FORM>
<?php include("footer.php"); ?>