<table width="200" border="0" align="center">
  <tr>
    <td><a href="http://ul.uc.edu/uclit/teaming/equipment/add_home.php"><img src="addequip.jpg" alt="Add" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/equipment/sel_allequiptdetail.php"><img src="equipbydept.jpg" alt="dept" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/equipment/show_move.php"><img src="searchequip.jpg" alt="search" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/equipment/show_assignequipt.php"><img src="Assign.jpg" alt="assign" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/equipment/printmon.php"><img src="printmon.jpg" alt="print" width="120" height="50" border="0" /></a></td>
  </tr>
</table>

<?php
	include('/var/www/html/uclit/protected/connections/db_equip.php');
	
	$db = mysql_select_db('equipment', $equipConn) or die ("Unable to select equipment database.");	
	    	
	//format date 2003-05-06 13:20:59
	$datetimenow = date('Y-m-d')." ".strftime("%H:%M:%S");
	
	if(isset($_POST['personnel']) && isset($_POST['pc_serial']) && isset($_POST['m_serial']) && isset($_POST['p_serial']) && isset($_POST['vdjacks']) && isset($_POST['voicejacks']))
	{
		//get date sent from show_assignequipt.php
		$pid = $_POST['personnel'];
		$pc_serial = $_POST['pc_serial'];
		$mserial = $_POST['m_serial'];
		$pserial = $_POST['p_serial'];
		$vdjack_id = $_POST['vdjacks'];
		$voicejack_id = $_POST['voicejacks'];
		$detail_id = $_POST['detailid'];
		
		$displayblock = "<table border='1' class='sortable' id='maintable' cellspacing='2' cellpadding='2'>
						   <tr>
							 <td align='center'>Detail ID</td>
							 <td align='center'>Employee ID</td>
							 <td align='center'>PC Serial</td>
							 <td align='center'>Monitor Serial</td>
							 <td align='center'>Printer Serial</td>
							 <td align='center'>Data Jack ID</td>
							 <td align='center'>Voice Jack ID</td>
						   </tr>";
		//sql statement to check if equipment is already in use
	
			$h2 = 'Equipment is ReAssigned to Equiptment Detail Table';
			
			//computer and monitor hasn't been assigned add to equipment detail table
			//$sql_link_equipt = "INSERT INTO equipment_detail (detail_id, personnel_id, computer_serial, monitor_serial, printer_serial, jacks_id, voice_id) VALUES ('', '$pid', '$pc_serial', '$mserial', '$pserial', '$vdjack_id', '$voicejack_id')";
			
			$sql_link_equipt = "UPDATE equipment_detail SET personnel_id='$pid', computer_serial='$pc_serial', monitor_serial='$mserial', printer_serial='$pserial', jacks_id='$vdjack_id', voice_id='$voicejack_id' WHERE detail_id='$detail_id'";
			//echo"$sql_link_equipt";
			if($sql_result = mysql_query($sql_link_equipt, $equipConn)) //
			{				
				//log user access
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql_link_equipt', '$datetimenow')";
				mysql_query($sql_useraccess, $equipConn);
			
			
			
			
				$sql_room = "UPDATE computers SET room='0' WHERE computer_serial='$pc_serial'";
				$sql_room_result = mysql_query($sql_room, $equipConn);

			
				$sql_detail2 = "SELECT * FROM equipment_detail WHERE detail_id='$detail_id'";
				$sql_detail2_result = mysql_query($sql_detail2, $equipConn);
				while($rowPC = mysql_fetch_array($sql_detail2_result))
				{
					$edid = $rowPC['detail_id'];
					$ekey = $rowPC['personnel_id'];
					$pckey = $rowPC['computer_serial'];
					$mkey = $rowPC['monitor_serial'];
					$pkey = $rowPC['printer_serial'];
					$vdjkey = $rowPC['jacks_id'];
					$voicekey = $rowPC['voice_id'];
										
					$displayblock .= "<tr>
					  					<td align='center'><a href='http://ul.uc.edu/uclit/protected/itstaff/show_relationdetail.php?edid=$edid&uaction=display'>$edid</a></td>
					  					<td align='center'><a href='http://ul.uc.edu/uclit/protected/itstaff/show_addemployee.php?pid=$ekey&uaction=edit'>$ekey</a></td>
					  					<td><a href='http://ul.uc.edu/uclit/protected/itstaff/show_pcspecs.php?computer_serial=$pckey'>$pc_serial</a></td>
					  					<td><a href='http://ul.uc.edu/uclit/protected/itstaff/show_addmonitor.php?monitor_serial=$mkey&uaction=edit'>$mserial</a></td>
					  					<td><a href='http://ul.uc.edu/uclit/protected/itstaff/show_addprinter.php?printer_serial=$pkey&uaction=edit'>$pserial</a></td>
					  					<td align='center'><a href='http://ul.uc.edu/uclit/protected/itstaff/show_addpdjack.php?jack_id=$vdjkey&uaction=edit'>$vdjack_id</a></td>
					  					<td align='center'><a href='http://ul.uc.edu/uclit/protected/itstaff/show_addvjack.php?jack_id=$voicekey&uaction=edit'>$voicejack_id</a></td>
									  </tr>";					
				}	
			}
		}
			else //error while adding 
			{
				echo "<strong><font color='red'>". mysql_errno() ." ..--.. ". mysql_error() ."</font></strong>";
				exit;
			}			
	
	
	echo "  <h2><i>$h2</i></h2>
		    <br />
		    $displayblock
		  </table>
		  <br />
		  <br /><br />
		  <a href='sel_allequiptdetail.php'>List Equipment by Department</a>";
		  
?>