<?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_pers.php');
	include('/var/www/html/uclit/protected/connections/db_comments.php');	

	// FORM Data
	
	//echo strtotime("now"), "\n";
	$twoweeksold = strtotime('-14 day');
		
	// Establish Database Connection
	$dbConn = mysql_select_db("comments", $commentsConn) or die("Couldn't select database");
	
	// Query Database
	
	//use if dept=0 and if type=0 to modify sql query
	
	$sql_main = "
	Select comments.comments.id AS id2, comments.comments.lib AS lib, comments.comments.visit_date AS visit_date, comments.comments.comment_date AS comment_date, comments.comments.patron_type AS patron_type, comments.comments.rating AS rating, comments.comments.`comment` AS `comment`, comments.comments.comment_type AS comment_type, comments.comments.`status` AS `status`, comments.comments.assigned_personnel AS personnel, comments.comments.email_check AS email_check, comments.comments.name AS name, comments.comments.email AS email, uclit_db.departments.dept_id AS dept_id, uclit_db.departments.dept_name AS dept_name, comments.followup_action.id, comments.followup_action.`desc` AS StatusDesc, uclit_db.personnel.personnel_id, uclit_db.personnel.last_name AS LastName, uclit_db.personnel.first_name AS FirstName
From uclit_db.departments Inner Join comments.comments ON uclit_db.departments.dept_id = comments.comments.lib Inner Join comments.followup_action ON comments.followup_action.id = comments.comments.`status` Inner Join uclit_db.personnel ON uclit_db.personnel.personnel_id = comments.comments.assigned_personnel WHERE ((comments.followup_action.id != 1) and (comments.followup_action.id != 5) and (comments.followup_action.id != 6)) ORDER BY comment_date Desc";
	
	//echo "$sql_main<br>";
	//echo "$sql_where<br>";
	$result_main = @mysql_query($sql_main, $commentsConn) or die ("Unable to query: $sql_main");
	
	
	

?>
	<H1>Past Due Comments</H1>
	<H2>It has been more than 2 weeks since these comments were submitted and these comments have not been resolved yet.</H2>
	<table cellspacing="2" cellpadding="2" border="1" bordercolor="#FFFFFF">
	  <tr >
<!--if ("$status" == "0") {  -->
	    <font size="-1">
	    <td bordercolor="#666666"><strong><font size="-1">Open</font></strong></td> 
	    <td bordercolor="#666666"><strong><font size="-1">Department</font></strong></td>
	    <td bordercolor="#666666">Date Visited</td>
	    <td bordercolor="#666666">Description</td>
	    <td bordercolor="#666666">Status</td>
		<td bordercolor="#666666">Person Assigned</td>
         </tr>	
	  <a href="javascript:history.back()"><strong>Main Page</strong></a>
	
<?php
	// $i = 0;
		while($row = @mysql_fetch_array($result_main))
		{
			$list_id = $row['id2'];
			$list_date = $row['visit_date'];
			$comp_date = strtotime("$list_date");
			$list_dept = $row['dept_name'];
			$list_desc = $row['comment'];
			$list_status = $row['StatusDesc'];
			$list_person = $row['personnel_id'];
			$list_lastname = $row['LastName'];
			$list_firstname = $row['FirstName'];
		if($comp_date <= $twoweeksold)
			{	  
			
?>


	  <tr>
<!--if ("$status" == "0") --> 
	  	<td nowrap bordercolor="#666666">
<?php 	
	echo"<a href='edit.php?idnum=$list_id'>open</a>
	</td>";
?>	
		<td nowrap bordercolor="#666666">
		  <font size="-1"><?php echo $list_dept; ?></font>
		</td>
		
		<td nowrap bordercolor="#666666">
		  <font size="-1"><?php echo $list_date; ?></font>
		</td>
		
		<td bordercolor="#666666">
		  <font size="-1"><?php echo $list_desc; ?></font>
		</td>
		
		<td nowrap bordercolor="#666666">
		  <font size="-1"><?php echo $list_status; ?></font>
		</td>
	
		<td nowrap bordercolor="#666666">
		  <font size="-1"><?php echo $list_lastname; echo", "; echo $list_firstname; ?></font>
		</td>
<?php
	$i++;
			}	
	}
?>
	  </tr>
	</table>

<?php include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); ?>