<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="btn-group" style="margin-bottom:20px;">
                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addphonecard">添加电话卡</button>
                            </div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <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>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if(is_array($list)){
                                                foreach ($list as $key => $val) {
                                                    ?>
                                                    <tr>
                                                        <td><?php echo $val['id'];?></td>
                                                        <td><?php echo $val['th_phone_num'];?></td>
                                                        <td><?php echo $val['th_phone_pwd'];?></td>
                                                        <td><?php echo $val['th_phone_operator'];?></td>
                                                        <td><?php echo $phonecardStatus[$val['th_phone_status']];?></td>
                                                        <td>
                                                            <button type="button" class="del btn btn-danger" data-mid="<?php echo $val['id'];?>">删除</button>
                                                        </td>
                                                    </tr>
                                                <?php } } else{?>
                                                <tr>
                                                    <td colspan="10">暂无数据</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <nav>
                                        <ul class="pagination">
                                            <li class="disabled"><a href="#">共<span class="pagetotal"><?php echo $total;?></span>条</a></li>
                                            <?php echo $pageurl;?>
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>


<!-- 添加电话卡 Modal Start -->
<div class="modal fade" id="addphonecard" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">添加电话卡</h4>
            </div>
            <form class="form-horizontal" method="post" action="<?php echo base_url('mall/actionaddphonecard')?>">
            <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="phone_card">卡号:</label>
                        <div class="col-sm-10">
                            <input type="text" name="phone_card" class="form-control" id="phone_card" placeholder="20个以内卡号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="phone_pwd">密码:</label>
                        <div class="col-sm-10">
                            <input type="text" name="phone_pwd" class="form-control" id="phone_pwd" placeholder="20个以内密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="operator">运营商:</label>
                        <div class="col-sm-10">
                            <input type="text" name="phone_operator" class="form-control" id="operator" placeholder="运营商">
                        </div>
                    </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary J_ajaxSubmitBtn">添加</button>
            </div>
            </form>
        </div>
    </div>
</div>
<!-- 添加电话卡 Modal End -->

<script>

    //删除商品
    $('.del').click(function(){
        if( confirm('确认删除吗?') ){
            var mid = $(this).attr('data-mid');
            $.ajax({
                type: "POST",
                url : 'mall/actionDelphonecard',
                dataType: "json",
                data: "mid="+mid,
                success:function(e){
                    if(e.num >= 1){
                        alert('删除成功');
                        location.reload();
                    }else{
                        alert('删除失败');
                    }
                }
            });
        }
    });
</script>