<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#A" data-toggle="tab">生成</a></li>
    </ul>
    <form class="form-horizontal margin-top-20" action="{:url('DiscountCoupon/add')}" method="post">
        <div class="tabbable" style="float: left;">
            <div class="tab-content">
                <div class="tab-pane active" id="A">
                    <fieldset>
                        <div class="control-group">
                            <label class="control-label">优惠券名称</label>
                            <div class="controls">
                                <input class="form-control" type="text" name="discount_coupon_name" value="">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"></label>
                            <div class="controls">
                                <input class="form-control" type="number" name="overflow" value="">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"></label>
                            <div class="controls">
                                <input class="form-control" type="number" name="reduce" value="">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">截止日期</label>
                            <div class="controls">
                                <input type="text" name="deadline" class="form-control js-bootstrap-datetime" autocomplete="off">
                            </div>
                        </div>
                    </fieldset>
                </div>
            </div>
        </div>
        <div class="user_list" style="float: left; margin-left: 100px; width: 350px; height:500px; overflow: scroll; overflow-x:hidden">
            <table class="table table-hover table-bordered table-list" id="TABLE">
                <tr>
                    <th><input type="checkbox" id="All" onclick="checkAll()"></th>
                    <th><input class="form-control" style="width: 200px; display: unset" type="text" placeholder="关键词" id="Search" onchange="ajax()">&nbsp;&nbsp;搜索</th>
                </tr>
                <volist name="user" id="vo">
                    <tr>
                        <td><input type="checkbox" name="user_id[]" value="{$vo.id}"></td>
                        <td>{$vo.user_nickname}</td>
                    </tr>
                </volist>
            </table>
        </div>
        <div style="clear: both">&nbsp;</div>
        <div class="form-actions" style="clear: both">
            <button class="btn btn-primary js-ajax-submit"type="submit">生成</button>
            <a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script>
    function ajax() {
        $.ajax({
            url:"{:url('DiscountCoupon/getUserList')}",
            data:{
                keywords:$("#Search").val()
            },
            type:"POST",
            dataType:"JSON",

            success:function (data) {
                //alert(data.data);
                $("#TABLE").html(data.data);
            }
        })
    }

    function checkAll() {
        var input = $("#TABLE input[type='checkbox']");
        var go = true;
        if(input[0].checked === false) {
            go = false;
        }
        for (var i = 1; i <= input.length; i++) {
            input[i].checked = go;
        }
    }

</script>
</body>
</html>