#! /bin/ksh

report-header Programs

line2="================================================================="
line1="-----------------------------------------------------------------"

echo "$line1
This report contains details of all the programs in the survey,
sorted by program code.  The report begins with a table of
contents containing:
 * the 'code' for the program, based on the institution and unit
 * the 'shortname' for the institution and academic unit
Entries in the main part of the report begin with the program
code, the shortname, and:
 CONTACT:       the name and title of the person to contact
                about the HCI program (see the data file for
                the program for application information)
 EMAIL:         the electronic mail address of the contact
 PHONE:         the phone number of the contact
 FAX:           the FAX number of the contact
 ADDRESS:       tha mailing address of the contact
 DEGREES:       degrees offered by the program
 HCI_THESES:    recent (last five years) theses in HCI
 HCI_STUDENTS:  current HCI students at PhD and Masters levels
 DESCRIPTION:   description of the program's academic unit
 FACILITIES:    computing and other facilities of the unit
 PROGRAM:       description of the HCI program in the unit
 HCI_FACULTY:   name (and email) of HCI faculty in the unit
 OTHER_FACULTY: names (and possibly other information) of
                other HCI faculty at the institution, but not
                in the academic unit
$line2"

echo 'Table of Contents'
for i in ${*-*}
do
	sssearch section=unit $i |
		ssadd -f codename -t "${i##*/}"
done | ssformat -t "%-14codename %shortname"

template_contact="$line1
CONTACT: %contact, %title
EMAIL: %email
PHONE: %phone  FAX: %fax
ADDRESS: %address"

template_unit="\
DEGREES: %degrees
RECENT_HCI_THESES:    PhD: %3HCI_PhD_Theses  Masters: %3HCI_MS_Theses
CURRENT_HCI_STUDENTS: PhD: %3HCI_PhD_Curren  Masters: %3HCI_MS_Current
DESCRIPTION: %description
FACILITIES: %facilities"

template_program="PROGRAM: %Program"

function clean
	{
	sed 's/ +$//' $*
	}

for i in ${*-*}
do
	# INSTITUTION BANNER
	echo "$line2 ${i##*/}"
	sssearch section=unit $i |
		ssformat -t "%shortname"
	# 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 HCI_FACULTY:
	sssearch section=faculty $i |
		ssformat -t " * %name (%email)"
	other=`sssearch section=program $i | ssformat -t "%other" | clean`
	if test "$other" != ""
	then
		echo "OTHER_FACULTY: $other" | clean
	fi
done 

exit
