<?php
/*
* ITMS ValleyData source file version 1.0 May 11, 2001
*
* gather details for the process to be 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="Assign Process - Step 3";
include("header.php");
if(isset($num_tasks)) // if the process is going to be assigned
{
$process_info = trim(make_clean($process_info));
for($i = 0; $i < $num_tasks; $i++)
{
$ttid = "id" . $i;
$task_name = "task_name" . $i;
$assign_to = "assign_to" . $i;
$cc = "cc" . $i;
$notify = "notify" . $i;
$notify_now = "notify_now" . $i;
$am_pm = "am_pm". $i;
$year = "year" . $i;
$month = "month" . $i;
$day = "day" . $i;
$hour = "hour" . $i;
$min = "min" . $i;
$task_info = "task_info" . $i;
$priority = "priority" . $i;
$repeat_amt = "repeat_amt" . $i;
$repeat_unit = "repeat_unit" . $i;
$notify = isset($$notify) ? "1" : "0";
$notify_now = $$notify_now;
if($$am_pm == "1")
{
$$hour += 12;
}
$task_due_date = $$year . "-" . $$month . "-" . $$day . " " . $$hour . ":" . $$min . ":00";
$assign_to = $$assign_to;
$cc = trim($$cc);
$task_name = trim(make_clean($$task_name));
$task_info = trim(make_clean($$task_info));
$priority = $$priority;
$repeat_amt = $$repeat_amt;
$repeat_unit = $$repeat_unit;
$task_info = "General Info: " . $process_info . "\nThis Task Info: " . $task_info;
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'," . $$ttid .", '$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='". $$ttid . "'";
$assigner_name = get_user_name($uid);
$assigner_email = get_user_email($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 new pending tasks and update default assignee
{
message_box("$task_name Assigned Successfully<br>\n");
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");
}
}//end for
//unset($num_tasks);
}
$process_name=get_process_name($process);
if(!isset($num_tasks))
{
print("<IMG SRC=\"images/assign_process.jpg\" WIDTH=\"400\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"Assign Process\">");
print("<br><H3><B>Step 3: $process_name</B></H3>");
}
?>
<form method="post" action="process_assign3.php" name="pa3_form">
<INPUT TYPE="hidden" name="process" value="<?php print($process); ?>">
<table>
<tr>
<td>
<?php
if(!isset($num_tasks))
{
print("<TEXTAREA NAME=\"process_info\" ROWS=\"10\" COLS=\"66\">");
db_open();
db_use();
$query = "SELECT default_info FROM processes WHERE pid = '$process'";
$result = db_query($query); // display process info.
if($row = db_fetch_row($result))
{
print($row["default_info"]);
}
print("</TEXTAREA>");
}
?>
</td>
</tr>
</table>
<?php if(!isset($num_tasks))print("<table border=\"0\">"); ?>
<tr>
<td>
<?php
if(!isset($num_tasks)) // if the user hasn't assign the process yet...
{
//get all tasks types for this process
$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 > 12)
{
$am_select = "";
$pm_select = "selected";
$curr_hour = $curr_hour - 12;
if($curr_hour < 10)
$curr_hour = "0" . $curr_hour;
}
$query = "SELECT title, task_types.ttid FROM task_types, process_tasks " .
"WHERE pid = '$process' AND task_types.ttid = process_tasks.ttid ORDER BY title";
$result = db_query($query); // get tasks that belong to the process
$tnum = 0;
$table_separator_string = "table-separator-even";
$row_separator_num = 0;
while($row = db_fetch_row($result)) // for each task in the process
{
//loop for each task type the amt
$ttamt = "amt" . $row["ttid"];
$ttid = $row["ttid"];
for($i = 0; $i < $$ttamt; $i++)
{
$row_separator_num++;
if($row_separator_num % 2 == 0)
$table_separator_string = "table-separator-even";
else
$table_separator_string = "table-separator-odd";
$db = db_open();
db_use();
//get the default info for that task
$query2 = "SELECT owner, title, group_owned, default_info, default_user FROM task_types " .
"WHERE ttid='$ttid'";
if($result2 = db_query($query2))
{
$row2 = db_fetch_row($result2);
}
$default = $row2["default_user"];
/*print("<INPUT TYPE=\"hidden\" name=\"task_name" . $tnum . "\" value=\"" . $row2["title"] . "\">\n");*/
print("<INPUT TYPE=\"hidden\" name=\"id" . $tnum . "\" value=\"" . $ttid . "\">\n");
print("<table border=\"0\">\n");
print("<tr class=\"$table_separator_string\">\n");
print("<td>Name:<INPUT TYPE=\"text\" NAME=\"task_name" . $tnum . "\" value=\"" . $row2["title"] . "\"></td>\n");
/*print("<td><b>" . $row2["title"] . "</b></td>\n");*/
print("<td>\n");
print("Assign to: <SELECT NAME=\"assign_to$tnum\">");
if($row2["group_owned"] == "1")
{
$users = get_users_in_group($row2["owner"]);
}
else
{
$users = get_users_in_groups($row2["owner"]);
}
$j = 0;
foreach($users as $u) // displays users and set to default assignee
{
$j++;
$selected = "";
if($default == $u["uid"])
{
$selected = "selected";
}
print("<option ". $selected ." value=\"" . $u["uid"] . "\">" . $u["name"] . "</option>\n");
}
if($j == 0)
{
print("<option value=\"" . $uid . "\">" . $user . "</option>\n");
}
print("</SELECT>\n");
print("</td>\n");
print("<td>\n");
print("Priority: <SELECT NAME=\"priority$tnum\">\n");
print("<option value=\"0\">Low</option><option value=\"1\">Medium</option><option value=\"2\">High</option><option value=\"3\">ASAP!!!</option>\n");
print("</SELECT>\n");
print("</td>\n");
print("</tr>\n");
print("<tr class=\"$table_separator_string\">\n");
print("<td>\n");
print("Due: <INPUT TYPE=\"text\" NAME=\"month$tnum\" value=\"$curr_month\" size=\"2\" onblur=\"verify_int(this); verify_date(this, document.pa3_form.year$tnum.value, document.pa3_form.month$tnum.value, document.pa3_form.day$tnum.value, document.pa3_form.hour$tnum.value, document.pa3_form.min$tnum.value)\">/<INPUT TYPE=\"text\" NAME=\"day$tnum\" value=\"$curr_day\" size=\"2\" onblur=\"verify_int(this); verify_date(this, document.pa3_form.year$tnum.value, document.pa3_form.month$tnum.value, document.pa3_form.day$tnum.value, document.pa3_form.hour$tnum.value, document.pa3_form.min$tnum.value)\">/<INPUT TYPE=\"text\" NAME=\"year$tnum\" value=\"$curr_year\" size=\"4\" onblur=\"verify_int(this); verify_date(this, document.pa3_form.year$tnum.value, document.pa3_form.month$tnum.value, document.pa3_form.day$tnum.value, document.pa3_form.hour$tnum.value, document.pa3_form.min$tnum.value)\">");
print("</td>\n");
print("<td>\n");
print("at:<INPUT TYPE=\"text\" NAME=\"hour$tnum\" value=\"$curr_hour\" size=\"2\" onblur=\"verify_int(this); verify_date(this, document.pa3_form.year$tnum.value, document.pa3_form.month$tnum.value, document.pa3_form.day$tnum.value, document.pa3_form.hour$tnum.value, document.pa3_form.min$tnum.value)\">:<INPUT TYPE=\"text\" NAME=\"min$tnum\" value=\"$curr_minute\" size=\"2\" onblur=\"verify_int(this); verify_date(this, document.pa3_form.year$tnum.value, document.pa3_form.month$tnum.value, document.pa3_form.day$tnum.value, document.pa3_form.hour$tnum.value, document.pa3_form.min$tnum.value)\"><SELECT NAME=\"am_pm$tnum\"><option value=\"0\" $am_select>AM</option><option value=\"1\" $pm_select>PM</option></SELECT>");
print("</td>\n");
print("<td>\n");
print("<INPUT TYPE=\"checkbox\" NAME=\"notify$tnum\" checked>Notify Me");
print("<INPUT TYPE=\"checkbox\" NAME=\"notify_now$tnum\" checked>Notify Them");
print("</td>\n");
print("</tr>\n");
print("<tr class=\"$table_separator_string\">");
print("<td valign=\"top\">");
print("Repeat every:<INPUT TYPE=\"text\" NAME=\"repeat_amt$tnum\" value=\"0\" size=\"4\" onblur=\"verify_int(this)\">");
print("<SELECT NAME=\"repeat_unit$tnum\">");
print("<option value=\"0\">days</option>");
print("<option value=\"1\">weeks</option><option value=\"2\">months</option></SELECT><br>");
print("CC:<INPUT TYPE=\"text\" NAME=\"cc$tnum\" size=\"20\">");
print("</td>");
print("<td colspan=\"2\">");
print("<TEXTAREA NAME=\"task_info$tnum\" ROWS=\"2\" cols=\"40\">");
print($row2["default_info"]);
print("</TEXTAREA>");
print("</td>");
print("</tr>");
print("</table>\n");
print("<hr>");
$tnum++;
}//end for
}//end while
}//end if(!isset($num_tasks))
?>
<table>
<tr>
<td>
<INPUT TYPE="hidden" name="num_tasks" value="<?php print($tnum); ?>">
<?php
if(!isset($num_tasks))
{
print("<INPUT TYPE=\"submit\" value=\"Assign Tasks\">");
print("<INPUT TYPE=\"button\" value=\"Cancel\" onClick=\"location='index.php'\">");
}
?>
</td>
</tr>
</table>
</td>
</tr>
<?php if(!isset($num_tasks))print("</table>"); ?>
</form>
<?php include("footer.php"); ?>