<link href="<?php echo base_url();?>public/h5/css/bootstrap.min14ed.css" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/font-awesome.min93e3.css" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/plugins/jqgrid/ui.jqgridffe4.css?0820" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/animate.min.css" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/style.min862f.css" rel="stylesheet">
<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/css/jquery.timepicker.min.css">
<style>
    #alertmod_activity_list {
        top: 900px !important;
    }
    #alertmod_schedule_list {
        top: 900px !important;
    }
</style>

<div class="container-fluid" style="background-color: #f3f3f4;">
    <div class="row">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>运营后台/活动配置</h5>
            </div>
            <div class="ibox-content">
                <h3 style="font-weight: bold">活动配置</h3>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-4">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>已排未上线活动</h5>
                </div>
                <div class="ibox-content">
                    <h2 class="no-margins">8个活动 到2020-04-1</h2>
                </div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>正在进行活动</h5>
                </div>
                <div class="ibox-content">
                    <h2 class="no-margins">金蛋 建筑大师 体力加速</h2>
                </div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>本周活动数</h5>
                </div>
                <div class="ibox-content">
                    <h2 class="no-margins">24个活动</h2>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="tabs-container">
                <ul class="nav nav-tabs">
                    <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">活动配置</a>
                    </li>
                    <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">活动排期</a>
                    </li>
                </ul>
                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="panel-body">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title" style="border-top: 0;">
                                    <h3 style="font-weight: bold">活动配置</h3>
                                </div>
                                <div class="ibox-content" id="firstTable" style="padding: 0;">
                                    <div class="jqGrid_wrapper">
                                        <table id="activity_list"></table>
                                        <div id="activity_pager_list"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-2" class="tab-pane">
                        <div class="panel-body">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-outline btn-success" data-toggle="modal" data-target="#myModal5">新建排期</button>
                            </div>
                            <div class="ibox float-e-margins">
                                <div class="ibox-title" style="border-top: 0;">
                                    <h3 style="font-weight: bold">活动排期</h3>
                                </div>
                                <div class="ibox-content" style="padding: 0;">
                                    <div class="jqGrid_wrapper">
                                        <table id="schedule_list"></table>
                                        <div id="schedule_pager_list"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content" style="width: 140%;left: -15%;">
            <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">新建排期</h4>
            </div>
            <div class="modal-body" style="height: 500px;">
                <div class="col-sm-9">
                    <form class="form-horizontal" role="form" method="post"  enctype="multipart/form-data" id="scheduleForm">
                        <div class="form-group">
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">活动类型</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <select class="form-control m-b" name="activityId" style="border-radius: 4px;">
                                    <?php foreach ($list as $k => $v) { ?>
                                        <option value="<?php echo $v['id']?>"><?php echo $v['name']?></option>
                                    <?php }?>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">收集物品</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <select class="form-control m-b" name="collection[collect]" style="border-radius: 4px;">
                                    <?php foreach ($collection[1] as $k => $v) { ?>
                                        <option value="<?php echo $v['path']?>"><?php echo $v['name']?></option>
                                    <?php }?>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">排行榜物品</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <select class="form-control m-b" name="collection[rank]" style="border-radius: 4px;">
                                    <?php foreach ($collection[2] as $k => $v) { ?>
                                        <option value="<?php echo $v['path']?>"><?php echo $v['name']?></option>
                                    <?php }?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">开始时间</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <input type="text" class="form-control datepicker stime" value="<?php echo date("Y-m-d")?>" placeholder="开始时间" name="startDay" />
                            </div>
                            <div class="col-sm-2" style="padding:0 3px">
                                <input type="text" class="form-control datetimepicker stime-hour" value="00:00" maxlength="5" placeholder="开始时间" name="startHour" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">奖励时间</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <input type="text" class="form-control datepicker rtime" value="<?php echo date("Y-m-d")?>" placeholder="奖励时间" name="rewardDay" />
                            </div>
                            <div class="col-sm-2" style="padding:0 3px">
                                <input type="text" class="form-control datetimepicker rtime-hour" value="00:00" maxlength="5" placeholder="奖励时间" name="rewardHour" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">结束时间</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <input type="text" class="form-control datepicker etime" value="<?php echo date("Y-m-d")?>" placeholder="结束时间" name="endDay" />
                            </div>
                            <div class="col-sm-2" style="padding:0 3px">
                                <input type="text" class="form-control datetimepicker etime-hour" value="00:00" maxlength="5" placeholder="结束时间" name="endHour" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label" style="padding: 7px 0;">循环方式</label>
                            <input type="hidden" name="isCycle" value="0" id="cycleTypeInput">
                            <div class="col-sm-4" style="padding:0 7px">
                                <div class="btn-group">
                                    <button class="btn btn-primary cycle" onclick="cycleType(0,this)" type="button">不循环</button>
                                    <button class="btn btn-white cycle" onclick="cycleType(1,this)" type="button">按小时</button>
                                    <button class="btn btn-white cycle" onclick="cycleType(2,this)" type="button">按天数</button>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" id="cycleDiv" style="display: none;">
                            <label class="col-sm-1 control-label" style="padding: 7px 0;" id="cycleLabel1">开启(天数)</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <input type="number" class="form-control" value="1" min="0" name="openNum" />
                            </div>
                            <label class="col-sm-1 control-label" style="padding: 7px 0;" id="cycleLabel2">关闭(天数)</label>
                            <div class="col-sm-2" style="padding:0 7px">
                                <input type="number" class="form-control" value="1" min="0" name="closeNum" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-12 control-label" style="padding: 7px 0;text-align: left">玩家群体选择</label>
                            <div class="col-sm-1"></div>
                            <div class="col-sm-11">
                                <div class="col-sm-3" style="width:18%;">
                                    <input type="checkbox" name="isVipLv" value="1">
                                    按vip等级
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label" style="padding: 7px 0;text-align: left">vip等级</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="1" placeholder="vip等级" name="minVipLv" />
                                    </div>
                                    <label class="col-sm-1 control-label" style="padding: 7px 0;text-align: center">到</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="1" placeholder="vip等级" name="maxVipLv" />
                                    </div>
                                </div>
                                <div class="col-sm-2" style="padding: 7px 0;">
                                    <input type="checkbox" name="isVip" value="1">
                                    是否vip
                                </div>
                            </div>
                            <div class="col-sm-1"></div>
                            <div class="col-sm-11">
                                <div class="col-sm-3" style="width:18%;">
                                    <input type="checkbox" name="isLv" value="1">
                                    按关卡等级
                                </div>
                                <div class="col-sm-6">
                                    <label class="col-sm-3 control-label" style="padding: 7px 0;text-align: left">关卡等级</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="1" placeholder="开始时间" name="minLv" />
                                    </div>
                                    <label class="col-sm-1 control-label" style="padding: 7px 0;text-align: center">到</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" value="1" placeholder="开始时间" name="maxLv" />
                                    </div>
                                </div>
                                <div class="col-sm-2" style="padding: 7px 0;">
                                    <input type="checkbox" name="isVisitor" value="1" id="inlineCheckbox1">
                                    是否游客
                                </div>
                            </div>
                            <div class="col-sm-1"></div>
                            <div class="col-sm-11">
                                <div class="col-sm-3" style="width:18%;">
                                    <input type="checkbox" name="isVersion" value="1" id="inlineCheckbox1">
                                    按客户端版本
                                </div>
                                <div class="col-sm-9">
                                    <label class="col-sm-2 control-label" style="padding: 7px 0;text-align: center">ios最低版本</label>
                                    <div class="col-sm-4">
                                        <select class="form-control m-b" name="minAndroidVersion" style="border-radius: 4px;">
                                            <?php foreach ($versionList['ios'] as $k => $v) { ?>
                                                <option value="<?php echo $v['gu_version']?>"><?php echo $v['gu_version']?></option>
                                            <?php }?>
                                        </select>
                                    </div>
                                    <label class="col-sm-2 control-label" style="padding: 7px 0;text-align: center">安卓最低版本</label>
                                    <div class="col-sm-4">
                                        <select class="form-control m-b" name="minIosVersion" style="border-radius: 4px;">
                                            <?php foreach ($versionList['android'] as $k => $v) { ?>
                                                <option value="<?php echo $v['gu_version']?>"><?php echo $v['gu_version']?></option>
                                            <?php }?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </form>
                </div>
                <div class="col-sm-3">
                    <img src="/images/default_img.png" class="upimg default-img" name="button" alt=""  style="height: 100%;width: 100%;"  />
                    <img src="" class="upimg  uploaded-img hide" alt=""  name="button" id="button" style="height: 90px;width: 90px;" />
                    <input type="file" name="imgfile_button" id="imgfile_button" class="imgfile hide"/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="scheduleSubmit()">保存</button>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo base_url();?>public/h5/js/jquery.min.js"></script>
