<!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>
                            <button style="margin:5px;" class="btn btn-success " onclick="clearBuyNum(<?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="goodForm" action="#" style="margin-top: 20px">
                <input type="hidden" value="<?php echo $id;?>" name="id"/>
                <input type="hidden" value="good" 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="goodsubmitBtn">提交</button>
                        </div>
                    </div>
                </div>
                    <div class="container-fluid">
                        <?php foreach ($good as $key => $vl) { ?>
                            <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                                <div class="form-group" >
                                    <label class="col-sm-1 control-label">商品GID*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" readonly name="good[<?php echo $vl['gid'];?>][gid]" value="<?php echo $vl['gid'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">商品名称*: </label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gname]" value="<?php echo $vl['gname'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">商品SKU*: </label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gsku]" value="<?php echo $vl['gsku'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">商品简介*: </label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdesc]" value="<?php echo $vl['gdesc'];?>">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-1 control-label">商品价格*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gprice]" value="<?php echo $vl['gprice'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">商品限购*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gMax]" value="<?php echo $vl['gMax'];?>">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <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" name="good[<?php echo $vl['gid'];?>][gbaseReward][spins]" value="<?php echo $vl['gbaseReward']['spins'];?>" style="display: inline-block;width: 75%">
                                        </div>
                                        <div class="col-sm-2">
                                            <span style="display: inline-block">材料:</span>
                                            <input type="text" class="form-control" name="good[<?php echo $vl['gid'];?>][gbaseReward][festival]" value="<?php echo $vl['gbaseReward']['festival'];?>" style="display: inline-block;width: 75%">
                                        </div>
                                        <div class="col-sm-2">
                                            <span style="display: inline-block">宝箱Id&nbsp;:</span>
                                            <input type="text" class="form-control" name="good[<?php echo $vl['gid'];?>][gbaseReward][chest][id]" value="<?php echo $vl['gbaseReward']['chest']['id'];?>" style="display: inline-block;width: 75%">
                                        </div>
                                        <div class="col-sm-2">
                                            <span style="display: inline-block">宝箱量:</span>
                                            <input type="text" class="form-control" name="good[<?php echo $vl['gid'];?>][gbaseReward][chest][num]" value="<?php echo $vl['gbaseReward']['chest']['num'];?>" style="display: inline-block;width: 75%">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </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"/>
                <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;">
                        <div class="row">
                            <div class="form-group" style="padding:5px 0">
                                <label class="col-sm-1 control-label">Tab名称*: </label>
                                <div class="col-sm-11">
                                    <?php foreach ($lang as $key => $vl) { ?>
                                        <div class="col-sm-1" style="width: 12%;">
                                            <input type="text" class="form-control" name="title[<?php echo $key;?>]" placeholder="<?php echo $vl;?>" value="<?php echo $reward['title'][strtoupper($key)];?>">
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">卡片Tab名称*: </label>
                                <div class="col-sm-11">
                                    <?php foreach ($lang as $key => $vl) { ?>
                                        <div class="col-sm-1" style="width: 12%;">
                                            <input type="text" class="form-control" name="titleCard[<?php echo $key;?>]" placeholder="<?php echo $vl;?>" value="<?php echo $reward['titleCard'][strtoupper($key)];?>">
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                            <div class="form-group" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                                <label class="col-sm-1 control-label">进度奖励*: </label>
                                <?php foreach ($reward['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['stage'];?>][stage]" value="<?php echo $vl['stage'];?>" 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['stage'];?>][max]" value="<?php echo $vl['max'];?>" style="display: inline-block;width: 55%">
                                        </div>
                                        <div class="col-sm-2">
                                            <span style="display: inline-block">金币(coin01):</span>
                                            <input type="text" class="form-control" name="reward[<?php echo $vl['stage'];?>][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['stage'];?>][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['stage'];?>][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['stage'];?>][chest][num]" value="<?php echo $vl['chest']['num'];?>" style="display: inline-block;width: 55%">
                                        </div>
                                    </div>
                                <?php } ?>
                            </div>
                        </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 clearBuyNum(id) {
        $.ajax({
            url: rootPath + 'activity/clearBuyNum',
            type: 'POST',
            data: {
                'id':id
            },
            dataType: 'json',
            success: function (data) {
                alert(data.msg);
            },
            error: function (msg) {
                alert(data.msg);
            }
        }) ;
    }
    $(function () {
        $('#goodsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("goodForm"));
            $.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);
                }
            });
        });
        $('#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>
