<{$bootstrap}>
<{$jquery}>
<{$toolbar}>


<{if $now_op=="list_tad_assignment_menu"}>
  <h2><{$smarty.const._MD_TADASSIGN_SELECT_ASSN}></h2>
  <{if $all}>
  <form action="index.php" method="post" id="myForm" enctype="multipart/form-data" onsubmit="return check_1() ;">
    <div class="row-fluid">
      <select   id="assn"  name="assn" class="span6">
        <option value=''><{$smarty.const._MD_TADASSIGN_SELECT_ASSN}></option>
        <{foreach from=$all item=data}>
          <option value='<{$data.assn}>' <{if $assn==$data.assn}>selected<{/if}>><{$class_list_c[$data.class_id]}>  -- <{$data.title}> (<{$data.uid_name}>) </option>
        <{/foreach}>
      </select>
    </div>
    <div class="row-fluid">
      你的座號：<input  type="text"  id="sit_id"  name="sit_id" class="span2"   placeholder="你的座號">
    </div>
    <div class="row-fluid">
      上傳密碼：<input  type="password"  id="passwd"  name="passwd" class="span3"   placeholder="這次作業的登入密碼">
      <input type="hidden" name="op" value="login_es_exam">
      <button type="submit" class="btn btn-primary" >登入</button>
    </div>
  </form>
	<script>
	function check_1() {
		//alert ($("#assn").val() ) ;
		if (  $("#assn").val()==0 ) {
			alert ('需要選擇作業主題！')　;
			return false ;
		}

		var re = /^[0-9]+$/;
		if ( !re.test($("#sit_id").val())  ) {
			alert ('輸入座號有問題！')　;
			return false ;
		}

		if (  $("#passwd").val()==""  ) {
			alert ('沒有輸入密碼！')　;
			return false ;
		}
　
	}
	</script>
  <{elseif $isAdmin}>
    <div class="hero-unit">
      <{$smarty.const._MD_TADASSIGN_EMPTY}>
      <a href="admin/add.php" class="btn btn-info"><{$smarty.const._TAD_ADD}></a>
    </div>
  <{else}>
    <div class="hero-unit">
      <{$smarty.const._MD_TADASSIGN_EMPTY}>
    </div>
  <{/if}>
<{elseif $now_op=="tad_assignment_file_form"}>
  <{*             上傳畫面                                    *}>
  <form action="index.php" method="post" id="myForm" enctype="multipart/form-data">
    <h2><{$title}></h2>
    <div class="alert alert-info"><{$note}></div>
    <table class="table table-striped table-bordered table-hover">
      <tr>
        <th>你的姓名</th>
        <td><span class="label label-info  span3"><{$class_list_c[$class_id]}> <{$sit_id}> 號 <{$stud_data.name}> </span><span class='span1' ></span>
          <a href="index.php?assn=<{$assn}>" class="btn btn-danger">如不正確，重選</a>
         </td>
      </tr>
      <tr>
        <th><{$smarty.const._MD_TADASSIGN_FILE}></th>
        <td><input  id="file" name="file" type="file" size=40  <{$accept_filestr}>  ><p>上傳的副檔名限制：<{$ext_file}></p></td>
      </tr>
      <tr>
        <th>檔案說明</th>
        <td><textarea name="desc"  class="span8" rows=4 placeholder="作業內容說明"><{$desc}></textarea></td>
      </tr>
      <tr>
        <th> </th>
        <td>
           <input type="hidden" name="assn" value="<{$assn}>">
          <input type="hidden" name="op" value="insert_tad_assignment_file">
          <input type="hidden" name="passwd" value="<{$passwd}>">
          <input type="hidden" name="class_id" value="<{$class_id}>">
          <input type="hidden" name="sit_id" value="<{$sit_id}>">
          <input type="hidden" name="author" value="<{$stud_data.name}>">
          <input type="hidden" name="stud_id" value="<{$stud_data.stud_id}>">
          <button type="submit"  class="btn btn-primary"  onclick="return check_2() ;" ><{$smarty.const._TAD_SAVE}></button>
        </td>
      </tr>
    </table>
  </form>
	<script>
	function check_2() {
		var fn = ($("#file").val() ) ;

		if (  $("#file").val()=="" ) {
			alert ('你還沒有選擇要上傳的檔案！')　;
			return false ;
		}　
		<{if ($j_ext_file) }>
			//允許的圖片副檔名
			var re = /\.(<{$j_ext_file}>)$/i;
			if (!re.test(fn) ) {
			 	alert ('只允許上傳檔案的副檔名：<{$ext_file}>！')　;
			 	return false ;
			}
		<{/if}>
　
	}
	</script>
<{/if}>