<script src="<?php echo base_url();?>public/h5/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>public/h5/js/plugins/peity/jquery.peity.min.js"></script>
<script src="<?php echo base_url();?>public/h5/js/plugins/jqgrid/i18n/grid.locale-cnffe4.js?0820"></script>
<script src="<?php echo base_url();?>public/h5/js/plugins/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>
<script src="<?php echo base_url();?>public/h5/js/content.min.js"></script>
<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>
<script src="<?php echo base_url();?>public/js/vendor/timepicker/timepicker.min.js"></script>
<script>
    $(document).ready(function(){
        $('#content').css("padding","0");
        $('#page_footer').css("position","fixed");
        $('#left_panel').css("position","fixed");
        $.jgrid.defaults.styleUI = "Bootstrap";
        var mydata = <? echo $mydata;?>;
        $("#activity_list").jqGrid({
            data: mydata,
            datatype: "local",
            height: 320,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 20,
            rowList: [10, 20, 30],
            colNames: ["活动ID", "活动icon", "活动名称", "状态", "上次更新时间", "上次结束时间", "操作"],
            colModel: [{
                name: "id",
                index: "id",
                editable: true,
                width: 40,
                sorttype: "int",
                search: true,
            }, {
                name: "icon",
                index: "icon",
                editable: true,
                width: 60,
                sortable: false
            }, {
                name: "name",
                index: "name",
                editable: true,
                width: 100,
                align: "center",
            }, {
                name: "status",
                index: "status",
                editable: true,
                width: 80,
                align: "center",
            }, {
                name: "lastUpdateTime",
                index: "lastUpdateTime",
                editable: true,
                width: 90,
                align: "center",
                sorttype: "date",
                formatter: function (cellValue, options, rowObject) {
                    return cellValue;
                }
            },{
                name: "lastEndTime",
                index: "lastEndTime",
                editable: true,
                width: 90,
                align: "center",
                sorttype: "date",
                formatter: function (cellValue, options, rowObject) {
                    return cellValue;
                }
            },{
                name: "action",
                index: "action",
                editable: true,
                width: 100,
                align: "center",
                sortable: false
            }],
            pager: "#activity_pager_list",
            viewrecords: true,
            caption: "",
            add: true,
            edit: true,
            addtext: "Add",
            edittext: "Edit",
            hidegrid: false
        });
        $("#activity_list").jqGrid("navGrid", "#activity_pager_list", {
            edit: false,
            add: false,
            del: false,
            search: true
        }, {
            height: 200,
            reloadAfterSubmit: true
        });

        var width = $("#firstTable").width();
        $("#schedule_list").jqGrid({
            data: mydata,
            datatype: "local",
            height: 320,
            width: width,
            shrinkToFit: true,
            rowNum: 20,
            rowList: [10, 20, 30],
            colNames: ["活动ID", "活动icon", "活动名称", "状态", "上次更新时间", "上次结束时间", "操作"],
            colModel: [{
                name: "id",
                index: "id",
                editable: true,
                width: 60,
                sorttype: "int",
                search: true,
            }, {
                name: "icon",
                index: "icon",
                editable: true,
                width: 60,
                sortable: false
            }, {
                name: "name",
                index: "name",
                editable: true,
                width: 100
            }, {
                name: "status",
                index: "status",
                editable: true,
                width: 80,
                align: "center",
            }, {
                name: "lastUpdateTime",
                index: "lastUpdateTime",
                editable: true,
                width: 90,
                sorttype: "date",
                formatter: function (cellValue, options, rowObject) {
                    return cellValue;
                }
            },{
                name: "lastEndTime",
                index: "lastEndTime",
                editable: true,
                width: 90,
                sorttype: "date",
                formatter: function (cellValue, options, rowObject) {
                    return cellValue;
                }
            },{
                name: "action",
                index: "action",
                editable: true,
                width: 100,
                sortable: false
            }],
            pager: "#schedule_pager_list",
            viewrecords: true,
            caption: "",
            add: true,
            edit: true,
            addtext: "Add",
            edittext: "Edit",
            hidegrid: false
        });
        $("#schedule_list").jqGrid("navGrid", "#schedule_pager_list", {
            edit: false,
            add: false,
            del: false,
            search: true
        }, {
            height: 200,
            reloadAfterSubmit: true
        });
    });
    $('.stime,.etime,.rtime').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
    //选择时间段
    $('.datetimepicker').timepicker({
        timeFormat:'HH:mm'
    });
    function cycleType(type,obj) {
        if(type){
            let str1 = "";
            let str2 = "";
            if(type == 1){
                str1 = "开启(小时)";
                str2 = "关闭(小时)"
            }else if(type == 2){
                str1 = "开启(天)";
                str2 = "关闭(天)"
            }
            $('#cycleLabel1').html(str1);
            $('#cycleLabel2').html(str2);
            $('#cycleDiv').show();
            $('#cycleTypeInput').val(type);
            $('.cycle').attr("class","btn btn-white cycle");
            $(obj).attr("class","btn btn-primary cycle");

        }else{
            $('#cycleDiv').hide();
        }
    }

    function scheduleSubmit() {
        var data = new FormData(document.getElementById("scheduleForm"));
        $.ajax({
            url: rootPath + 'activity/actionSchedule',
            type: 'POST',
            data: data,
            dataType: 'json',
            contentType: false, //必须
            processData: false, //必须
            success: function (data) {
                if (data.ret != 0) {//新增失败
                    msgTip.messager().error(data.msg);
                } else {
                    location.reload();
                }
            },
            error: function (msg) {
                msgTip.messager().error('网络错误，请刷新后重试');
            }
        });
    }

</script>