<?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');
?>
<table>
  <td width="30" valign="top">&nbsp;</td>
    <td width="490" valign="top"> 
     <!--<h2>Add a computer</h2>-->
<?php
	$dbConn = mysql_select_db("equipment", $equipConn) or die("Couldn't select database equipment");

	if(isset($_POST[monitor_serial]))
	{
		//format date 2003-05-06 13:20:59
		$datetimenow = date('Y-m-d')." ".strftime("%H:%M:%S");
		$monitor_make = $_POST[monitor_make];
		
		if(strtoupper($_POST[monitor_model]) == "")
			$monitor_model = "N/A";
		else
			$monitor_model = strtoupper($_POST[monitor_model]);
			
		$monitor_serial = strtoupper($_POST[monitor_serial]);
		
		if (strtoupper($_POST[monitor_uc_property_num]) == "")
			$monitor_uc_property_num = "N/A";
		else
			$monitor_uc_property_num = strtoupper($_POST[monitor_uc_property_num]);
		
		if(strtoupper($_POST[monitor_lock_key]) == "")
			$monitor_lock_key = "000000";
		else
			$monitor_lock_key = strtoupper($_POST[monitor_lock_key]);
			
		$monitor_size = $_POST[monitor_size];
		$monitor_type = $_POST['monitor_type'];
		
		function error()
		{
			if (mysql_errno() == 1062)
			{
				die("<p><b>".mysql_error()."</b></p><font color=red>'$monitor_serial' already exist in the monitors table.</font>
				<br /><p>Click on back button to make correction.</p>");
			}	
		}
		
		$sql_test = "SELECT monitor_serial FROM monitors WHERE monitor_serial = '$monitor_serial'";

		if (!($tResult = mysql_query($sql_test, $equipConn)))
			echo mysql_errno()."   ".mysql_error();
		else 
		{
			$sql = "INSERT INTO monitors (monitor_make, monitor_model, monitor_serial, monitor_uc_property_num, monitor_lock_key, monitor_size, monitor_type) VALUES ('$monitor_make', '$monitor_model', '$monitor_serial', '$monitor_uc_property_num', '$monitor_lock_key', '$monitor_size', '$monitor_type')";
		
			if( !($result = @mysql_query($sql, $equipConn)))
			{
				error(); //error while query sql statement
				exit;	
			}
			else 
			{	
				//sql to statement to log
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql', '$datetimenow')";
				//log user access
				mysql_query($sql_useraccess, $equipConn);
			
				echo "
				
				<h2><i>Add a Monoitor - Monitor Added</i></h2>
				<table cellspacing='3' cellpadding='3'>
				 <tr>
				  <td VALIGN=top><strong>Monitor Make:</strong><br>$monitor_make</br></td>
				 </tr>
				 <tr>		
				  <td valign=top><P><strong>Monitor Model:</strong><br>$monitor_model</br></td>
				 </tr>		
				 <tr>
				  <td valign=top><strong>Monitor Size:</strong><BR>$monitor_size</br></td>
				 </tr>
		 		 <tr>
				  <td valign=top><strong>Monitor Type:</strong><BR>$monitor_type</br></td>
				 </tr>
				 <tr>
				  <td valign=top><strong>Monitor Serial:</strong><br>$monitor_serial</br></td>
				 </tr>
				 <tr>
				  <td valign=top><strong>UC Proterty Number:</strong><br>$monitor_uc_property_num</br></td>
				 </tr>
				 <tr>
				  <td valign=top><strong>Monitor Lock-Key:</strong><br>$monitor_lock_key</br></td>
				 </tr>
				</table>
				<p><a href='./show_addmonitor.php'>Add Another Monitor</a></p>";
			}//line 45-46
		}//35-36
	}//end if
?>    
	</td>
   </tr>
</table>
<?php 
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); 
?>