<?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');
?>
<h2> University Libraries User Comment Entry</h2>

<form action="process.php" method="POST">

<table cellspacing="2" cellpadding="2" border="0">

<tr>
	<td colspan="2"><font face="Tahoma"><font size="-1">Which of the University Libraries did you visit?</font></font><br>
		<select name="lib">
		
		<?php
		$sqlConn = mysql_connect($hostname, $username, $password) or die("Couldn't connect to database");
		$dbConn = mysql_select_db("uclit_db", $uclit_dbConn) or die("Couldn't select database");

		$sql = "Select dept_id, dept_name From departments WHERE (dept_id = 12 OR dept_id=23 OR dept_id=42 OR dept_id=30 OR dept_id=15 OR dept_id=33 OR dept_id=9 OR dept_id=4 OR dept_id=16 OR dept_id=7 OR dept_id=10 OR dept_id=31 OR dept_id=13 OR dept_id=23 OR dept_id=20 or dept_id=8 or dept_id=47)
";
		$result_lib = mysql_query($sql);
		while ($lib_row = mysql_fetch_array($result_lib))
		{
			$lib_name = $lib_row['dept_name'];
			$lib_id = $lib_row['dept_id'];
			echo $lib_name;
		?>
		<option value="<?php echo $lib_id?>"><?php echo $lib_name?></option>
		<?php 
		}
		?>
		
		</select>
	</td>
</tr>
<tr>
	<td colspan="2">
<font size="-1"><font face="Tahoma">When did you visit this library?</font></font><br>

<?php 

// Set default date information
$sel_d = date('d');
$sel_m = date('m');
$sel_y = date('Y');

$min_y = date('Y');			// minimum year
$max_y = date('Y');			// maximum year

$sel_y = date('Y');			//default year, this year
$sel_m = date('m');			//default month;
$sel_d = date('d');			//default day;

$min_y = ($sel_y - 1);




// MONTH

	echo "<select name='month'>";
	
	for ($i = 1; $i <= 12; $i++) {
	 echo '\t<option value="'. $i. '"';

    if ($i == $sel_m) 
      echo ' selected="selected"';

    echo '>'. date('F', mktime(3, 0, 0, $i)). '</option>';

  }

  // Close the select element
  echo '</select>';
// END MONTH


// DAY
  echo "<select name='day'>";

  // Loop round and create an option element for each day (1 - 31)
  for ($i = 01; $i <= 31; $i++) {

    // Start the option element
    echo '\t<option value="'. $i. '"';

    // If this is the selected day, add the selected attribute
    if ($i == $sel_d) {
      echo " selected";
	}
    // Display the value and close the option element
    echo '>'. $i. '</option>';

  }

  // Close the select element
  echo '</select>';
// END DAY


// YEAR
echo "<select name='year'>";
for ($i = $min_y; $i <= $max_y; $i++) {
    echo '\t<option value="'. $i. '"';

	if ($i == $sel_y) 
	  echo "selected='selected'";
	  echo '>'. $i. '</option>\n';

  }

  // Close the select element
  echo "</select>";
// END YEAR
?>



	</td>
	
</tr>


<tr>
	<td colspan="2">
<font size="-1"><font face="Tahoma">Please select one</font></font><br>
<input type="radio" name="who" value="Student"><font size="-1"><font face="Tahoma">Student&nbsp;</font></font>
<input type="radio" name="who" value="Faculty"><font size="-1"><font face="Tahoma">Faculty&nbsp;</font></font>
<input type="radio" name="who" value="Staff"><font size="-1"><font face="Tahoma">Staff&nbsp;</font></font>
	</td>
	
</tr>
<tr>
	<td colspan="2">
<input type="radio" name="who" value="Emeritus"><font size="-1"><font face="Tahoma">Emeritus&nbsp;</font></font>
<input type="radio" name="who" value="Visitor"><font size="-1"><font face="Tahoma">Visitor&nbsp;</font></font>
<input type="radio" name="who" value="Other"><font size="-1"><font face="Tahoma">Other&nbsp;</font></font>
	</td>
	
</tr>



<tr>
	<td height="166" colspan="2">
	  <p><font face="Tahoma"><font size="-1">Select Comment Type: </font></font></p>
	  <p><font size="-1" face="Tahoma">
	    <select name="ctype">
		<?php
		$commentsConn = mysql_connect($hostname_menu, $username_menu, $password_menu) or trigger_error(mysql_error(),E_USER_ERROR); 
		$dbConn = mysql_select_db($database_menu, $commentsConn ) or die("Couldn't select database");

		$sql2 = "SELECT id, description FROM comment_type";
		$result_lib2 = mysql_query($sql2);
		while ($lib_row2 = mysql_fetch_array($result_lib2))
		{
			$cid = $lib_row2['id'];
			$cdesc = $lib_row2['description'];
				
		?>
			<option value="<?php echo $cid ?>"><?php echo $cdesc ?></option>
	      <?php } ?>
		  </select>
		  
	  </font></p>
	  <p>Enter Comment: <br>
	        <textarea cols="40" rows="4" name="general"></textarea>
        </p></td>

</tr>
<tr>
	<td colspan="2"><font size="-1"><font face="Tahoma">Your Name (<font color="#800000">optional</font>)</font></font><br>
	<input type="text" name="name">
	</td>
	</tr>
<tr>
	<td colspan="2">
	<font size="-1"><font face="Tahoma">Your E-mail Address (<font color="#800000">optional</font>)</font></font><br>
	<input type="text" name="email"><br>
<font size="-1"><font face="Tahoma">Would you like to receive a response to your comments via e-mail?</font><br>
	<input type="radio" name="emailcheck" value="0" checked>No
	&nbsp;<input type="radio" name="emailcheck" value="1">Yes
	</td>
	<td></td>
</tr>
<tr>
	<td><input type="submit" value="Submit Comment" name="enter_process"></td>
	<td></td>
</tr>
</table>
</form>
<?php
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php');
?>  