#!/bin/csh -f
#
# mod: September 13, 1999 rcg -- change help.gif to helpbutton.gif per
#	Chris Hammond request.
# mod: November 2, 1998 clh  -- add a combination operator button
#                            used to indicate 'OR' or 'AND' to list
#                            of selections
#
echo "Content-type: text/html"
echo ""
#echo "inside selopt " >>/usr/local/httpdOO/logs/error_log

source build-opt-env
#echo "DISPSS is ${DISPSS} " >>/usr/local/httpdOO/logs/error_log
cd ${USETEMPDIR}
set tmp=${PATH_INFO}
unsetenv PATH_INFO

if ( "${SUBSELS}x" == "x" ) then
  set DISPSS = "[empty]"
  set DISPFULL=${OBJECT}
  set CALLURL=${OBJECT}
else
  set DISPFULL="${OBJECT}(${DISPSS})"
  set CALLURL="${OBJECT}?${SUBSELS}"
endif

#echo "callurl is $CALLURL" >>/usr/local/httpdOO/logs/error_log

echo "<html><head><title>Data Subsetting page</title></head>"
echo "<body>"

# target="_blank" will pop a new window
cat <<EOFSEL
<a href="/subhelp.html">
<img alt="[HELP]" border=0 src="/images/helpbutton.gif" align=right>
</a>
<h1>Data Subsetting</h1>
EOFSEL

echo "<form method="\""POST"\"" action="\""/jg/selopt1$CALLURL"\"">"
echo "<b>Current object is: $DISPFULL<br>"
echo "Active subset list - $DISPSS"
cat << XXstuffXX
</b>
<hr noshade><p>
<font color=ff0000>
<b>
<input type="submit" value="Clear subset list">
</b>
</font>
</form>
XXstuffXX
#
# DO NOT put the active sub-selections on the listvar command
#
${OPTHOME}/bin/listvar "${OBJECT}" > variables
#
# begin the form part of the script
#
cat <<EOFSEL
<b>
<font size="5">
To add to the active subset list, either :
</font>
<br>
<img alt="&lt;li&gt;" src="/icons/ball.red.gif">
<font size="4">
 Choose from the cells below, 
 and then click on an '<font color=0000ff>Add ...</font>' button
</font>
</b>
<center>
<table border=4>
<tr border=2>
<td><center><a href="/sel-proj-defn.html#sel">Selections</a></center></td>
<td><center><a href="/sel-proj-defn.html#proj">Projections</a></center></td>
</tr>
<tr valign="top">
<td valign="top">
EOFSEL
#
# SELECTIONS
#
echo "<form method="\""POST"\"" action="\""/jg/selopt2$CALLURL"\"">"
echo "<select name="\""var"\"">"
${OPTHOME}/bin/nawkscr < variables
echo "</select>"

echo "<select name="\""op"\"">"
#
# Below options fall into 2 categories: 
#  numeric operators, which have to be html-escaped
#  string operators, which MUST have a leading and trailing space
#
${OPTHOME}/bin/nawkscr << XXSTUFFXX
=
&lt;
&gt;
&lt;&gt;
&lt;=
&gt;=
 eq 
 ne 
 lt 
 le 
 gt 
 ge 
 contains 
 is_contained_in 
 begins_with 
 ends_with 
XXSTUFFXX
echo "</select>"

echo "<input name="\""val"\"" type="\""text"\"" size="\""10"\"">"
echo "<br>"

if ("${SUBSELS}x" != "x") then
 echo "Combine this selection with active subset list using "
 echo "<select name="\""combo"\"">"
 echo "<option>AND"
 echo "<option>OR</select>"
endif

cat <<XXstuffXX
<br>
<font color=0000ff>
<center><input type="submit" value="Add selection">
</center>
</font>
Note: the first 6 selection operators are for Numeric comparisons.<br>
The remaining operators in the list perform String selections.<p>
If you do not understand the implications of these operators,<br>
<b>Please see examples in ---&gt;</b>
<a href="/sub-pick.html">
<img alt="[HELP]" border=0 src="/images/helpbutton.gif" align="middle"></a>
<br>
</form></td><td valign="top">
XXstuffXX
#
# PROJECTIONS
#
echo "<form method="\""POST"\"" action="\""/jg/selopt3$CALLURL"\"">"
echo "Multiple projections are accepted.<p>"
echo "<select multiple size=6 name="\""var"\"" align=middle>"
${OPTHOME}/bin/nawkscr < variables
cat <<EOFSEL
</select>
<font color=0000ff>
<input type="submit" value="Add projection(s)">
</font>
</form>
</td>
</tr>
</table>
</center>

<img alt="&lt;li&gt;" src="/icons/ball.red.gif">
<b><font size="4">Or, enter the criteria for new subsetting below:</font></b>
EOFSEL

echo "<form method="\""POST"\"" action="\""/jg/selopt4$CALLURL"\"">"

cat <<XXstuffXX
<center>
<input type="text" name="sel" size=50>
<input type="submit" value="Replace criteria">
</center>
</form>
</body>
</html>
XXstuffXX

setenv PATH_INFO $tmp
echo "<b><font size=5>Then, <a href="\""/jg/otheropt$CALLURL"\"">continue</a> using the new subset list</font>"
