#!/bin/csh -f
#
# cruise-report-list script
# 1996/01/23 RCG

# Creates html output from inventory data of available cruise reports.

set tmppath=/data/globec/httpd/htdocs/temp-dir
set datain=/data/rgroman/Inventory/toplevel.dat
set method=/data/globec/methods/defrpt_url

setenv PATH_INFO=.flat2
 
#	echo " method = $method"
#	echo " tmppath = $tmppath"
#	echo " datain = $datain"
#	echo " PATH_INFO = $PATH_INFO"

set tmp=`date '+%H%M%S'`
if ($REMOTE_HOST == "") then
	setenv REMOTE_HOST "tmp.host"
endif

set htmlout=$tmppath/$tmp.$REMOTE_HOST.html
#	echo " htmlout = $htmlout"

	$method $datain data_type=cruise_report status=on-line project platform description >  $htmlout

#	echo "after first method execution"

chmod o+w $tmppath/*.$REMOTE_HOST.html


if (-e $htmlout) then

	echo "Content-type: text/html"
	echo ""

	echo "<title> Cruise Reports</title>"
	echo "<head>"
	echo "<h1>Cruise Reports</h1>"
	echo "</head>"
	echo "Click on the link to review on-line cruise reports.  Note that in"
	echo "some cases the figures, tables and other images may not yet be"
	echo "available and you will receive a message that the link " 
	echo "has not been"
	echo "found.  The text is searchable using whatever search (or find)"
	echo "capabilities are available in your browser."
	echo " "
	echo "<p>Many of these reports were converted directly to "
	echo "Web format and would"
	echo "benefit from  tailoring for on-line use. " 
	echo "<body>"
	echo "<hr>"
	echo "<h3 align=center>Cruise reports available on-line</h3>"
	echo "<pre>"
	cat $htmlout | grep -v "Content-type:" | tr -d '\042' 
	echo "</pre>"
	cp $htmlout /tmp/htmlout.debug_1
	\rm $htmlout
	
	echo "<hr><p><p><h3 align=center>Cruise reports will be available"
	echo "for all cruises</h3>"
	$method $datain data_type=cruise_report status=printed project platform description siname >  $htmlout
	echo "<pre>"
	cat $htmlout | grep -v "Content-type:" | tr -d '\042'
	echo "</pre>"
	cp $htmlout /tmp/htmlout.debug_2
	\rm $htmlout
else
	echo " Content-type: text/plain"
	echo ""
	echo " Could not output cruise report inventory from the file "
	echo "  $datain " 
	echo " Please contact the U.S. GLOBEC Georges Bank"
	echo " Data Mangement Office."
	echo " "
	echo " The following information may be useful for debugging the problem."
	echo " QUERY_STRING = $QUERY_STRING"
	echo " tmppath = $tmppath"
	echo " datain = $datain"
	echo " htmlout = $htmlout"
	echo " method = $method"
endif


