Include a list of previous reports.

Change-Id: I0a6ed269f1f81105daba0138732cbf15d091d969
diff --git a/tools/wg/ecd.php b/tools/wg/ecd.php
index c5472fe..0f41c6e 100755
--- a/tools/wg/ecd.php
+++ b/tools/wg/ecd.php
@@ -35,19 +35,33 @@
 <div class="homeitem">
 
 <?php
-function includeContent() {
+function includeContent($wg) {
+
+	$Nav->addNavSeparator("Previous Reports", null);
+	$dates = array();
+	foreach(glob("/home/data/httpd/writable/projects/{$wg}-*.html") as $file) {
+		$matches = array();
+		if (preg_match('^\/home\/data\/httpd\/writable\/projects\/(?<wg>.+)\-(?<date>\d\d\d\d\-\d\d\-\d\d)\-(?<time>.+)\.html$', $file, $matches)) {
+			$dates[$matches['date']] = $matches['date']; // eliminate duplicates
+		}
+	}
+	krsort($dates);
+	foreach($dates as $date) {
+		$Nav->addCustomNav("{$date}", "?date={$date}", "_self", 2);
+	}
+
 	if (isset($_GET['date'])) {
 		$date = date('Y-m-d', strtotime($_GET['date']));
 		// We just want the first one that we find.
-		foreach(glob("/home/data/httpd/writable/projects/ecd-tools-{$date}-*.html") as $file) {
+		foreach(glob("/home/data/httpd/writable/projects/{$wg}-{$date}-*.html") as $file) {
 			include $file;
 			return;
 		}
 	}
-	include "/home/data/httpd/writable/projects/ecd-tools.html";
+	include "/home/data/httpd/writable/projects/{$wg}.html";
 }
 
-includeContent();
+includeContent('ecd-tools');
 
 ?>