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

<?cs def:print_list(data) ?>
<table width="100%">
 <tr><td align="center">
 <br />
 <br />
  <fieldset style="width:60%">
  <legend class="fieldset_legend"><?cs var:data.title ?></legend>
  <div><form method="post" action="admin_del_student" onsubmit="return validate_form()">
   <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">
   <tr><td><select name="student" size="10" title="<?cs var:data.select.help ?>" id="student">
    <?cs each:this = user ?>
     <option value="<?cs var:this.value ?>"><?cs var:this.realname ?></option>
    <?cs /each ?>
    </select></td>
    <td valign="middle" class="regheading" align="center">
     <?cs var:data.check[0] ?><input type="checkbox" name="validate" id="validate" title="<?cs var:data.check[0] ?>" /><?cs var:data.check[1] ?><input type="checkbox" name="validate2" id="validate2" title="<?cs var:data.check[1] ?>" /><br />
     <?cs var:data.check[2] ?><br />
     <input type="submit" value="<?cs var:data.check[3] ?>" title="<?cs var:data.check[3] ?> <?cs var:data.check[4] ?>" /><br />
     <?cs var:data.check[4] ?>
    </td>
   </tr>
  </table> 
  </form></div>
  <div >
 <span class="instructions"><?cs var:lang.admin_del_student_form.notes ?></span>
  </div>
  </fieldset>
 </td></tr>
</table>
<?cs /def ?>


<?cs def:print_delete_group_student_form() ?>
<?cs if:std[0].username ?>
<table width="100%">
<tr><td align="center">
<br />

  <fieldset style="width: 60%">
    <legend class="fieldset_legend">
      <?cs var:lang.admin_del_student_form.quickly_delete_students ?> 
    </legend>
    <div>
     <a href="javascript:checkAll(document.forms[1].list)">Check All</a> | <a href="javascript:uncheckAll(document.forms[1].list)">Uncheck All</a>
    </div>
    <div>
     <form method="post" action="admin_del_group_students" onsubmit="return delete_warn()">
    <div>
      <input type="hidden" name="id" value="<?cs var:id ?>" />
      <input type="hidden" name="crs" value="<?cs var:crs ?>" />
    </div>
      <table width="100%">
      <tr><td align="center">
       <table cellspacing="0" cellpadding="4" border="1">
       <tr>
         <th><?cs var:lang.admin_del_student_form.select ?></th>
       <?cs each:this = lang.admin_del_student_form.label ?>
         <th><?cs var:this ?></th>
       <?cs /each ?>
       </tr>
     <?cs set:num = #0 ?>
     <?cs each:student = std ?>
       <tr>
          <td><input type="checkbox" name="list" value="<?cs var:student.username ?>:<?cs var:student.realname ?>:<?cs var:student.id ?>" />
          </td>
          <td><?cs var:student.username ?></td>
          <td><?cs var:student.realname ?></td>
          <td><?cs var:student.id ?></td>
       </tr>
       <?cs set:num = num + #1 ?>
    <?cs /each ?>
       <tr>
          <td colspan="4" align="center">
           <input type="hidden" name="num" value="<?cs var:num ?>" />
           <input  type="submit" title="<?cs var:lang.admin_del_student_form.delete_button ?>" value="<?cs var:lang.admin_del_student_form.delete_button ?>" />
          </td>
      </tr>
     </table>
    </td></tr>
   </table>
   </form></div>
   <div class="instructions">
    <?cs var:lang.admin_del_student_form.notes ?>
   </div>
 </fieldset>
</td></tr></table>
<?cs /if ?>
<?cs /def ?>
 



<?cs def:print_success(data) ?>
 <table width="100%">
  <tr><td align="center">
  <br />
  <br />
   <fieldset style="width:60%">
   <legend class="fieldset_legend"><?cs var:data.title ?></legend>
   <div class="regheading">
   <?cs var:realname ?> <?cs if:!hide_manhattan_username ?>(<?cs var:username ?>)<?cs /if ?> <?cs var:data.student_removed_label ?>
   </div><br /><br />
  <div>
   <span class="instructions"><?cs var:data.delete_note[deleted] ?></span>
  </div>
 </fieldset>
</td></tr>
</table>
<?cs /def ?>

<?cs def:print_student(one) ?>
   <tr>
    <td><?cs if:!hide_manhattan_username ?><?cs var:one.username ?><?cs else ?>&nbsp;<?cs /if ?></td>
    <td><?cs var:one.realname ?></td>
    <td><?cs var:one.id ?></td>
  </tr>
<?cs /def ?>

<?cs def:print_deleted_students() ?>
<table width="100%">
<tr><td align="center">
  <fieldset style="width:60%" >
  <legend class="fieldset_legend"><?cs var:lang.admin_del_student_form.delete_msg ?> 
   <i><?cs var:current_time ?></i>
   </legend>
   <table width="100%">
   <tr><td align="center">
   <table cellspacing="0" cellpadding="4" border="1">
    <tr>
      <?cs each:label = lang.admin_del_student_form.label ?>
        <th><?cs var:label ?></th>
      <?cs /each ?>
    </tr>
   <?cs each:this = student ?>
     <?cs call:print_student(this) ?>
   <?cs /each ?>
   </table>
</td></tr>
</table>
</fieldset>
<?cs /def ?>


<?cs call:html_heading() ?>
   <head>
      <title><?cs var:lang.admin_del_student_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 validate_form()
   {
      var index = document.getElementById('student').selectedIndex;
      if(index < 0)
      {
         window.alert('<?cs var:lang.admin_del_student_form.select_student_warn ?>');  
         return false;
      }
      var validate = document.getElementById('validate').checked;
      var validate2 = document.getElementById('validate2').checked;
      if(!validate || !validate2)
      {
         window.alert('<?cs var:lang.admin_del_student_form.check_validation_warn ?>');  
         return false;
      }
      return window.confirm('<?cs var:lang.admin_del_student_form.you_really_mean ?>'); 
   }
  </script>
  <?cs if:std[0].username ?>
   <script type="text/javascript" src="<?cs var:image_path ?>form_validation.js"></script>
     <script type="text/javascript" >
     function validate_list()
     {
      var obj = document.forms[1].list;
      if(obj.checked)
             return true;
      else
      {
             if(obj.length >0)
             {
                 for(i =0; i<obj.length; i++)
                 {
                    if(obj[i].checked)
                      return true;
                 }
             }
             return false;
      }
   }
   function delete_warn()
   {
       if(validate_list() == false)
       {
            window.alert('<?cs var:lang.admin_del_student_form.must_select_one ?>');
            return false;
       }
       return window.confirm('<?cs var:lang.admin_del_student_form.confirm_msg ?>');

   }
  </script>
  <?cs /if ?>

  </head>

<?cs call:define_body() ?>
<?cs call:print_course_heading(back_url, lang.admin_del_student_form.goback) ?>
<?cs if:display_deleted ?>
   <?cs call:print_success(lang.admin_del_student_form) ?>
<?cs elif:display_deleted_students ?>
   <?cs call:print_deleted_students() ?>
<?cs else ?>
  <?cs call:print_list(lang.admin_del_student_form) ?>
  <?cs call:print_delete_group_student_form() ?>
<?cs /if ?>
</body>
</html>
<?cs call:runtime() ?>
