<table class="table table-striped work-list">
    <tr>
      <th class="hidden-xs">序号</th>
      <th>事务名称</th>
      <th>提交时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
  	<?php $i=1;foreach ($list as $key => $v) { ?>
    <tr>
      <td class="hidden-xs" scope="row">
        <?php if($left_nav && $left_nav!='userlist'){ ?>
        <input type="checkbox" class="work_flow_item" data-key="<?php echo $i; ?>" data-wfsn="<?php echo $v->wf_sn; ?>" data-mailtitle="<?php echo $f_datas[$v->wf_sn]['mail_title']; ?>" data-kaoqintime="<?php if($v->wt_userdefined==1) echo isset($f_datas[$v->wf_sn]['rest_days'])?$f_datas[$v->wf_sn]['rest_days']*7+$f_datas[$v->wf_sn]['rest_days2']:''; ?>"> 
        <?php } ?>
        <?php echo ($i++); ?>
      </td>
      <td><?php echo $v->wt_name.'('.$v->OPI_Name.')'; ?></td>
      <td><?php echo date('Y-m-d H:i:s',$v->wf_time); ?></td>
      <td><?php $status=$v->wf_status==0? ($v->isverify!=1?'还没处理':'处理中'):'已审核';echo $status; ?></td>
      <td>
        <a href="<?php echo site_url('apps/workflow/index/verify/'.$v->wf_sn.'/'.$v->wf_status.'/'.$nav_type); ?>"><?php $navename='审核';if($nav_type=='userlist' || $nav_type=='rata_list' || $wv_status==1) $navename='查看';echo $navename; ?></a>
        <?php if($v->wf_status==0 && $v->isverify!=1 && $nav_type=='userlist'){ ?>
          <a href="javascript:void(0);" class="ajax-link" data-href="<?php echo site_url('apps/workflow/index/dalete_work_flow/'.$v->wf_sn); ?>">删除</a>
        <?php } ?>
      </td>
    </tr>
    <?php } ?>
    <tr>
      <td colspan="5">
            <label style="padding-right:20px;"><input type="checkbox" id="checkall_item"> 全选</label>
            <?php $userdata=$this->session->userdata('admin_chtcdn'); if (isset($left_nav) && $left_nav=='unverify' && ($userdata['OPI_Name']=='侯敏' || $userdata['OPI_Name']=='王婷' )) { ?>
        <a class="btn btn-default verify_all_item" href="javascript:void(0);" data-status="0" data-lastkey="0">批量审核</a>
        <a class="btn btn-default verify_all_item" href="javascript:void(0);" data-status="1" data-lastkey="0">审核不通过</a>
        <?php } ?>
      </td>
    </tr>
  </tbody>
</table>

<div class="col-xs-24">
  <nav>
    <ul class="pager pull-left">
        <?php echo $pageinfo['htmls']; ?>
    </ul>
  </nav>
</div>

<script>

$("#checkall_item").click(function(){
  if ($(this).attr("checked")) {
    $(".work_flow_item").attr("checked",'checked');
  }else{
    $(".work_flow_item").removeAttr("checked");
  }
});

var selected_item=0;
$(".verify_all_item").click(function(event) {
  $(this).text('正在处理，请耐心等待...');
  var $that=$(this);

  $(".work_flow_item").each(function(){
    if ($(this).attr("checked")) {
      selected_item=$(this).attr('data-key');
    };
  });
  $that.attr("data-lastkey",selected_item);

  $(".work_flow_item").each(function(){
    if ($(this).attr("checked")) {
      var wv_wf_sn=$(this).attr('data-wfsn');
      var wv_comment='';
      var mail_title=$(this).attr('data-mailtitle');
      var kaoqin_time=$(this).attr('data-kaoqintime');
      if (kaoqin_time=='') {
        var data={"wv_wf_sn":wv_wf_sn,"wv_comment":wv_comment,"mail_title":mail_title};
      }else{
        var data={"wv_wf_sn":wv_wf_sn,"wv_comment":wv_comment,"mail_title":mail_title,"kaoqin_time":kaoqin_time};
      }
      var wv_status=$that.attr('data-status');
      var url="<?php echo site_url('apps/workflow/index/do_verify'); ?>"+'/'+wv_status;
      var $this=$(this);
      $.post(url,data,function(res){
        if ($that.attr("data-lastkey")==$this.attr('data-key')) {
          $that.text('已处理完成');
        };
      });
    };
    
  });
});

</script>