<?
$pre   = '../../';
include  $pre . "common.php";
$title = "2007 US GLOBEC Pan-Regional Synthesis Workshop";
$logo  = false;
$valid = true;
//$t = array('m_p','t_a','t_p','w_a','w_p','th_a','th_p');

if($_POST['but'] == "Submit"){
   $data = $_POST;
   if(empty($data['last']) && $valid){
      $indication = 'You must enter your last name';
      $valid = false;
   }
   if(empty($data['first']) && $valid){
      $indication = 'You must enter your first name';
      $valid = false;
   }
   if(empty($data['institution']) && $valid){
      $indication = 'You must enter your institution';
      $valid = false;
   }
   if(empty($data['email']) && $valid){
      $indication = 'You must enter your email address';
      $valid = false;
   }
   if(empty($data['attending']) && $valid){
      $indication = 'Please tell us whether or not you will be attending';
      $valid = false;
   }
   if( !empty($data['hotel']) && ( !empty($data['h_checkin']) || !empty($data['h_checkout']) ) && $valid ){
      $indication = 'You have selected a hotel check-in and/or check-out date but indicted that you do not need a hotel room. Please specify one or the other.';
      $valid = false;
   }
}


if($_POST['but'] == "Submit" && $valid){
   include "audit.php";
   $audit=audit();      
}

if($_POST['but'] == "Submit" && $audit && $valid){

   foreach($data as $key => $value){
      if($key != "but" && $key != "userdigit"){
         $$key = $value;
      }
   }
         
   $tbname = TABLE_WORKSHOPS;
   $query  = "INSERT INTO $tbname SET workshop='synth07', last='$last', first='$first', institution='$institution', email='$email', attending='$attending'";
   if(!empty($address))
      $query .= ", address='$address'";
   if(!empty($phone))
      $query .= ", phone='$phone'";
   if(!empty($support))
      $query .= ", support='$support'";
   else
      $query .= ", support='N'";
   if(!empty($sup_contrib))
      $query .= ", sup_contrib='$sup_contrib'";
   else
      $query .= ", sup_contrib='N'";
   if(!empty($region))
      $query .= ", region='$region'";
   if(!empty($interest))
      $query .= ", interest='$interest'";
   if(!empty($interest))
      $query .= ", interest_contrib='$interest_contrib'";
   if(!empty($ao_interest))
      $query .= ", ao_interest='$ao_interest'";
   else
      $query .= ", ao_interest='N'";
   if(!empty($contrib))
      $query .= ", contrib='$contrib'";
   if(!empty($h_checkin))
      $query .= ", h_checkin='$h_checkin'";
   if(!empty($h_checkout))
      $query .= ", h_checkout='$h_checkout'";

   //$indication = $query;
   $result = $db->sql_query($query);
   if(!$result){
      $indication = "unknown error please try again 1";
   }
   else{
      $event_id   = $db->sql_nextid($result);
      $indication = "$first $last Added Successfully!";
      $from       = "From: lagle@marine.rutgers.edu";
      $message    = 'You have successfully registered for the 2007 U.S. GLOBEC Pan-Regional Synthesis Workshop';
//      $admin_mess = "$first $last from $institution has registered for the 2006 U.S. GLOBEC Pan-Regional Synthesis Meeting using the following email address: $email";
      mail($email,"Registration Confirmation",$message,$from,"-frobertson@marine.rutgers.edu");
//      mail(ADMINS,"New Register",$admin_mess,$from,"-frobertson@marine.rutgers.edu");
      $success    = true;
   }
}

if(isset($success) && $success){
   include HEAD;
?>
<h2>You have successfully registered for the 2007 US GLOBEC Pan-Regional Synthesis Workshop. Thank you.<br/><br />You should receive a confirmation email shortly. If you do not receive a confirmation please contact the webmaster via the link at the bottom of all U.S. GLOBEC webpages.</h2>
<?
   include FOOT;
   exit;
}

$data  = $_POST;

