#!/usr/local/bin/perl

# input:   a tab-delimited "phonelist"
# output:  an HTML table "phonetable.html"
#
# Rob Salgado (salgado@npac.syr.edu) 2 Jun 1995


open(OUT,">phonetable.html");
open(IN, "cat phonelist |") || die "phonelist missing\n";

print OUT "<HTML>\n";
print OUT "<H1>NPAC Phone List</H1>\n<HR>";

print OUT "If your browser does not support tables, a preformatted list will be available shortly.<hr>\n"; 
print OUT "<TABLE BORDER>\n";

print OUT "<TR><TD COLSPAN=5 ALIGN=CENTER>
	<H1>NPAC Phone List</H1> </TD></TR>\n";

#print OUT "<CAPTION><H1>NPAC Phone List</H1></CAPTION>";

print OUT "<TR> <TH> Last Name </TH> <TH> First Name </TH> <TH> Extension </TH>\n";
print OUT "<TH>Email Address</TH> <TH>Office</TH> </TR>\n";

FILE:
while (<IN>) {
	chop $_;
	($name_last, $name_first, $phone, $login, $office) = split(/\t/,$_); 
	print OUT "<TR>\n";
	print OUT "<TD>&#160 <B>$name_last</B>  </TD>\n" ;
	print OUT "<TD>&#160 $name_first        </TD>\n" ;
	print OUT "<TD ALIGN=RIGHT> $phone </TD>\n" ;
	print OUT "<TD>&#160 <tt>$login</tt>    </TD>\n" ;
	print OUT "<TD>&#160 $office            </TD>\n" ;
	print OUT "</TR>\n";
	
	next FILE;
}
close(IN);

print OUT "<TR><TD COLSPAN=5 ALIGN=CENTER>
	All phone extensions are <b><tt>(315)-443-xxxx</tt></b>. </TD></TR>\n";
print OUT "<TR><TD COLSPAN=5 ALIGN=CENTER>
	All email addresses are <b><tt>@npac.syr.edu</tt></b> unless otherwise noted.</TD></TR>\n";



print OUT "</TABLE>\n<HR>\n";

#print OUT "<DT> All phone extensions are <b><tt>(315)-443-xxxx</tt></b>.\n";
#print OUT "<DT> All email addresses are <b><tt>@npac.syr.edu</tt></b> unless otherwise noted.<br>\n";


#
# generate timestamps
#

open(UPDATE, "ls -l phonelist |") || die "phonelist missing\n";
while(<UPDATE>){
    chop $_;
    ($mod, $num, $owner, $size, $month, $date, $time, $name)=split(/\s+/,$_);
    print OUT "<I>Data last updated: $date $month <BR>\n";
}
close(UPDATE);

    require "ctime.pl";
    ($day, $month, $date, $time, $year)=split(/\s+/,&ctime(time));
    print OUT "Table generated: $date $month $year </I>\n";

print OUT "</HTML>\n";















