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

<?cs def:display_roster_list() ?>
<div>
  <form id="list_form" action="super_use_auto_file" >
  <div><input type="hidden" name="id" value="<?cs var:Query.id ?>" /></div>
  <table border="1" cellspacing="0" cellpadding="4">
  <caption><i><?cs var:lang.super_auto_update_form.roster_file_list ?></i></caption>
  <tr>
       <th><?cs var:lang.super_auto_update_form.select ?></th>
       <th><?cs var:lang.super_auto_update_form.filename ?></th>
       <th><?cs var:lang.super_auto_update_form.create_time ?></th>
       <th><input type="button" value="<?cs var:lang.super_auto_update_form.view_log ?>" onclick="javascript:openwindow('super_roster_log_list?id=<?cs var:Query.id ?>', 'logWindow')" /></th>
  </tr>
   <?cs each:file = roster_file ?>
   <?cs if:file.new == #1 ?>
   <tr style="background: #fcc">
   <?cs else ?>
   <tr>
   <?cs /if ?>
     <td><input type="radio" name="roster_file" value="<?cs var:file.name ?>" /></td>
     <td style="font-size:12px; text-align:left"><?cs var:file.name ?></td>
     <td style="font-size:12px; text-align:left"><?cs var:file.timestring ?></td>
     <td><input type="button" value="<?cs var:lang.super_auto_update_form.test_xml_file ?>" onclick="javascript:openwindow('super_use_auto_file?id=<?cs var:Query.id ?>&amp;roster_file=<?cs var:file.name ?>&amp;test=roster', 'xmltest')" title="<?cs var:lang.super_auto_update_form.test_xml_file_help ?>"  /></td>
   </tr> 
   <?cs /each ?>
<?cs if:roster_file[0].name ?>
   <tr>
     <td colspan="4" align="center">
     <input type="submit" name="delete" value="<?cs var:lang.super_auto_update_form.delete_file ?>" title="<?cs var:lang.super_auto_update_form.delete_file_help ?>" onclick="return check_select_file('delete')" />
     <input type="submit" name="create" value="<?cs var:lang.super_auto_update_form.create_courses ?>" title="<?cs var:lang.super_auto_update_form.create_courses_help ?>" onclick="return check_select_file('create')" />
     <input type="submit" name="add_faculty" value="<?cs var:lang.super_auto_update_form.add_faculty ?>" title="<?cs var:lang.super_auto_update_form.add_faculty_help ?>" onclick="return check_select_file('add_faculty')" />
     <input type="submit" name="add_student" value="<?cs var:lang.super_auto_update_form.add_student ?>" title="<?cs var:lang.super_auto_update_form.add_student_help ?>" onclick="return check_select_file('add_student')" />
     <input type="submit" name="update" value="<?cs var:lang.super_auto_update_form.update ?>" title="<?cs var:lang.super_auto_update_form.update_help ?>" onclick="return check_select_file('update')" />
     </td>
   </tr> 
<?cs /if ?>
  </table>
  </form>
</div>
<?cs /def ?>

<?cs def:display_request_list() ?>
<?cs if:request_file[0].name ?> 
<div>
<br />
<br />
  <form id="request_form" action="super_use_auto_file" >
  <div><input type="hidden" name="id" value="<?cs var:Query.id ?>" /></div>
  <table border="1" cellspacing="0" cellpadding="4">
  <caption><i><?cs var:lang.super_auto_update_form.request_file_list ?></i></caption>
  <tr>
       <th><?cs var:lang.super_auto_update_form.select ?></th>
       <th><?cs var:lang.super_auto_update_form.filename ?></th>
       <th><?cs var:lang.super_auto_update_form.create_time ?></th>
       <th>&nbsp;</th>
  </tr>
   <?cs each:file = request_file ?>
   <tr>
     <td><input type="radio" name="roster_file" value="<?cs var:file.name ?>" /></td>
     <td style="font-size:12px; text-align:left"><?cs var:file.name ?></td>
     <td style="font-size:12px; text-align:left"><?cs var:file.timestring ?></td>
     <td><input type="button" value="<?cs var:lang.super_auto_update_form.test_xml_file ?>" onclick="javascript:openwindow('super_use_auto_file?id=<?cs var:Query.id ?>&amp;roster_file=<?cs var:file.name ?>&amp;test=request', 'xmltest')" title="<?cs var:lang.super_auto_update_form.test_xml_file_help ?>"  /></td>
   </tr> 
  <?cs /each ?> 
   <tr>
     <td colspan="4" align="center">
     <input type="submit" name="request" value="<?cs var:lang.super_auto_update_form.request ?>" title="<?cs var:lang.super_auto_update_form.request_help ?>" onclick="return check_request_file()" />
     </td>
   </tr>
   </table>
   </form>
</div>
<?cs /if ?>
<?cs /def ?>

