Location: PHPKode > projects > Internet Task Management System > itms_mysql_build_0111/task_create.php
<?php

/*
 * ITMS ValleyData source file version 1.0 May 11, 2001
 *
 * Used to create a task template
 *
 *
 * 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="Create Task";

include("header.php");
print("<IMG SRC=\"images/create_task.jpg\" WIDTH=\"400\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"Create Task\">");

if(isset($create_task_now)) // If the user has hit the 'create task' button
{
    $task_title = trim(make_clean($task_title));
    $task_info = trim(make_clean($task_info));

	if($task_title != "")
	{
		if($owner == "group_task")
		{
			$owner = $group_num; 
			$group_owned = "1";
		}
		else
		{
			$owner = $uid;
			$group_owned = "0";
		}
		db_open();
		db_use();
		$query = "SELECT * FROM task_types WHERE owner = '$owner' AND group_owned = '$group_owned' AND title = '$task_title'";
		$result = db_query($query); // Check for duplicate name of task template
		if(!isset($task_title) || $task_title == "")
		{
			message_box("Please Enter a Task Name", "error");
		}
		else if(db_fetch_row($result))
		{
			error_out("Attempted to add a Task Name that already exists.", "LOG_DEBUG");
			message_box("Couldn't add Task with Duplicate Name", "error");
		}
		else
		{
			$query = "INSERT INTO task_types (title, owner, default_info, group_owned)" .
					 "VALUES('$task_title', '$owner', '$task_info', '$group_owned')";
			$result = db_query($query); // Insert the new task template

			if($result)
			{
			   message_box("The task: $task_title was added successfully to the Database");
			}
			else
			{
				message_box("Unable to add Task: $task_title to the Database", "error");
			}
		}
		db_close();
	}
	else
	{
	    message_box("Name cannot be blank.  Task not created.<br>\n", "error");
	}
}

?>

<form method="post" action="task_create.php">
<table>
<tr>
	<td>
		Name:<INPUT TYPE="text" NAME="task_title" size="49" value="Task Name">
	</td>
</tr>
<tr>
	<td>
		<TEXTAREA NAME="task_info" ROWS="10" COLS="47">Type Additional Instructions for the Task Here</TEXTAREA>
	</td>
</tr>
<tr>
    <td>
        Owner of Task:
    </td>
</tr>
<tr>
	<td>
		<INPUT TYPE="radio" NAME="owner" value="group_task" checked>Group Task
        <SELECT NAME="group_num">
        <?php
			$all_groups = get_all_groups();
			foreach($all_groups as $group) //  Display all groups user belongs to...
			{
				if(is_user_in_group($uid, $group["gid"]))
					print("<option value=\"" . $group["gid"] . "\">" . $group["groupname"] . "</option>");
				
			}
		?>
        </SELECT>
    </td>
</tr>
<tr>
    <td>
		<INPUT TYPE="radio" NAME="owner" value="private_task">Private Task
	</td>
</tr>

</table>
<p>

<table>
<tr>
	<td>
		<INPUT TYPE="hidden" name="create_task_now" value="true">
		<INPUT TYPE="submit" value="Create Task">
	</td>
	<td>
		<INPUT TYPE="button" value="Finished" onClick="location='index.php'">
	</td>
</tr>
</table>
<p>

</form>

<?php include("footer.php"); ?>
Return current item: Internet Task Management System