#!/usr/local/bin/perl


# Script for on-line signup for reg-day appointment


print "Content-type: text/html \n\n";
print "<html>";
print "<head><title>Reg Day Sign up Sheet - Professor Charles Leiserson</title></head>";
print "<body>";
print "<center>";
print "<H3>";
print "Professor Charles Leiserson<br>";
print "Fall Term 2000<BR>";
print "Registration Day Sign Up Sheet<BR>";
print "September 5, 2000<BR>";
print "</H3>";
print "<br><BR><BR>";
print "</center>";
print "<form action=/c/deacon/WWW/mkAppointment_Leiserson.pl>";
print "<P><font size=3><b>Please choose your name from the list:<b></font><br>";

print "<SELECT NAME=\"name\">";
print "<option>";

 open(ADVISEES, "/c/deacon/WWW/advisees.txt") ||
     die "Couldn't open file advisees.txt";

    while (<ADVISEES>){
	   print "<option>";
	    print $_;
	   }
print "</select><p>";
print "<p>";
print "<font size=3>Please choose a time:</font> <font size=2><i>Current schedule is shown below.</i></font><br>";

print "<select name=\"time\">";
#get available slots
 open(SCHEDULE, "/c/deacon/WWW/schedule_Leiserson.txt") ||
     die "Couldn't open file schedule_Leiserson.txt";


$count = 0;
    while(<SCHEDULE>){
	$available[$count]=$_;
	$count++;
    }
    foreach(@available){
	@junk=split(" ", $_);    
	if($junk[1] eq ""){
	    print "<option>";
	    print $junk[0];
	    print "\n";
	}
    }
print "</select>";
close (SCHEDULE);

print "<BR><BR>";
print "<BR><BR>";
print "<input TYPE=\"SUBMIT\" Value = \"Schedule Appointment\">";
print "</form>";
print "<hr>";

  open(SCHEDULE, "/c/deacon/WWW/schedule_Leiserson.txt") ||
     die "Couldn't open file schedule_Leiserson.txt";

print "<center><FONT SIZE=4>CURRENT SCHEDULE</FONT></CENTER><BR><BR>";
print "<table border = 2 align=center>";
$count=0;

    while (<SCHEDULE>){
	$appointments[$count]=$_;
	$count++;
    }
    foreach(@appointments){
	@junk=split(" ", $_);    
	if($junk[1] eq ""){
    print "<tr>  <td width = 100><font color=\"RED\">$junk[0]</font></td><td width=300><font color=\"RED\"><b>$junk[1] $junk[2] $junk[3]<b></font><td><TD>  </tr>\n";
    }
	else{
	    print "<tr>  <td width = 100>$junk[0]</td><td width=300><b>$junk[1] $junk[2]<b><td><TD>  </tr>\n";
	}
    }
print "</table>";

   close (SCHEDULE);


print " </body>";
print " </html><br>\n\n";











