<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/smalot_bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
<script src="<?php echo base_url();?>public/js/vendor/smalot_bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/smalot_bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<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 style="margin-bottom:20px;">
                                        <button style="margin: 10px;" type="button" class="btn btn-success" data-toggle="modal" data-target="#actionCode">新增消息</button>

                                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#actionCode2">新增公告</button>

                                    </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 foreach($list as $v) { ?>
                                            <tr>
                                                <td><?php echo $v['id'];?></td>
                                                <td><?php echo $v['sn_type'] == 1 ? '消息' : '公告';?></td>
                                                <td>
                                                    <textarea readonly="readonly" class="form-control" rows="5"><?php echo $v['sn_content'];?></textarea>
                                                </td>
                                                <td><?php echo $v['sn_player']?></td>
                                                <td><?php echo date('Y-m-d H:i:s', $v['sn_stime']);?></td>
                                                <td><?php echo $v['sn_notice_stime'] ? date('Y-m-d H:i:s', $v['sn_notice_stime']) : '无';?></td>
                                                <td><?php echo $v['sn_notice_etime'] ? date('Y-m-d H:i:s', $v['sn_notice_etime']) : '无';?></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>

<div class="modal fade" id="actionCode" 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>
                <h4 class="modal-title" id="myModalLabel">新建消息</h4>
            </div>
            <form class="form-horizontal J_ajaxForm" role="form" method="post" action="user/actionAddNews">
                <div class="alert alert-danger" role="alert">如果是给全服玩家发送消息, 提交后, 每隔10分钟开始运行</div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">玩家类型:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                              <input type="radio" name="usertype" value="1"> 全服
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="usertype" value="2" checked="checked"> 少数(填UID)
                            </label>
                        </div>
                    </div>
                    <div class="form-group uiddiv">
                        <label class="col-sm-3 control-label">UID列表:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="UID(一行一个UID)" name="uidlist"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">消息内容:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="消息内容" name="news_content"></textarea>
                        </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>

<div class="modal fade" id="actionCode2" 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>
                <h4 class="modal-title" id="myModalLabel">新建公告</h4>
            </div>
            <form class="form-horizontal J_ajaxForm" role="form" method="post" action="user/actionAddNotice">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">开始时间</label>
                        <div class="col-sm-9">
                            <input type="text" class="col-sm-9 form-control datetimepicker" placeholder="公告开始时间" name="notice_stime" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">结束时间</label>
                        <div class="col-sm-9">
                            <input type="text" class="col-sm-9 form-control datetimepicker" placeholder="公告结束时间" name="notice_etime" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">公告内容:</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="5" placeholder="公告内容" name="notice_content"></textarea>
                        </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>

<script type="text/javascript">
    $("input[name='usertype']").click(function(){
        var usertype = $(this).val();
        if( usertype == 2 ){
            $(".uiddiv").removeClass('hide'); 
        }else{
            $(".uiddiv").addClass('hide');
        }
    });

    //选择日期
    $('.datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd hh:ii:ss',
        locale: 'zh-cn'
    });
</script>