Location: PHPKode > projects > TimeSheet4dotProject > ts4dp/timesheet/showReporting.php
<?php
require_once('session.php');
require_once('global4app.php');
if ($_SESSION['uid'] == "")
{
	echo '<html><head><meta http-equiv="refresh" content="5; URL=index.php"></head><body>';
	echo '<center>Fatal Error. You haven\'t logged in properly<br/><a href=index.php>'.'Click Here To exit and login again </a> (forwarded in 5 sec.)</center></body></html>';
	exit();
}
?>
<html>
<head>
<title>Timesheet4dP : Assign reporting hierarchy</title>
<link rel=stylesheet type="text/css" href="./css/main.css">
<script language="javascript" type="text/javascript" src="./js/getObj.js"></script> 
<script>
function getReporting()
{
	//alert (getObj("selecteduser").value);
	var http = getHTTPObject();
	var URLString = 'getReporting.php'
	http.open("POST", URLString, true); 
	var params = "eid=" + getObj("selecteduser").value;
	//alert (params);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{ 
		if (http.readyState == 4) 
		{ 
			var replyValue = http.responseText;
			//alert (replyValue);
			if (replyValue == "")
			{
				//alert ("Unassigned");
				getObj("reportingTo").value = "Unassigned";
			}
			else
			{
				//alert(replyValue);
				getObj("reportingTo").value = replyValue;
			}
			
		}
	}
	http.send(params);
}

function changeReporting()
{
	if (getObj("selecteduser").value == getObj("reportingUser").value)
	{
		alert ("No self-reporting possible");
	}
	else
	{
		//setReporting
		var http = getHTTPObject();
		var URLString = 'setReporting.php'
		http.open("POST", URLString, true); 
		var params = "parent=" + getObj("reportingUser").value + "&child=" + getObj("selecteduser").value ;
		//alert (params);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function() 
		{ 
			if (http.readyState == 4) 
			{ 
				var replyValue = http.responseText;
				alert (replyValue);
			}
		}
		http.send(params);
	}
}
</script>
</head>
<body class=" yui-skin-sam" bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br><br>
<table width=90% cellpadding=7 cellspacing=1 border=1 align=center valign=center>
<tr>
	<td>Assign reporting hierarchy</td>
	<td align=right><a href="startPage.php"><b><h1>Home</h1></b></a></td>
</tr>
<form method=POST action=showReporting.php>
<tr>
	<td align=center rowspan=2>Select a user to view his/her reporting hierarchy... <br><br>
	<input type=hidden id=selectedUsername name=selectedUsername>
	<select align=center id=selecteduser name=selecteduser size=10 onChange="javascript:document.forms[0].selectedUsername.value =document.forms[0].selecteduser.options[document.forms[0].selecteduser.selectedIndex].text;getReporting();"><option value=0>Select a user</option>
	<?php
		$result = db_loadList('select * from users where user_username != \'admin\'');
		foreach($result as $row)
		{
			echo '<option value='.$row['user_id'].'>'.$row['user_username'].'</option>';
		}
	?>
	</select>
	</td>
	<td>was reporting to  <input id=reportingTo name=reportingTo type=text value=Unassigned size=25 disabled></td>
</tr>
<tr>
	<td>should report to
	<select align=center id=reportingUser name=reportingUser size=1 onChange=""><option value=0>Select a user</option>
	<?php
		$result = db_loadList('select * from users');
		foreach($result as $row)
		{
			echo '<option value='.$row['user_id'].'>'.$row['user_username'].'</option>';
		}
	?> 
	</select> &nbsp;&nbsp;  <input type=button value="Update" onClick="changeReporting()">
	</td>
</tr>
</form>
Return current item: TimeSheet4dotProject