<?cs def:display_upload_form() ?>
  <div>
   <br /><br />
   <form id="auto_upload" method="post" enctype="multipart/form-data" action="super_upload_xml_roster" onsubmit="return check_file()">
      <div> 
         <input type="hidden" name="id" value="<?cs var:Query.id ?>" />
         <input type="hidden" name="auto" value="yes" />
      </div>
     <div class="center_block">
       <input type="file" name="file" title="<?cs var:lang.super_auto_update_form.file.help ?>" />
       <input type="submit" value="<?cs var:lang.super_auto_update_form.auto_upload.msg ?>" title="<?cs var:lang.super_auto_update_form.auto_upload.help ?>"  />
     </div>
     </form>
  </div>
<?cs /def ?>





<?cs def:display_notes() ?>  
<div style="text-align: left">
<p><?cs var:lang.super_auto_update_form.help_intro ?></p>

<dl>
<dt><?cs var:lang.super_auto_update_form.upload_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.upload_desc ?><br /></dd>


<dt><?cs var:lang.super_auto_update_form.view_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.view_desc ?><p /></dd>


<dt><?cs var:lang.super_auto_update_form.delete_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.delete_desc ?><p /></dd>

<dt><?cs var:lang.super_auto_update_form.create_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.create_desc ?><p /></dd>


<dt><?cs var:lang.super_auto_update_form.new_faculty_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.new_faculty_desc ?><p /></dd>

<dt><?cs var:lang.super_auto_update_form.update_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.update_desc ?><p /></dd>

<dt><?cs var:lang.super_auto_update_form.logs_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.logs_desc ?><p /></dd>


<dt><?cs var:lang.super_auto_update_form.request_term ?></dt>
<dd><?cs var:lang.super_auto_update_form.request_desc ?><p /></dd>

</dl>

</div>
<?cs /def ?>





<?cs def:display_auto_form() ?>
<fieldset>
<legend><?cs var:lang.super_auto_update_form.auto_update ?></legend>
<table width="100%">
<tr><td align="center">
<?cs call:display_roster_list() ?>
<?cs call:display_upload_form() ?>
<?cs call:display_request_list() ?> 
<?cs call:display_notes() ?>
</td></tr>
</table>
</fieldset>
<?cs /def ?>


<?cs call:html_header() ?>
   <head>
      <title><?cs var:lang.super_auto_update_form.auto_update ?></title>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <link rel="StyleSheet" href="<?cs var:image_path ?>super_template.css" type="text/css"  />
   
   <?cs call:addDoIMenu()  ?> 
   <script type="text/javascript">
    function check_file()
    {
        var value = document.getElementById('auto_upload').file.value;
        if(value == "")
        {
            window.alert('<?cs var:lang.super_auto_update_form.must_provide_xml_file ?>');
            return false;
        }
        return true;
    }
    <?cs if:request_file[0].name ?> 
    function check_request_file()
    {
        var form = document.getElementById('request_form');
        var radio = form.roster_file;
	var i =0;
	var select = 0;

        if(radio.checked)
           select = 1;
	else
	{
	   var len = radio.length;
	   for(i =0; i<len; i++)
	   {
	      if(radio[i].checked)
		  select = 1;
	   }
	}
        if(!select)
	{
           window.alert('<?cs var:lang.super_auto_update_form.must_select_one_file ?>');
	   return false;
	}
        var confirm = window.confirm('<?cs var:lang.super_auto_update_form.request_confirm ?>');
        if(!confirm)
           return false;
       return true;
     }
    <?cs /if ?>
    <?cs if:roster_file[0].name ?>
    function check_select_file(action)
    {
        var form = document.getElementById('list_form');
        var radio = form.roster_file;
	var i =0;
	var select = 0;

        if(radio.checked)
           select = 1;
	else
	{
	   var len = radio.length;
	   for(i =0; i<len; i++)
	   {
	      if(radio[i].checked)
		  select = 1;
	   }
	}
        if(!select)
	{
            window.alert('<?cs var:lang.super_auto_update_form.must_select_one_file ?>');
	   return false;
	}	
	if(action == "delete")
	{
           var confirm = window.confirm('<?cs var:lang.super_auto_update_form.delete_confirm ?>');
           if(!confirm)
	     return false;
	}
	if(action == "create")
	{
           var confirm = window.confirm('<?cs var:lang.super_auto_update_form.create_confirm ?>');
           if(!confirm)
	     return false;
	}
	if(action == "add_faculty")
	{
           var confirm = window.confirm('<?cs var:lang.super_auto_update_form.add_confirm ?>');
           if(!confirm)
	     return false;
	}
	if(action == "add_student")
	{
           var confirm = window.confirm('<?cs var:lang.super_auto_update_form.add_student_confirm ?>');
           if(!confirm)
	     return false;
	}
       if(action == "update")
	{
           var confirm = window.confirm('<?cs var:lang.super_auto_update_form.update_confirm ?>');
           if(!confirm)
	     return false;
	}

        return true;
    }
   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();
    }

   <?cs /if ?>
   </script>
 </head>
<body>
<div id="container">
<?cs call:top_container() ?>
<?cs call:doIMenu() ?>
  <div id="content">
   <?cs call:display_auto_form() ?>
  </div>
</div>
</body>
</html>

<?cs call:runtime() ?>
