<?php
	include('/var/www/html/uclit/protected/connections/db_help.php');

	//Select a database
	$db1 = mysql_select_db('helpcalls', $helpConn) or die("Couldn't select helpcalls database ");

	$today="";
	
	//conditional query
	if ($_POST['help_tech'] == "") 
	{
		$JobListFor = 'All engineers';
		$query= "SELECT help_id, date_arrived, help_phone, help_desc, help_dept, help_user, help_resolution, help_tech FROM log WHERE (completed is NULL or Completed='0') AND help_catagory != '' ORDER BY help_tech";
	} 
	else 
	{
		$JobListFor = $_POST['help_tech'];
		$query= "SELECT help_id, date_arrived, help_phone, help_desc, help_dept, help_user, help_resolution, help_tech FROM log WHERE (help_tech='$JobListFor' and completed is NULL) or ( help_tech='$JobListFor' and completed=0) AND help_catagory != ''";
	}
		
?><table width="200" border="0" align="center">
  <tr>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/sort_helpcalls.php"><img src="sort3.jpg" alt="Sort" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/show_tech.php"><img src="Check3.jpg" alt="Check" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/show_hreport.php"><img src="Report3.jpg" alt="Report" width="120" height="50" border="0" /></a></td>
    <td><a href="http://ul.uc.edu/uclit/teaming/helpcalls/show_calls.php"><img src="Knowledge3.jpg" alt="Knowledge" width="120" height="50" border="0" /></a></td>
  </tr>
</table>
<table border='1' class="sortable" id="maintable">
  <tr>
	<td align='center'><b>Date Arrived</b></td>
	<td align='center'><b>Department</b></td>
	<td align='center'><b>Assigned To</b></td>
	<td align='center'><b>Description</b></td>
	<td align='center'><b>Posted By</b></td>
	<td align='center'><b>Phone</b></td>
	<td align='center'><b>Edit</b></td>
  </tr>
<?php		

	echo "<p id='headings'>Help Calls for $JobListFor</p>";
	//execute query
	$result = mysql_query($query, $helpConn) or die("Couldn't execute query. <p>$query</p>");
			
	while ($row = mysql_fetch_array($result)) 
	{
		$help_id=$row['help_id'];
		$date_arrived = $row['date_arrived'];
		$help_desc = $row['help_desc'];
		$help_dept = $row['help_dept'];
		$help_user = $row['help_user'];
		$help_phone = $row['help_phone'];
		$help_resolution = $row['help_resolution'];
		$help_tech = $row['help_tech'];
		
		echo "<tr>
				<td>$date_arrived</td>
				<td>$help_dept</td>
				<td>$help_tech</td>
				<td>$help_desc</td>
				<td>$help_user</td>
				<td>$help_phone</td>
				<td  align='center'><a href='edit_ticket.php?help_id=$help_id'><img src='../../images/edit.gif' border='0'></a></td>
			  </tr>";
	}		
	echo"
	</table>
	<p>
	  &nbsp; &nbsp;
	  <a href='show_tech.php'>Return to Select a Tech</a>
	</p>";
?>	
<script language="Javascript1.2">
var message = "Print this Page";

function printpage() 
{
	window.print();  
}

document.write("<form><input type=button "+"value=\""+message+"\" onClick=\"printpage()\"></form>");
</script>
