<?php
/*
* ITMS ValleyData source file version 1.0 May 11, 2001
*
* Gather details about assigned tasks
*
*
* 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="Assign Task - Step 2";
include("header.php");
$done_button_text = "Cancel";
if($assign_task != "true") // If the user has not hit the 'assign task' button
{
if($AT == "one_time_task")
{
$task_name = $task_title;
$group_owned = "0";
$task_type = "";
}
else
{
db_open();
db_use();
$query = "SELECT owner, title, group_owned, default_user FROM task_types WHERE ttid = '$task_type'";
$row = db_fetch_row(db_query($query)); // Harvest info about task template
$group_owned = $row["group_owned"];
$task_name = $row["title"];
$default = $row["default_user"];
}
}
$time = time();
//first: get the date and time
$date_array = getdate($time);
$curr_year = date('Y');
$curr_month = date('m');
$curr_day = date('d');
$curr_hour = date('H');
$curr_minute = date('i');
$curr_second = date('s');
$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;
}
if($assign_task == "true") // If the user has hit the 'assign task' 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";
$task_name = trim(make_clean($task_name));
$task_info = trim(make_clean($task_info));
$repeat_amt = (int)$repeat_amt;
$cc = trim($cc);
if($task_name != "")
{
db_open();
db_use();
$query = "INSERT INTO pending_tasks " .
"(uid, original_id, title, info, assigner, date_assigned, " .
"due_date, notify, priority, period, period_unit) " .
"VALUES ('$assign_to', '$task_type', '$task_name', '$task_info', '$uid', NOW(), " .
"'$task_due_date', '$notify', '$priority', '$repeat_amt', '$repeat_unit')";
$default_user = "UPDATE task_types SET default_user='$assign_to', last_time_used='NOW()' WHERE ttid='" . $task_type . "'";
$assigner_name = get_user_name($uid);
$email_to = get_user_email($assign_to);
$to_name = get_user_name($assign_to);
$priority = get_priority_string($priority);
if(db_query($query) && db_query($default_user)) // Insert pending task and update default assignee
{
message_box("Task Assigned Successfully<br>\n");
$assigner_email = get_user_email($uid);
if(isset($notify_now))
{
notifyAssigned($task_name, $email_to, $to_name, $assigner_name, $assigner_email, $cc, $task_info, $task_due_date, $priority);
}
}
else
{
message_box("Task Assignment Unsuccessfull<br>\n", "warning");
error_out("Error Assigning Task", "LOG_INFO");
}
}
else
{
message_box("Name cannot be blank. Task not assigned.<br>\n", "error");
}
}
print("<IMG SRC=\"images/assign_tasks.jpg\" WIDTH=\"400\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"Assign Task\">");
print("<br><H3><B>Step 2: $task_name</B></H3>");
?>
<form method="post" action="task_assign2.php" name="ta2_form">
<table>
<tr>
<td>
Name:<INPUT TYPE="text" NAME="task_name" value="<?php print($task_name); ?>">
</td>
</tr>
<tr>
<td>
Assign to: <SELECT NAME="assign_to">
<?php
if($group_owned == "1")
{
$groupnum = $row["owner"];
$users = get_users_in_group($groupnum);
}
else
{
$users = get_users_in_groups($uid);
}
$i = 0;
foreach($users as $u) // Display all relevant users in list box and pre-select any default assignee
{
$i++;
$selected = "";
if($default == $u["uid"])
{
$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>
<TEXTAREA NAME="task_info" ROWS="10" COLS="30"><?php
if($AT == "one_time_task")
{
print("Type your task info here");
}
else
{
db_open();
db_use();
$query = "SELECT default_info FROM task_types WHERE ttid = '$task_type'";
$row = db_fetch_row(db_query($query)); // Show task template details in text area
print($row["default_info"]);
}
?></TEXTAREA>
</td>
</tr>
<tr>
<td>
Due Date and Time
</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.ta2_form.year.value, document.ta2_form.month.value, document.ta2_form.day.value, document.ta2_form.hour.value, document.ta2_form.min.value)">/<INPUT TYPE="text" NAME="day" value="<?php print($curr_day); ?>" size="2" onblur="verify_int(this); verify_date(this, document.ta2_form.year.value, document.ta2_form.month.value, document.ta2_form.day.value, document.ta2_form.hour.value, document.ta2_form.min.value)">/<INPUT TYPE="text" NAME="year" value="<?php print($curr_year); ?>" size="4" onblur="verify_int(this); verify_date(this, document.ta2_form.year.value, document.ta2_form.month.value, document.ta2_form.day.value, document.ta2_form.hour.value, document.ta2_form.min.value)">
</td>
</tr>
<tr>
<td>
Time: <INPUT TYPE="text" NAME="hour" value="<?php print($curr_hour); ?>" size="2" onblur="verify_int(this); verify_date(this, document.ta2_form.year.value, document.ta2_form.month.value, document.ta2_form.day.value, document.ta2_form.hour.value, document.ta2_form.min.value)">:<INPUT TYPE="text" NAME="min" value="<?php print($curr_minute); ?>" size="2" onblur="verify_int(this); verify_date(this, document.ta2_form.year.value, document.ta2_form.month.value, document.ta2_form.day.value, document.ta2_form.hour.value, document.ta2_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>
Priority: <SELECT NAME="priority"><option value="0">Low</option><option value="1">Medium</option><option value="2">High</option><option value="3">ASAP!!!</option></SELECT>
</td>
</tr>
<tr>
<td>
<INPUT TYPE="checkbox" NAME="notify" checked>Notify me when this task is completed.
</td>
</tr>
<tr>
<td>
<INPUT TYPE="checkbox" NAME="notify_now" checked>Notify them that they have been assigned this task.
</td>
</tr>
</table>
<p>
<TABLE>
<TR>
<TD>Repeat every:<INPUT TYPE="text" NAME="repeat_amt" size="4" value="0" onblur="verify_int(this)"><SELECT NAME="repeat_unit"><option value="0">days</option><option value="1">weeks</option><option value="2">months</option></SELECT></TD>
</TR>
<TR>
<TD>CC:<INPUT TYPE="text" NAME="cc" size="30"></TD>
</TR>
</TABLE>
<table>
<tr>
<td>
<INPUT TYPE="hidden" name="assign_task" value="true">
<INPUT TYPE="hidden" name="task_type" value="<?php print($task_type); ?>">
<INPUT TYPE="hidden" name="default" value="<?php print($default); ?>">
<INPUT TYPE="submit" value="Assign Task">
<INPUT TYPE="button" value="<?php print($done_button_text); ?>" onClick="location='index.php'">
</td>
</tr>
</table>
<p>
</form>
<?php include("footer.php"); ?>