<?php

/*
 * user/newproject.php
 *
 * - without arguments: displays the registration form
 *
 * - with the "pb" argument set
 *
 *    - if it has the value of a field name, displays the registration form
 *       and ask the user for correction.
 *
 *    - if it has the value "duplication", exlain the problem(ids of people
 *       already registred should be found in $ids).
 *
 *    - if it has the value "error", displays the $errorno and $errormsg and
 *       ask for registrating again.
 *
 *
 *
 *
 */

//add by Isa on 08.09.2009: keep login info
if (isset($_COOKIE['login'])) { $login = strip_tags($_COOKIE['login']); } else { $login = ""; }
if (isset($_COOKIE['password'])) { $password = strip_tags($_COOKIE['password']); } else { $password = ""; }


require_once("../databases.php");
include("../sequencer.php");
require("../opendb.php");

require("checkpass.php");


function printhappy()
{
 echo '<IMG SRC="../images/smiley1.gif" BORDER=0 ALT="happy smiley">';
}

function printsad()
{
 echo '<IMG SRC="../images/smiley2.gif" BORDER=0 ALT="sad smiley">';
}

function printquestion()
{
 echo '<IMG SRC="../images/smiley5.gif" BORDER=0 ALT="question smiley">';
}

// This function displays the status of the field given as $1
// If there is not problem (indicated by $pb), do nothing
// Otherwise, if the problem is the $field, displays ":-("

function displaystatus($field)
{
 global $pb, $pbdisplayed, $empty;

// echo "$field='${$field}'; pb='$pb'";

 if("$pb" != "")
 {
  echo "<TD ALIGN=CENTER>";

  if("$pb" == "$field")
  {
   $pbdisplayed = TRUE;
   printsad();
  }
  else
  {
   if ($pbdisplayed == FALSE)
    printhappy();
   else
    printquestion();
  }


  echo "</TD>";
 }
}


// This function displays a field
// mandatory: [M|O]
// pass: [Y|N]  $value is not used
//

function displayfield($field, $legend, $value, $maxlength, $example, $mandatory, $pass)
{
 global $pb, $pbdisplayed, $empty;

 echo "<TR>";

 echo "<TD>";

 if("$pb" == "$field")
  echo "<SPAN CLASS=RED><B>";
 elseif("$mandatory" == "M")
  echo "<SPAN CLASS=CUTEBLUE><B>";

 echo "$legend:";


 if("$pb" == "$field")
  echo "</B></SPAN>";
 elseif("$mandatory" == "M")
  echo "</B></SPAN>";

 echo "</TD>";

 echo "<TD>";

 if("$pass" == "Y")
  echo "<INPUT TYPE=PASSWORD SIZE=30 MAXLENGTH=$maxlength NAME=$field VALUE=\"\"></TD>";
 else
  echo "<INPUT TYPE=TEXT SIZE=30 MAXLENGTH=$maxlength NAME=$field VALUE=\"$value\"></TD>";

 echo "<TD>&nbsp;&nbsp;<I>$example</I></TD>";

 displaystatus("$field");

 echo "</TR>";
}


// displays a field, but with hidden attribute

