<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改活动</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/bootstrap/bootstrap.min.css" >
    <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">
    <!-- Select2 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">

    <style type="text/css">
        .thumbnail {
            margin:10px;
        }

        .lang-name {
            margin-left:42px;
        }

        .upimg {
            cursor: pointer;
        }

    </style>
</head>
<body>
<div id="msg-tip">

</div>
<div class="content_wrapper">
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="goodForm" action="#" style="margin-top: 20px">
                <input type="hidden" value="<?php echo $id;?>" name="id"/>
                <header><i class="fa fa-fw fa-file"></i>分组配置</header>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success" id="submitBtn">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid" style="margin-top: 2rem">
                        <div class="form-group" >
                            <label class="col-sm-1 control-label">名称*: </label>
                            <div class="col-sm-2">
                                <input type="text" class="form-control" name="name" value="<?php echo $info['name'];?>">
                            </div>
                            <label class="col-sm-1 control-label">广告概率*: </label>
                            <div class="col-sm-1">
                                <input type="text" class="form-control"  name="adPro" value="<?php echo $info['adPro'];?>">
                            </div>
                            <label class="col-sm-1 control-label">广告总次数*: </label>
                            <div class="col-sm-1">
                                <input type="text" class="form-control"  name="adTotal" value="<?php echo $info['adTotal'];?>">
                            </div>
                        </div>
                    </div>
                </section>
            </form>
        </aside>
    </div>
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="configForm" action="#" style="margin-top: 20px">
                <input type="hidden" value="<?php echo $id;?>" name="id"/>
                <header><i class="fa fa-fw fa-file"></i>分组条件配置</header>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success" id="configsubmitBtn">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-12">
                                <label class="col-sm-1 control-label">平台*: </label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="platform">
                                        <option value="0" <?php if($condition['platform'] == 0){ echo 'selected';}?>>全选</option>
                                        <option value="1" <?php if($condition['platform'] == 1){ echo 'selected';}?>>安卓</option>
                                        <option value="2" <?php if($condition['platform'] == 2){ echo 'selected';}?>>IOS</option>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">设备*: </label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="userType">
                                        <option value="0" <?php if($condition['userType'] == 0){ echo 'selected';}?>>全选</option>
                                        <option value="1" <?php if($condition['userType'] == 1){ echo 'selected';}?>>FB</option>
                                        <option value="2" <?php if($condition['userType'] == 2){ echo 'selected';}?>>游客</option>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">VIP*: </label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="vip">
                                        <option value="0" <?php if($condition['vip'] == 0){ echo 'selected';}?>>全选</option>
                                        <option value="1" <?php if($condition['vip'] == 1){ echo 'selected';}?>>非VIP</option>
                                        <option value="2" <?php if($condition['vip'] == 2){ echo 'selected';}?>>VIP</option>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">首冲*: </label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="firstPay">
                                        <option value="0" <?php if($condition['firstPay'] == 0){ echo 'selected';}?>>全选</option>
                                        <option value="1" <?php if($condition['firstPay'] == 1){ echo 'selected';}?>>非首冲</option>
                                        <option value="2" <?php if($condition['firstPay'] == 2){ echo 'selected';}?>>首冲</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">VIP积分*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="point">
                                            <option value="0" <?php if($condition['point'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['point'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['point'] == 0){ echo 'readonly';}?> name="points[]" value="<?php echo intval($condition['point'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['point'] == 0){ echo 'readonly';}?> name="points[]" value="<?php echo intval($condition['point'][1]);?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">等级*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="levelId">
                                            <option value="0" <?php if($condition['levelId'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['levelId'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['levelId'] == 0){ echo 'readonly';}?> name="levelIds[]" value="<?php echo intval($condition['levelId'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['levelId'] == 0){ echo 'readonly';}?> name="levelIds[]" value="<?php echo intval($condition['levelId'][1]);?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">活跃天数(天)*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="active">
                                            <option value="0"  <?php if($condition['active'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['active'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['active'] == 0){ echo 'readonly';}?> name="actives[]" value="<?php echo intval($condition['active'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['active'] == 0){ echo 'readonly';}?>  name="actives[]" value="<?php echo intval($condition['active'][1]);?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">累计游戏时长(分)*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="onlineTime">
                                            <option value="0" <?php if($condition['onlineTime'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['onlineTime'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control"  <?php if($condition['onlineTime'] == 0){ echo 'readonly';}?> name="onlineTimes[]" value="<?php echo intval($condition['onlineTime'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control"  <?php if($condition['onlineTime'] == 0){ echo 'readonly';}?>  name="onlineTimes[]" value="<?php echo intval($condition['onlineTime'][1]);?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">注册时长(天)*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="regTime">
                                            <option value="0"  <?php if($condition['regTime'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['regTime'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['regTime'] == 0){ echo 'readonly';}?> name="regTimes[]" value="<?php echo intval($condition['regTime'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['regTime'] == 0){ echo 'readonly';}?>  name="regTimes[]" value="<?php echo intval($condition['regTime'][1]);?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">好友数量*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="friendNum">
                                            <option value="0" <?php if($condition['friendNum'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['friendNum'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['friendNum'] == 0){ echo 'readonly';}?> name="friendNums[]" value="<?php echo intval($condition['friendNum'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['friendNum'] == 0){ echo 'readonly';}?>  name="friendNums[]" value="<?php echo intval($condition['friendNum'][1]);?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">好友排行*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="friendRank">
                                            <option value="0" <?php if($condition['friendRank'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['friendRank'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['friendRank'] == 0){ echo 'readonly';}?> name="friendRanks[]" value="<?php echo intval($condition['friendRank'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control"  <?php if($condition['friendRank'] == 0){ echo 'readonly';}?> name="friendRanks[]" value="<?php echo intval($condition['friendRank'][1]);?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">国家排行*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="countryRank">
                                            <option value="0" <?php if($condition['countryRank'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['countryRank'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['countryRank'] == 0){ echo 'readonly';}?> name="countryRanks[]" value="<?php echo intval($condition['countryRank'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['countryRank'] == 0){ echo 'readonly';}?>  name="countryRanks[]" value="<?php echo intval($condition['countryRank'][1]);?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">世界排行*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" name="worldRank">
                                            <option value="0" <?php if($condition['worldRanks'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['worldRanks'] != 0){ echo 'selected';}?>>区间</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['worldRanks'] == 0){ echo 'readonly';}?> name="worldRanks[]" value="<?php echo intval($condition['worldRanks'][0]);?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" <?php if($condition['worldRanks'] == 0){ echo 'readonly';}?> name="worldRanks[]" value="<?php echo intval($condition['worldRanks'][1]);?>">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">国家分组*: </label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" id="countrySet" name="countrySet">
                                            <option value="0" <?php if($condition['countrySet'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['countrySet'] != 0){ echo 'selected';}?>>限定</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-8">
                                        <div class="checkbox" id="countrySetDiv" <?php if($condition['countrySet'] == 0){ echo 'style="display:none;"';}?>>
                                            <?php foreach ($country as $key => $vl) { ?>
                                                <label class="checkbox-inline"><input type="checkbox" name="countrySetArr[]" <?php if(in_array($key,$condition['countrySet'])){ echo 'checked';}?> value="<?php echo $key;?>"><?php echo $vl;?></label>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin:1rem 0">
                            <div class="col-sm-6">
                                <label class="col-sm-2 control-label">Adjust来源分组:</label>
                                <div class="col-sm-10">
                                    <div class="col-sm-4">
                                        <select class="form-control typeControl" id="adjustGroup" name="adjustGroup">
                                            <option value="0" <?php if($condition['adjustGroup'] == 0){ echo 'selected';}?>>全选</option>
                                            <option value="1" <?php if($condition['adjustGroup'] != 0){ echo 'selected';}?>>限定</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-8">
                                        <div class="checkbox" id="adjustGroupDiv" <?php if($condition['adjustGroup'] == 0){ echo 'style="display:none;"';}?>>
                                            <label class="checkbox-inline"><input type="checkbox" name="adjustGroupArr[]" <?php if(in_array("UAC2.0",$condition['adjustGroup'])){ echo 'checked';}?> value="<?php echo "UAC2.0";?>">UAC2.0用户</label>
                                            <label class="checkbox-inline"><input type="checkbox" name="adjustGroupArr[]" <?php if(in_array("UAC2.5",$condition['adjustGroup'])){ echo 'checked';}?> value="<?php echo "UAC2.5";?>">UAC2.5用户</label>
                                            <label class="checkbox-inline"><input type="checkbox" name="adjustGroupArr[]" <?php if(in_array("AEO",$condition['adjustGroup'])){ echo 'checked';}?> value="<?php echo "AEO";?>">AEO用户</label>
                                            <label class="checkbox-inline"><input type="checkbox" name="adjustGroupArr[]" <?php if(in_array("VO",$condition['adjustGroup'])){ echo 'checked';}?> value="<?php echo "VO";?>">VO用户</label>
                                            <label class="checkbox-inline"><input type="checkbox" name="adjustGroupArr[]" <?php if(in_array("Recall",$condition['adjustGroup'])){ echo 'checked';}?> value="<?php echo "Recall";?>">Recall用户</label>
                                            <label class="checkbox-inline"><input type="checkbox" name="adjustGroupArr[]" <?php if(in_array("Not",$condition['adjustGroup'])){ echo 'checked';}?> value="<?php echo "Not";?>">未归类用户</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </form>
    </div>
</div>
</body>

<script type="text/javascript">
    $(".typeControl").change(function(){
        var type = $(this).val();
        if(type == 1){
            $(this).parent().next().children().attr("readonly",false);
            $(this).parent().next().next().children().attr("readonly",false);
        }else{
            $(this).parent().next().children().attr("readonly",true);
            $(this).parent().next().next().children().attr("readonly",true);
        }
    });

    $("#countrySet").change(function () {
        var type = $(this).val();
        if(type == 1){
            $("#countrySetDiv").show();
        }else{
            $("#countrySetDiv").hide();
        }
    });

    $("#adjustGroup").change(function () {
        var type = $(this).val();
        if(type == 1){
            $("#adjustGroupDiv").show();
        }else{
            $("#adjustGroupDiv").hide();
        }
    });

    $(function () {
        $('#submitBtn').click(function () {
            var data = new FormData(document.getElementById("goodForm"));
            $.ajax({
                url: rootPath + 'config/actionUserGroup',
                type: 'POST',
                data: data,
                dataType: 'json',
                contentType: false, //必须
                processData: false, //必须
                success: function (data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function (msg) {
                    alert(data.msg);
                }
            });
        });
        $('#configsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("configForm"));
            $.ajax({
                url: rootPath + 'config/actionUserGroupCondition',
                type: 'POST',
                data: data,
                dataType: 'json',
                contentType: false, //必须
                processData: false, //必须
                success: function (data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function (msg) {
                    alert(data.msg);
                }
            });
        });
    });

</script>
</html>
