Location: PHPKode > projects > Eridu - Web based Groupware > eridu-0.9.1/eridu/html/calendar/edittaskroot.php
<?php
/**************************************************************************
 * Eridu - Web based Groupware                                            *
 **************************************************************************
 * Copyright (c) 2000, The Eridu Project                                  *
 **************************************************************************
 * This source file is subject to version 2.0 of the GNU GENERAL PUBLIC   *
 * LICENSE that is bundled with this package in the file COPYING, and is  *
 * available through the world-wide-web at:                               *
 * http://www.gnu.org/copyleft/gpl.html                                   *
 * If you did not receive a copy of the license and are unable to         *
 * obtain it through the world-wide-web, please send a note to            *
 * eridu-hide@address.com so we can mail you a copy          *
 * immediately.                                                           *
 **************************************************************************
 *
 * $Id: edittaskroot.php,v 1.8 2000/12/07 09:20:31 mhroberts Exp $
 */
	include ("eridu.conf");
	include ("$eriduBasePath/html/lib/uiFunctions.php");
	$useTypes=array("calendar");
	uiPreHeader ($useTypes);
	uiHeader ("Edit Task", "compose.css");

	$commonIPath = "$eriduBaseURL/html/images";
	$ipath = "images";

	session_start();
	$temp = 0;

	if (!$isName)
		$isName = $myEriduState->currentIS["calendar"];
   
	$eriduCal =& $myEriduState->ISArray["calendar"][$isName];
	$taskList = $myEriduState->ISArray["calendar"][$isName]->getTasks();
	if (isset($taskid))
	{
		// we need to get the tasknum
		for($i=0;$i<count($taskList);$i++)
		{
			if ($taskList[$i][id] == $taskid)
				$tasknum = $i;
		}
	}

	if (! isset ($activeTab))
		$activeTab = "general";

	if (! isset($tasknum)) {
		$tasknum = count ($taskList);
		$task = array("subject" => "",
			"id" => -1,
			"status" => 0,
			"dueDate" => "None",
			"startDate" => "None",
			"complete" => 0,
			"priority" => 5,
			"dateComplete" => "None",
			"totalWork" => "0 hours",
			"actualWork" => "0 hours",
			"miles" => "0",
			"billingInfo" => "");
 }

	if (!isset($task))
		$task = $taskList[$tasknum];

	$statusstr = array ("Not Started", "Started", "On Hold", "Completed");

?>
<SCRIPT language="Javascript">
function newWindow(fileName,windowName,theWidth,theHeight) {
  window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}
