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


<?cs def:print_submit() ?>
   <input type="submit" value="<?cs var:lang.admin_list_students_in_courses[add_type] ?>" title="<?cs var:lang.admin_list_students_in_courses[add_type] ?>" />
<?cs /def ?>

<?cs def:print_one_course(crs) ?>
<div style="margin-bottom: 2em;">
   <table cellspacing="0" cellpadding="4" border="1">
    <tr class="table_heading">
      <?cs each:label = lang.admin_list_students_in_courses.table ?>
       <th><?cs var:label ?></th>
      <?cs /each ?>
    </tr>
    <?cs set:this_num = #0 ?>
    <?cs each:person = crs.user ?>
     <tr>
       <?cs if:!person.in_class ?>
         <?cs set:this_num = this_num + #1 ?>
         <td align="center">
            <input type="checkbox" name="users" value="<?cs var:person.username ?>:<?cs var:person.realname ?>:<?cs var:person.id ?>" title="<?cs var:lang.admin_list_students_in_courses.select.help ?> <?cs var:person.realname ?> <?cs var:lang.admin_list_students_in_courses.select.help1 ?>" />
         </td>
       <?cs else ?>
          <td align="center">
           <a href="javascript:openwindow('<?cs var:person.url ?>', 'mywindow')" title="<?cs var:lang.admin_list_students_in_courses.see_pass_list ?>" >
            <?cs var:lang.admin_list_students_in_courses.in_your_class ?></a>
          </td>
       <?cs /if ?>
       <td><?cs var:person.username ?></td>
       <td><?cs var:person.realname ?></td>
       <td><?cs var:person.id ?></td>
       <?cs if:!person.in_class ?>
         <td><select name="<?cs var:person.username ?>" title="<?cs var:lang.admin_list_students_in_courses.select.team ?> <?cs var:person.realname ?>" >
         <?cs each:this = team_letter ?>
              <option value="<?cs var:this.internal ?>" <?cs if:person.team == this.internal ?>selected="selected"<?cs /if ?>><?cs var:this.display ?></option>
         <?cs /each ?>
         </select></td>
       <?cs else ?>
        <td>&nbsp;</td>
       <?cs /if ?>
       
     </tr>
    <?cs /each ?>
    <?cs if:this_num > #0 ?>
     <tr><td colspan="5" align="center">
         <?cs call:print_submit() ?>
    </td></tr>
    <?cs /if ?> 
   </table>
</div>
<?cs /def ?>

<?cs def:print_result() ?>
  <table width="100%">
  <tr><td align="center">
    <div><form method="post" action="admin_add_group_students" onsubmit="return validate_user_selections()">
    <div>
      <input type="hidden" name="crs" value="<?cs var:crs ?>" />
      <input type="hidden" name="id" value="<?cs var:id ?>" />
      <input type="hidden" name="group" value="<?cs var:group ?>" />
    </div> 
    <?cs each:crs = course ?>
     <div class="regheading">
       <?cs var:crs.course_no ?> <?cs var:crs.title ?> (<?cs var:crs.dir ?>)<br />
       <a href="javascript:checkAll(document.forms[0].users)" title="<?cs var:lang.admin_list_students_in_courses.check_all_help ?>"> <?cs var:lang.admin_list_students_in_courses.check_all ?> </a> |
       <a href="javascript:uncheckAll(document.forms[0].users)" title="<?cs var:lang.admin_list_students_in_courses.uncheck_all_help ?>"> <?cs var:lang.admin_list_students_in_courses.uncheck_all ?> </a>
     </div>
     <?cs call:print_one_course(crs) ?>
    <?cs /each ?>   
  </form></div>
 </td></tr>
</table>
<?cs /def ?>


<?cs call:html_heading() ?>
 <head>
      <title><?cs var:lang.admin_list_students_in_courses[add_type] ?></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 openwindow(some_url,winname)
   {
    var new_window = window.open(some_url, winname,'menubar=0,toolbar=0,status=0,scrollbars=yes,resizable=yes,width=650,height=600');
    new_window.focus();
   }

function validate_user_selections()
{
 var obj = document.forms[0].users;
 if(obj.checked)
    return true;
 else
 {
   var len = obj.length;
   for(i = 0; i < len; i++)
   {
     if(document.forms[0].users[i].checked)
       return true;
    }
  }

   window.alert('<?cs var:lang.admin_list_students_in_courses.no_users_selected ?>');
   return false;
}
</script>
</head>

<?cs call:define_body() ?>
<?cs call:print_course_heading("javascript:history.back()", lang.admin_list_students_in_course.goback) ?>
<div class="center_msg"><span class="alert_color"><?cs var:lang.admin_list_students_in_courses[add_type] ?></span></div>
<?cs call:print_result() ?>
</body>
</html>

<?cs call:runtime() ?> 