function displayhiddenfield($field, $value)
{
 echo "<INPUT TYPE=HIDDEN VALUE=\"$value\" NAME=\"$field\">";
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<LINK rel="stylesheet" type="text/css" href="../sequencerstyle.css">
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="Author" lang="fr" content="Pierre Berthier">
<META name="keywords" lang="en"    content="">
<META name="keywords" lang="fr"    content="">
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache">
<META http-equiv="Cache-Control" content="must-revalidate">
<META http-equiv="Content-Script-Type" content="text/javascript">

<TITLE>CMPG sequencer - New Project</TITLE>
</HEAD>

<BODY><A NAME="TOP"></A>

<TABLE BORDER=0 WIDTH="100%">
<TR>
<TD ALIGN=LEFT VALIGN=BOTTOM>
<A HREF="http://www.unibe.ch" TARGET=BLANK><IMG SRC="../images/unibern_logo.gif" BORDER=0></A>&nbsp;
<A HREF="http://cmpg.unibe.ch" TARGET=BLANK><IMG SRC="../images/new_banner_CMPG_Panorama_s3.jpg" BORDER=0></A>
</TD>
<TD ALIGN=RIGHT VALIGN=BOTTOM>
<H1 ALIGN=RIGHT CLASS=RED><A HREF="http://cmpg.unibe.ch/sequencer/">ABI 3100</A></H1>
</TD>
</TR>
</TABLE>



<HR NOSHADE SIZE=3>



<TABLE BORDER=0><TR><TD>





<H2>Online registration of a new project for the CMPG sequencer</H2>


<?php
echo "<A HREF=\"$home\">Home</A>&nbsp;|&nbsp;<A HREF=\"$home/user\">User page</A><P>" ;
?>

<TABLE WIDTH="50%" CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD><HR SIZE=3 NOSHADE></TD></TR></TABLE>


<?php

if ("$pb" != "") { $pbdisplayed = FALSE; ?>

<H3>There was a problem in your submission (your project have NOT been registred)</H3>

<?php if ("$pb"=="duplication") { ?>

<B>The problem was that at least a project already exists with this name (<?php echo $name; ?>).</B>

<P>Please try again, review your submission in the form below and click on the &#8220;<B>Submit</B>&#8221; button.




<?php

} // end pb dupli

else { // other pb

echo "Please review your submission below and correct the field in <SPAN CLASS=RED><B>red</B></SPAN> (&#8220;<I>" . "$columnsprojects[$pb]" . "</I>&#8221;).";

if ("$empty" == "1")
echo "<BLOCKQUOTE><I>Note: the field was empty whereas it is <SPAN CLASS=CUTEBLUE><B>mandatory</B></SPAN> to fill it.</I></BLOCKQUOTE>";


} // end other pb

} // end pb

else {  // no problemo

?>





<H3>Registration of a new project</H3>

Here you can register a new project to our ABI 3100 managing system.


<H3>Instructions for registration</H3>

<OL>
<LI><SPAN CLASS=SPACED>Please fill in the following form. <SPAN CLASS=CUTEBLUE><B>Mandatory fields</B></SPAN> are hereafter indicated in <SPAN CLASS=CUTEBLUE><B>blue</B></SPAN>. Other fields are optional.</SPAN>


<LI><SPAN CLASS=SPACED>Upon completion, click on the &#8220;<B>Submit</B>&#8221; button at the bottom of the form.</SPAN>

<LI><SPAN CLASS=SPACED>Alternatively, click on the &#8220;<B>Reset</B>&#8221; button below the form to erase all the fields content.</SPAN>

</OL>



<?php } // end no problemo
?>





<P>
<HR NOSHADE SIZE=3>





<FORM ACTION="<?php echo "registerproject.php"; ?>" METHOD=POST>

<TABLE BGCOLOR=BLACK BORDER=0 CELLPADDING=2>

<TR><TD><TABLE BORDER=0 BGCOLOR=WHITE CELLPADDING=5 CELLSPACING=0>

<?php if("$pb" != "") { ?>
<TR><TD COLSPAN=4>
<B>Legend:</B><BR>
<?php printhappy() ?> the field value is valid<BR>
<?php printsad() ?> the field value is <SPAN CLASS=RED><B>invalid</B></SPAN><BR>
<?php printquestion() ?> I did not review the field value yet<BR>
</TD></TR>
<TR><TD COLSPAN=4>&nbsp;</TD></TR>
<?php } ?>


<TR>
<TH>Field</TH>
<TH>Value</TH>
<TH ALIGN=LEFT>Example</TH>
<?php if("$pb" != "") echo "<TH>Status</TH>";?>
</TR>

<?php

displayfield("name", "Name of the project", "$name", 80, "Myotis", "M", "N");

?>




<TR><TD COLSPAN=<?php if("$pb"=="") echo 3; else echo 4; ?> >&nbsp;</TD></TR>

<TR><TD COLSPAN=<?php if("$pb"=="") echo 3; else echo 4; ?> >
<INPUT TYPE=SUBMIT VALUE="Submit">&nbsp;
<INPUT TYPE=RESET>
</TD></TR>

<?php if("$pb" != "") { ?>
<TR><TD COLSPAN=4>
<B>Legend:</B><BR>
<?php printhappy() ?> the field value is valid<BR>
<?php printsad() ?> the field value is <SPAN CLASS=RED><B>invalid</B></SPAN><BR>
<?php printquestion() ?> I did not review the field value yet<BR>
</TD></TR>
<?php } ?>

</TABLE>
</TD></TR></TABLE>
</FORM>



<P><I>Any problem?</I> Please contact the <A HREF="mailto:isabelle.duperret@iee.unibe.ch">Webmaster</A>.

<P><A HREF="#TOP"><img SRC="../images/up.gif" BORDER=0 height=11 width=14 ALT="Top of the page">Top of the page</A>

</TD></TR></TABLE>



<HR NOSHADE SIZE=3>

<TABLE WIDTH="100%">
<TR>
<TD WIDTH="50%" VALIGN=MIDDLE><A HREF="mailto:isabelle.duperret@iee.unibe.ch"><IMG SRC="../images/mail.gif" BORDER=0 WIDTH=30 ALIGN=TOP HSPACE=2 ALT="[Webmaster: isabelle.duperret@iee.unibe.ch]">Webmaster</A><BR><A HREF="../version.html">Version</A>: 2.0, 07.09.2009
</TD>
</TR>
</TABLE>

</BODY>
</HTML>


<?php mysql_close($db); ?>
