#!/usr/bin/perl
#
# AMAD Submit Script
#
##############################################################################
# Modification List
# JD 1/30/2000
# JavaScript added to prevent nonalphanumeric characters in the user or category fields
#

use CGI qw(:standard);
require "arraylib.pl";

&LoadArrays();

$user = $ENV{'REMOTE_USER'};
$bs="\\";

print "Content-type: text/html\n";
print "\n";

print << "EOF";

<HTML><HEAD>
<TITLE>Process Scanner Data</TITLE>

    <script language = "JavaScript">
    
    function ValidateEntry(item) {
EOF

# Use Javascript to validate field entries. No wierd characters allowed.
print "if (item.indexOf(\'$bs\@\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\-\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\'\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\"\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\+\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\=\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\(\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\)\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\[\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\]\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\{\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\}\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\/\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\,\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\.\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\<\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\>\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\?\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\!\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\#\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\$\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\%\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\*\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\~\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\`\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\|\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\\\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\;\',0) != -1) return false;\n";
print "if (item.indexOf(\'$bs\:\',0) != -1) return false;\n";

print << "EOF";
    	
    	return true;
    }
    
    function Validate() {

    	errfound = false;
    	if (!ValidateEntry(document.submitform.newuser.value))
    		error(document.submitform.newuser, "User names may contain no punctuation or special characters.");
    	if (!ValidateEntry(document.submitform.cat.value))
    		error(document.submitform.cat, "Category names may contain no punctuation or special characters.");

    	return !errfound;
    }
    
    function error(elem,text) {
    	if (errfound) return;
    	window.alert(text);
    	elem.select();
    	elem.focus();
    	errfound = true;
    }
    
   </SCRIPT>
   </HEAD>
   <BODY bgcolor=FFFFFF>
EOF
    
&PrintNavBar();

print << "EOF";

<CENTER>


<form name="submitform" onSubmit="return Validate();" method=POST ENCTYPE="multipart/form-data" action=$servercgi/nph-process.pl>



<TABLE BORDER="1" WIDTH="600"><TR><TD>

    <TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" BGCOLOR="#FFFFFF" WIDTH=100%>
    <TR><TD BGCOLOR="#EEEEEE" WIDTH=100% ALIGN=CENTER>
	<h2>Submit Data to the Database</h2>
    </TD></TR>
	</TABLE>

<TABLE BORDER="1" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD  BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Upload File</FONT></TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=CENTER><input type=file name=uploadfile size=60></TD>
	</TR>
</TABLE>


<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD WIDTH="33%" ALIGN=CENTER>
		
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Experimenter</FONT></TD>
	</TR>

	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=CENTER>
			<select name=user>
			<option value="">None</option>
EOF
# <input type=text name=user value=$user>
  foreach $user (values %arrayuser)
   {
      $useuser{$user} = "1";
   }
   @users = sort {$a cmp $b} keys %useuser;
  
   @arrays = sort {$arrayname{$a} cmp $arrayname{$b}} keys %arrayuser;

   foreach $user (@users)
   {
			 print "<option value=$user>$user</option>\n";
   }
   print "</SELECT><BR><BR>";

print << "EOF";
		
		</TD>
	</TR>
</TABLE>

</TD>
		
		<TD WIDTH="33%" ALIGN=CENTER>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Experiment UID</FONT></TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=CENTER>
		<input type=text name=expid><BR><BR>
		</TD>
	</TR>
</TABLE>

</TD>
		<TD WIDTH="33%" ALIGN=CENTER>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Print List</FONT></TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=CENTER>
		<select name=printlist>

EOF
@printlists = `/bin/ls $printlistpath`;
print "<option value=\"\" >None</option>";
#print "<option value=0></option>\n";
foreach $file (@printlists)
{
    print "<option value=$file>$file</option>\n";
}
print "</select><br><BR>\n";
print << "EOF";
         
		</TD>
	</TR>
</TABLE>

</TD>
	</TR>
	<TR>
		<TD WIDTH="33%" ALIGN=CENTER>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Number of Tips</FONT></TD>
	</TR>
	<TR>
		<TD  BGCOLOR="#EEEEEE" ALIGN=CENTER>
		<select name=sectors>
		<option value=16>  16  </option>
		<option value=1>  1  </option>
		<option value=4>  4  </option>
		<option value=32>  32  </option>
		</select><BR><BR>
		</TD>
	</TR>
</TABLE>

</TD>
		<TD WIDTH="33%" ALIGN=CENTER>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Analysis Software</FONT></TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=CENTER>
		<select name=software>
		<option value=GenePix>Gene Pix</option>
		<option value=ScanAlyze>ScanAlyze</option>
        </select><BR><BR>
		</TD>
	</TR>
</TABLE>

</TD>
		<TD WIDTH="33%" ALIGN=CENTER>
<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD BGCOLOR="#0A01AA" ALIGN=CENTER><FONT COLOR="#FFFFFF">Normalization Factor</FONT></TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=CENTER>
		<input type=text name=norm>
		<BR><BR>
		</TD>
	</TR>
</TABLE>
</TD>
	</TR>
</TABLE>

<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="0" WIDTH="100%">
	<TR>
		<TD  BGCOLOR="#EEEEEE" ALIGN=LEFT>Category</TD>
		<TD BGCOLOR="#EEEEEE">
		<input type=text name=cat size=25>
		<select name=precat>
EOF

foreach $cat (values %arraycat)
    {
	$usecat{$cat} = "1";
    }
@categories = sort {$a cmp $b} keys %usecat;

print "<option value=\"\" >None</option>";
foreach $cat (@categories)
{
	print "<option value=$cat>$cat</option>\n";
}

print << "EOF";	
		</select>
		
		</TD>
	</TR>
	
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=LEFT>New User Name</TD>
		<TD BGCOLOR="#EEEEEE">
		<input type=text name=newuser size=70 >
		</TD>
	</TR>

	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=LEFT>Experiment Description</TD>
		<TD BGCOLOR="#EEEEEE">
		<input type=text name=expdesc size=70>
		</TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=LEFT>Cy3 Description</TD>
		<TD BGCOLOR="#EEEEEE">
		<input type=text name=cy3 size=70>
		</TD>
	</TR>
	<TR>
		<TD BGCOLOR="#EEEEEE" ALIGN=LEFT>Cy5 Description</TD>
		<TD BGCOLOR="#EEEEEE">
		<input type=text name=cy5 size=70>
		</TD>
	</TR>
</TABLE>
<TABLE BORDER=0 WIDTH="100%">
	<TR><TD BGCOLOR="#EEEEEE" ALIGN=CENTER>
	<input type="SUBMIT" NAME="submit" value="Submit"><BR>
	</TD></TR>
</TABLE>

</TD></TR></TABLE>
<BR>
</form>

EOF
&PrintFooter();
