<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>链接列表</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="btn-group" style="margin-bottom:20px;">
                                        <a class="btn btn-primary" href="<?php echo base_url('#config/editShareLink')?>" role="button">添加链接</a>
                                    </div>
                                    <div class="table-responsive">
                                        <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>名称</th>
                                                <th>链接</th>
                                                <th>短链</th>
                                                <th>成功人数</th>
                                                <th>失效时间</th>
                                                <th>编辑</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if($list){
                                                foreach ($list as $val) {
                                                    ?>
                                                    <tr>
                                                        <td><?php echo $val['id'];?></td>
                                                        <td><?php echo $val['name'];?></td>
                                                        <td><textarea readonly="readonly" class="form-control show" rows="5"><?php echo $val['longUrl'];?></textarea></td>
                                                        <td><textarea readonly="readonly" class="form-control show" rows="5"><?php echo $val['shortUrl'];?></textarea></td>
                                                        <td><?php echo $val['success'];?></td>
                                                        <td>
                                                            <?php echo date('Y-m-d H:i:s',$val['expireTime']);?>
                                                            <button type="button" class="btn btn-<?=$val['expireTime']>$time?'success':'danger'?>"><?=$val['expireTime']>$time?'生效中':'已过期'?></button>
                                                        </td>
                                                        <td>
                                                            <a href="<?php echo base_url('#config/editShareLink/'.$val['id'])?>" class="btn btn-primary" role="button">详情</a>
                                                            <button pid="<?php echo $val['id'];?>" class="btn btn-danger delp">删除</button>
                                                        </td>
                                                    </tr>
                                                    <?php
                                                }}
                                            ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <nav>
                                        <ul class="pagination">
                                            <li class="disabled"><a href="#">共<?php echo count($list);?>条</a></li>
                                            <!--                                            <li class="disabled"><a href="#"><i class="fa fa-angle-left"></i></a></li>-->
                                            <!--                                            <li class="active"><a href="#">1</a></li>-->
                                            <!--                                            <li><a href="#">2</a></li>-->
                                            <!--                                            <li><a href="#"><i class="fa fa-angle-right"></i></a></li>-->
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    $('.delp').click(function(){
        if(confirm('确定删除该用户吗?')){
            var id = $(this).attr('pid');
            $.post(
                "<?php echo base_url('config/delShareLink')?>",
                {id:id},
                function(){
                    alert('删除成功');
                    window.location.reload();
                }
            );
        }
    });
</script>