<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');
	
	//select a database
	$dbselected = mysql_select_db('equipment', $equipConn) or die ("<p>Unable to select equipment database.</p>");

	//format date 2003-05-06 13:20:59
	$datetimenow = date('Y-m-d')." ".strftime("%H:%M:%S");
	
	if(!isset($_POST['uaction']))
	{
		//page was not called from another page
		header("Location: show_allprinter.php");
		exit;    	
	}
	else 
	{
		$printer_serial = strtoupper($_POST['prntr_serial']);			
		$printer_name = strtoupper($_POST['tf_printer_name']);
		$printer_server = strtoupper($_POST['tf_printer_server']);
		$printer_make = $_POST['printer_make'];
		$printer_model = $_POST['tf_printer_model'];
		$printer_uc = strtoupper($_POST['tf_printer_uc_property_num']);
		
		if($_POST['uaction'] == 'edit')
		{
			//sql statement to track user activity		    
			$sql_viewed = "VIEWED  printer_serial='$printer_serial',  printer_name='$printer_name',  printer_server='$printer_server',  printer_make='$printer_make',  printer_model='$printer_model',  printer_uc_property_num='$printer_uc' ";
			
			//update sql statement
			$sql = "UPDATE printers SET printer_name='$printer_name', printer_server='$printer_server', printer_make='$printer_make',  printer_model='$printer_model',  printer_uc_property_num='$printer_uc' WHERE printer_serial='$printer_serial' ";
			
			//exercute sql statement
			$sql_result = mysql_query($sql, $equipConn) or die ("Couldn't exercute query<p>$sql</p>");
			
			if(!mysql_errno())
			{
				//log user access
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql_viewed', '$datetimenow')";
				@mysql_query($sql_useraccess, $equipConn);
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql', '$datetimenow')";
				@mysql_query($sql_useraccess, $equipConn);
				
				$h2 = "printer_serial[ '$printer_serial' ] has been successfully updated.";
			}
		}
		elseif($_POST['uaction'] == 'delete')
		{
			$sql = "DELETE FROM printers WHERE printer_serial='$printer_serial'";
			
			$sql_result = mysql_query($sql, $equipConn) or die ("Couldn't execute query:<p>$sql</P>");
			if(!mysql_errno())
			{
				//log user access
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql_viewed', '$datetimenow')";
				mysql_query($sql_useraccess, $equipConn);
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql', '$datetimenow')";
				mysql_query($sql_useraccess, $equipConn);
				
				$h2 = "printer_serial[ '$printer_serial' ] has been successfully deleted.";
			}//end if for mysql_errno()
		    	
		}
	}
	echo "
    <h2><i>$h2</i></h2>
	

	<br><br><br><br><br><br><br><br>
    <div align='bottom' id='footer'>";
     $last_modified = filemtime("process_printerud.php");
     print("Last Modified ");
     print(date("m/j/y", $last_modified));
     echo "</div>"; ?>