<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');
	
	error_reporting(0);
	
	if (isset($_POST['puter_serial']) && isset($_POST['uaction']))
	{
		//format date 2003-05-06 13:20:59
		$datetimenow = date('Y-m-d')." ".strftime("%H:%M:%S");
	
		$cserial = strtoupper($_POST['puter_serial']);
		$uaction = $_POST['uaction'];
		//save store data from previous form to corresponding variable
		$wid = strtoupper($_POST['workstation_id']);
		//$cserial = strtoupper($_POST['computer_serial']);
		
		if(!isset($_POST['computer_uc_property_num']) || $_POST['computer_uc_property_num'] == "" || $_POST['computer_uc_property_num'] == null)
			$ucid = 'NONE';
		else
			$ucid = strtoupper($_POST['computer_uc_property_num']);
			
		$ctype = $_POST['comp_type'];
		$cpu = $_POST['cpu_type_speed'];
		$ram = $_POST['ram'];
		$hdd = $_POST['hd_capacity'];
		$vdocard = $_POST['video_card'];
		$sapasset = $_POST['sap_asset_number'];
			
		if(!isset($_POST['sound_card']) || $_POST['sound_card'] == "" || $_POST['sound_card'] == null)
			$sndcard = 'NONE';
		else
			$sndcard = $_POST['sound_card'];
			
		$removeable_storage = $_POST['removeable_storage'];
		
		if(!isset($_POST['cd_rw']))
			$cd_rw = '0';
		else
			$cd_rw = $_POST['cd_rw'];
			
		if(!isset($_POST['dvd']))
			$dvd = '0';
		else			
			$dvd = $_POST['dvd'];
			
		if(!isset($_POST['scsi_adapter']))
			$scsi_adapter = '0';
		else			
			$scsi_adapter = $_POST['scsi_adapter'];
			
		if(!isset($_POST['wand_gun']))
			$wand_gun = '0';
		else
			$wand_gun = $_POST['wand_gun'];
			
		if(!isset($_POST['card_reader']))
			$card_reader = '0';
		else
			$card_reader = $_POST['card_reader'];
				
		$additional_peripherals = $_POST['additional_peripherals'];
		if (!isset($_POST['additional_peripherals']) || $_POST['additional_peripherals'] == "" || $_POST['additional_peripherals'] == null)
			$additional_peripherals = 'NONE';
		
		$installed_date = $_POST['installed_date'];
		if(!isset($_POST['installed_date']) || $_POST['installed_date'] == "" || $_POST['installed_date'] == null)
			$installed_date = '0000-00-00';
		
		if(!isset($_POST['cascade_date']) || $_POST['cascade_date'] == "" || $_POST['cascade_date'] == null)
			$cascade_date = '0000-00-00';
		else			
			$cascade_date = $_POST['cascade_date'];
			
		$cascade_from_location = $_POST['cascade_from_location'];
		if(!isset($_POST['$cascade_from_location']) || $_POST['$cascade_from_location'] == "" || $_POST['$cascade_from_location'] == null)
			$cascade_from_location = '*';
		
		if(!isset($_POST['surplus_date']) || $_POST['sound_card'] == "" || $_POST['sound_card'] == null)
			$surplus_date = '0000-00-00';
		else 
			$surplus_date = $_POST['surplus_date'];
		
		$nic_make = $_POST['nic_make'];
		if(!isset($_POST['nic_make']) || $_POST['nic_make'] == "" || $_POST['nic_make'] == null)
			$nic_make = '*';
		
		$nic_model = $_POST['nic_model'];
		if(!isset($_POST['nic_model']) || $_POST['nic_model'] == "" || $_POST['nic_model'] == null)
			$nic_model = '*';
				
		$network_access_speed = $_POST['network_access_speed'];
		if(!isset($_POST['network_access_speed']) || $_POST['network_access_speed'] == "" || $_POST['network_access_speed'] == null)
			$network_access_speed = '*';
			
		$ip_address = $_POST['ip_address'];
		if(!isset($_POST['ip_address']) || $_POST['ip_address'] == "" || $_POST['ip_address'] == null)
			$ip_address = '*';
			
		$ip_gateway = $_POST['ip_gateway'];
		if(!isset($_POST['ip_gateway']) || $_POST['ip_gateway'] == "" || $_POST['ip_gateway'] == null)
			$ip_gateway = '*';
			
		$mac_address = strtoupper($_POST['mac_address']);
		if(!isset($_POST['mac_address']) || $_POST['mac_address'] == "" || $_POST['mac_address'] == null)
			$mac_address = '*';

		$primary_server = strtoupper($_POST['primary_server']);
		if(!isset($_POST['primary_server']) || $_POST['primary_server'] == "" || $_POST['primary_server'] == null)
			$primary_server = '*';			
			
		$operating_system = $_POST['operating_system'];
		if(!isset($_POST['operating_system']) || $_POST['operating_system'] == "" || $_POST['operating_system'] == null)
			$operating_system = 'Windows 2000';
			
		$office_suite = $_POST['office_suite'];
		if(!isset($_POST['office_suite']) || $_POST['office_suite'] == "" || $_POST['office_suite'] == null)
			$office_suite = '*';
		
		$browser_app = $_POST['browser_app'];
		if(!isset($_POST['browser_app']) || $_POST['browser_app'] == "" || $_POST['browser_app'] == null)
			$browser_app = '*';
			
		$email_app = $_POST['email_app'];
		if(!isset($_POST['email_app']) || $_POST['email_app'] == "" || $_POST['email_app'] == null)
			$email_app = '*';
		
		$graphic_app = $_POST['graphic_app'];
		if(!isset($_POST['graphic_app']) || $_POST['graphic_app'] == "" || $_POST['graphic_app'] == null)
			$graphic_app = '*';
			
		$specialized_appz = $_POST['specialized_appz'];
		if(!isset($_POST['specialized_appz']) || $_POST['specialized_appz'] == "" || $_POST['specialized_appz'] == null)
			$specialized_appz = '*';
			
		$catagory = $_POST['catagory'];
		if(!isset($_POST['catagory']) || $_POST['catagory'] == "" || $_POST['catagory'] == null)
			$catagory = '*';

		//copy of record before update/delete
		$sql_viewed = $sql_viewed = "VIEWED.... workstation_id='$wid', computer_serial='$cserial', "
									."computer_uc_property_num='$ucid', computer_type='$ctype', "
									."cpu_type_speed='$cpu', ram='$ram', hd_capacity='$hdd', "
									."video_card='$vdocard', sound_card='$sndcard', "
									."removeable_storage='$removeable_storage', cd_rw='$cd_rw', "
									."dvd='$dvd', scsi_adapter='$scsi_adapter', wand_gun='$wand_gun', "
									."card_reader='$card_reader', additional_peripherals='$additional_peripherals', "
									."installed_date='$installed_date', cascade_date='$cascade_date', "
									."cascade_from_location='$cascade_from_location', surplus_date='$surplus_date', "
									."nic_make='$nic_make', nic_model='$nic_model', network_access_speed='$network_access_speed', "
									."ip_address='$ip_address', ip_gateway='$ip_gateway', mac_address='$mac_address', "
									."primary_server='$primary_server', operating_system='$operating_system', "
									."office_suite='$office_suite', browser_app='$browser_app', email_app='$email_app', "
									."graphic_app='$graphic_app', specialized_appz='$specialized_appz', catagory='$catagory' ";
		
										
		//connect to equipment database
		$db = mysql_select_db('equipment', $equipConn) or die ("Unable to select equipment database.");
		
		if ($uaction == 'edit')
		{
			$sql_update = "UPDATE computers SET sap_asset_num='$sapasset', workstation_id='$wid', computer_uc_property_num='$ucid', "
						 ."computer_type='$ctype', ram='$ram', hd_capacity='$hdd', "
						 ."cd_rw='$cd_rw', dvd='$dvd', scsi_adapter='$scsi_adapter', wand_gun='$wand_gun', "
						 ."card_reader='$card_reader', additional_peripherals='$additional_peripherals', "
						 ."installed_date='$installed_date', cascade_date='$cascade_date', "
						 ."cascade_from_location='$cascade_from_location', "
						 ."nic_make='$nic_make', nic_model='$nic_model', "
						 ."ip_address='$ip_address', mac_address='$mac_address', "
						 ."primary_server='$primary_server', operating_system='$operating_system', office_suite='$office_suite', "
						 ."browser_app='$browser_app', email_app='$email_app', graphic_app='$graphic_app', "
						 ."specialized_appz='$specialized_appz', catagory='$catagory' WHERE computer_serial='$cserial'";	
						 
			//exercute update query
			$result_update = mysql_query($sql_update, $equipConn) or die ("Unable to exercute query.<p>$sql_update</p>");
			
			//if rows affected is > zero do the following
			if($result_update)
			{
				//log user action - record before update
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql_viewed', '$datetimenow')";
				mysql_query($sql_useraccess, $equipConn);
				//log user action to record
				$sql_useraccess = "INSERT INTO EquipmentUserAccessLog VALUES ('', '$suser', '$sql_update', '$datetimenow')";
				mysql_query($sql_useraccess, $equipConn);
				
				$h3 = "Record [ '$cserial' ] has been successfully updated in $dbname table.";
			}
			
		}//end if for edit
		elseif ($uaction == 'delete')
		{
			$sql_delete = "DELETE FROM computers WHERE computer_serial='$cserial'";
			$result_delete = mysql_query($sql_delete, $equipConn) or die ("Unable to exercute query.<p>$sql_delete</p>");
			
			if($result_delete)
			{
				//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_delete', '$datetimenow')";
				mysql_query($sql_useraccess, $equipConn);

				$h3 = "Record [ '$cserial' ] has been successfully deleted from $dbname table.";	
			}
		}//end else for delete
	}//end (isset($_POST['computer_serial']) && isset($_POST['uaction']))
	else
	{
		header ("location: show_allcomputer.php");
		exit;
	}
		
	echo "<h3>$h3</h3>
		<br /><br />
	
		";
?>