<link rel="stylesheet" type="text/css" media="all" href="<{$xoops_url}>/modules/tadtools/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" media="all" href="<{$xoops_url}>/modules/tadtools/bootstrap/css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" media="all" href="<{$xoops_url}>/modules/tadtools/css/xoops_adm.css" />



<div id='frm' class="row-fluid"  >
  郵局帳號 EXCEL 格式順序：
  <table  class="table table-bordered"><tr><td>年級</td><td>	班級代號</td><td>	座號</td><td>	學生姓名</td><td>繳費</td>
    <td>	轉帳戶名</td><td>	轉帳戶身份證編號</td><td>	存款別(P/G)</td><td>		立帳局號</td><td>		存簿帳號</td><td>		劃撥帳號</td><tr></table>

    <form class="form-horizontal"   action="poster_list.php" method='post' enctype='multipart/form-data' >
        <span class='span2'>最新的郵局帳號 EXCEL 檔：</span>
        <input type=file name=userdata>
    	<button type='submit'  name='do_key' value='add' class='btn btn-primary' title='修正 EXCEL 檔中資料，再更新資料庫'>更新帳號資料(EXCEL)</button>
        <span class="label label-warning">檔案不可有密碼保護</span>

        <p></p><p>
        <button type='submit'  name='do_clear' value='clear' class='btn btn-danger' onclick='return confirm("確定要刪除?")'  title='把全部資料清除可移除不在籍學生資料，建議新學年要做一次。'>清除全部帳號資料</button>
        <a class="btn btn-success"  href="export_account.php" title='下載備份保存，再次校對帳號是否正確'>匯出帳號 Excel(備份、比對)</a>
        </p>
   </form>
</div>
<div class="alert alert-info">
<strong>相關說明：</strong>
<a href='pay_sample.xlsx' target='_blank' class='btn btn-inverse'>EXCEL 範例檔</a><br/>
<div>使用 EXCEL 格式匯入，請依範例檔欄位填放資料，不使用的欄位也要保留。</div>
<div>比對以班級、座號、姓名和學生資料庫比對。</div>
<div>帳號做更新時，建議先匯出帳號 EXCEL 檔，修改後再匯入。</div>


</div>


<{ if ($bank_account_use) }>
<{if $chk_message }>
<span class="alert alert-danger"><{$chk_message}></span>
<{/if}>
<div class="alert alert-success"><{$infomessage}></div>

