<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 style="margin-right:5px;" type="button" class="btn btn-warning goback" >返回</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>UID</th>
                                                <th>兑换商品</th>
                                                <th>收件人名称</th>
                                                <th>电话</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['uid'];?></td>
                                                        <td><?php echo $mallname[$val['mid']];?></td>
                                                        <td><?php echo $val['name'];?></td>
                                                        <td><?php echo $val['phone'];?></td>
                                                        <td><?php echo $val['address'];?></td>
                                                        <td><?php echo $val['email'];?></td>
                                                        <td><?php echo $val['etime'];?></td>
                                                        <td><?php echo $val['status'] == 0 ? '未发货' : '发货';?></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" data-validate="verify" method="post" action="<?php echo base_url('mall/actionAddCoupon')?>">
            <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="phone_card">名称:</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" placeholder="zh=中文名称(一行一种语言)" rows="5" name="cname"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="phone_card">过期天数:</label>
                        <div class="col-sm-10">
                            <input type="text" name="cexpire" placeholder="过期天数填数字 0为永不过期" class="form-control">
                        </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>

    $('.goback').click(function () {
        window.history.go(-1);
    });

    //验证 名称是否填写
    function verify(){
        var cname = $("textarea[name='cname']");
        if ( $.trim(cname.val()) == '' ){
            cname.focus();
            return '名称为必填参数';
        }
        return true;
    }

    //删除商品
    $('.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>