<?php
	include('/var/www/html/uclit/protected/common/login/check.php'); 
 	include('/var/www/html/uclit/protected/common/css_login/css_head2.php'); 
	include ('/var/www/html/uclit/protected/connections/db_help.php');
	
	$today="";
	$dbConn2 = mysql_select_db("uclit_db", $uclit_dbConn) or die("Couldn't select database");
	
	$sql_dept = "SELECT dept_id, dept_name FROM departments ORDER BY dept_name";
	$dept_result = mysql_query($sql_dept, $uclit_dbConn) or die("Couldn't execute query. <p>$sql_dept</p>");
		
?>	
<h2><center>UNIVERSITY LIBRARIES
<br />
TELEPHONE AND DEPARTMENTAL LISTING</center></h2>
<h3><center>(Back section includes listing for Academic Information Technology
<br />
and Libraries, Clermont, Law and Raymond Walters Libraries)</center></h3>
<br />
<h2><center><?php echo date("F"); echo" - "; echo date("Y"); ?></center></h2>
<br />
<table border="0" width="100%">
	<tr>
		<td width="50%"><strong><u>Department</u></strong></td>
		<td width="30%"><strong><u>Telephone</u></strong></td>
		<td width="20%"><strong>Office/<br /><u>Mail Location</u></strong></td>
	</tr>
</table>
<?php	
	while ($row_dept = @mysql_fetch_array($dept_result))
	{
		$dept_id = $row_dept['dept_id'];
		$dept_name = $row_dept['dept_name'];
		
		echo"<h2>$dept_name</h2>";

		$sql_per = "SELECT last_name, first_name, middle_name, dept_id, phone, room FROM personnel WHERE (dept_id = '$dept_id' and removed != '1') 
					ORDER BY last_name";
		$per_result = mysql_query($sql_per, $uclit_dbConn) or die("Couldn't execute query. <p>$sql_per</p>");
	
		while ($row_per = @mysql_fetch_array($per_result)) 
		{
			$lname = $row_per['last_name'];
			$fname = $row_per['first_name'];
			$mname = $row_per['middle_name'];
			$phone = $row_per['phone'];
			$room = $row_per['room'];
echo"		
<table border='1' width='100%'>
	<tr>
		<td width='50%'>$lname, $fname $mname</td>
		<td width='30%'>$phone</td>
		<td width='20%'>$room</td>
	</tr>
</table>";

		}
	}
?>
<br />
<br />
<center><strong><u>PERSONNEL DIRECTORY</u></strong>
<br />
<br />
(With Selected Listing for Law; AIT&L, RWC and Clermont)</center>
<br />
<table border="1" id="output" width="100%">
	<tr>
		<td><strong><u>NAME</u></strong></td>
		<td><strong><u>Department</u></strong></td>
		<td><strong><u>ML#</u></strong></td>
		<td><strong><u>E-MAIL#</u></strong></td>
		<td><strong><u>PHONE#</u></strong></td>
	</tr>

<?php	
	$sql_all = "SELECT DISTINCT departments.dept_name, personnel.last_name, personnel.first_name, personnel.middle_name, 
				personnel.e_mail, personnel.phone,personnel.removed, personnel.type_id, departments.mail_location FROM personnel INNER JOIN departments  ON departments.dept_id=personnel.dept_id WHERE (personnel.removed != '1' AND personnel.type_id = '1') ORDER BY personnel.last_name"; 
	$all_result = mysql_query($sql_all, $uclit_dbConn) or die("Couldn't execute query. <p>$sql_all</p>");
	
	while ($row_all = @mysql_fetch_array($all_result)) 
	{
		$dept = $row_all['dept_name'];
		$lname = $row_all['last_name'];
		$fname = $row_all['first_name'];
		$mname = $row_all['middle_name'];
		$email = $row_all['e_mail'];
		$phone = $row_all['phone'];
		$mail = $row_all['mail_location'];
	
		echo"<tr>
				<td>$lname, $fname $mname</td>
				<td>$dept</td>
				<td>$mail</td>
				<td>$email</td>
				<td>$phone</td>
			</tr>";
	}
	
	echo"</table>";
	echo date("F Y");
	
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); 
?>