Location: PHPKode > projects > Work project > workproject/include_workload_user.inc
<?php
function cost_workload_user_planned ($userid,$select_project) {

	#calculation of workload planned for the selected user assigned to the current project
	global $filename_log;

	$workload_planned = 0;
	$result_workload = mysql_query("SELECT a.WORKLOAD FROM TASK a, PROJECT b 
		WHERE a.USER_CODE_ASSIGNED = $userid and a.PROJECT_CODE=b.PROJECT_CODE and b.PROJECT_CODE=$select_project") 
		or $error_select=mysql_error();
	write_log_user ($filename_log, "Result: ".$result_workload." - SELECT a.WORKLOAD FROM TASK a, PROJECT b 
		WHERE a.USER_CODE_ASSIGNED = $userid and a.PROJECT_CODE=b.PROJECT_CODE and b.PROJECT_CODE=$select_project");
	if ($error_select) {
		$workload_planned = 0;	
	} else {
		$total_rows_workload = mysql_numrows($result_workload);
		$counter_w = 0;
		$workload_planned = 0;
		while($counter_w < $total_rows_workload) {
			$workload_planned = $workload_planned + mysql_result($result_workload,$counter_w,WORKLOAD);
			$counter_w = $counter_w +1;
		}
		mysql_free_result($result_workload);
	}
	
	return $workload_planned;
}

function cost_workload_user_done ($userid,$select_project){
	
	#calculation of workload done by the selected user assigned to the current project
	global $filename_log;
	$workload_done = 0;
	
	$result_workload = mysql_query("SELECT C_WORKLOAD_DONE 
			FROM COMMENT_TASK a, TASK b, PROJECT c
			WHERE b.USER_CODE_ASSIGNED = $userid and c.PROJECT_CODE=$select_project 
			and a.USERID=$userid
			and a.TASK_CODE=b.TASK_CODE and b.PROJECT_CODE=c.PROJECT_CODE") or $error_select=mysql_error();
	
	if ($error_select) {
		$workload_done = 0;
	} else {
		$total_rows = mysql_numrows($result_workload);
		$counter = 0;
		$workload_done = 0;
		while($counter < $total_rows) {
			$workload_done = $workload_done + mysql_result($result_workload,$counter,C_WORKLOAD_DONE);
			$counter = $counter +1;
		}
		mysql_free_result($result_workload);
	}
	
	return $workload_done;
}

function cost_workload_user_todo ($userid,$select_project) {
	
	#calculation of workload todo by the selected user assigned to the current project
	global $filename_log;
	$workload_todo = 0;
	
	$result_workload = mysql_query("SELECT WORKLOAD_TODO FROM TASK a, PROJECT b
		WHERE USER_CODE_ASSIGNED  = $userid AND TASK_STATE <> 4 
		and b.PROJECT_CODE=$select_project
		and a.PROJECT_CODE=b.PROJECT_CODE") or $error_select=mysql_error();

	if ($error_select) {
		$workload_todo = 0;
	} else {
		$total_rows = mysql_numrows($result_workload);
		$counter = 0;
		$workload_todo = 0;
		while($counter < $total_rows) {
			$workload_todo = $workload_todo + mysql_result($result_workload,$counter,WORKLOAD_TODO);
			$counter = $counter +1;
		}
		mysql_free_result($result_workload);
	}
	
	return $workload_todo;
}
?>
Return current item: Work project