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

	$dbConn = mysql_select_db('comments', $commentsConn) or die("Couldn't select database");
	
		
	$ID = $_POST['id'];	
	$response = $_POST['text_response'];
	$technician = $_POST['technician'];
	$status = $_POST['status2'];
	$rating = $_POST['rating'];
	$new_tech = $_POST['new_tech'];
	
	$query= "UPDATE comments SET resolution=\"$response\", assigned_personnel=\"$technician\", status=\"$status\", rating=\"$rating\" WHERE id=\"$ID\"" ;
 
	$result = @mysql_query($query,$commentsConn)
		or die("Couldn't execute query; $query");
		if (!$result) {
			echo"<P>Couldn't update record!";
		}
		else
		{
		echo "
<title>Staff Update</title>
<p>Your record has been updated.</p><BR>

<a href='http://ul.uc.edu/uclit/protected/depthead/comments/sel_commentbyloc.php'>Edit another Comment</a>
</body>
</html>
";

if($new_tech == "true")
		{
			$dbConn = mysql_select_db('uclit_db', $uclit_dbConn) or die("Couldn't select database");
						
			$query_tech_email = "SELECT e_mail FROM personnel WHERE personnel_id = '$technician'";		
			$sql_tech_email = mysql_query($query_tech_email, $uclit_dbConn) or die("Couldn't execute query.<p>$query_tech_email</p>");
			while($row = mysql_fetch_array($sql_tech_email))
			{
				$tech_email = $row['e_mail'];
			}
			if($last_name[1] == "Johnson" && $last_name[0] == "Brian")
				$tech_email = "libhelp@uc.edu";
			elseif($last_name[1] =="Pons")
				$tech_email = "lisa.pons@uc.edu";
			if($tech_email != "")
			{
				//echo "$tech_email<br />";
				$mail_to = $tech_email;
				$mail_subj = "Library Information Technology Services (New Comment Card )";
				$mail_text = "You have a new comment card.\n
					Please visit:\nhttp://ul.uc.edu/uclit/protected/general/comments/sel_commentbyid.php to review your comment card.\n  
					Thanks a lot!\n\nLibrary Information Technology Services.";
				$mail_header = "From: libhelp@uc.edu\r\n";
				$mail_header .= "X-Mailer: server\r\n";
				$mail_header .= "Reply To: libhelp@uc.edu\r\n";
				$sendmail_param = "libhelp@uc.edu";
	
				//mail("$mail_to","$mail_subj","$mail_text","$mail_header","-f$sendmail_param");
				$sentmsgRespondTech = "true";
			}
		}



} ?>
