<?php
	/**************************************************************************\
	* phpGroupWare - todo list                                                 *
	* http://www.phpgroupware.org                                              *
	* Written by Joseph Engo <jengo@phpgroupware.org>                          *
	* --------------------------------------------                             *
	*  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.                                              *
	\**************************************************************************/

	/* $Id: graphview.php,v 1.11 2001/05/07 02:40:03 jengo Exp $ */

	$phpgw_info['flags'] = array(
		'currentapp' => 'todo'
	);
	include('../header.inc.php');
  
	$db2         = $phpgw->db;
	$gv          = createobject('phpgwapi.matrixview');
	$phpgw->todo = createobject('todo.todo');
  
	// define some colors
	$colors = array(
		'#CC0033',
		'#006600',
		'#00CCFF',
		'#FF6600',
		'#0000FF'
	);

	$gv->matrixview($month,$year);
	
	$phpgw->db->query("select * from phpgw_todo where todo_id_parent=0 AND todo_owner='" . $phpgw_info["user"]["account_id"] ."'");
	while ($phpgw->db->next_record())
   {
		$o++;
		$ind = $o % count($colors);
		if ($phpgw->db->f(todo_startdate)>0 and $phpgw->db->f(todo_enddate)>0) 
		{
			$startd = date("Y", $phpgw->db->f(todo_startdate)).
										date("m",$phpgw->db->f(todo_startdate)).
										date("d",$phpgw->db->f(todo_startdate));
			$endd = date("Y", $phpgw->db->f(todo_enddate)) . 
										date("m",$phpgw->db->f(todo_enddate)) .
										date("d",$phpgw->db->f(todo_enddate));
			$gv->setPeriod($phpgw->strip_html($phpgw->db->f('todo_des')),$startd,$endd, $colors[$ind]);

			$db2->query("select * from phpgw_todo where todo_id_parent=" . $phpgw->db->f("todo_id"));
			while ($db2->next_record())
			{
				if ($db2->f(todo_startdate)>0 and $db2->f(todo_enddate)>0) 
				{
								$startd = date("Y", $db2->f(todo_startdate)).
										date("m",$db2->f(todo_startdate)).
										date("d",$db2->f(todo_startdate));
								$endd = date("Y", $db2->f(todo_enddate)) . 
										date("m",$db2->f(todo_enddate)) .
										date("d",$db2->f(todo_enddate));
								$gv->setPeriod($phpgw->strip_html($db2->f('todo_des')),$startd,$endd, $colors[$ind]);
				}
			}
		}
	}	

	$gv->out($phpgw->link('/todo/graphview.php'));

	$phpgw->common->phpgw_footer();
?>