<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<?php $this->endBlock(); ?>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <form role="form" class="form-horizontal" id="theFrm" onsubmit="return false;">
                <input type="hidden" name="celuo_id" value="<?=$celuo_id?>">
                <input type="hidden" name="fanxian_id" value="<?=$fanxian_id?>">
                <input type="hidden" name="gift_type" value="<?=$type?>">
                <div class="form-group">
                    <label class="col-sm-2 control-label">模式</label>
                    <div class="col-sm-4">
                        <select name="free_type" id="type" class="form-control">
                            <option value="2">收费模式</option>
                            <option value="1">免费模式</option>
                        </select>
                    </div>
                    <label class="col-sm-2 control-label">最大选择数</label>
                    <div class="col-sm-2">
                        <div class="input-group">
                            <input type="text" name="n" id="n" class="form-control">
                            <div class="input-group-addon">个</div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">选择礼品/礼券</label>
                    <div class="col-sm-9">
                        <div class="row">
                            <?php foreach($items as $item) { ?>
                            <div class="col-sm-3 mb-8">
                                <div class="checkbox checkbox-inline">
                                    <input type="checkbox" id="gift_id_<?=$item->id?>" name="gift_ids[]" value="<?=$item->id?>">
                                    <label for="gift_id_<?=$item->id?>"><?=$item->name?></label>
                                </div>
                            </div>
                            <div class="col-sm-3 mb-8">
                                <div class="input-group">
                                    <input type="text" name="gift_prices[<?=$item->id?>]" class="form-control" value="<?=$item->price?>">
                                    <div class="input-group-addon">元</div>
                                </div>
                            </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
                <button type="button" class="col-sm-offset-2 btn btn-primary btn-save">保存</button>
            </form>
        </div>
    </div>
</div>

<?php $this->beginBlock('footer_js'); ?>
<script type="text/javascript" language="javascript">
    $(function () {
        //提交按钮
        $(".btn-save").click(function(){
            parent.layer.confirm('是否确认提交？', {
                btn: ['确认','取消'], //按钮
                shade: false //不显示遮罩
            }, function(){
                var params = $("#theFrm").serialize();
                $.post('/marketing-strategy/gift-save',params,function(obj){
                    if(obj.success) {
                        parent.layer.msg('保存成功');
                        parent.readFanXians();
                        layer_close();
                    } else {
                        layer.msg(data.msg);
                    }
                },'json');
            }, function(){
                //
            });
        });
    })
</script>
<?php $this->endBlock('footer_js'); ?>
