--- ltp	Sun May 12 14:41:40 2002
+++ ltp-0.3	Sun May 12 14:46:06 2002
@@ -18,9 +18,59 @@
 my $dbh = DBI->connect($engine,"","",{'PrintError' =>0}) or die "Can't connect to $dbname: $DBI::errstr\n";
 
 
-# This sub exits and returns an ascii list of all sleepingplaces
-# call with () or (sleepingplace)
-#
+
+#This is new, generates a list of all supporters (name,email)
+#it accecpts --out ascii and latex
+sub supporters {
+	my $opt_out = "ascii" unless $opt_out;
+	
+	if ($opt_out =~ /ascii/i) {
+		my %supporters= query_supporters();
+		foreach my $name (keys %supporters) {
+		print "$name \t $supporters{$name}{'email'} \n";
+		}	
+	} elsif ($opt_out =~ /latex/i) {
+		my %supporters= query_supporters();
+		print latex_head('\usepackage{supertabular}');
+		print '\\begin{supertabular}{||c||c||}';
+		print '\hline';
+		print "\\multicolumn{2}{||c||}{List of all Supporters}\\\\\n";
+		print '\hline\hline';
+	 	print "\\textbf{Name}&\\textbf{Email}\\\\\n";
+		print '\hline';
+		foreach my $name (keys %supporters) {
+		print " $name  & $supporters{$name}{'email'} \\\\\n"; 
+		print '\hline';
+		}
+		print '\end{supertabular}';
+		print "$latex_foot";
+			
+	} else {
+		print "Unknown format for --out, you should use either ascii or latex\n";
+	}
+}
+
+sub query_supporters {
+
+	my $sth = $dbh->prepare(q{
+		SELECT name,email from person 
+		WHERE project = 'Supporter'
+		}) or die "Can't prepare Query: $DBI::errstr\n";
+
+	$sth->execute or die "Can't execute query: $DBI::errstr\n";
+	
+	my %names;
+	#building a hash of hashes, this would be much more easy if the are more keys(street..)
+	while (our @row = $sth->fetchrow_array) {
+	$names{"$row[0]"}{'email'}="$row[1]";	
+	}
+	return %names;
+}
+		
+
+#This sub exits and returns an ascii list of all sleepingplaces
+#call with () or (sleepingplace)
+
 sub night
 {
     my $loc = shift;
@@ -50,10 +100,10 @@
 
 }
 
-# This sub returns a hash with the bootnumbers of all project
-# keys: project.name->project.boothnr
-# Used in: supplies
-#
+#This sub returns a hash with the bootnumbers of all projectt
+#keys: project.name->project.boothnr
+#Used in: supplies
+
 sub get_projects
 {
     my $query = "SELECT name,boothnr FROM project";
@@ -65,17 +115,18 @@
     $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
     $query .= " ORDER BY name";
     $sth = $dbh->prepare($query) or die "Cannot prepare Query: $DBI::errstr\n";
+    
     $sth->execute or die "Cannot execute Query: $DBI::errstr\n";
-
-        while (@row = $sth->fetchrow_array) {
+        
+	while (@row = $sth->fetchrow_array) {
 	    $projects{$row[0]} = $row[1];
         }
-
+    
     return %projects;
 }
 
 # This sub lists all suplies needed for the projects
-#
+
 sub supplies
 {
     my $query;
@@ -111,9 +162,9 @@
 }
 
 
-# lists projects and boothnumbers
-# if --onlybooth only projects with an existing booth are listed
-#
+#lists projects and boothnumbers
+#if --onlybooth only projects with an existing booth are listed
+
 sub list
 {
     my $query = "SELECT name,boothnr FROM project ";
@@ -133,9 +184,9 @@
 }
 
 
-# Lists the mailadresses sorted by projects 
-# Accepts $project as parameter, then only $project is shown
-#
+#Lists the mailadresses sorted by projects 
+#Accepts $project as parameter, then only $project is shown
+
 sub list_mails
 {
     my $onlyproject = shift;
@@ -749,6 +800,7 @@
     print "   --cols <n>         Text will be wrapped at n columns\n";
     print "   --nospace          No leading spaces\n";
     print "   --onlybooth        Only projects with a non-empty boothnr\n";
+    print "   --out <type>       Chooses LaTex/ASCII output (currently ony for --supporters\n";
     print "Commands:\n";
     print "   --help             This help\n";
     print "   --descr            List project descriptions\n";
@@ -767,6 +819,7 @@
     print "   --table            LaTeX table with all projects\n";
     print "   --workshops        Workshop Schedule\n";
     print "   --workshops.tex    Workshop Schedule for LaTeX\n";
+    print "   --supporters	 List supporters (see --out, ASCII is default)\n";
 
 }
 
@@ -788,6 +841,11 @@
 	if (($argc < $#ARGV) && ($ARGV[$argc+1] !~ /^-/)) {
 	    $opt_cols = $ARGV[++$argc];
 	}
+     } elsif ($ARGV[$argc] eq "--out") {
+             if (($argc < $#ARGV) && ($ARGV[$argc+1] !~ /^-/)) {
+	           $opt_out = $ARGV[++$argc];
+	     } else { print "No argument for --out, should be either ascii or latex\n"; exit; }
+	     
     } elsif ($ARGV[$argc] eq "--list" || $ARGV[$argc] eq "-l") {
         list ();
     } elsif ($ARGV[$argc] eq "--descr") {
@@ -801,7 +859,6 @@
     } elsif ($ARGV[$argc] eq "--exportlt") {
 	exportlt ();
     } elsif ($ARGV[$argc] eq "--mails") {
-    	# inserted for choosing specified project (Note: would be much easier with getopt)
     	if (($argc < $#ARGV) && ($ARGV[$argc+1] !~ /^-/)) {
 		list_mails ($ARGV[++$argc]);
 	} else {
@@ -835,6 +892,8 @@
 	workshops ();
     } elsif ($ARGV[$argc] eq "--workshops.tex") {
 	latex_workshops ();
+    } elsif ($ARGV[$argc] eq "--supporters") {
+            supporters();
     }
     $argc++;
 }

