<?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_help.php');

	//Select a database
	$db1 = mysql_select_db('helpcalls', $helpConn) or die("Couldn't select helpcalls database ");
	
	$bdate = $_POST['bdate'];
	$edate = $_POST['edate'];
	$help_type = $_POST['help_catagory'];
	
	if($bdate > $edate)
	{
		echo "<script language='javascript'> history.back(-1);</script>";
	}

	//sql statement to select help catagories
	$sql_helpcat = "SELECT DISTINCT Help_Catagory FROM log ORDER BY Help_Catagory";
	//execute query statement for help catagories
	$helpcat_result = mysql_query($sql_helpcat, $helpConn) or die ("Unable to execute query<p>$sql_helpcat</p>");
	
	echo"
	<table border='1'>
	  <tr>
		<td colspan='2' align='center'><font color='red'><strong>FROM [$bdate] --- TO --- [$edate]</strong></font></td>
	  </tr>
	  <tr>
		<td align='center'><b>Help Call Catagory</b></td>
		<td align='center'><b>Count</b></td>
	  </tr>";
	
	while($row = mysql_fetch_array($helpcat_result))
	{
		$help_type = $row['Help_Catagory'];
		echo"<tr><td>$help_type&nbsp;</td>";
				
		
		$sql = "SELECT COUNT(*) AS 'icount' FROM log WHERE Help_Catagory='$help_type' AND Date_Completed BETWEEN '$bdate' AND '$edate'";
		
		$count_result = mysql_query($sql, $helpConn) or die ("Unable to execute query<p>$sql</p>");
		
		while($row = mysql_fetch_array($count_result))
		{
			$icount = $row['icount'];
			echo"<td align='right'>$icount&nbsp;</td></tr>";
		}
	}
	echo "</table>";
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php');
?>