#!/opt/local/bin/perl

use strict;
use CGI;
use lib '/Library/WebServer/perl/lib';
use EduFileTwo;

my $form = new CGI;

print $form->header;

EduFileTwo::Util::printHead("View Activity");

my $outStr = "<P>The following is a list of files downloaded by this student.</P>\n";
if($form->param())
{
	$outStr .= "<table cellpadding=\"3\" cellspacing=\"1\" border=\"0\" bgcolor=\"black\">\n";
	$outStr .= "<tr>\n";
	$outStr .= "	<th bgcolor=\"#c0c0c0\">Name</th>\n";
	$outStr .= "	<th bgcolor=\"#c0c0c0\">Login ID</th>\n";
	$outStr .= "	<th bgcolor=\"#c0c0c0\">Email Address</th>\n";
	$outStr .= "	<th bgcolor=\"#c0c0c0\">Filename</th>\n";
	$outStr .= "	<th bgcolor=\"#c0c0c0\">File Description</th>\n";
	$outStr .= "</tr>\n";

	my $id = $form->param('student_id');
	my @items = EduFileTwo::StudentData::getActivity($id);
	foreach my $item (@items)
	{

		$outStr .= "<tr>\n";
		$outStr .= "<td bgcolor=\"#FAF5E2\">$item->[0]</td>\n";
		$outStr .= "<td bgcolor=\"#FAF5E2\">$item->[1]</td>\n";
		$outStr .= "<td bgcolor=\"#FAF5E2\">$item->[2]</td>\n";
		$outStr .= "<td bgcolor=\"#FAF5E2\">$item->[3]</td>\n";
		$outStr .= "<td bgcolor=\"#FAF5E2\">$item->[4]</td>\n";
		$outStr .= "</tr>\n";
	}

	$outStr .= "</table>\n";
}

print <<END_HTML;
	<div id="content2" align="center">
$outStr<br>
	        <p>Select the student for which you'd like to view download activity and click &quot;View&quot;.</p>
	
	<form action="viewactivity.cgi" method="post">
	<select name="student_id" size="15">
		<option value="0">--Select--
END_HTML

my @people = EduFileTwo::StudentData::getAllOrderBy("name");
foreach my $student (@people)
{
	my $id = $student->getID();
	my $name = $student->getName();
	
	print "          <option value=\"$id\">$name\n";
}
print <<END_HTML;
</select>
<input type="Submit" value="View">

</form>
</div>
END_HTML


EduFileTwo::Util::printFoot();
