Location: PHPKode > projects > TimeSheet4dotProject > ts4dp/timesheet/drawProjects.php
<?php
// GRAPHS PAGE ONLY WORKS FOR MYSQL DB, WE NEED TO CHANGE mysql_query TO db_loadList, delayed due to object array to json conversion bug
require_once('session.php');
require_once('global4app.php');
if ($_SESSION['uid'] == "")
{
	exit();
}
if ($_REQUEST["selecteduser"] == "0")
{
	//DATE_SUB(SYSDATE(), INTERVAL 31 DAY)	
	$s1_query = 'select ceil(sum(task_log_hours)) as total_time, project_name from dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_date <= \''.$_POST["s1d1"].'\'  and task_log_task = task_id and task_project = project_id and project_company = company_id  and company_id = \''.$_POST["companyID"].'\' group by project_name order by total_time desc';
	$s2_query = 'select ceil(sum(task_log_hours)) as total_time, project_name from dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_date <= \''.$_POST["s2d2"].'\'  and task_log_task = task_id and task_project = project_id and project_company = company_id  and company_id = \''.$_POST["companyID"].'\' group by project_name order by total_time desc';
	$s3_query = 'select ceil(sum(task_log_hours)) as total_time, project_name from dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_date between \''.$_POST["s1d1"].'\' and \''.$_POST["s2d2"].'\'  and task_log_task = task_id and task_project = project_id and project_company = company_id  and company_id = \''.$_POST["companyID"].'\' group by project_name order by total_time desc';
}
else
{
	$s1_query = 'select ceil(sum(task_log_hours)) as total_time, project_name from dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_creator = '.$_REQUEST["selecteduser"].' and task_log_date <= \''.$_POST["s1d1"].'\'  and task_log_task = task_id and task_project = project_id and project_company = company_id  and company_id = \''.$_POST["companyID"].'\' group by project_name order by total_time desc';
	$s2_query = 'select ceil(sum(task_log_hours)) as total_time, project_name from dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_creator = '.$_REQUEST["selecteduser"].' and task_log_date <= \''.$_POST["s2d2"].'\'  and task_log_task = task_id and task_project = project_id and project_company = company_id  and company_id = \''.$_POST["companyID"].'\' group by project_name order by total_time desc';
	$s3_query = 'select ceil(sum(task_log_hours)) as total_time, project_name from dotproject.task_log, dotproject.tasks, dotproject.projects, dotproject.companies where task_log_creator = '.$_REQUEST["selecteduser"].' and task_log_date between \''.$_POST["s1d1"].'\' and \''.$_POST["s2d2"].'\'  and task_log_task = task_id and task_project = project_id and project_company = company_id  and company_id = \''.$_POST["companyID"].'\' group by project_name order by total_time desc';
}

	//echo "//" . $s2_query ."\n";
	$result = mysql_query($s1_query);
	$returnArray = array();
	while($row = mysql_fetch_object($result))
	{
		//array_push($returnArray, $row);
		$returnArray[] = $row;
		//echo $row['project_name'].'-'.$row['total_time'].'<br>';
	}
	print 'ResultSet1p = '.json_encode($returnArray)."\n";
	
	$result = mysql_query($s2_query);
	$returnArray = array();
	while($row = mysql_fetch_object($result))
	{
		//array_push($returnArray, $row);
		$returnArray[] = $row;
		//echo $row['project_name'].'-'.$row['total_time'].'<br>';
	}
	print 'ResultSet2p = '.json_encode($returnArray)."\n";
	
	$result = mysql_query($s3_query);
	$returnArray = array();
	while($row = mysql_fetch_object($result))
	{
		//array_push($returnArray, $row);
		$returnArray[] = $row;
		//echo $row['project_name'].'-'.$row['total_time'].'<br>';
	}
	print 'ResultSet3p = '.json_encode($returnArray)."\n";
?>
Return current item: TimeSheet4dotProject