#!/bin/csh -f

# /bin/csh -xv

# doupate_status  Update the U.S. GLOBEC Georges Bank Inventory files
# with status data for each datatype

# Edited March 17 1998 Change /data to /data5 rcg
# February 20, 1997 rcg

# Parameters from script_loc/inventoryopt1
#	1 project
#	2-end = list of data types
echo "Content-type: text/html"
echo ""

echo "<title>Update to U.S. GLOBEC Georges Bank Inventory, "
echo "level 2 (status)</title>"
echo "<h2 align=center>Update to U.S. GLOBEC Georges Bank Inventory,"
echo "<br>level 2 (status)</h2>"

setenv HD /data5/globec
set script_loc=/data/rgroman/Inventory/scripts

set datatop = /data/rgroman/Inventory
#set datatop = /data/rgroman/Inventory/debug
#echo "<p> *** Note: you are in DEBUG mode, datatop = $datatop <p>"
#echo "<p> **DEBUG - in doupdate_status"

set inventorytop=$datatop/toplevel.dat
set statuslevel2=/data/rgroman/Inventory/status-level2

#set scriptcgi="invtest"
set scriptcgi="inv"

cd $script_loc

set curopt="`cat inventoryopt1 | tr ' ' '\012' `"
#echo " <p> **DEBUG curopt = $curopt"
set existing="`grep $curopt[1] ${inventorytop}`"


echo "<p> Select all the status lines that apply"
echo "by clicking on the status word.  To deselect, click on the status word again."
echo "You will be asked for additional descriptive text for each status word"
echo "you select on the next input screen."
echo "<p>When you are satisfied with your choices, "
echo "click on <form action="\""/$scriptcgi/doupdate_get_desc "\"" "
echo "method="\""POST"\"">"

	echo "<input type="\""submit"\""value="\""Add to Level "
	echo "2-get descriptions"\""><p>"

echo "For the project: <input name="\""project"\"" size="\""15"\"
echo "value="\""$curopt[1]"\""> "
echo "<p>"

if ( $#curopt == 1 ) then
	echo " Done processing - go to finish/success page"
	$script_loc/inventory_updated $curopt[1]
else
	set datatype=$curopt[2]
	echo "<p>"
	echo "For data type <input name="\""${datatype}"\"" "
	echo "size="\""20"\"
	echo "value="\""$datatype"\""> "

	echo " ... ... Status: <select name="\""${datatype}_status"\"" "
	echo "multiple > "
	$script_loc/nawkscr < $statuslevel2
	echo "</select>"	
	echo <p>

end
echo "</form>"
exit 0
