<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css">
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
<!--                                    <button class="btn btn-primary" onclick="addMsg">添加</button>-->
                                    <button type="button" class="btn btn-primary addMsg" data-toggle="modal" data-target="#addMsg">添加</button>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <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="table-responsive">
                                        <table class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>消息模板id</th>
                                                <th>接收者</th>
                                                <th>奖励内容</th>
                                                <th>发放时间</th>
                                                <th>操作者</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if(is_array($list) && !empty($list)){
                                                foreach ($list as $key => $val) {
                                                    ?>
                                                    <tr>
                                                        <td><?=$val['id'];?></td>
                                                        <td><?=$val['mid'];?></td>
                                                        <td><?=$val['uids'];?></td>
                                                        <td class="rewardShow" data-value='<?=$val["rewards"]?>'></td>
                                                        <td><?=date('Y-m-d H:i:s', $val['creat_ts']);?></td>
                                                        <td><?=$val['optuser']?></td>
                                                    </tr>
                                                <?php }} else{?>
                                                <tr>
                                                    <td colspan="20">暂无数据</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 class="modal fade" id="addMsg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    </div>
                    <form class="form-horizontal J_ajaxForm" role="form" method="post" action="Customer/sendGameMailReward" data-callBack="updateother" id="mForm">
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">消息模板id:</label>
                                <div class="col-sm-9">
                                    <input type="text" value="" class="form-control modal_money" name="mid">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">接收者uid(以英文“,”隔开):</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" name="uids" required value="0">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">设置奖励:</label>
                                <input type="hidden" name="rewards">
                                <div class="col-sm-9">
                                    <table class="col-sm-12">
                                        <tr>
                                            <td class="formPropsRewardsTag" data-value="[]"></td>
                                            <td class="text-right">
                                                <button type="button"
                                                        class="btn btn-outline btn-success"
                                                        onclick="propsJs.initEdit(this, 'formPropsRewardsTag')">
                                                    奖励配置
                                                </button>
                                            </td>
                                        </tr>
                                    </table>
                                </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" id="subAdd">提交</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    <div>



    </div>
</div>
<script src="<?php echo base_url(); ?>public/js/common.js"></script>
<script>
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
</script>
<script>

    propsJs.initTag('formPropsRewardsTag')
    propsJs.initTag('rewardShow')
    $("#subAdd").click(function (){
        var data = $('#mForm').toObject()
        data["rewards"] = $(".formPropsRewardsTag").data("value")
        // console.log(data)
        $.ajax({
            url: rootPath + 'Customer/sendGameMailReward',
            type: 'POST',
            data: data,
            dataType: 'json',
            success: function (data2) {

                console.log('----------',data2)
                alert(data2.msg);
                // confirm(data.msg);
                window.location.reload();
            },
            error: function (data2) {
                console.log(data2)
                alert(data2.msg);
            }
        });

    })
</script>
<script src="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
