<div style="width:90%;margin:30px auto;">
  <div class="panel panel-primary">
      <div class="panel-heading">
        <h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/tuniu_train/ht_order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/export');?>">导出交易记录>></a> <span style="margin-left:200px;">途牛抢票测试版</span></h3>
      </div>
      <div class="panel-body">
       <form style="width: 300px;float: left;" action="" method="post">
        <input type="text" name="ht_order" value="<?php echo isset($cols_id)?$cols_id:""; ?>">
        <button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 获取信息</button>  
       </form>
       <p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">外联：<span><?php if(!empty($wl)){echo $wl[0]->OPI_Name;}?></span></p>
      </div>
    </div>
    <div class="panel panel-primary">
      <div class="panel-heading">
        <h3 class="panel-title">火车订单信息</h3>
      </div>
    <div class="panel-body">
      <?php if(!empty($info)):?>
      <?php $num=1; foreach($info as $v):?>
          <table class="table table-bordered table-hover"  style="text-align:center;">
        <thead>
          <tr>
            <th style="text-align:center;">序号</th>
            <th style="text-align:center;">车次</th>
            <th style="text-align:center;">座位</th>
            <th style="text-align:center;">出发城市</th>
            <th style="text-align:center;">抵达城市</th>
            <th style="text-align:center;">发车日期</th>
            <th style="text-align:center;">发车时间</th>
            <th style="text-align:center;">抵达时间</th>
            <th style="text-align:center;">票价</th>
            <th style="text-align:center;">是否提交过</th>
          </tr>
        </thead>
        <tbody>
        
          <tr>
            <td><?php echo $num++;?></td>
            <td><?php echo $v->train[0]->FlightsNo;?></td>
            <td><?php echo $v->train[0]->Cabin;?></td>
            <td><?php echo $v->train[0]->DepartureCity;?></td>
            <td><?php echo $v->train[0]->ArrivalCity;?></td>
            <td><?php echo $v->train[0]->DepartureDate;?></td>
            <td><?php echo $v->train[0]->DepartureTime;?></td>
            <td><?php echo $v->train[0]->ArrivalTime;?></td>
            <td><?php echo $v->train[0]->adultcost;?></td>
            <td><?php echo !empty($v->status)?"否":"<span style='color:green;'>是</span>";?></td>
          </tr>
          <tr>
            <td colspan="11">
              <table class="table table-condensed table-bordered">
                <thead>
                  <tr>
                    <th style="text-align:center;"><input  class="check_people" type="checkbox" /></th>
                    <th style="text-align:center;">序号</th>
                    <th style="text-align:center;">姓名</th>
                    <th style="text-align:center;">护照</th>
                    <th style="text-align:center;">年龄类型</th>
                  </tr>
                </thead>
                <tbody>
                  <?php foreach($v->people as $key=>$p): ?>
                  <tr>
                    <td><input name="" type="checkbox" value="<?php echo $p->BPE_SN;?>" /></td>
                    <td><?php echo $key+1;?></td>
                    <td class="people_name"><?php echo $p->BPE_FirstName." ".$p->BPE_MiddleName." ".$p->BPE_LastName;?></td>
                    <td><?php echo $p->BPE_Passport;?></td>
                    <td><?php echo $p->BPE_GuestType==1?"成人":($p->BPE_GuestType==2?"儿童":"婴儿");?></td>
                  </tr>
                  <?php endforeach;?>
                  <tr style="text-align:;">
                    <td>
                      <button type="button" class="btn btn-success checked_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">抢票</button>
                    </td>
                    <td colspan="4"  class="biaoqian"><span class="back_mes" style="color:red;line-height: 30px;"></span>
                    </td>
                  </tr>
                  <tr id="back_<?php echo $v->train[0]->FOI_COLD_SN;?>" style="display:none;">
                    <td colspan="5">
                      快捷订票处理结果：<span style="color:red;"></span>
                    </td>
                  </tr>
                </tbody>
              </table>
              
            </td>
          </tr>
          

        </tbody>
      </table>
    <?php endforeach;endif;?> 
    </div>
    </div>
</div>
 
<script>
  $(".check_people").click(function(){
      if($(this).is(":checked")){
        $(this).parent().parent().parent().parent().find("input[type=checkbox]").attr("checked","checked");
      }else{
        $(this).parent().parent().parent().parent().find("input[type=checkbox]").removeAttr("checked");
      }
  });
  $(".checked_pay").click(function(){
    var url2="<?php echo site_url('apps/train/tuniu_train/grabTicketBook?').'order=';?>";
    var checkbox=$(this).parent().parent().parent().find(":checked");
    var people_sn="";
    checkbox.each(function(i){
      people_sn+=","+$(this).val();
    });
    people_sn=people_sn.substring(1);
    var coli_id = $('input[name="ht_order"]').val();
    url2+=$(this).attr("data-order")+"&people="+people_sn+"&coli_id="+coli_id;

    var THIS=$(this);
    THIS.parent().parent().find(".back_mes").html(" ");//清空提示
    $.ajax({
        url:url2,
        beforeSend:function(data){
          //THIS.html("处理中...");
          //THIS.attr("disabled","disabled")
        },
        success:function(data){
          //THIS.removeAttr("disabled");
          //THIS.html("订票");
          //THIS.parent().parent().find(".back_mes").html(data.mes);
              
          },
        dataType: "json", 
        
    });
        
    return false;
  });
</script>