<?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');
                  
	if(!$_GET['computer_serial'])
	{
		$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 = '';
		$nic_make = '';
		$nic_model = '';
		$network_access_speed = '';
		$ip_address = '';
		$ip_gateway = '';
		$mac_address = '';
		$primary_server = '';
		$operating_system = '';
		$office_suite = '';
		$browser_app = '';
		$email_app = '';
		$graphic_app = '';
		$specialized_appz = '';
		$catagory = '';	
		$sapasset = '';				
		
	}
	else //Page is being called from edit or delete
	{
		$computer_serial = $_GET['computer_serial'];
		$uaction = $_GET['uaction'];

		$db = mysql_select_db('equipment', $equipConn) or die ("Unable to select equipment database.");
		$sql = "SELECT * FROM computers WHERE computer_serial='$computer_serial'";
		$computer_result = mysql_query($sql, $equipConn) or die ("Unable to exercute query: <p>$sql</p>");
		
		while($row = mysql_fetch_array($computer_result))
		{
			$sapasset = $row['sap_asset_num'];
			$workstation_id = $row['workstation_id'];
			$computer_uc_property_num = $row['computer_uc_property_num'];
			$computer_type = $row['computer_type'];
			$cpu_type_speed = $row['cpu_type_speed'];
			$ram = $row['ram'];
			$hd_capacity = $row['hd_capacity'];
			$video_card = $row['video_card'];
			$sound_card = $row['sound_card'];
			$removeable_storage = $row['removeable_storage'];
			$cd_rw = $row['cd_rw'];
			$dvd = $row['dvd'];
			$scsi_adapter = $row['scsi_adapter'];
			$wand_gun = $row['wand_gun'];
			$card_reader = $row['card_reader'];
			$additional_peripherals = $row['additional_peripherals'];
			$installed_date = $row['installed_date'];
			$cascade_date = $row['cascade_date'];
			$cascade_from_location = $row['cascade_from_location'];
			$nic_make = $row['nic_make'];
			$nic_model = $row['nic_model'];
			$ip_address = $row['ip_address'];
			$mac_address = $row['mac_address'];
			$primary_server = $row['primary_server'];
			$operating_system = $row['operating_system'];
			$office_suite = $row['office_suite'];
			$browser_app = $row['browser_app'];
			$email_app = $row['email_app'];
			$graphic_app = $row['graphic_app'];
			$specialized_appz = $row['specialized_appz'];
			$catagory = $row['catagory'];
					
		}//end while
	}	

	if($uaction == '')
	{
		$h2 = 'Add Computer';
		$goto = 'process_computer_add.php';
		$buttonvalue = 'Add this Computer';
	}
	elseif ($uaction == 'edit')
	{
		$h2 = "Update Record[ '$computer_serial' ] from Computers";
		$goto = 'process_computerud.php';
		$buttonvalue = 'Update Computer';
	}
	elseif ($uaction == 'delete')
	{
		$h2 = "Delete Current Record[ '$computer_serial' ] from Computers?";
		$goto = 'process_computerud.php';
		$buttonvalue = 'Delete Computer';
	}
	
	//select statement statement
	$db = mysql_select_db('uclit_db', $uclit_dbConn) or die ("Unable to select uclit_db database.");
	$sql = "SELECT dept_name FROM departments ORDER BY dept_name";
	//execute sql statement
	$result = mysql_query($sql, $uclit_dbConn) or die ("<p>Unable to perform the following query<br><br>$sql</br></br></p>");

   	echo "<h2>$h2</h2>
		  <font color='red'>*</font><font size='-1'>- Indicates required fields</font><br />
		  View list of computer types
          <form action='$goto' method='post' name='computer_form' onSubmit='return validator();'>
            <table width='800'border='1' cellspacing='1' cellpadding='1'>
              <tr>
                <td align='left' width='400'>Workstation ID:&nbsp;<input size='40' type='text' name='workstation_id' value='$workstation_id'><font color='red'>*</font></td><td align='left'>Make and Model:&nbsp;
			<select name='comp_type'>
              <option value='' selected>Select.....</option>
			   <option value='$computer_type' selected>$computer_type</option>
              <option value='ALIENWARE' >ALIENWARE</option>
              <option value='DELL DIMENSION 8200'>DELL DIMENSION 8200</option>
              <option value='DELL INSPIRON 4000'>DELL INSPIRON 4000</option>
              <option value='DELL INSPIRON 7500'>DELL INSPIRON 7500</option>
              <option value='DELL INSPIRON 8000'>DELL INSPIRON 8000</option>
              <option value='DELL LATITUDE C600'>DELL LATITUDE C600</option>
              <option value='DELL LATITUDE D600'>DELL LATITUDE D600</option>
              <option value='DELL LATITUDE LS'>DELL LATITUDE LS</option>
              <option value='IBM THINKPAD 600'>IBM THINKPAD 600</option>
              <option value='IBM THINKPAD T22'>IBM THINKPAD T22</option>
		   	  			  <option value='IBM THINKPAD T43'>IBM THINKPAD T43</option>
			   <option value='IBM THINKPAD T60'>IBM THINKPAD T60</option>
			   <option value='IBM THINKPAD T60P'>THINKPAD T60P</option>
			   <option value='IBM THINKPAD X40'>IBM THINKPAD X40</option>
			   <option value='LENOVO THINKPAD X61'>LENOVO THINKPAD X61</option>
              <option value='MICRON CLIENTPRO 414 ALL-IN-ONE'>MICRON CLIENTPRO 414 ALL-IN-ONE</option>
			  <option value='MICRON CLIENTPRO 434 ALL-IN-ONE'>MICRON CLIENTPRO 434 ALL-IN-ONE</option>
              <option value='MICRON CLIENTPRO 325D'>MICRON CLIENTPRO 325D</option>
	      <option value='MICRON CLIENTPRO 385'>MICRON CLIENTPRO 385</option>
              <option value='MICRON CLIENTPRO CLT-503 P4 1.7'>MICRON CLIENTPRO CLT-503 P4 1.7</option>
              <option value='MICRON CLIENTPRO CN PIII933'>MICRON CLIENTPRO CN PIII933</option>
              <option value='MICRON CLIENTPRO CN P4 1.5'>MICRON CLIENTPRO CN P4 1.5</option>
              <option value='MICRON CLIENTPRO CN P4 1.9'>MICRON CLIENTPRO CN P4 1.9</option>
              <option value='MICRON CLIENTPRO D845GRG-ODYD'>MICRON CLIENTPRO D845GRG-ODYD</option>
	      <option value='MICRON CLIENTPRO D865GLC'>MICRON CLIENTPRO D865GLC</option>
              <option value='MICRON CLIENTPRO D845HV-ODY P4'>MICRON CLIENTPRO D845HV-ODY P4</option>
              <option value='MICRON CLIENTPRO DX5000'>MICRON CLIENTPRO DX5000</option>
              <option value='MICRON CLIENTPRO D915GX-ODYD'>MICRON CLIENTPRO D915GX-ODYD</option>
              <option value='POWERMAC 7200'>POWERMAC 7200</option>
              <option value='POWERMAC G3'>POWERMAC G3</option>
              <option value='OTHER'>OTHER</option>
			
            </select>
			
			<font color=red>*</font>
			</td>    </tr>
            
   				";
   		
	if(empty($uaction))
	{ 
		echo"<td width='400'>Serial Number:&nbsp;
			   <input type='text' size ='40' name='computer_serial' value='$computer_serial'><font color=red>*</font>
			 </td>";
	}
	else
	{
		echo"<td width='400'>Serial Number:&nbsp;
			   <input type='text' size = '40' name='computer_serial' value='$computer_serial' disabled='true'><font color=red>*</font>
			 </td>";
	}
            
    echo "     <td align='left'>UC Property Number:&nbsp;<input size = '20' type='text' name='computer_uc_property_num' value='$computer_uc_property_num'></td></tr>
        
       
        
            <tr>
              <td colspan='3' align='center'>";	
	if (empty($cd_rw))
		echo "<input name='cd_rw' type='checkbox' value='1'>CD-RW &nbsp;";
	else 
		echo "<input name='cd_rw' type='checkbox' value='1' checked>CD-RW&nbsp;"; 
		
	if (empty($dvd))
		echo "<input name='dvd' type='checkbox' value='1'>DVD &nbsp;";
	else
		echo "<input name='dvd' type='checkbox' value='1' checked>DVD &nbsp;";
	
	if (empty($scsi_adapter))
		echo "<input name='scsi_adapter' type='checkbox' value='1'>SCSI Adapter &nbsp;";
	else
		echo "<input name='scsi_adapter' type='checkbox' value='1' checked>SCSI Adapter &nbsp;";
			
	if (empty($wand_gun))
		echo "<input name='wand_gun' type='checkbox' value='1'>Wand Gun &nbsp;";
	else 
		echo "<input name='wand_gun' type='checkbox' value='1' checked>Wand Gun &nbsp;";
			
	if (empty($card_reader))
		echo "<input name='card_reader' type='checkbox' value='1'>Card Reader";
	else 
		echo "<input name='card_reader' type='checkbox' value='1' checked>Card Reader";
                      
    echo "  </td>
    	  </tr>
          <tr>
            <td colspan='3'  align='left'>Additional Peripherals:&nbsp;<input type='text' name='additional_peripherals' size='60' value='$additional_peripherals'></td>
			 <tr>
            <td colspan='3' align='center'><hr width='75%' color='#000066' /></td>
          </tr>
          <tr>
            <td align='left'>NIC Make:
			  <select name='nic_make' id='nic_make'>
        		  <option value='$nic_make'>$nic_make</option>
                  <option value='N/A'>N/A</option>
                  <option value='3COM'>3COM</option>
                  <option value='CISCO'>Cisco</option>
                  <option value='D-LINK'>D-Link</option>
                  <option value='INTEL'>Intel</option>
                  <option value='LINKSKEY'>Linkskey</option>
                  <option value='LINKSYS'>Linksys</option>
                  <option value='NETGEAR'>Netgear</option>
                  <option value='MARVELL YUKON'>Marvell Yukon</option>
                  <option value='SMC'>SMC</option>
				  <option value='BROADCOM'>Broadcom NetXtreme Gigabit</option>
                </select>
			</td>
                <td>NIC Model:&nbsp;<input name='nic_model' type='text' value='$nic_model'></td>
          </tr>
          <tr>
                <td>IP Address:&nbsp;<input type='text' name='ip_address' value='$ip_address'></td>
		        <td>MAC Address:&nbsp;<input type='text' name='mac_address' value='$mac_address'></td>
          </tr>    
          <tr>
            <td align='left'>Primary Server:&nbsp;<input name='primary_server' type='text' value='$primary_server'></td>
             </tr>
          <tr>
            <td colspan='3' align='center'><hr width='75%' color='#000066' /></td>
          </tr>
          <tr>
            <td align='left'>Operating System:
			  <select name='operating_system' id='operating_system'>
        		  <option value='$operating_system' selected>$operating_system</option>
                   <option value='Windows Vista'>Windows Vista</option>
				  <option value='Windows XP SP2'>Windows XP SP2</option>
                  <option value='Windows 2000'>Windows 2000</option>
                  <option value='Windows 2000 Server'>Windows 2000 Server</option>
                  <option value='Mac OS 8'>Mac OS 8</option>
                  <option value='Mac OS 8.1'>Mac OS 8.1</option>
                  <option value='Mac OS 8.5'>Mac OS 8.5</option>
                  <option value='Mac OS 8.6'>Mac OS 8.6</option>
                  <option value='Mac OS 9.x'>Mac OS 9.x</option>
                  <option value='Mac OS X'>Mac OS X</option>
                  <option value='Red Hat Linux 9.0'>Red Hat Linux 9.0</option>
                  <option value='Red Hat Linux 8.0'>Red Hat Linux 8.0</option>
                  <option value='Red Hat Linux 7.3'>Red Hat Linux 7.3</option>
                  <option value='Red Hat Linux 7.2'>Red Hat Linux 7.2</option>
                  <option value='Red Hat Linux 6.2'>Red Hat Linux 6.2</option>
				  <option value='SUSE Linux 10.0'>SUSE Linux 10.0</option>
                   <option value='SUSE Linux 9.0'>SUSE Linux 9.0</option>
				     <option value='SUSE Linux 8.0'>SUSE Linux 8.0</option>
                  <option value='UNIX'>UNIX</option>
                </select><font color=red>*</font>
			</td>
			 <td>Office Suite Application:
			  <select name='office_suite' id='office_suite'>
                  <option value='$office_suite' selected>$office_suite</option>
                  <option value='N/A'>N/A</option>
                  <option value='MS Office 2000 Premium'>MS Office 2000 Premium</option>
                  <option value='MS Office 2000 Professional'>MS Office 2000 Professional</option>
				  <option value='MS Office 2003 Professional'>MS Office 2003 Professional</option>
                  <option value='MS Office 2007 '>MS Office 2007 </option>
                     </select>
			</td>
          </tr>
          <tr>
            <td align='left'>Web Browser Software:
			  <select name='browser_app' id='browser_app'>
        		  <option value='$browser_app' selected>$browser_app</option>
                  <option value='N/A'>N/A</option>
                  <option value='IE 7.0'>IE 7.0</option>
				  <option value='IE 6.0'>IE 6.0</option>
                  <option value='Mozilla Firefox 2'>Mozilla Firefox 2.0</option>
				   <option value='Mozilla Firefox 3'>Mozilla Firefox 3.0</option>
                 </select>
			</td>
           
            <td>E-mail Software:&nbsp;
              <select name='email_app' id='email_app'>
        		  <option value='$email_app' selected>$email_app</option>
                  <option value='N/A'>N/A</option>
                  <option value='Outlook 2000 (Exchange)'>Outlook 2000 (Exchange)</option>
				  <option value='Outlook 2003 (Exchange)'>Outlook 2003 (Exchange)</option>
                  <option value='Outlook 2007 (Exchange)'>Outlook 2007</option>
                  <option value='Outlook Express'>Outlook Express</option>
                 </select>
			</td>
          </tr>
          <tr>
            <td align='left' colspan='3'>Graphic Software:&nbsp;<input name='graphic_app' type='text' size='60' value='$graphic_app'></td>
          </td>
          <tr>
            <td align='left' colspan='3'>Specialized Software:&nbsp;<input name='specialized_appz' type='text' size='60' value='$specialized_appz'></td>
          </tr>
          <tr><td align='left'>Installed Date:&nbsp;<input type='text' name='installed_date' value='$installed_date'></td>
            <td align='left'>Catagory:
			  <select name='catagory'>
                  <option value='$catagory' selected>$catagory</option>
				  <option value='CDROM'>CDROM</option>
                  <option value='INFOCOMMONS'>InfoCommons</option>
                  <option value='PUBLIC'>Public</option>
                  <option value='SERVICE DESK'>Service Desk</option>
				     <option value='SERVER'>Server</option>
                  <option value='SPECIAL SERVICES'>Special Services</option>
                  <option value='STAFF'>Staff</option>
                  <option value='STORAGE'>Storage</option>
                </select><font color=red>*</font></td>
           
		  </tr>
		  <tr><td align='left'>SAP Asset Number:&nbsp;<input size = '20' type='text' name='sap_asset_number' value='$sapasset'></td></tr>";
		  		if($uaction == 'edit')
					echo"<tr> <td>RAM:&nbsp;<input type='text' name='ram' value='$ram'></td><td>HD Capapcity:&nbsp;<input type='text' name='hd_capacity' value='$hd_capacity'></td></tr>";
		
	  
		  echo"
		  <tr>
            <td align='right'><input name='submit' type='submit' value='$buttonvalue'></td>
            <td colspan='2'>
              <input name='puter_serial' type='hidden' value='$computer_serial'>
              <input name='uaction'; type='hidden' value='$uaction'>
            </td>		    
          </tr>
        </table>
        <a href='http://ul.uc.edu/uclit/protected/itstaff/show_allcomputer.php'>List All Computer</a>
        </form>";
		

		
		
		
