<?
$pre   = '../../';
include  $pre . "common.php";
include $pre . "admin/" . ADMIN_FUNCTIONS;
eval($auth_synth);
$title = "2009 US GLOBEC Pan-Regional Synthesis Workshop";
$logo  = false;
$imenu = 'calendar';
$valid = true;
$t = array('t_p','t_s','w_a','w_p','w_s','th_a','th_p','th_s','f_a');

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['phone']) && $valid){
      $indication = 'You must enter your phone number';
      $valid = false;
   }
   if($valid && empty($data['proj_role'])){
      $indication = 'Please specify your "Project Role"';
      $valid = false;
   }
   if($valid && empty($data['role_other']) && $data['proj_role'] == 'Other'){
      $indication = 'Please specify what you mean by \'Other\' under "Project Role"';
      $valid = false;
   }
   if(empty($data['attending']) && $valid){
      $indication = 'Please tell us whether or not you will be attending';
      $valid = false;
   }
   if($valid && $data['attending'] == 'Y' && empty($data['support'])){
      $indication = 'Please choose a "Travel Support" option';
      $valid = false;
   }
   if($valid && $data['attending'] == 'Y'){
      $valid = false;
      foreach($t as $key => $value){
         if($data[$value] == "on")
            $valid = true;
      }
      if(!$valid)
         $indication='You must choose at least one time that you will be attending';
   }
/* if($valid && $data['attending'] == 'Y' && empty($data['fres'])){
      $indication = 'Please choose a "Flight Reservations" option';
      $valid = false;
   }
   if($valid && $data['fres'] == 'N' && $data['support'] == 'S'){
      $indication = 'Only those attendees supported by the national office may request that the national office make their reservations';
      $valid = false;
   }*/
}


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

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

   foreach($data as $key => $value){
      if($key != "but" && $key != "userdigit"){
         if(strpos($key,'_') && !strpos($key,'o') && !empty($value)){
            $times .= $key . ';';
         }
         else{
            $$key = $value;
         }
      }
   }
         
   $tbname = TABLE_WORKSHOPS;
   $query  = "INSERT INTO $tbname SET workshop='synth08', last='$last', first='$first',
              institution='$institution', email='$email', phone='$phone', attending='$attending'";

   // late registers must make their own flight reservations
   $query .= ", fres='S'";

   for($i=1;$i<=11;$i++){
      unset($tmp);
      if($i<10){
         $tmp = "P0" . $i;
         if(!empty(${$tmp}))
            $proj .= $tmp.";";
      }
      else{
         $tmp = "P" . $i;
         if(!empty(${$tmp}))
            $proj .= $tmp.";";
      }
   }
   if(!empty($proj))
      $query .= ", projects='" . perl_chop($proj) . "'";
   if(!empty($times))
      $query .= ", times='" . perl_chop($times) . "'";
   if(!empty($proj_role))
      $query .= ", proj_role='$proj_role'";
   if(!empty($proj_role) && $proj_role == 'Other' && !empty($role_other))
      $query .= ", role_other='$role_other'";
   if(!empty($support))
      $query .= ", support='$support'";
   //if(!empty($fres))
      //$query .= ", fres='$fres'";
   if(!empty($hotel))
      $query .= ", hotel='$hotel'";

// $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    = 'Congratulations,

You are successfully registered for the 2009 U.S. GLOBEC Pan-Regional
Synthesis Workshop. 

';

      /* Late registers must make their own flight arrangements
      if(!empty($fres) && $fres == 'N'){
         $message .= 'In order for the national office to make your flight reservations for
this workshop, please send an email to lagle@marine.rutgers.edu that
indicates the following:

- Preferred time frames (2-3 hour window) for flight departure from home
  airport and from Denver airport for departure and arrival
- Preferred airline may also be indicated. (Please note, however, the
  office will select another airline if there is a significant cost
  differential.)
- Home airport (and acceptable alternate if there is one).

';
      }*/

      $message .= 'Looking forward to seeing you in Boulder,
The organizing committee';

      $admin_mess = "$first $last from $institution has late registered for the 2009 U.S. GLOBEC
Pan-Regional Synthesis Meeting using the following email address:

$email

Click the link below for more details:

http://www.usglobec.org/workshops/synth08/attendee_detail.php?id=$event_id";
      mail($email,"Registration Confirmation",$message,$from,"-flagle@marine.rutgers.edu");
//      mail("robertson@marine.rutgers.edu","Registration Confirmation",$message,$from,"-frobertson@marine.rutgers.edu");
      mail("lagle@marine.rutgers.edu","New Register",$admin_mess,$from,"-flagle@marine.rutgers.edu");
      $success    = true;
   }
}

if(isset($success) && $success){
   include HEAD;
?>
<h2>You have successfully registered for the 2009 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 "\n";
}
?>
<h1>Registration</h1>
<center><h2>Third Annual U.S. GLOBEC<br />Pan-Regional Synthesis Workshop<br />17 - 20 February 2009<br />National Center for Atmospheric Research<br>Boulder, CO</h2></center>
<h3><font color="blue">There is a $30 cash only workshop registration fee to be collected at the workshop.</font></h3>
<br /><br />
<form name="mainform" method="post" action="late_register.php">
<table class="register">
<?
if(!empty($data['last']))
   $tmp=stripslashes($data['last']);
