<!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>
            <header><i class="fa fa-fw fa-file"></i>活动数据&商品限购</header>
            <section>
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-12">
                            <button style="margin:5px;" class="btn btn-success " onclick="refreshActivity(<?php echo $id;?>)" role="button">刷新活动数据</button>
                        </div>
                    </div>
                </div>
            </section>
        </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"/>
                <input type="hidden" value="config" name="type"/>
            <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="container-fluid" style="border: 1px solid #CCC;margin: 20px 15px;padding: 10px 0;"">
                        <div class="row">
                            <label class="col-sm-1 control-label">进度奖励*: </label>
                            <?php foreach ($reward as $key => $vl) { ?>
                                <?php if($key !=0 ){ echo "<label class=\"col-sm-1 control-label\"></label>";}?>
                                <div class="col-sm-11">
                                    <div class="col-sm-2">
                                        <span style="display: inline-block">进度:</span>
                                        <input type="text" class="form-control" readonly name="reward[<?php echo $vl['levelId'];?>][levelId]" value="<?php echo $vl['levelId'];?>" style="display: inline-block;width: 55%">
                                    </div>
                                    <div class="col-sm-2">
                                        <span style="display: inline-block">金币(coin):</span>
                                        <input type="text" class="form-control" name="reward[<?php echo $vl['levelId'];?>][money]" value="<?php echo $vl['money'];?>" style="display: inline-block;width: 55%">
                                    </div>
                                    <div class="col-sm-2">
                                        <span style="display: inline-block">体力:</span>
                                        <input type="text" class="form-control" name="reward[<?php echo $vl['levelId'];?>][spins]" value="<?php echo $vl['spins'];?>" style="display: inline-block;width: 55%">
                                    </div>
                                    <div class="col-sm-2">
                                        <span style="display: inline-block">宝箱Id&nbsp;:</span>
                                        <input type="text" class="form-control" name="reward[<?php echo $vl['levelId'];?>][chest][id]" value="<?php echo $vl['chest']['id'];?>" style="display: inline-block;width: 55%">
                                    </div>
                                    <div class="col-sm-2">
                                        <span style="display: inline-block">宝箱量&nbsp;:</span>
                                        <input type="text" class="form-control" name="reward[<?php echo $vl['levelId'];?>][chest][num]" value="<?php echo $vl['chest']['num'];?>" style="display: inline-block;width: 55%">
                                    </div>
                                    <div class="col-sm-2">
                                        <span style="display: inline-block">经验&nbsp;:</span>
                                        <input type="text" class="form-control" name="reward[<?php echo $vl['levelId'];?>][exp]" value="<?php echo $vl['exp'];?>" style="display: inline-block;width: 55%">
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </form>
                </div>
            </section>

        </aside>
    </div>
</div>
</div>
</body>

<script>
    function refreshActivity(id) {
        $.ajax({
            url: rootPath + 'activity/refreshActivity',
            type: 'POST',
            data: {
                'id':id
            },
            dataType: 'json',
            success: function (data) {
                alert(data.msg);
            },
            error: function (msg) {
                alert(data.msg);
            }
        }) ;
    }

    $(function () {
        $('#configsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("configForm"));
            $.ajax({
                url: rootPath + 'activity/actionConfig',
                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>