<form class="form-horizontal"   action="poster_list.php" method='post' enctype='multipart/form-data' >
    <button type='submit'  name='do' value='input' class='btn btn-primary'>寫入</button>
    <span class="alert alert-info">可以多欄貼入(空白、逗號、換行，但欄位內容要有資料)</span>
    <{assign var='tab_i' value='1001'}>
    <{foreach  key=stud_sn item=stud   from= $data }>


    <{if  ($class_sit_message[$stud.class_id][$stud.class_sit_num]) }>
      <div class="row-fluid" id= 'div_<{$stud.stud_id}>_<{$stud.name}>'>

      <span class="span1" ><{$stud.class_id}>班</span>
      <span class="span1" ><{$stud.class_sit_num}>號</span>
      <span class="span1" ><{$stud.name}></span>
      <input name="st_name[<{$stud_sn}>]" value="<{$stud.name}>" type="hidden">
      <span class="span1" >
          <input   class='form-control'  name='acc_name[<{$stud_sn}>]' type='text' id='acc_name<{$stud_sn}>'  title='扣款帳號使用人'  tabindex='<{$stud.stud_id}>1'
      placeholder='帳戶姓名'  value='<{ $class_sit_message[$stud.class_id][$stud.class_sit_num].v[5]}>'    />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_person_id[<{$stud_sn}>]' type='text' id='acc_person_id<{$stud_sn}>'  title='帳號人身份証號'  tabindex='<{$stud.stud_id}>2'
      placeholder='身份証號'   value='<{ $class_sit_message[$stud.class_id][$stud.class_sit_num].v[6]}>'    />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_mode[<{$stud_sn}>]' type='text' id='acc_mode<{$stud_sn}>'  title='存款別(P/G)'  tabindex='<{$stud.stud_id}>3'
      placeholder='存款別存簿/劃撥(P/G)'  value='P' />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_b_id[<{$stud_sn}>]' type='text' id='acc_b_id<{$stud_sn}>'  title='立帳局號'  tabindex='<{$stud.stud_id}>4'
      placeholder='立帳局號'  value='<{ $class_sit_message[$stud.class_id][$stud.class_sit_num].v[8]}>'    />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_id[<{$stud_sn}>]' type='text' id='acc_id<{$stud_sn}>'  title='存簿帳號'  tabindex='<{$stud.stud_id}>5'
      placeholder='存簿帳號' value='<{ $class_sit_message[$stud.class_id][$stud.class_sit_num].v[9]}>'  />

      </span>
      <span class="span2" >
          <input   class='form-control'  name='acc_g_id[<{$stud_sn}>]' type='text' id='acc_g_id<{$stud_sn}>'  title='劃撥帳號'  tabindex='<{$stud.stud_id}>6'
      placeholder='劃撥帳號'  value='<{ $class_sit_message[$stud.class_id][$stud.class_sit_num].v[10]}>' />

      </span>
      </div>
      <div class="row-fluid">
        <span class="alert alert-info">
      ......(姓名比對不到，資料先放入，如果不對請清除上方格中資料！)：

      <{ $class_sit_message[$stud.class_id][$stud.class_sit_num].s}>
      </span>
      </div>
    <{else}>
      <div class="row-fluid" id= 'div_<{$stud.stud_id}>_<{$stud.name}>'>
      <span class="span1" ><{$stud.class_id}>班</span>
      <span class="span1" ><{$stud.class_sit_num}>號</span>
      <span class="span1" ><{$stud.name}></span>
      <input name="st_name[<{$stud_sn}>]" value="<{$stud.name}>" type="hidden">
      <span class="span1" >
          <input   class='form-control'  name='acc_name[<{$stud_sn}>]' type='text' id='acc_name<{$stud_sn}>'  title='扣款帳號使用人'  tabindex='<{$stud.stud_id}>1'
      placeholder='帳戶姓名'   />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_person_id[<{$stud_sn}>]' type='text' id='acc_person_id<{$stud_sn}>'  title='帳號人身份証號'  tabindex='<{$stud.stud_id}>2'
      placeholder='身份証號'   />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_mode[<{$stud_sn}>]' type='text' id='acc_mode<{$stud_sn}>'  title='存款別(P/G)'  tabindex='<{$stud.stud_id}>3'
      placeholder='存款別存簿/劃撥(P/G)'  value='P' />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_b_id[<{$stud_sn}>]' type='text' id='acc_b_id<{$stud_sn}>'  title='立帳局號'  tabindex='<{$stud.stud_id}>4'
      placeholder='立帳局號'   />

      </span>
      <span class="span1" >
          <input   class='form-control'  name='acc_id[<{$stud_sn}>]' type='text' id='acc_id<{$stud_sn}>'  title='存簿帳號'  tabindex='<{$stud.stud_id}>5'
      placeholder='存簿帳號'   />

      </span>
      <span class="span2" >
          <input   class='form-control'  name='acc_g_id[<{$stud_sn}>]' type='text' id='acc_g_id<{$stud_sn}>'  title='劃撥帳號'  tabindex='<{$stud.stud_id}>6'
      placeholder='劃撥帳號'   />

      </span>

      </div>
    <{/if}>

    <{/foreach}>
    <button type='submit'  name='do' value='input' class='btn btn-primary'>寫入</button>
    <span class="alert alert-info">可以多欄貼入(空白、逗號、換行，但欄位內容要有資料)</span>
</form>

<script>
//可支援 多欄位貼上，以空白、逗號、換行，但資料不能為空白值
$('input').bind('paste', null, function(e){

    $this = $(this);

    setTimeout(function(){
        var columns = $this.val().split(/[\s,\n]+/);
        $this.val(' ');
        var i;

        for(i=0; i < columns.length; i++){
            var focused = $(':focus');
            var inputs = $(focused).closest('form').find(':input[type=text]');
            inputs.eq(inputs.index(focused)).val(columns[i]);
            inputs.eq(inputs.index(focused) + 1).focus();

            //window.console.log( inputs.index(focused)  );
         }
    }, 0);
});

</script>
<{/if}>


<{if $message}>
     <div class="alert alert-error">
         <{$message}>
     </div>
<{/if}>