include HEAD;
?>
<?
if($_POST['but'] == "Submit" && !$audit && $valid) echo '<h2><font color="red">You must enter a correct validation code</font></h2>';
if(!empty($indication)){
   echo '<h3><font color="red">' . $indication . "</font></h3>\n";
}
else{
   echo "<br />\n";
}
?>
<h1>Registration</h1>
<center><h2>Second Annual U.S. GLOBEC<br />Pan-Regional Synthesis Workshop<br />25 - 28 September 2007<br />Seattle, WA 98105</h2></center>
The Second Announcement (<a target="_blank" href="Second_Accouncement_US_GLOBEC_Synthesis_Workshop.doc">here</a>)
describes the goals and logistics of the Workshop in more detail.
Please read this carefully if you are interested in attending the Workshop.
<br /><br />
<form name="mainform" method="post" action="<?=SYNTH07_REGISTER?>">
<table class="register">
<?
if(!empty($data['last']))
   $tmp=stripslashes($data['last']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>Last name: </b>
   </td>
   <td>
      <input type="text" name="last" value="<?=$tmp?>" size="40" maxlength="255" onkeypress="return noenter(this,event)" />
   </td>
</tr>
<?
if(!empty($data['first']))
   $tmp=stripslashes($data['first']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>First Name: </b>
   </td>
   <td>
      <input type="text" name="first" value="<?=$tmp?>" size="40" maxlength="255" onkeypress="return noenter(this,event)" />
   </td>
</tr>
<?
if(!empty($data['institution']))
   $tmp=stripslashes($data['institution']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>Institution: </b>
   </td>
   <td>
      <input type="text" name="institution" value="<?=$tmp?>" size="40" maxlength="255" onkeypress="return noenter(this,event)" />
   </td>
</tr>
<?
if(!empty($data['email']))
   $tmp=stripslashes($data['email']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>email: </b>
   </td>
   <td>
      <input type="text" name="email" value="<?=$tmp?>" size="40" maxlength="255" onkeypress="return noenter(this,event)" />
   </td>
</tr>
<?
if(!empty($data['address']))
   $tmp=stripslashes($data['address']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>Address: </b>
   </td>
   <td>
      <textarea name="address" cols="40" rows="5"><?=$tmp?></textarea>
   </td>
</tr>
<?
if(!empty($data['phone']))
   $tmp=stripslashes($data['phone']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>Phone: </b>
   </td>
   <td>
      <input type="text" name="phone" value="<?=$tmp?>" size="40" maxlength="255" onkeypress="return noenter(this,event)" />
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td valign="top">
      <b>Interested in Attending? </b>
   </td>
   <td>
      <input type="radio" name="attending" <?if(!empty($data['attending']) && $data['attending'] == 'Y') echo "checked";?> value="Y" /> Yes, I wish to attend<br />
      <input type="radio" name="attending" <?if(!empty($data['attending']) && $data['attending'] == 'N') echo "checked";?> value="N" /> No, I cannot attend, but add me to the Workshop e-mail list<br />
      <input type="radio" name="attending" <?if(!empty($data['attending']) && $data['attending'] == 'O') echo "checked";?> value="O" /> No, but I may watch on-line if this is an option
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td valign="top">
      <b>Will you be seeking travel support? </b>
   </td>
   <td>
      <input type="radio" name="support" <?if(!empty($data['support']) && $data['support'] == 'Y') echo "checked";?> value="Y" /> Yes<br />
      <input type="radio" name="support" <?if(!empty($data['support']) && $data['support'] == 'N') echo "checked";?> value="N" /> No<br /><br />
      <b>If yes, will you be able to fund some of the costs (travel, hotel, meals) associated with your attendance at this workshop?</b><br />
      <input type="radio" name="sup_contrib" <?if(!empty($data['sup_contrib']) && $data['sup_contrib'] == 'Y') echo "checked";?> value="Y" /> Yes<br />
      <input type="radio" name="sup_contrib" <?if(!empty($data['sup_contrib']) && $data['sup_contrib'] == 'N') echo "checked";?> value="N" /> No
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<?
if(!empty($data['region']))
   $tmp=stripslashes($data['region']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>What US GLOBEC regional program are you affiliated with? (blank for none) </b>
   </td>
   <td>
      <input type="text" name="region" value="<?=$tmp?>" size="40" maxlength="255" onkeypress="return noenter(this,event)" />
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<?
if(!empty($data['interest']))
   $tmp=stripslashes($data['interest']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>What are your primary research interests? </b>
   </td>
   <td>
      <textarea name="interest" cols="40" rows="5"><?=$tmp?></textarea>
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<?
if(!empty($data['interest_contrib']))
   $tmp=stripslashes($data['interest_contrib']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>How do those interests relate/apply to the goals of US GLOBEC Pan-Regional Synthesis? </b>
   </td>
   <td>
      <textarea name="interest_contrib" cols="40" rows="5"><?=$tmp?></textarea>
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td valign="top">
      <b>Are you considering submitting a proposal for the upcoming Announcement of Opportunity? (<a target="_blank" href="http://www.usglobec.org/download/PRS_AO_unofficial_draft.php">DRAFT</a>) </b>
   </td>
   <td>
      <input type="radio" name="ao_interest" <?if(!empty($data['ao_interest']) && $data['ao_interest'] == 'Y') echo "checked";?> value="Y" /> Yes<br />
      <input type="radio" name="ao_interest" <?if(!empty($data['ao_interest']) && $data['ao_interest'] == 'N') echo "checked";?> value="N" /> No
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<?
if(!empty($data['contrib']))
   $tmp=stripslashes($data['contrib']);
else
   $tmp='';
?>
<tr>
   <td valign="top">
      <b>What can you contribute (e.g., specific expertise, complementary data sets from similar studies outside of US GLOBEC, etc.) to this workshop and to US GLOBEC Pan-Regional Synthesis? </b>
   </td>
   <td>
      <textarea name="contrib" cols="40" rows="5"><?=$tmp?></textarea>
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<?
if(!empty($data['h_checkin']))
   $tmp1=stripslashes($data['h_checkin']);
else
   $tmp1='';
if(!empty($data['h_checkout']))
   $tmp2=stripslashes($data['h_checkout']);
else
   $tmp2='';
?>
<tr>
   <td valign="top">
      <b>Please enter your checkin and checkout dates if you require a hotel. </b>
   </td>
   <td>
      Checkin: <input type="text" name="h_checkin" value="<?=$tmp1?>" size="10" maxlength="255" onkeypress="return noenter(this,event)" />
      Checkout: <input type="text" name="h_checkout" value="<?=$tmp2?>" size="10" maxlength="255" onkeypress="return noenter(this,event)" /><br /><br />
      <input type="checkbox" name="hotel" <?if(!empty($data['hotel']) && $data['hotel'] == 'N') echo "checked";?> value="N" /> I do not need a hotel room<br />
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td>
      <b>Authentication: </b>
   </td>
   <td>
      please enter the numbers you see in the image below.
      <img width="120" height="30" src="button.php" border="1" />
      <br />
      <input maxlength="5" SIZE="5" name="userdigit" type="text" value="" />
      <br />
   </td>
</tr>
<tr>
   <td>&nbsp;</td>
   <td>
      <input type="submit" name="but" value="Submit" />
   </td>
</tr>
</table>
</form>
<hr />
<b>NOTES:</b><br />
<?
include FOOT;
?>
