<?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');
	
	//$comp_type = $_POST['comp_type'];
	
	if(isset($_POST['computer_serial']))
	{
		//format date 2003-05-06 13:20:59
		$datetimenow = date('Y-m-d')." ".strftime("%H:%M:%S");
		$workstation_id = strtoupper($_POST['workstation_id']);
		$computer_serial = strtoupper($_POST['computer_serial']);
		$sapasset = ($_POST['sap_asset_number']);
		
		
		if(!isset($_POST['computer_uc_property_num']) || $_POST['computer_uc_property_num'] == "" || $_POST['computer_uc_property_num'] == null)
			$computer_uc_property_num = 'N/A';
		else
			$computer_uc_property_num = $_POST['computer_uc_property_num'];
			
		$computer_type = $_POST['comp_type'];
		
		if(!isset($_POST['sound_card']) || $_POST['sound_card'] == "" || $_POST['sound_card'] == null)
			$sound_card = 'N/A';
		else
			$sound_card = $_POST['sound_card'];
			
		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'];
		//echo "$installed_date";
		if(!isset($_POST['installed_date']) || $_POST['installed_date'] == "" || $_POST['installed_date'] == null)
			$installed_date = '2222-00-00';
		
		$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 = '*';
			
		$ip_address = $_POST['ip_address'];
		if(!isset($_POST['ip_address']) || $_POST['ip_address'] == "" || $_POST['ip_address'] == null)
			$ip_address = '*';
			
		$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 = '*';

		/// ADDED 7/29/04
		switch($computer_type)
		{
			case "":
				$cpu_type_speed = "";
				$ram = "";
				$video_card="";
				$sound_card="";
				$removeable_storage="";
				break;
			case "ALIENWARE":
				$cpu_type_speed = "P4 2.53 GHZ";
				$ram = "1024 MB";
				$video_card="NVIDIA GEFORCE4";
				$sound_card="CREATIVE SP AUDIGY";
				$removeable_storage="DVD-R";
				break;
			case "DELL DIMENSION 8200":
				$cpu_type_speed = "P4";
				$ram = "525 MB";
				$video_card="32 MB NVIDIA w/ TV OUT";
				$sound_card="Turtle Beach";
				$removeable_storage="250 MB ZIP";
				break;
			case "DELL INSPIRON 4000":
				$cpu_type_speed = "";
				$ram = "";
				$video_card="";
				$sound_card="";
				$removeable_storage="";
				break;
			case "DELL INSPIRON 7500":
				$cpu_type_speed = "PIII 500";
				$ram = "128 MB";
				$video_card="RAGE MOBILITY";
				$sound_card="ESS";
				$removeable_storage="100 MB ZIP";
				break;
			case "DELL INSPIRON 8000":
				$cpu_type_speed = "PIII 933";
				$ram = "128 MB";
				$video_card="ATI Graphics";
				$sound_card="ESS";
				$removeable_storage="100 MB ZIP";
				break;
			case "DELL LATITUDE C600":
				$cpu_type_speed = "PIII 850";
				$ram = "256 MB";
				$video_card="";
				$sound_card="";
				$removeable_storage="";
				break;
			case "DELL LATITUDE LS":
				$cpu_type_speed = "PIII 600";
				$ram = "128 MB";
				$video_card="NEOMAGICMAGICMEDIA 256AV";
				$sound_card="NEO MAGIC 256";
				$removeable_storage="100 MB ZIP";
				break;
			case "DELL OPTIPLEX GX1":
				$cpu_type_speed = "PIII 500";
				$ram = "128 MB";
				$video_card="Rage Pro Turbo AGP 2X (English)";
				$sound_card="Crystal";
				$removeable_storage="100 MB ZIP";
				break;
			case "IBM THINKPAD 600":
				$cpu_type_speed = "PII 233";
				$ram = "128 MB";
				$video_card="Neomagic Magic Media";
				$sound_card="Crystal Sound Fusion";
				$removeable_storage="100 MB ZIP";
				break;
			case "IBM THINKPAD X40":
				$cpu_type_speed = "PIM";
				$ram = "256 MB PC2-4200 Slots: 2";
				$video_card="Neomagic Magic Media";
				$sound_card="Crystal Sound Fusion";
				$removeable_storage="";
				break;
			case "IBM THINKPAD T43":
				$cpu_type_speed = "PIM";
				$ram = "512 MB PC2-4200 Slots: 2";
				$video_card="Neomagic Magic Media";
				$sound_card="Crystal Sound Fusion";
				$removeable_storage="";
				break;
			case "MICRON CLIENTPRO 414 ALL-IN-ONE":
				$cpu_type_speed = "P4 3.0 GHZ";
				$ram = "512MB DDR2 SDRAM Slots: 2";
				$video_card = "Intel Integrated Graphics";
				$sound_card = "Vinyl AC97 Sound";
				$removeable_storage = "";
				$CD_RW = "1";
				$DVD = "1";
				break;
			case "MICRON CLIENTPRO 325D":
				$cpu_type_speed = "P4 2.4 GHZ";
				$ram = "256 MB PC2100 Slots: 2";
				$video_card="NVIDIA MX400";
				$sound_card="AC97";
				$removeable_storage="250 MB ZIP";
				$CD_RW="1";
				$DVD="1";
				break;
			case "MICRON CLIENTPRO D845HV-ODY P4":
				$cpu_type_speed = "P4 1.5";
				$ram = "256 MB";
				$video_card="NVIDIA GEFORCE2 32 MB";
				$sound_card="SOUNDMAX";
				$removeable_storage="250 MB ZIP";
				break;
			case "MICRON CLIENTPRO D845GRG-ODYD":
				$cpu_type_speed = "P4 2.4";
				$ram = "256 MB PC2700 Slots: 4";
				$video_card="NVIDIA GEFORCE2 MX400";
				$sound_card="SOUNDMAX";
				$removeable_storage="250 MB ZIP";
				break;
			case "MICRON CLIENTPRO CLT-503 P4 1.7":
				$cpu_type_speed = "P4 1.7";
				$ram = "261 MB PC3200 Slots: 2";
				$video_card="NVIDIA GFORCE 2 32 MB";
				$sound_card="INTEL AC 97";
				$removeable_storage="250 MB ZIP";
				break;
			case "MICRON CLIENTPRO CN PIII933":
				$cpu_type_speed = "PIII 933";
				$ram = "256 MB PC133 Slots: 4";
				$video_card="NVIDIA Vanta AGP 16 MB";
				$sound_card="SOUNDMAX";
				$removeable_storage="250 MB ZIP";
				break;
			case "MICRON CLIENTPRO CN P4 1.5":
				$cpu_type_speed = "P4 1.5";
				$ram = "256 MB PC133 Slots:4";
				$video_card="NVIDIA GEFORCE 2 32 MB";
				$sound_card="SOUNDMAX";
				$removeable_storage="250 MB ZIP";
				break;
			case "MICRON CLIENTPRO CN P4 1.9":
				$cpu_type_speed = "P4 1.9";
				$ram = "256 MB";
				$video_card="NVIDIA GEFORCE 2 32 MB";
				$sound_card="SOUNDMAX";
				$removeable_storage="250 MB ZIP";
				break;
			case "MICRON CLIENTPRO DX5000":
				$cpu_type_speed = "PIII 733";
				$ram = "128 MB";
				$video_card="NVIDIA RIVA TNT2";
				$sound_card="SOUNDMAX";
				$removeable_storage="250 MB ZIP";
				break;
			case "POWERMAC 7200":
				$cpu_type_speed = "Mac 120";
				$ram = "100 MB";
				$video_card="MAC";
				$sound_card="MAC";
				$removeable_storage="100 MB ZIP";
				break;
			case "POWERMAC G3":
				$cpu_type_speed = "G3";
				$ram = "32 MB";
				$video_card="MAC";
				$sound_card="MAC";
				$removeable_storage="100 MB ZIP";
				break;
			case "OTHER":
				$cpu_type_speed = "";
				$ram = "";
				$video_card="";
				$sound_card="";
				$removeable_storage="";
				break;
			case "MICRON CLIENT PRO D865GLC":
				$cpu_type_speed = "P4 2.8";
				$ram = "512 MB DDR SDRAM Slots: 4";
				$video_card="Intel 82865G Graphics Controller";
				$sound_card="SoundMax";
				$removeable_storage="ZIP 250 MB";
				break;
			case "MICRON CLIENT D915GX-ODYD":
				$cpu_type_speed = "P4 2.8";
				$ram = "512 MB";
				$video_card="Intel 82915G Graphics Controller";
				$sound_card="RealTek";
				$removeable_storage="ZIP 250 MB";
				break;	
			case "MICRON CLIENTPRO 434 ALL-IN-ONE":
				$cpu_type_speed = "P4 1.8";
				$ram = "1.024 GB PC2-5300 Slots:2";
				$video_card="Intel Q965/Q963 Express Chipset";
				$sound_card="Intel";
				$removeable_storage="None";
				$hd_capacity="80.0 GB";
				break;
			case "THINKPAD T61P":
				$cpu_type_speed = "Dual Core Intel R 2.0";
				$ram = "2.048 GB";
				$video_card="NVIDIA FX 570M";
				$sound_card="SoundMAX";
				$removeable_storage="None";
				$hd_capacity="80.0 GB";
				break;
			case "THINKPAD T60":
				$cpu_type_speed = "Dual Core Intel R 2.0";
				$ram = "2.048 GB";
				$video_card="NVIDIA FX 570M";
				$sound_card="SoundMAX";
				$removeable_storage="None";
				$hd_capacity="80.0 GB";
				break;	
			case "MICRON CLIENTPRO 385":
				$cpu_type_speed = "Intel Duo Core 2.2 GHz E4500";
				$ram = "3 GB Dual Channel DDR2 667 SDRAM";
				$video_card="GMA3000 64MB Intel";
				$sound_card="Intel HD 5.1";
				$removeable_storage="None";
				$hd_capacity="160 GB Serial ATA";
				break;
			case "LENOVO THINKPAD X61":
				$cpu_type_speed = "Intel Solo Core 1.8 GHz";
				$ram = "3 GB Dual Channel DDR2 PC2-5300";
				$video_card="Intel X3100";
				$sound_card="Intel HD Azalia";
				$removeable_storage="None";
				$hd_capacity="80.0 GB";
				break;
				
		}

	
		/// END ADDED 7/29/2004		
		function error()
		{
			if (mysql_errno() == 1062)
				die("<p><b>Error number: ".mysql_errno()." --- ".mysql_error()."</b></p><font color=red>Data already exist in the computers table.</font>");	
		}

		//include ('./conn_equipment.inc.php');
		$db = mysql_select_db('equipment', $equipConn) or die ("Unable to select equipment database.");
		$sql_test = "SELECT computer_serial FROM computers WHERE computer_serial = '$computer_serial'";

		if (!($tResult = mysql_query($sql_test, $equipConn)))
		{
			echo mysql_errno()."   ".mysql_error();
			echo "<p>$sql_test</p>";	
		}
		else 
		{  //no duplicated id found
		
			//sql statement to insert data into computer table	
			$sql = "INSERT INTO computers 
					VALUES ('$sapasset','$workstation_id', '$computer_serial','$computer_uc_property_num', '$computer_type', 
						'$cpu_type_speed', '$ram', '$hd_capacity', '$video_card', '$sound_card', 
						'$removeable_storage', '$cd_rw', '$dvd', '$scsi_adapter', '$wand_gun', '$card_reader', 
						'$additional_peripherals', '$installed_date', 'NA', 'NA', 
						'$nic_make', '$nic_model', '$ip_address', '$mac_address', '$primary_server', '$operating_system', '$office_suite', 
						'$browser_app', '$email_app', '$graphic_app', '$specialized_appz', '$catagory','','','')";
			//echo $sql;
			if( !($result = @mysql_query($sql, $equipConn)))
			{
				error(); //error while query sql statement
				exit;	
			}
			else 
			{	
		echo "<h2><i>Add a Computer - Computer Added</i></h2>
				<table width='75%' border='1' cellspacing='1' cellpadding='1'>
				  <tr>
					<th colspan='4'><h3>The following information was successfullly added to the computers table.</h3></th>		
				  </tr>
				  <tr>
				    <td align='center'><strong>Workstation ID</strong></td>
				    <td align='center'><strong>Computer Serial</strong></td>
				    <td align='center' colspan='2'><strong>UC Property Number</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$workstation_id</td>
				    <td align='center'>$computer_serial</td>
				    <td align='center' colspan='2'>$computer_uc_property_num</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>Computer Type</strong></td>
				    <td align='center'><strong>CPU Type and Speed</strong></td>
				    <td align='center'><strong>Memory</strong></td>
				    <td align='center'><strong>HD Capacity</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$computer_type</td>
				    <td align='center'>$cpu_type_speed</td>
				    <td align='center'>$ram</td>
				    <td align='center'>$hd_capacity</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>Video Card</strong></td>
				    <td align='center'><strong>Sound Card</strong></td>
				    <td align='center'><strong>Removeable Storage</strong></td>
				    <td align='center'><strong>CD-RW</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$video_card</td>
				    <td align='center'>$sound_card</td>
				    <td align='center'>$removeable_storage</td>
				    <td align='center'>$cd_rw</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>DVD</strong></td>
				    <td align='center'><strong>SCSI Adapter</strong></td>
				    <td align='center'><strong>Wand Gun</strong></td>
				    <td align='center'><strong>Card Reader</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$dvd</td>
				    <td align='center'>$scsi_adapter</td>
				    <td align='center'>$wand_gun</td>
				    <td align='center'>$card_reader</td>
				  </tr>
				  <tr>
				    <td align='center' colspan='4'><strong>Additional Peripherals</strong></td>
				  </tr>
				  <tr>
				    <td align='center' colspan='4'>$additional_peripherals</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>Installed Date</strong></td>
				   </tr>
				  <tr>
				    <td align='center'>$installed_date</td>
				   </tr>
				  <tr>
				    <td align='center'><strong>NIC Make</strong></td>
				    <td align='center'><strong>NIC Model</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$nic_make</td>
				    <td align='center'>$nic_model</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>IP Address</strong></td>
				    <td align='center'><strong>MAC Address</strong></td>
				    <td align='center'><strong>Primary Server</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$ip_address</td>
				    <td align='center'>$mac_address</td>
				    <td align='center'>$primary_server</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>Operating System</strong></td>
				    <td align='center'><strong>Office Suite</strong></td>
				    <td align='center'><strong>Browser</strong></td>
				    <td align='center'><strong>Email App.</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$operating_system</td>
				    <td align='center'>$office_suite</td>
				    <td align='center'>$browser_app</td>
				    <td align='center'>$email_app</td>
				  </tr>
				  <tr>
				    <td align='center' colspan=4><strong>Graphic App.</strong></td>
				  </tr>
				  <tr>
				    <td colspan=4 align='center'>$graphic_app</td>
				  </tr>
				  <tr>
				    <td align='center' colspan=4><strong>Specialized Appz.</strong></td>
				  </tr>
				  <tr>
				    <td colspan=4 align='center'>$specialized_appz</td>
				  </tr>
				  <tr>
				    <td align='center'><strong>Catagory</strong></td>
				    <td align='center' colspan='3'><strong>&nbsp;</strong></td>
				  </tr>
				  <tr>
				    <td align='center'>$catagory</td>
				    <td align='center' colspan='3'>&nbsp;</td>
				  </tr>
				    <tr>
					  <tr>
				    <td align='center'><strong>SAP Asset Number:</strong></td>
				    <td align='center' colspan='3'><strong>&nbsp;</strong></td>
				  </tr>
				    <td align='center'>$sapasset</td>
				    <td align='center' colspan='3'>&nbsp;</td>
				  </tr>
				</table>
				<p><a href='./show_addcomputer.php'>Add Another Computer</a></p></td>";
				}
		}
	}
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); 
?>