else
   $tmp='';
?>
<tr>
   <td width="170px;">
      <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>
      <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>
      <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>
      <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['phone']))
   $tmp=stripslashes($data['phone']);
else
   $tmp='';
?>
<tr>
   <td>
      <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>
      <b>Project(s) represented: </b><br>check all that apply
   </td>
   <td align="left">
      <table border="1"><tr><td width="50%"><div class="hangwrap">
         <div class="hang"><input type="checkbox" name="P01" <?if(!empty($data['P01']) && $data['P01'] == 'Y') echo "checked";?> value="Y">Comparative Ecology of Krill in Coastal and Oceanic Waters around the Pacific Rim</div>
         <div class="hang"><input type="checkbox" name="P02" <?if(!empty($data['P02']) && $data['P02'] == 'Y') echo "checked";?> value="Y">Comparative Analysis of Salmon and Cod Population Responses</div>
         <div class="hang"><input type="checkbox" name="P03" <?if(!empty($data['P03']) && $data['P03'] == 'Y') echo "checked";?> value="Y">Climate Variability and Change in the U.S. GLOBEC Regions as Simulated by the IPCC Climate Models: Ecosystem Implications</div>
         <div class="hang"><input type="checkbox" name="P04" <?if(!empty($data['P04']) && $data['P04'] == 'Y') echo "checked";?> value="Y">Copepods in a Warming Climate: A Pan-Regional Model of Arctic and Northwest Atlantic Systems</div>
         <div class="hang"><input type="checkbox" name="P05" <?if(!empty($data['P05']) && $data['P05'] == 'Y') echo "checked";?> value="Y">Pacific Ocean Boundary Ecosystems: response to natural and anthropogenic climate forcing</div>
         <div class="hang"><input type="checkbox" name="P06" <?if(!empty($data['P06']) && $data['P06'] == 'Y') echo "checked";?> value="Y">The Effect of Varying Freshwater Inputs on Regional Ecosystems in the North Atlantic</div>
      </div></td>
      <td width="50%"><div class="hangwrap">
         <div class="hang"><input type="checkbox" name="P07" <?if(!empty($data['P07']) && $data['P07'] == 'Y') echo "checked";?> value="Y">End-to-end Energy Budgets in US-GLOBEC Regions</div>
         <div class="hang"><input type="checkbox" name="P08" <?if(!empty($data['P08']) && $data['P08'] == 'Y') echo "checked";?> value="Y">Climate Forcing of Calanus finmarchicus Populations of the North Atlantic</div>
         <div class="hang"><input type="checkbox" name="P09" <?if(!empty($data['P09']) && $data['P09'] == 'Y') echo "checked";?> value="Y">Estimating Ecosystem Model Uncertainties in Pan-Regional Syntheses and Climate Change Impacts on Coastal Domains of the North Pacific Ocean</div>
         <div class="hang"><input type="checkbox" name="P10" <?if(!empty($data['P10']) && $data['P10'] == 'Y') echo "checked";?> value="Y">Life histories of species in the genus Calanus in the North Atlantic and North Pacific Oceans and responses to climate forcing</div>
         <div class="hang"><input type="checkbox" name="P11" <?if(!empty($data['P11']) && $data['P11'] == 'Y') echo "checked";?> value="Y">National Office / Pan-Regional Synthesis Working Group</div>
      </td></tr></table>
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<?
if(!empty($data['role_other']))
   $tmp = stripslashes($data['role_other']);
else
   $tmp='';