?>
<script language='JavaScript'>
function validator()
{
	var noErrors;
	var msgError = 'Please enter a value for the following fields\\n';
	var obj = document.computer_form;

	//required fields not blank
	if (obj.workstation_id.value != '' && obj.computer_serial.value != '' && obj.computer_type.value != ''
		&& obj.ram.value != '' && obj.hd_capacity.value != '' && obj.video_card.value != '') 
	{
		noErrors = true;
		return (noErrors);
	}
	else
	{
		noErrors = false;

		//required field/s is blank
		if (obj.workstation_id.value == '')
		{
				msgError += '\\n\\t'workstation ID' field\\n';
				obj.workstation_id.focus();
		}

		if (obj.computer_serial.value == '')
		{
				msgError += '\\t'Computer Serial' field\\n';
				if(obj.workstation_id.value != '')
						obj.computer_serial.focus();
		}

		if (obj.computer_type.value == '')
		{
			msgError += '\\t'Computer Type' field\\n';
		
			if(obj.computer_serial.value != '')
				obj.computer_type.focus();
		}
	
		if (obj.cpu_type_speed.value == '')
		{
			msgError += '\\t'CPU Type and Speed' field\\n';
			
			if(obj.computer_type.value != '')
				obj.cpu_type_speed.focus();
		}
	
		if (obj.ram.value == '')
		{
			msgError += '\\t'Memory (RAM)' list\\n';
			
			if(obj.cpu_type_speed.value != '')
				obj.ram.focus();
		}
	
		if (obj.hd_capacity.value == '')
		{
			msgError += '\\t'HD Capacity' list\\n';
			
			if(obj.ram.value != '')
				obj.hd_capacity.focus();
		}
	
		if (obj.video_card.value == '')
		{
			msgError += '\\t'Video Card' field\\n';
			
			if(obj.hd_capacity.value != '')
				obj.video_card.focus();
		}
	
		if(!noErrors) 
		{
			alert(msgError);
			return (noErrors);
		}
	}
}
</script>
<?php
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); 
?>