<?php
if(!$excel)
{
    ?>
    <script language="JavaScript">
      $().ready(function(e) {
        $(".time-picker").hunterTimePicker();
    });
      function v_check(id,tel,state,s_type)
      {
        //type 1,审核
        //支付相关，退款或确认支付
        if(s_type=='1')
        {
            URL = "index.php?c=ajax&action=race_reg_member_check&type=1&id=" + id+"&tel="+tel+"&state="+state;
        }

        if(s_type=='2')
        {
            URL = "index.php?c=ajax&action=race_reg_member_check&type=2&race_id=<?php echo $_GET['race_id']?>&id=" + id+"&tel="+tel+"&state="+state;
            alert(URL);
            return false;
        }

        $.get(URL, function (result) {
            if (result == '0') {
                if(state =='5')
                {
                    $("#check" + id).html("审核不通过");
                }
                else
                {

                    $("#check" + id).html("审核成功");
                }
            }
        })
    }
    
    function finish_time_update(id,value)
    {
    	url="index.php?c=ajax&action=finish_time_update&member_id="+id+"&finish_time="+value;
    	$.get(url, function (result) {
            if (result == '1') 
            {
            	alert("更新成功");
            }
        })
    }

    function menu_display(id)
    {
        $(".d_menu").css('visibility','hidden');
        $("#menu_"+id).css('visibility','visible');
    }
</script>

<div class="col-lg-12">
    <section class="panel">
        <div ><a href="index.php?c=race&action=race_reg_member_list&race_id=<?php echo $race_id?>&excel=1"  target="_blank" class="label label-primary">导出excel</a>
  <form action="?c=race&action=race_reg_member_list&race_id=<?php echo $race_id?>" method="post" style="float:right">
            筛选：
          <select name='state'>
            <!-- 1未审核 4 已付费未审核 2审核未付费 3审核已付费  5审核不通过-->
            <option value="">全部</option>
            <option value = 1 <?php if($state == 1) {echo "selected"; }?> >
                未审核
            </option>
            <option value = 2 <?php if($state == 2) {echo "selected"; }?>>
                已审核未付款
            </option>
            <option value = 3 <?php if($state == 3) {echo "selected"; }?>>
                报名成功
            </option>
            <option value = 4 <?php if($state == 4) {echo "selected"; }?>>
                已付款未审核
            </option>
            <option value = 5 <?php if($state == 5) {echo "selected"; }?>>
                审核不通过
            </option>
        </select>
        <input type="text" name="idcard" placeholder="请输入证件信息">
        <input type="submit" value="搜索" class="btn btn-default btn-sm"/>
    </form>
        </div>

    </section>
    
</div>
<div class="row">
    <div class="col-lg-12">
       <section class="panel">
        <?php
    }
    ?>
    <table class="table table-striped table-advance table-hover">
        <tr>
            <th width=100>状态</th>
            <th>操作</th>
            <th>编号</th>
            <th>组别</th>
            <th>团队</th>
            <th>姓名</th>
            <th>完赛信息</th>
            <th>证件类型</th>
            <th>证件号码</th>
            <th>性别</th>
            <th>出生日期	</th>
            <th>手机号码</th>
            <th>联系邮箱</th>
            <th>联系地址</th>
            <?php echo $race->get_race_reg_member_list_title($race_id);?>
        </tr>
        <?php
        if ($result) {
            foreach ($result as $row) {
                ?>
                <tr>
                    <td><?php
               // echo $row['state'];
                    if(!$excel)
                    {
                        if($row['state']==1)
                        {
                            ?>
                            未付审
                            <?php
                        }
                        elseif($row['state']==2)
                        {
                            ?>
                            未付已审
                            <?php
                        }
                        elseif($row['state']==3)
                        {
                            ?>
                            <font style="color:#09e47f">成功</font>
                            <?php
                        }
                        elseif($row['state']==4)
                        {
                         ?>
                         <font style="color:#09e47f">审核中</font>
                         <?php
                     }elseif($row['state']==5)
                     {
                         ?>
                         <font style="color:#09e47f">审核不通过</font>
                         <?php
                     }
                 }
                 ?>

             </td>
             <td>
                <?php 
                if(!$excel)
                {?>
               <div style="position: relative;">
                <a href="javascript:void(0)" onclick="menu_display('<?php echo $row['id']?>')">
                    <i class="fa fa-pencil"></i>
                </a>
                <div id="menu_<?php echo $row['id']?>" class="d_menu" >
                    <?php if($row['state']==4 || $row['state']==1)
                    {
                        ?>
                        <div id ="check<?php echo $row['id']?>">
                            <?php 
                            if($row['state']==4)
                            {
                                $state_s = 3;
                            }
                            elseif($row['state']== 1)
                            {
                                $state_s = 2;
                            }?>
                            <a href="#" onclick="v_check('<?php echo $row['id']?>','<?php echo $row['tel']?>','<?php echo $state_s?>',1)"  >审核通过</a>
                            <br/>
                            <a href="#" onclick="v_check('<?php echo $row['id']?>','<?php echo $row['tel']?>','5',1)"  >审核不通过</a>
                        </div> 
                        <?php
                    }
                    ?>
                    <a href="<?php echo $row['cert_img']?>" target="_blank">审核证书</a><br/>
                    <a href="index.php?c=race&action=race_cert_msg&regid=<?php echo $row['id']?>">完赛证书</a><br/>
                    <?php 
if($row['state']==2){
    ?>
    确认收款<br/>
    <?php
}
elseif($row['state']==3)
{
    ?>
    <a href="JavaScript:void(0)" onclick="v_check('<?php echo $row['id']?>','<?php echo $row['tel']?>','6',2)">确认退款</a><br/>
    <?php
}
                    ?>
                    <a href="javascript:if(confirm('确实要删除吗?数据将不可恢复，请慎重操作！'))location='index.php?c=race&action=race_reg_del&id=<?php echo $row['id']?>&race_id=<?php echo $race_id?>&group_id=<?php echo $row['group_id']?>'" >删除</a>
                </div>
            </div>
            <?php }?>
        </td>
        <td><?php echo $row['id']?></td>
        <td><?php echo $race->get_group_name($row['group_id'])?></td>
        <td><?php echo $race->team_name($row['team_id'])?></td>
        <td><?php echo $row['realname']?></td>
        <td><input type="text" size="5" value="<?php echo $row['finish_time']?>" id="finish_time_<?php echo $row['id']?>"  class="time-picker"><a herf="#" onclick="finish_time_update('<?php echo $row['id']?>',document.getElementById('finish_time_'+<?php echo $row['id']?>).value)" class="label label-primary">更新</a>
        </td>
        <td><?php echo $race->idcard_type($row['idcard_type'])?></td>
        <td style="vnd.ms-excel.numberformat:@">&nbsp;<?php echo $row['idcard']?>&nbsp;</td>
        <td><?php echo $race->sex($row['sex'])?></td>
        <td><?php echo $row['born']?>	</td>
        <td style="vnd.ms-excel.numberformat:@"><?php echo $row['tel']?></td>
        <td><?php echo $row['email']?></td>
        <td><?php echo $row['address']?></td>
        <?php echo $race->get_race_reg_member_list($race_id,$row['id'])?>
    </tr>
    <?php
}
} else {
    ?>
    <tr>
        <td>nothing</td>
    </tr>
    <?php
}
?>
</table>
</section>
</div>
</div>
总数(<?php echo  count($result);?>) 
<style type="text/css">
.d_menu {
    position: absolute;top: 0px;left: 20px;width: 100px; background-color: white; padding: 5px;border:1px solid #999999; visibility: hidden;line-height: 23px;
}
.table tr th{white-space: nowrap;}
.table tr td{white-space: nowrap;}
.table tr td input{border:1px #f0f0f0 solid;}
</style>