function newFullWindow(fileName,windowName,theWidth,theHeight) {
  window.open(fileName,windowName,"toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}
function submitAction(formAction) {
  document.taskform.formaction.value = formAction;
  document.taskform.submit();
}
function openNewWindow(fileName,windowName,theWidth,theHeight) {
	if (windowName == "newMessageWindow") 
	{
		//generate random window ID

		 windowName = new String(Math.round(Math.random() * 100000));

	}
	window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}

<?php
if (! empty($formaction) ) switch ($formaction)
{
	case "rm":
		$eriduCal->removeTask($taskList[$tasknum][id]);
		if ($opener != "") 
			echo $opener;
		echo "window.close();";
		break;
	case "general":
		if ($useDateComplete) $task["dateComplete"] = mktime (0,0,0,$dateCompleteMonth,$dateCompleteDay,$dateCompleteYear);
		else $task["dateComplete"] = "None";
		$activeTab = "general";
		break;
	case "details":
		if ($useDueDate) $task["dueDate"] = mktime (0,0,0,$dueDateMonth,$dueDateDay,$dueDateYear);
		else $task["dueDate"] = "None";
		if ($useStartDate) $task["startDate"] = mktime (0,0,0,$startDateMonth,$startDateDay,$startDateYear);
		else $task["startDate"] = "None";
		$activeTab = "details";
		break;
	case "save":
		if ($activeTab == "general") {
			if ($useDueDate) $task["dueDate"] = mktime (0,0,0,$dueDateMonth,$dueDateDay,$dueDateYear);
			else $task["dueDate"] = "None";
			if ($useStartDate) $task["startDate"] = mktime (0,0,0,$startDateMonth,$startDateDay,$startDateYear);
			else $task["startDate"] = "None";
		}
		if ($activeTab == "details") {
			if ($useDateComplete) $task["dateComplete"] = mktime (0,0,0,$dateCompleteMonth,$dateCompleteDay,$dateCompleteYear);
			else $task["dateComplete"] = "None";
		}

		if ($task["subject"] == "") {
			echo "alert (\"You must enter a subject\");";
			break;
		}
		$oldTask = $taskList[$tasknum];
		if ($oldTask["status"] != 0 && $task["status"] == 0) {
			$task["complete"] = 0;
			$task["startDate"] = "None";
			$task["dateComplete"] = "None";
		}
		if ($oldTask["complete"] == 0 && $task["complete"] != 0)
			$task["status"] = 1;
		if ($oldTask["complete"] != 100 && $task["complete"] == 100)
			$task["status"] = 3;
		if ($task["startDate"] == "None" && $task["status"] != 0)
			$task["startDate"] = time();
		if ($task["dateComplete"] == "None" && $task["status"] == 3)
			$task["dateComplete"] = time();
		if ($task["status"] == 3)
			$task["complete"] = 100;
		if ($task["id"] == -1)
			$eriduCal->addTask($task);
		else
			$eriduCal->updateTask($task);

		if ($opener != "") {
			echo $opener;
		}
		echo "window.close();";
		break;
}
?>
</SCRIPT>
<FORM name=taskform method=POST action="edittaskroot.php">
<?php
	drawInput ("hidden", "activeTab", $activeTab);
	drawInput ("hidden", "opener", $opener);
	drawInput ("hidden", "formaction", "");
	drawInput ("hidden", "tasknum", $tasknum);
?>
<TABLE bgColor=#c0c0c0 border=0 cellPadding=2 cellSpacing=0 width=450>
	<TR>
		<TD nowrap>
			<A href="javascript:submitAction('save')"><IMG align=middle alt="Save and Close" border=0 height=24 src="<?php echo $commonIPath; ?>/save.gif" width=24></A>
			<IMG align=middle height=24 src="<?php echo $commonIPath; ?>/divider.gif" width=4>
			<A href="javascript:submitAction('rm')"><IMG align=middle alt=Delete border=0 height=24 src="<?php echo $commonIPath; ?>/delmark.gif" width=24></A>
			<IMG align=middle height=24 src="<?php echo $commonIPath; ?>/divider.gif" width=4>
                        <a href="JavaScript:parent.openNewWindow('<?php echo $eriduBaseURL; ?>/calendar/help/taskover.htm','inlineHelpWindow',600,500)">
                        <IMG align="middle" SRC="<?php echo $commonIPath; ?>/help.gif" alt="Get help information on the current window" border=0 width=20 height=20>
                </a>
		</TD>
		<TD align=right>
			<?php drawInput ("button", "", "Close", "", "", "", "onClick=window.close()"); ?>
		</TD>
	</TR>
</TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0>
	<TR>
		<TD height=5 vAlign=top width=5><IMG height=5 src="<?php echo $commonIPath; ?>/tablcor.gif" width=5></TD>
		<TD vAlign=top width=122><IMG height=2 src="<?php echo $commonIPath; ?>/tabWdot.gif" width=122></TD>
		<TD vAlign=top width=5><IMG height=5 src="<?php echo $commonIPath; ?>/tabrcor.gif" width=5></TD>
		<TD height=5 vAlign=top width=5><IMG height=5 src="<?php echo $commonIPath; ?>/tablcor.gif" width=5></TD>
		<TD vAlign=top width=122><IMG height=2 src="<?php echo $commonIPath; ?>/tabWdot.gif" width=122></TD>
		<TD vAlign=top width=5><IMG height=5 src="<?php $commonIPath; ?>/tabrcor.gif" width=5></TD>
	</TR><TR>
		<TD><IMG height=22 src="<?php echo $commonIPath; ?>/tabWdot.gif" width=2></TD>
		<TD align=middle vAlign=top><A href="javascript:submitAction('general')"><FONT size=2>General</FONT></A></TD>
		<TD align=right><IMG height=22 src="<?php echo $commonIPath; ?>/tabrline.gif" width=2></TD>
		<TD><IMG height=22 src="<?php echo $commonIPath; ?>/tabWdot.gif" width=2></TD>
		<TD align=middle vAlign=top><A href="javascript:submitAction('details')"><FONT size=2>Details</FONT></A></TD>
		<TD align=right><IMG height=22 src="<?php echo $commonIPath; ?>/tabrline.gif" width=2></TD>
		<TD><IMG height=22 src="<?php echo $commonIPath; ?>/tabWdot.gif" width=2></TD>
	</TR><TR>
		<?php if( $activeTab == "general" ) echo "<TD colSpan=3 height=2>&nbsp;</TD>\n"?>
		<TD colSpan=3 height=2 vAlign=top><IMG height=2 src="<?php echo $commonIPath; ?>/tabWdot.gif" width=132></TD>
		<?php if( $activeTab == "details" ) echo "<TD colSpan=3 height=2>&nbsp;</TD>\n"?>
	</TR>
</TABLE>
<?php
if ( $activeTab == "general" ) include("edittaskgeneral.php");
if( $activeTab == "details" ) include("edittaskdetails.php");
?>
</FORM>

<?php uiFooter (); ?>
Return current item: Eridu - Web based Groupware