<!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" class="form-control" name="type" value="<?php echo $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 ($list as $key => $vl) { ?>
                            <div class="row AllTypeControl" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                                <div class="form-group" >
                                    <input type="hidden" class="form-control" readonly name="good[<?php echo $vl['gid'];?>][gid]" value="<?php echo $vl['gid'];?>">
                                    <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'];?>][gname]" value="<?php echo $vl['gname'];?>">
                                    </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_en]" value="<?php echo $vl['gname_en'];?>">
                                    </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'];?>][goriginReward]" value="<?php echo $vl['goriginReward'];?>">
                                    </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'];?>][gbaseReward]" value="<?php echo $vl['gbaseReward'];?>">
                                    </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'];?>][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'];?>][gdiscount]" value="<?php echo $vl['gdiscount'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">上架(1上架)*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gstatus]" value="<?php echo $vl['gstatus'];?>">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <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>
                                    <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_en]" value="<?php echo $vl['gdesc_en'];?>">
                                    </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'];?>][gimg]" value="<?php echo $vl['gimg'];?>">
                                    </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'];?>][gattribute]" value="<?php echo $vl['gattribute'];?>">
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </div>

                    <!--钻石兑换列表Start-->
                    <div class="container-fluid">
                        <?php foreach ($exchanges as $group => $val) { ?>
                        <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                            <label class="col-sm-1 control-label pull-left">兑换分组: <?=$group?></label>
                        <?php foreach ($val as $v) { ?>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
                                    <div class="form-group"> 
                                        <input type="hidden" class="form-control" readonly name="diamond[<?php echo $v['gid'];?>][pid]" value="<?php echo $v['pid'];?>">
                                        <input type="hidden" class="form-control" readonly name="diamond[<?php echo $v['gid'];?>][gid]" value="<?php echo $v['gid'];?>">
                                        <label class="col-sm-1 control-label">兑换商品名称*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control"  name="diamond[<?php echo $v['gid'];?>][name]" value="<?php echo $v['name'];?>">
                                        </div>
                                        <label class="col-sm-1 control-label">所需钻石数*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control"  name="diamond[<?php echo $v['gid'];?>][price]" value="<?php echo $v['price'];?>">
                                        </div>
                                        <label class="col-sm-1 control-label">兑换次数*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control"  name="diamond[<?php echo $v['gid'];?>][times]" value="<?php echo $v['times'];?>">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <?php foreach ($v['gbaseReward'] as $k => $num) { ?>
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">奖励*: </label>
                                                <div class="col-sm-3">
                                                    <select class="form-control typeControl" name="diamond[<?php echo $v['gid'];?>][gbaseReward][type]">
                                                        <?php foreach ($idData as $x => $y) { ?>
                                                            <option value="<?php echo $y['value'];?>" <?php if($k == $y['value']) echo 'selected'; ?>><?php echo $y['name'];?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                <label class="col-sm-1 control-label">数量*: </label>
                                                <div class="col-sm-2">
                                                    <input type="text" class="form-control" name="diamond[<?php echo $v['gid'];?>][gbaseReward][num]" value="<?php echo $num;?>">
                                                </div>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php } ?>
                        </div>
                        <?php } ?>
                    </div>
                    <!--钻石兑换列表End-->

                    <!--体力/金币不足兑换列表Start-->
                    <div class="container-fluid">
                        <?php foreach ($notenough as $group => $val) { ?>
                        <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                            <label class="col-sm-1 control-label pull-left">不足兑换分组</label>
                        <?php foreach ($val as $v) { ?>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
                                    <div class="form-group"> 
                                        <input type="hidden" class="form-control" readonly name="enough[<?php echo $v['gid'];?>][pid]" value="<?php echo $v['pid'];?>">
                                        <input type="hidden" class="form-control" readonly name="enough[<?php echo $v['gid'];?>][gid]" value="<?php echo $v['gid'];?>">
                                        <label class="col-sm-1 control-label">兑换商品名称*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control"  name="enough[<?php echo $v['gid'];?>][name]" value="<?php echo $v['name'];?>">
                                        </div>
                                        <label class="col-sm-1 control-label">所需钻石数*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control"  name="enough[<?php echo $v['gid'];?>][price]" value="<?php echo $v['price'];?>">
                                        </div>
                                        <label class="col-sm-1 control-label">兑换加成*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control"  name="enough[<?php echo $v['gid'];?>][gaddRatio]" value="<?php echo $v['gaddRatio'];?>">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="form-group">
                                            <label class="col-sm-1 control-label">奖励*: </label>
                                            <div class="col-sm-3">
                                                <select class="form-control typeControl" name="enough[<?php echo $v['gid'];?>][gbaseReward][type]">
                                                    <?php foreach ($idData2 as $yy) { ?>
                                                        <?php foreach ($yy as $x => $y) { ?>
                                                        <option value="<?php
                                                        echo $y['value'];?>"
                                                        <?php if((isset($v['gbaseReward']['coins']) ?  $v['gbaseReward']['coins'] : isset($v['gbaseReward']['spins']) ?  "spins" : 'crazyPassExp') == $y['value']) echo 'selected'; ?>><?php echo $y['name'];?></option>
                                                        <?php } ?>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                            <label class="col-sm-1 control-label">数量*: </label>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control" name="enough[<?php echo $v['gid'];?>][gbaseReward][num]" value="<?php echo isset($v['gbaseReward']['coins']) ? $v['gbaseReward']['num'] : $v['gbaseReward']['spins'];?>">
                                            </div>
                                        </div>
                                        <label class="col-sm-1 control-label">加成*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control" name="enough[<?php echo $v['gid'];?>][gaddRatio]" value="<?php echo $v['gaddRatio'];?>">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php } ?>
                        </div>
                        <?php } ?>
                    </div>
                    <!--金币/体力不足兑换列表End-->
                </section>
            </form>
        </aside>
    </div>
</div>
</body>

<script>
    $(function () {
        $('#goodsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("goodForm"));
            $.ajax({
                url: rootPath + 'shop/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>
