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


<?cs def:print_table_heading() ?>
  <tr class="table_heading">
   <?cs if:!hide_manhattan_username ?>
    <th><?cs var:lang.admin_assign_team_form.username ?></th>
   <?cs /if ?>
   <?cs each:this = lang.admin_assign_team_form.heading ?>
    <th><?cs var:this ?></th>
   <?cs /each ?>
 </tr>
<?cs /def ?>

<?cs def:print_team(data) ?>
  <select name="<?cs var:data.username ?>" title="<?cs var:lang.admin_assign_team_form.select.help ?> <?cs var:data.realname ?>">

  <?cs each:my_team = team_letter ?>
   <?cs if:my_team.internal == data.team_internal ?>
    <option value="<?cs var:my_team.internal ?>" selected="selected"><?cs var:my_team.display ?></option>
   <?cs else ?>
    <option value="<?cs var:my_team.internal ?>" ><?cs var:my_team.display ?></option>
   <?cs /if ?>
  <?cs /each ?>
</select>
<?cs /def ?>


<?cs def:print_row(data, num_color) ?>
  <?cs if:num_color % #2  == #1 ?>
   <tr class="even_color">
  <?cs else ?>
  <tr class="odder_color">
  <?cs /if ?>
   <?cs if:!hide_manhattan_username ?>
   <td><?cs var:data.username ?></td>
   <?cs /if ?>
   <td>
   <?cs if:data.url ?>
    <a href="javascript:openwindow('<?cs var:data.url ?>', 'bio')" title="<?cs var:lang.admin_assign_team_form.bio_help ?>" class="normal">
     <?cs var:data.realname ?></a> 
   <?cs else ?>
     <?cs var:data.realname ?> 
   <?cs /if ?> 
   </td>
  <td><?cs var:lang.admin_assign_team_form.group[data.group] ?></td>
  <td><?cs var:data.alias ?></td>
  <td><?cs var:data.id ?></td>
  <td><?cs call:print_team(data) ?></td>
 </tr>
<?cs /def ?>

<?cs def:print_submit(data) ?>
  <tr>
    <td colspan="6" align="center">
    <input type="submit" value="<?cs var:data.submit.msg ?>" title="<?cs var:data.submit.help ?>" />
    </td>
  </tr>
<?cs /def ?>

<?cs def:print_change_row(data, user, color) ?>
  <?cs if:color % #2 == #1 ?>
   <tr class="even_color">
  <?cs else ?>
   <tr class="odder_color">
  <?cs /if ?>
   <?cs if:!hide_manhattan_username ?>
    <td><?cs var:user.username ?></td>
   <?cs /if ?>
    <td><?cs var:user.realname ?></td>
    <td><?cs var:data.group[user.group] ?></td>
    <td><?cs var:user.alias ?></td>
    <td><?cs var:user.id ?></td>
    <td><?cs var:user.new_team ?></td>
    <?cs if:user.old_team ?>
      <td><?cs var:user.old_team ?>---&gt;<?cs var:user.new_team ?></td>
    <?cs else ?>
      <td><?cs var:data.unchange ?></td>
    <?cs /if ?>
   </tr>
<?cs /def ?>



<?cs def:print_change(data) ?>
<table width="100%">
 <tr><td align="center">
   <table cellspacing="0" cellpadding="4" border="1">
   <tr class="table_heading">
    <?cs each:head = data.heading ?>
     <th><?cs var:head ?></th>
    <?cs /each ?>
     <th><?cs var:data.heading_status ?></th>
   </tr>
   <?cs set:color = #0 ?>
   <?cs set:team = "A" ?>
   <?cs each:user = person ?>
    <?cs if:user.new_team != team ?>
     <?cs set:color = color + #1 ?>
     <?cs set:team = user.new_team ?>
    <?cs /if ?>
    <?cs call:print_change_row(data, user, color) ?>
   <?cs /each ?>
   </table>
 </td></tr>
</table> 
<?cs /def ?>

<?cs call:html_heading() ?>
   <head>
      <title><?cs var:lang.admin_assign_team_form.title ?></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">
   function openwindow(some_url,winname)
   {
   var new_window = window.open(some_url, winname,'menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=760,height=500');
   new_window.focus();
  }
  </script>
 
  </head>
<?cs call:define_body() ?>
<?cs if:back_url ?>
   <?cs call:print_course_heading(back_url, lang.admin_assign_team_form.goback) ?>
<?cs else ?>
   <?cs call:print_course_heading("javascript:history.back()", lang.admin_assign_team_form.goback) ?>
<?cs /if ?>

<div class="center_msg">
  <?cs if:changed ?>
      <span class="alert_color"><?cs var:lang.admin_assign_team_form.teams_changed ?></span>
  <?cs else ?>
      <span class="alert_color"><?cs var:lang.admin_assign_team_form.title ?></span>
  <?cs /if ?>
   <div class="regheading"><?cs var:lang.admin_assign_team_form.number_user_label ?> <?cs var:num_people ?></div>  
</div>
<?cs if:changed ?>
   <?cs call:print_change(lang.admin_assign_team_form) ?>
<?cs else ?>
<table width="100%">
<tr><td align="center">
 <div><form method="post" action="admin_assign_team" >
   <div>
     <input type="hidden" name="id" value="<?cs var:id ?>" />
     <input type="hidden" name="crs" value="<?cs var:crs ?>" />
   </div>
 <table cellspacing="0" cellpadding="4" border="1"> 
  <?cs call:print_table_heading() ?>
  <?cs set:start = "A" ?>
  <?cs set:color = #0 ?>
  <?cs each:this = users ?>
  <?cs if:start != this.team_internal ?>
    <?cs set:start = this.team_internal ?>
    <?cs set:color = color + #1 ?>
  <?cs /if ?>
   <?cs call:print_row(this, color) ?>
  <?cs /each ?>
  <?cs call:print_submit(lang.admin_assign_team_form) ?>
 </table>
 </form></div>
</td></tr>
</table>
<?cs /if ?>
</body>
</html>
<?cs call:runtime() ?>
