#!/usr/bin/perl
#
# Name:         $OPTHOME/optbin/download-problem
# Purpose:      part of JGOFS data download package
#               handles user problems; assistance requested
#
# Modification history:
#  20 Jul 16.  WJS
#    Changed code to just exit
#    Put comments in reverse chronological order
#    Add  undefine  statements to deal with "only used once" diagnostics
#    There is evidence that this file was missing from the OOserver since at least
#      2009.  Further, there is evidence that the code won't work now (eg, use
#      of /cgi-bin/form-mail.pl).
#    This program intended to gather useful debugging info.  Info IS useful, but
#      this program didn't get called all the time, plus we can get info other ways.
#
# ###### download version 1.1  (991206)
# 991201.clc. merge/debug with ooptserver on synthesis; dispobj; fmt header
# 991122-26.clc. mods for merge with rest of oopt software
#                remove 'do download-env'-JG envs not used in this script
# 990621. clc. port to OO server for installation/testing.
# ###### download version 1.0
# 990616.clc. report subselections list; dbasemgr.
# 990614.clc. DBG comment changed to DWNLD.
# 990312.clc. appearance mods.
# Dec 98.clc. created; under development.
#
# =====================================================================

require "cgi-lib.pl";

MAIN:
{
  exit(0);

###############

  print STDERR " DWNLD:  using script: $0 \n";

  # color pallette
  $credhi = "indianred";
  $chdrbar1 = "skyblue";
  $cgobar = "mediumaquamarine";

  $dbasemgr = "$ENV{'SERVER_ADMIN'}";   # local database manager

  # Read in all the variables set by the form
  &ReadParse(*input);

  # Print the header
  print &PrintHeader;
  print &HtmlTop ("Data Download Feedback Form");
  print <<ENDOFTEXT;
  <BODY BGCOLOR="#FBFBFF">
  <p>
  <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=6>
  <TR><TD COLSPAN=3 BGCOLOR="$chdrbar1">
    <H3> May we provide some assistance?
  </TR></H3></TABLE>

If you have run into some difficulty trying to download a data set,
please use this form to provide us with some information and we will
get in touch with you.
<p>

<p><em>Note:</em> This is an HTML form.  You must have a browser
that supports forms in order to use it.  If you do not see text
editing areas below, your browser does not support forms.  Please send
email directly to $dbasemgr instead.<p>
<p>

<Form method=POST action="/cgi-bin/form-mail.pl">

<HR>

<input name="realname">Your name<p>
<input name="username">Your email address<p>

  <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=6>
  <TR><TD COLSPAN=3 BGCOLOR="$chdrbar1"><H4>
We have collected some information about your status, and will send this <BR>
along with any additional information you type in the text window below.
  </TR></H4></TABLE>

<TEXTAREA NAME="comments" ROWS=20 COLS=60>
I'm trying to download some $input{'dispobj'} data.
Subselections (if any) are: $input{'subsdisp'}

ENDOFTEXT

print "I received the following error message: \n$input{'errmsg'} \n" unless $errsta;

print <<ENDOFTEXT;

 ====>  ADD YOUR COMMENTS HERE, PLEASE. <====


===========================================================
Please don't make any changes below this point.  Thanks.

Server collected this potentially useful information:
The user selected form responses are:
          data object:  $input{'dobject'}
        subselections:  $input{'subsels'}
  packaging file type:  $input{'bulk'}
      levels (maxlev):  $input{'maxlev'}
         determinants:  $input{'determine'}
       parameter list:  $input{'levelparams'}
         tar filename:  $input{'filename'}

The comlete list of environment variables:
ENDOFTEXT

  foreach $var (sort keys %ENV) {
     print "$var:  $ENV{$var} \n";
  }

  print "\nThe complete set of form responses so far: \n";
  foreach $item (sort keys %input) {
     print "$item: \t $input{$item} \n";
  }

print <<ENDOFTEXT;

</TEXTAREA><P>

<font size=+1><b>
<Input TYPE="submit" VALUE="Send comments">
<Input TYPE="reset" VALUE="Erase comments"><p>
</font></b>
</Form>

ENDOFTEXT

  # Close the document cleanly.
  print &HtmlBot;

  undefine $cgobar;
  undefine $credhi;
  undefine $errsta;
}
