<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;">
                                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#actionCode">新增推送</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>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php foreach($list as $v) { ?>
                                            <tr>
                                                <td><?php echo $v['id'];?></td>
                                                <td>
                                                    <textarea readonly="readonly" class="form-control" rows="5"><?php echo $v['pn_title'];?></textarea>
                                                </td>
                                                <td>
                                                    <textarea readonly="readonly" class="form-control" rows="5"><?php echo $v['pn_content'];?></textarea>
                                                </td>
                                                <td><?php echo $v['pn_player']?></td>
                                                <td><?php echo date('Y-m-d H:i:s', $v['pn_time']);?></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="push/actionAddNews">
                <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="2" checked="checked"> 少数(填UID)
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="usertype" value="1"> 全服
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="usertype" value="3" > 按语言
                            </label>
                        </div>
                    </div>
                    <div class="alert alert-danger alertmsg hide" role="alert">全服推送有延迟6分钟</div>
                    <div class="form-group hide devicetype">
                        <label class="col-sm-3 control-label">设备:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                              <input type="radio" name="devicetype" value="1" checked="checked"> 安卓
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="devicetype" value="2"> 苹果
                            </label>
                        </div>
                    </div>
                    <div class="form-group hide accounttype">
                        <label class="col-sm-3 control-label">账号类型:</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
                              <input type="radio" name="accounttype" value="1" checked="checked"> 游客
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="accounttype" value="0"> FB
                            </label>
                        </div>
                    </div>

                    <div class="form-group hide langtype">
                        <label class="col-sm-3 control-label">语言:</label>
                        <div class="col-sm-9">

                            <?php foreach ($langList as $langKey => $langName) {?>
                                <label class="radio-inline">
                                    <input type="radio" name="lang" value="<?php echo $langKey;?>" <?php if($langKey == 'en'){ echo 'checked';} ?> > <?php echo $langName;?>
                                </label>
                            <?php }?>
                        </div>

                        <br/> <br/>
                            <label class="col-sm-3 control-label" style="line-height: 7px;">包:</label>
                            <div class="an-checkbox-div col-sm-9 android-package">
                                <label>
                                    <input type="checkbox" id="android-checkall"> 【全选】
                                </label>
                                <?php foreach ($androidPackageList as $k => $v) { ?>
                                    <label style="font-weight: normal;">
                                        <input type="checkbox" class="android-check" name="package[]" value="<?php echo $k;?>"> <?php echo '安卓'.$v;?>
                                    </label>
                                <?php }?>
                                <br/>
                                <br/>

                                <?php foreach ($iosPackageList as $k => $v) { ?>
                                    <label style="font-weight: normal;">
                                        <input type="checkbox" class="android-check" name="package[]" value="<?php echo $k;?>"> <?php echo '苹果'.$v;?>
                                    </label>
                                <?php }?>
                            </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_title"></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>

<script type="text/javascript">
    $("input[name='usertype']").click(function(){
        var usertype = $(this).val(),
            langType = $(".langtype");
        if( usertype == 1 ){//按全服
            $(".uiddiv").addClass('hide');
            $(".devicetype").removeClass('hide');
            $(".accounttype").removeClass('hide');
            $(".alertmsg").removeClass('hide');
            langType.addClass('hide');
        }else if(usertype == 3) {//按语言
            $(".uiddiv").addClass('hide');
            $(".devicetype").addClass('hide');
            $(".accounttype").addClass('hide');
            $(".alertmsg").addClass('hide');
            langType.removeClass('hide');
        }else{//按uid
            $(".uiddiv").removeClass('hide');
            $(".devicetype").addClass('hide');
            $(".accounttype").addClass('hide');
            $(".alertmsg").addClass('hide');
            langType.addClass('hide');
        }
    });

    //全选/全不选
    $('#android-checkall').change(function () {
        if($(this).is(':checked')) {//已经是全选的状态
            $('.android-check').prop('checked', true);
        }else {
            $('.android-check').prop('checked', false);
        }
    });
</script>