<?cs include:"util.cs" ?>


<?cs def:print_text(name, value, max) ?>
  <tr>
     <td class="regheading"><?cs var:value.msg ?></td>
     <td><input type="text" name="<?cs var:name ?>" id="<?cs var:name ?>" title="<?cs var:value.help ?>" size="15" maxlength="<?cs var:max ?>" /></td>
  </tr>
<?cs /def ?>

<?cs def:print_new_form(data) ?>
  <table width="100%">
  <tr><td align="center">

  <fieldset style="width: 40%">
   <legend class="fieldset_legend"><?cs var:lang.admin_add_student_form.title[group] ?></legend>
   <div><form method="post" action="admin_add_standalone_student" onsubmit="return validate_new_add()" >
      <div>
      <input type="hidden" name="id" value="<?cs var:id ?>" />
      <input type="hidden" name="crs" value="<?cs var:crs ?>" />
      <input type="hidden" name="group" value="<?cs if:group == #1?>faculty<?cs else ?>student<?cs /if ?>" /> 
      </div> 
   <table>
      <?cs call:print_text("first", data.form[0], max_name) ?>
      <?cs call:print_text("last", data.form[1], max_name) ?>
      <?cs if:group == #0 ?>
      <?cs call:print_text("user_id", data.form[2], max_id) ?>
      <?cs else ?>
      <?cs call:print_text("user_id", data.form[5], max_id) ?>
      <?cs /if ?>
      <tr>
        <td class="regheading"><?cs var:data.form[6].msg ?></td>
        <td><select name="team" title="<?cs var:data.form[6].help ?>" >
        <?cs each:this = team_letter ?>
          <?cs if:group == 0 && this.internal == "A" ?>
              <option value="<?cs var:this.internal ?>" selected="selected"><?cs var:this.display ?></option>
          <?cs elif:group == 1 && this.internal == "Z" ?> 
              <option value="<?cs var:this.internal ?>" selected="selected"><?cs var:this.display ?></option>
          <?cs else ?>
              <option value="<?cs var:this.internal ?>" ><?cs var:this.display ?></option>
          <?cs /if ?>
        <?cs /each ?>
       </select></td>
     </tr> 
     <tr><td colspan="2" align="center">
        <?cs if:group == 0 ?>
         <input type="submit" value="<?cs var:data.form[3].msg ?>" title="<?cs var:data.form[3].help ?>" />
        <?cs else ?>
         <input type="submit" value="<?cs var:data.form[4].msg ?>" title="<?cs var:data.form[4].help ?>" />
        <?cs /if ?>
        </td>
     </tr>
   </table> 
   </form></div>
   <div class="notes"><?cs var:lang.admin_add_student_form.notes ?></div>
  </fieldset>
  </td></tr>
  </table>
<?cs /def ?>

<?cs def:print_row(data, value) ?>
 <tr>
   <td class="regheading"><?cs var:data ?></td>
   <td><?cs var:value ?></td>
 </tr>
<?cs /def ?>


<?cs def:print_success(data) ?>
<table width="100%">
<tr><td align="center">
  <fieldset style="width: 35%">
   <legend class="fieldset_legend"><?cs var:lang.admin_add_student_form.title[group] ?></legend>
   <table cellspacing="0" cellpadding="4" border="1">
    <?cs call:print_row(data.success[0], username) ?>
    <?cs call:print_row(data.success[1], realname) ?>
    <?cs call:print_row(data.success[2], userid) ?>
    <?cs call:print_row(data.success[3], team) ?>
   </table>
   <div class="notes"><?cs var:realname ?> (<?cs var:username ?>) <?cs var:data.success[4] ?></div>
 </fieldset>
</td></tr>
</table>
<?cs /def ?>

<?cs call:html_heading() ?>
<head>
    <title><?cs var:lang.admin_add_student_form.title[group] ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="StyleSheet" href="<?cs var:image_path ?>common.css" type="text/css"  />
    <script type="text/javascript" src="<?cs var:image_path ?>form_validation.js"></script>
    <script type="text/javascript">
    function validate_new_add()
    {
        var value = document.getElementById('first').value;
        if( is_whitespace(value)  )
        {
          window.alert('<?cs var:lang.admin_add_student_form.first_name_blank ?>');
          return false;
        }

    value = document.getElementById('last').value;
    if(is_whitespace(value))
    {
       window.alert('<?cs var:lang.admin_add_student_form.last_name_blank ?>');
       return false;
    }
    value = document.getElementById('user_id').value;

    if( is_whitespace(value))
    {
       window.alert('<?cs var:lang.admin_add_student_form.id_number_blank ?>');
       return false;
    }

    return true;

   }

  </script>
  </head>
<?cs call:define_onload_body("first") ?> 
<?cs call:print_course_heading(back_url, lang.admin_add_student_form.goback) ?>
<?cs if:add_success ?>
<?cs call:print_success(lang.admin_add_student_form) ?>
<?cs else ?>
<?cs call:print_new_form(lang.admin_add_student_form) ?>
<?cs /if ?>
</body>
</html>
<?cs call:runtime() ?>
