<?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_equip.php');
	include('/var/www/html/uclit/protected/connections/db_pers.php');
?>	
<h2>Re-Assign Equipment to Employee</h2>
<form action='process_reassign.php' method='post' name='equiptdetail_form'>
  <table border='0' cellspacing='1' cellpadding='1'>
	<tr>
	  <td>Personnel ID</td>
	  <td>Computer Serial</td>
	  <td>Monitor Serial</td>
	</tr>
	<tr>
	  <td><select name='personnel'>
<?php

	$cdetail = $_GET['edid'];
	$cperson = $_GET['pid'];
	$ccomp = $_GET['computer_serial'];
	$cmon = $_GET['monitor_serial'];
	$cprint = $_GET['pkey'];
	$cdj = $_GET['jack_id'];
	$cvj = $_GET['vjack_id'];

	$db = mysql_select_db('uclit_db', $equipConn) or die ("Unable to select equipment database.");
	$sql_personnel = "SELECT personnel_id, last_name, first_name, middle_name FROM personnel ORDER BY last_name";
	$employee_result = mysql_query($sql_personnel, $equipConn) or die ("Unable to query: $sql_personnel");
	while($emp_row = mysql_fetch_array($employee_result))
	{	
		$pid = $emp_row['personnel_id'];
		$lname = $emp_row['last_name'];
		$fname = $emp_row['first_name'];
		$mname = $emp_row['middle_name'];
		echo "\\n<option value='$pid'"; 
		if($cperson==$pid)
			echo" selected ";
		echo">$lname, $fname $mname</option>";
	}
	echo "</select></td>
		<td><select name='pc_serial'>";
	$db = mysql_select_db('equipment', $equipConn) or die ("Unable to select equipment database.");
	$sql_computers = "SELECT computer_serial FROM computers ORDER BY computer_serial";
	$pcserial_result = mysql_query($sql_computers, $equipConn) or die ("Unable to query: $sql_computers");
	while($pc_row = mysql_fetch_array($pcserial_result))
	{
		$case_serial = $pc_row['computer_serial'];
		echo "\\n<option value='$case_serial'";
		if($ccomp==$case_serial)
			echo" selected ";


		echo">$case_serial</option>";
	}
	echo "</select></td>
		<td><select name='m_serial'>";
	$sql_monitors = "SELECT monitor_serial FROM monitors ORDER BY monitor_serial";
	$mserial = mysql_query($sql_monitors, $equipConn) or die ("Unable to query: $sql_monitors");
	while($mon_row = mysql_fetch_array($mserial))
	{
		$mon_serial = $mon_row['monitor_serial'];
		echo "\\n<option value='$mon_serial'";
			if($cmon==$mon_serial)
			echo" selected ";

		echo">$mon_serial</option>";
	}
?>
			</select></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
		<td>Printer Serial</td>
		<td>Data Jack ID</td>
		<td>Voice Jack ID</td>
	  </tr>
	  <tr>
		<td><select name='p_serial'>
<?
	$sql_printers = "SELECT printer_serial FROM printers ORDER BY printer_serial";
	$pserial_result = mysql_query($sql_printers, $equipConn) or die ("Unable to query: $sql_printers");
	while($p_row = mysql_fetch_array($pserial_result))
	{
		$pserial = $p_row['printer_serial'];
		echo "\\n<option value='$pserial'";
		if($cprint==$pserial)
			echo" selected ";
		echo">$pserial</option>";
	} 
	echo "</select></td>
		<td><select name='vdjacks'>";
	
	$sql_vdjacks = "SELECT jack_id, data_jack FROM data_jacks ORDER BY data_jack";
	$vdjacks_result = mysql_query($sql_vdjacks, $equipConn) or die ("Unable to query: $sql_vdjacks");
	while($vdjack_row = mysql_fetch_array($vdjacks_result))
	{
		$jid = $vdjack_row['jack_id'];
		$data_jack = $vdjack_row['data_jack'];
		echo "\\n<option value='$jid'";
			if($cdj==$jid)
			echo" selected ";
		echo">$data_jack</option>";
	}
	echo "</select></td>
		 <td><select name='voicejacks'>";
	
	$sql_voicejacks = "SELECT jack_id, voice_jack FROM voice_jacks ORDER BY voice_jack";
	$voicejacks_result = mysql_query($sql_voicejacks, $equipConn) or die ("Unable to query: $sql_vdjacks");
	echo "\\n<option value='0'>N/A</option>";
	while($voicejack_row = mysql_fetch_array($voicejacks_result))
	{
		$vid = $voicejack_row['jack_id'];
		$voice_jack = $voicejack_row['voice_jack'];
		echo "\\n<option value='$vid'";
			if($cvj==$vid)
			echo" selected ";
		
		echo">$voice_jack</option>";
		
	}
	echo"  </select></td>
	</tr>
    <tr> 
	  	<td>&nbsp;</td></tr>

<tr>
	  <td>	<input name='detailid' type='hidden' value='$cdetail'><input name='submit' type='submit' value='ReAssign'></td>
    </tr>
    <tr>";
?>



	  <td column='3'><br><p><a href='http://ul.uc.edu/uclit/protected/itstaff/show_allequiptdetail.php'>Show All Assigned Equipment</a></p></td>
    </tr>

  </table>

</form>
<?php
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); 
?>