#! /bin/ksh

html-header Programs

echo "
This report contains details of all the programs in the survey,
sorted by program code.  The report begins with a table of
contents containing:
<ul>
 <li>the 'shortname' for the institution and academic unit
</ul>
Entries in the main part of the report begin with the program
code, the shortname, and:
<table border=0>
<tr valign=top>
 <td>Contact:<td>       the name and title of the person to contact
                about the HCI program (see the data file for
                the program for application information)
<tr valign=top>
 <td>Email:<td>         the electronic mail address of the contact
<tr valign=top>
 <td>Phone:<td>         the phone number of the contact
<tr valign=top>
 <td>Fax:<td>           the FAX number of the contact
<tr valign=top>
 <td>Address:<td>       tha mailing address of the contact
<tr valign=top>
 <td>Degrees:<td>       degrees offered by the program
<tr valign=top>
 <td>Hci_Theses:<td>    recent (last five years) theses in HCI
<tr valign=top>
 <td>HCI_Students:<td>  current HCI students at PhD and Masters levels
<tr valign=top>
 <td>Description:<td>   description of the program's academic unit
<tr valign=top>
 <td>Facilities:<td>    computing and other facilities of the unit
<tr valign=top>
 <td>Program:<td>       description of the HCI program in the unit
<tr valign=top>
 <td>WWW:<td>           Web page of the HCI program
<tr valign=top>
 <td>HCI_Faculty:<td>   name (and email) of HCI faculty in the unit
<tr valign=top>
 <td>Other_Faculty:<td> names (and possibly other information) of
                other HCI faculty at the institution, but not
                in the academic unit
<tr valign=top>
 <td>Updated:<td>   Date of last update of the information about the unit
</table>
"

echo "<ol>"
for i in ${*-*}
do
	sssearch section=unit $i |
		ssadd -f codename -t "${i##*/}"
done | ssformat -t "	<li><a href=\"#%codename\">%shortname</a>"
echo "</ol>"

template_contact="
	<tr valign=top><td>Contact:<td> %contact, %title
	<tr valign=top><td>Email:<td> <a href=mailto:%email>%email</a>
	<tr valign=top><td>Phone:<td> %phone
	<tr valign=top><td>Fax:<td> %fax
	<tr valign=top><td>Address:<td> %address
"

template_unit="\
	<tr valign=top><td>Degrees:<td> %degrees
	<tr valign=top><td>Recent_HCI_Theses:<td>    PhD: %3HCI_PhD_Theses  Masters: %3HCI_MS_Theses
	<tr valign=top><td>Current_HCI_Students:<td> PhD: %3HCI_PhD_Curren  Masters: %3HCI_MS_Current
	<tr valign=top><td>Description:<td> %description
	<tr valign=top><td>Facilities:<td> %facilities
"

template_program="
	<tr valign=top><td>WWW:<td><a href=\"%WWW\">%WWW</a>
	<tr valign=top><td>Program:<td> %Program
"

function clean
	{
	sed '
		s/ +$//
		s/<ul>+/<ul>/
		s/<ol>+/<ol>/
		s/^ \* /<li>/
		s/^ - /<li>/
		s/^ + /<li>/
		' $*
	}

for i in ${*-*}
do
	# INSTITUTION BANNER
	echo "<hr>"
	echo "<table border=0>"
	sssearch section=unit $i |
		ssformat -t "<tr><td colspan=2><a href=\"$i\" name=\"${i##*/}\"><b>%shortname</b></a>"
	# CONTACT SECTION
	sssearch section=program $i |
		ssformat -t "$template_contact" |
			clean
	# UNIT INFO
	sssearch section=unit $i |
		ssfill -f degrees,desc,facil -w 65 |
			ssformat -t "$template_unit" |
				clean
	sssearch section=program $i |
		ssfill -f program -w 65 |
			ssformat -t "$template_program" |
				clean
	# FACULTY INFO
	echo "<tr valign=top><td>HCI Faculty<td>"
	echo "<ol>"
	sssearch section=faculty $i |
		ssformat -t " <li>%name (<a href=mailto:%email>%email</a>)"
	echo "</ol>"
	Other=`sssearch section=program $i | ssformat -t "%other" | clean`
	if test "$other" != ""
	then
		echo "<tr valign=top><td>Other_Faculty:<td> <ol>$other</ol>" | clean
	fi
	# UPDATE information
	sssearch section=unit $i |
		ssformat -t "<tr valign=top><td>Updated:<td>%updated"
	echo "</table>"
done 

exit
