<div class="row-fluid">
  <div class="span2">
    <ul class="nav nav-tabs nav-stacked" style="min-height:800px;background:#f5f5f5;">
      <legend style="border:none;">订单邮件发送管理</legend>
      <li class="<?php if($nav_status=='index') echo 'active'; ?>"><a style="border-right: none;" href="<?php echo site_url('sendmail/index');?>">待发送邮件</a></li>
      <li class="<?php if($nav_status=='sent_mail') echo 'active'; ?>"><a style="border-right: none;" href="<?php echo site_url('sendmail/index/1');?>">已发送邮件</a></li>
      <li class="<?php if($nav_status=='loglist') echo 'active'; ?>"><a style="border-right: none;" href="<?php echo site_url('sendmail/log_list');?>">投递失败邮件</a></li>
      <li><a style="border-right: none;" href="<?php echo site_url('sendmail/send_mail');?>" target="_blank">触发邮件发送</a></li>
      <legend style="border:none;margin-top:30px;">HT邮件发送管理</legend>
      <li class="<?php if($nav_status=='failed_nav') echo 'active'; ?>"><a style="border-right: none;" href="<?php echo site_url('sendmail/ht_failed_mail/0');?>">投递失败邮件</a></li>
      <li class="<?php if($nav_status=='unsend_nav') echo 'active'; ?>"><a style="border-right: none;" href="<?php echo site_url('sendmail/ht_failed_mail/2');?>">待发送邮件</a></li>
      <li class="<?php if($nav_status=='success_nav') echo 'active'; ?>"><a style="border-right: none;" href="<?php echo site_url('sendmail/ht_failed_mail/1');?>">已发送邮件</a></li>
      <li><a style="border-right: none;" href="<?php echo site_url('sendmail/is_ht_mail_running');?>" target="_blank">发送程序状态</a></li>
    </ul>
  </div>
  <div class="span10">
    <table class="table table-striped">
  <thead>
    <tr>
      <th>时间</th>
      <th>发件人</th>
      <th>收件人</th>
      <th>标题</th>
      <th>内容</th>
      <?php if($status!=0){ ?>
      <th>设置</th>
      <?php } ?>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($maillist as $key => $m) { ?>
    <tr>
      <td><?php echo $m->M_AddTime; ?></td>
      <td><?php echo $m->M_ReplyToName.':<br>'.$m->M_ReplyToEmail; ?></td>
      <td><?php echo $m->M_ToName.':<br>'.$m->M_ToEmail; ?></td>
      <td title="<?php echo $m->M_SN; ?>"><?php echo $m->M_Title; ?></td>
      <td><?php $text=get_text_short($m->M_Body,40,'...'); echo $text['content']; ?></td>
      <?php if($status!=0){ ?>
      <td><a class="unsend" href="<?php echo site_url('sendmail/set_unsend').'/'.$m->M_SN; ?>">重新投递</a></td>
      <?php } ?>
    </tr>
    <?php } ?>
  </tbody>
</table>
  </div>
</div>
<script type="text/javascript">
//设置邮件状态，重新投递该邮件
$(".unsend").click(function(event){
  event.preventDefault();
  var $a=$(this);
  var url=$a.attr('href');
  $.post(url,'',function(text){
    $('.modal').modal('hide');
    if (text==1) {
      $a.text('');
      $.modaldialog.success("设置成功,稍后会重新投递该邮件！");
    }else{
      $.modaldialog.error("设置失败，请稍后再试！");
    }
  });
});
</script>
