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

<?cs def:group_description(string) ?>
<?cs if:string ?><?cs var:string ?><?cs else ?><?cs var:lang.admin_course_search_form.no_description ?><?cs /if ?>
<?cs /def ?>

<?cs def:print_search_form() ?>
<div><form method="post" action="<?cs var:server_name ?>/<?cs var:bin_alias ?>/admin_course_search_form">
<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 var:group ?>" />
<input type="hidden" name="type" value="<?cs var:type ?>" />
<input type="hidden" name="where" value="<?cs var:where ?>" />
</div>
<div class="center_msg"><span class="alert_color"><?cs if:add_type == "student" ?><?cs var:lang.admin_course_search_form.add_students_heading ?><?cs else ?><?cs var:lang.admin_course_search_form.add_teachers_heading ?><?cs /if ?></span></div>

<table cellspacing="0" cellpadding="2"  >
  <tr>
    <td align="right" class="regheading"><?cs var:lang.admin_course_search_form.search_label ?></td>
    <td align="center">
    <input type="text" name="search" id="search" size="12" maxlength="<?cs var:max_search_len ?>" title="<?cs var:lang.admin_course_search_form.search_box_title ?>" />
    </td>
    <td align="right" class="regheading"><?cs var:lang.admin_course_search_form.course_group_label ?></td>
    <td>
     <select name="subdir"  id="subdir"  title="<?cs var:lang.admin_course_search_form.course_group_title ?>">
     <?cs set:count = #1 ?>
    <?cs each:this = course_group ?>
         <option value="<?cs var:this.value ?>" 
                <?cs if:this.is_selected ?>selected="selected"<?cs /if ?> >
                 <?cs var:this.value ?> 
                (<?cs call:group_description(this.description) ?>)
         </option>
    <?cs set:count = count + #1 ?>
    <?cs /each ?>
     </select>
    </td>
    <td valign="middle">
     <input type="hidden" name="dir_count" value="<?cs var:count ?>" />
     <input  type="submit" name="mysearch" value="<?cs var:lang.admin_course_search_form.search_button ?>" title="<?cs var:lang.admin_course_search_form.search_button_title ?>" />
  </td>
 </tr>
</table>
</form>
</div>
<?cs /def ?>








<?cs def:print_course_list() ?>
    <div><form method="post" action="<?cs var:server_name ?>/<?cs var:bin_alias ?>/admin_list_students_in_courses" onsubmit="return validate_course_selection()" >
     <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 var:group ?>" />
   <input type="hidden" name="type" value="<?cs var:type ?>" />
   <input type="hidden" name="where" value="<?cs var:where ?>" />
  </div>
 <div class="dtree">
   <h4><a href="javascript: d.openAll();" title="<?cs var:lang.super_course_search.open_all ?>"><?cs var:lang.super_course_search.open_all ?></a> | <a href="javascript: d.closeAll();" title="<?cs var:lang.super_course_search.close_all ?>"><?cs var:lang.super_course_search.close_all ?></a></h4>

   <script type="text/javascript">
     d = new dTree('d');
     d.add(0, -1, '<?cs var:lang.admin_course_search_form.page_title ?>');

     <?cs if:normal_count ?>
            d.add(1, 0, '<?cs var:normal_count ?> <?cs var:lang.super_course_search.num_central_courses ?>');
     <?cs /if ?>
     <?cs each:mynode = node ?>
       d.add(<?cs var:mynode ?>);
     <?cs /each ?>
   document.write(d);
  </script>
  </div>
     <div class="center_msg"><input type="submit" value="<?cs var:lang.admin_course_search_form.submit.msg ?>" title="<?cs var:lang.admin_course_search_form.submit.help ?>" />
     </div>
   </form>
 </div>
<?cs /def ?>
 

<?cs call:html_heading() ?>
<head>
      <title><?cs var:lang.admin_course_search_form.page_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"  />

<?cs if:normal_count ?>
   <link rel="StyleSheet" href="<?cs var:image_path ?>dtree.css" type="text/css"  />
   <base href="<?cs var:server_name ?><?cs var:image_path ?>index.html" />
   <script type="text/javascript" src="<?cs var:image_path ?>dtree.js"></script>
 
<script type="text/javascript">
function validate_course_selection()
   {
      var true_test = 0;

      var obj = document.forms[1].course_list;
      if(obj.checked)
          true_test = 1;
      
      else
      {
             if(obj.length >0)
             {
                 for(i =0; i<obj.length; i++)
                 {
                    if(obj[i].checked)
                       true_test = 1;
                
                 }
             }
      }
      if(true_test == 0)
      {
             window.alert('<?cs var:lang.admin_course_search_form.no_courses_selected ?>');
             return false;
      }
      else
         return  true;
   }


</script>
<?cs /if ?>
</head>

<?cs call:define_onload_body("search") ?>
<?cs call:print_course_heading(back_url, lang.admin_course_search_form.goback) ?>
<table width="100%">
 <tr><td align="center">
   <?cs call:print_search_form() ?>
</td></tr>
</table>
<?cs if:normal_count ?>
<div style="margin-left: 50px; padding:12px">
<fieldset style="width: 90%">
   <?cs call:print_course_list() ?>
</fieldset>
</div>
<?cs /if ?>
</body>
</html>
<?cs call:runtime() ?> 
