<!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">
                <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">
                    	<div class="row">
                    		<div class="col-sm-6">
	                        <?php foreach ($list as $key => $vl) { ?>
	                        	<?php if(in_array($vl['gid'],[1501,1503,1504,1505,1506,1507])){ ?>
	                            <div class="row AllTypeControl" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
	                                <div class="form-group" >
	                                    <label class="col-sm-2 control-label">商品GID*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control" readonly name="good[<?php echo $vl['gid'];?>][gid]" value="<?php echo $vl['gid'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品名称*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gname]" value="<?php echo $vl['gname'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品简介*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdesc]" value="<?php echo $vl['gdesc'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品价格*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gprice]" value="<?php echo $vl['gprice'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">积分*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="config[<?php echo $vl['gid'];?>][point]" value="<?php echo $config[$vl['gid']]['point'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">等级*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="config[<?php echo $vl['gid'];?>][level]" value="<?php echo $config[$vl['gid']]['level'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品SKU*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gsku]" value="<?php echo $vl['gsku'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品折扣*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdiscount]" value="<?php echo $vl['gdiscount'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品加成*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gaddRatio]" value="<?php echo $vl['gaddRatio'];?>">
	                                    </div>
	                                </div>
	                                <div class="form-group">
	                                    <label class="col-sm-2 control-label">商品货物*: </label>
	                                    <div class="col-sm-10">
	                                        <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
	                                            
	                                                <div class="form-group">
	                                                    <label class="col-sm-2 control-label">金币*: </label>
	                                                    <div class="col-sm-4">
	                                                        <select class="form-control typeControl" name="good[<?php echo $vl['gid'];?>][gbaseReward][coins][coins]">
	                                                            <option value="coins01" <?php if($vl['gbaseReward']['coins']['coins'] == "coins01") echo 'selected'; ?>>coins01</option>
	                                                            <option value="coins02" <?php if($vl['gbaseReward']['coins']['coins'] == "coins02") echo 'selected'; ?>>coins02</option>
	                                                            <option value="coins03" <?php if($vl['gbaseReward']['coins']['coins'] == "coins03") echo 'selected'; ?>>coins03</option>
	                                                            <option value="coins04" <?php if($vl['gbaseReward']['coins']['coins'] == "coins04") echo 'selected'; ?>>coins04</option>
	                                                            <option value="coins05" <?php if($vl['gbaseReward']['coins']['coins'] == "coins05") echo 'selected'; ?>>coins05</option>
	                                                            <option value="coins06" <?php if($vl['gbaseReward']['coins']['coins'] == "coins06") echo 'selected'; ?>>coins06</option>
	                                                        </select>
	                                                    </div>
	                                                    <label class="col-sm-2 control-label">倍率*: </label>
	                                                    <div class="col-sm-4">
	                                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gbaseReward][coins][bet]" value="<?php echo $vl['gbaseReward']['coins']['bet'];?>">
	                                                    </div>
	                                                </div>
	                                        </div>
	                                    </div>
	                                </div>
	                            </div>
	                            <?php };?>
	                        <?php } ?>
	                        </div>
	                        <div class="col-sm-6">
	                        <?php foreach ($list as $key => $vl) { ?>
	                        	<?php if(in_array($vl['gid'],[1502,1508,1509,1510,])){ ?>
	                            <div class="row AllTypeControl" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
	                                <div class="form-group" >
	                                    <label class="col-sm-2 control-label">商品GID*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control" readonly name="good[<?php echo $vl['gid'];?>][gid]" value="<?php echo $vl['gid'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品名称*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gname]" value="<?php echo $vl['gname'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品简介*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdesc]" value="<?php echo $vl['gdesc'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品价格*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gprice]" value="<?php echo $vl['gprice'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">积分*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="config[<?php echo $vl['gid'];?>][point]" value="<?php echo $config[$vl['gid']]['point'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">等级*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="config[<?php echo $vl['gid'];?>][level]" value="<?php echo $config[$vl['gid']]['level'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品SKU*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gsku]" value="<?php echo $vl['gsku'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品折扣*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdiscount]" value="<?php echo $vl['gdiscount'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品加成*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gaddRatio]" value="<?php echo $vl['gaddRatio'];?>">
	                                    </div>
	                                    
	                                </div>
	                                <div class="form-group">
	                                    <label class="col-sm-2 control-label">商品货物*: </label>
	                                    <div class="col-sm-10">
	                                        <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
	                                            
	                                                <div class="form-group">
	                                                    <label class="col-sm-2 control-label">体力*: </label>
	                                                    <div class="col-sm-4">
	                                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gbaseReward]" value="<?php echo $vl['gbaseReward'];?>">
	                                                    </div>
	                                                </div>
	                                            
	                                        </div>
	                                    </div>
	                                </div>
	                            </div>
	                            <?php };?>
	                        <?php } ?>
	                        </div>
	                        <div class="col-sm-12">
	                        <div class="col-sm-6">
	                        <?php foreach ($list as $key => $vl) { ?>
	                        	<?php if(in_array($vl['gid'],[1511,1512,1513,1516,1514,1515])){ ?>
	                            <div class="row AllTypeControl" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
	                                <div class="form-group" >
	                                    <label class="col-sm-2 control-label">商品GID*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control" readonly name="good[<?php echo $vl['gid'];?>][gid]" value="<?php echo $vl['gid'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品名称*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gname]" value="<?php echo $vl['gname'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品简介*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdesc]" value="<?php echo $vl['gdesc'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品价格*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gprice]" value="<?php echo $vl['gprice'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">积分*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="config[<?php echo $vl['gid'];?>][point]" value="<?php echo $config[$vl['gid']]['point'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">等级*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="config[<?php echo $vl['gid'];?>][level]" value="<?php echo $config[$vl['gid']]['level'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品SKU*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gsku]" value="<?php echo $vl['gsku'];?>">
	                                    </div>
	                                    
	                                    <label class="col-sm-2 control-label">商品折扣*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gdiscount]" value="<?php echo $vl['gdiscount'];?>">
	                                    </div>
	                                    <label class="col-sm-2 control-label">商品加成*: </label>
	                                    <div class="col-sm-4">
	                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gaddRatio]" value="<?php echo $vl['gaddRatio'];?>">
	                                    </div>
	                                </div>
	                                <div class="form-group">
	                                    <label class="col-sm-2 control-label">商品货物*: </label>
	                                    <div class="col-sm-10">
	                                        <div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;">
	                                            
	                                                <div class="form-group">
	                                                    <label class="col-sm-2 control-label">钻石*: </label>
	                                                    <div class="col-sm-4">
	                                                        <input type="text" class="form-control"  name="good[<?php echo $vl['gid'];?>][gbaseReward]" value="<?php echo $vl['gbaseReward'];?>">
	                                                    </div>
	                                                </div>
	                                            
	                                        </div>
	                                    </div>
	                                </div>
	                            </div>
	                            <?php };?>
	                        <?php } ?>
	                        </div>
                            </div>
                        </div>
                    </div>
                </section>
            </form>
        </aside>
    </div>
</div>
</body>

<script>
    $(function () {
        var idData = JSON.parse('<?php echo json_encode($idData); ?>');

        $('.addOrDelControl').on("click",'.deleteParent',function(){
            $(this).parent().remove();
        });

        $('.addParent').on("click",function(){
            var gid = $(this).attr('gid');
            var str = "";
            str += '<div class="form-group"><label class="col-sm-1 control-label">道具*: </label><div class="col-sm-3"><select class="form-control" name="good['+gid+'][gbaseReward][props][propsId][]"">';
            for(var x in idData) {
                str += '<option value="'+x+'">'+idData[x]['msg']+'</option>';
            }
            str += '</select></div><label class="col-sm-1 control-label">数量*: </label><div class="col-sm-2"><input type="text" class="form-control"  name="good['+gid+'][gbaseReward][props][num][]" value="1">'+
                '</div><button type="button" class="btn btn-danger deleteParent" >删除</button></div>';
            $(this).before(str);
        });


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