#! /bin/ksh

report-header Faculty

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

echo "$line1
This summary discusses all the faculty in the survey, sorted by last name."

template="$line1
NAME: %+name, %title
DEGREE: %degree
EMAIL: %email
PHONE: %phone
INSTITUTION: %institution
UNIT: %unit
INTERESTS: %interests
PUBLICATIONS: %publications"

FACULTY=/tmp/fac$$
/bin/rm -f $FACULTY

for i in ${*-Data/*}
do
    #echo "$line2 ${i##*/}"
	# Add unit institution and unit to faculty records
	record=`sssearch section=unit $i`
	country=`echo "$record" | ssformat -t "%country"`
	shortname=`echo "$record" | ssformat -t "%shortname"`
	sssearch section=faculty $i |
		ssadd -f codename -t ${i##*/} |
			ssadd -f shortname -t "$shortname" |
				ssadd -f country -t "$country" >> $FACULTY
done

# Table of Contents
sssort -f name:P $FACULTY |
	ssformat -t "%-22.22name %-14.14codename %-15.15country %-22.22phone %email"

/bin/rm -f $FACULTY
