<?php
	include "head.html";
	include "main.html";
	
	echo "\t\t\t<h1>Participants</h1>\n";

        echo "\t\t\t<p><a href=\"presence.pdf\">Overview of invited speakers and staff members in pdf format</a></p>\n";
	
	$groups = array("guests","staff","sb-students","ed-students","ext-students");
	$weekdays = array("Wednesday, July 6","Thursday, July 7","Friday, July 8","Saturday, July 9","Sunday, July 10","Monday, July 11","Tuesday, July 12","Wednesday, July 13","Thursday, July 14","Friday, July 15");
	
	foreach($groups as $group){
		$lines = file("$group.txt","r");
	
		echo "\t\t\t<h2>",rtrim($lines[0]),"</h2>\n";
	
		array_shift($lines);
	
		echo "\t\t\t<table>\n";
	
		foreach($lines as $line){
			preg_match("/(.+)\t(.*)\t([01])([01])([01])([01])([01])([01])([01]{4})/",$line,$matches);
			$name = $matches[1];
			$email = $matches[2];
			for($d=0;$d<=5;$d++){
				$day[$d] = $matches[$d+3];
			}
			$restdays = $matches[9];
			preg_match("/([01])([01])([01])([01])/",$restdays,$matches);
			for($d=6;$d<=9;$d++){
				$day[$d] = $matches[$d-5];
			}
	
			echo "\t\t\t\t<tr>\n";
	
			for($d=0;$d<=9;$d++){
				if($day[$d] == 0){
					$pres = "Absent";
				}
				else{
					$pres = "Present";
				}
				
				echo "\t\t\t\t\t<td title=\"$pres on $weekdays[$d]\" class=\"$pres\">&nbsp;&nbsp;</td>\n";
	
			}
	
			echo "\t\t\t\t\t<td><a href=\"mailto:$email\">$name</a></td>\n";
			echo "\t\t\t\t</tr>\n";
		}
		echo "\t\t\t</table>\n";
	}

	$timestamp = date("D, M d, Y H:i:s", filemtime(__FILE__))." by ".get_current_user();
	include "foot.html";
?>