?>
<tr>
   <td>
      <b>Project role: </b>
   </td>
   <td align="left">
      <table border="1">
      <tr>
         <td width="50%">
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'PI') echo "checked";?> value="PI" /> PI<br />
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'Co-PI') echo "checked";?> value="Co-PI" /> Co-PI<br />
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'Intl Collab') echo "checked";?> value="Intl Collab" /> International Collaborator<br>
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'Program Manager / National Office') echo "checked";?> value="Program Manager / National Office" /> Program Manager / National Office
         </td>
         <td width="50%">
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'Grad Student') echo "checked";?> value="Grad Student" /> Grad Student<br />
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'Post-doc') echo "checked";?> value="Post-doc" /> Post-doc<br />
            <input type="radio" name="proj_role" <?if(!empty($data['proj_role']) && $data['proj_role'] == 'Other') echo "checked";?> value="Other" /> Other (please specify)
            <input type="text" name="role_other" value="<?=$tmp?>" size="35" maxlength="255"  onkeypress="return noenter(this,event)" />
         </td>
      </tr>
      </table>
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td>
      <b>Attendance: </b>
   </td>
   <td>
      <input type="radio" name="attending" <?if(!empty($data['attending']) && $data['attending'] == 'Y') echo "checked";?> value="Y" /> I will attend in person<br />
      <input type="radio" name="attending" <?if(!empty($data['attending']) && $data['attending'] == 'W') echo "checked";?> value="W" /> I will attend via WebEx<br />
      <input type="radio" name="attending" <?if(!empty($data['attending']) && $data['attending'] == 'N') echo "checked";?> value="N" /> I will not be able to attend
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td>
      <b>Travel Support: </b>
   </td>
   <td><div class="hangwrap">
      <div style="text-indent:-25px"><input type="radio" name="support" <?if(!empty($data['support']) && $data['support'] == 'A') echo "checked";?> value="A" /> I am a US academic PI or Co-PI and will accept support from the national office</div>
      <div style="text-indent:-25px"><input type="radio" name="support" <?if(!empty($data['support']) && $data['support'] == 'S') echo "checked";?> value="S" /> I am not a US academic PI or Co-PI but will attend on my own support</div>
      <div style="text-indent:-25px"><input type="radio" name="support" <?if(!empty($data['support']) && $data['support'] == 'N') echo "checked";?> value="N" /> I am a US academic student, post-doc or affiliated scientist (not a PI or Co-PI) who would like to attend but would need support if available</div>
      <div style="text-indent:-25px"><input type="radio" name="support" <?if(!empty($data['support']) && $data['support'] == 'F') echo "checked";?> value="F" /> I am a Federal PI or Co-PI wishing to attend as a citizen scientist and will accept support from the national office</div>
   </div></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
   <td>
      <b>I intend to attend the workshop on the following days:</b>
   </td>
   <td>
   <table class="reg" border="1">
      <tr>
         <td width="160"><b>Sessions</b></td>
         <td width="40" align="center"><b>AM</b></td>
         <td width="40" align="center"><b>PM</b></td>
         <td width="40" align="center"><b>Reception</b></td>
      </tr>

      <tr>
         <td>Tuesday, February 17</td>
         <td align="center">&nbsp;</td>
         <td align="center"><input type="checkbox" name="t_p" <?if(!empty($data['t_p']) && $data['t_p'] == 'on') echo "checked";?> /></td>
         <td align="center"><input type="checkbox" name="t_s" <?if(!empty($data['t_s']) && $data['t_s'] == 'on') echo "checked";?> /></td>
      </tr>
      <tr>
         <td>Wednesday, February 18</td>
         <td align="center"><input type="checkbox" name="w_a" <?if(!empty($data['w_a']) && $data['w_a'] == 'on') echo "checked";?> /></td>
         <td align="center"><input type="checkbox" name="w_p" <?if(!empty($data['w_p']) && $data['w_p'] == 'on') echo "checked";?> /></td>
         <td align="center"><input type="checkbox" name="w_s" <?if(!empty($data['w_s']) && $data['w_s'] == 'on') echo "checked";?> /></td>
      </tr>
      <tr>
         <td>Thursday, February 19</td>
         <td align="center"><input type="checkbox" name="th_a" <?if(!empty($data['th_a']) && $data['th_a'] == 'on') echo "checked";?> /></td>
         <td align="center"><input type="checkbox" name="th_p" <?if(!empty($data['th_p']) && $data['th_p'] == 'on') echo "checked";?> ></td>
         <td align="center"><input type="checkbox" name="th_s" <?if(!empty($data['th_s']) && $data['th_s'] == 'on') echo "checked";?> ></td>
      </tr>
      <tr>
         <td>Friday, February 20</td>
         <td align="center"><input type="checkbox" name="f_a" <?if(!empty($data['f_a']) && $data['f_a'] == 'on') echo "checked";?> ></td>
         <td align="center">&nbsp;</td>
         <td align="center">&nbsp;</td>
      </tr>
      </table>
   </td>
</tr>
   <td>
      <b>
<tr><td colspan="2">&nbsp;</td></tr>

<? /* Late registers must make their own flight arrangements<tr>
   <td>
      <b>Flight Reservations: </b><br>National office supported attendees only
   </td>
   <td>
      <input type="radio" name="fres" <?if(!empty($data['fres']) && $data['fres'] == 'S') echo "checked";?> value="S" /> I will make my own flight reservations<br />
      <input type="radio" name="fres" <?if(!empty($data['fres']) && $data['fres'] == 'N') echo "checked";?> value="N" /> I would like the national office to make my flight reservations<br><br>

      <b>Note:</b> If you wish to have your reservations handled by the national office please be sure to read the registration confirmation email for further details.
   </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
*/?>

<tr>
   <td>
      <b>Hotel Information:</b>
   </td>
   <td>
      All attendees are responsible for making their own hotel reservations.<br>
      For reservation information <a target="_blank" href="hotels.php">click
      here</a>.<br><br>To assist in planning, if you do not require a hotel room
      please check the box below.<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>
      <img width="120" height="30" src="button.php" border="1" /><br>
      please enter the numbers you see in the image above.
      <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>
<?
include FOOT;
?>
