<div class="wrap">
    <h2>收佣进度表</h2>
    <form method="get" class="form-horizontal">
        <input type="hidden" name="page" value="commissionList">
        {% import "selectOrganization.html" as macro %}
        {{ macro.selectOrganization("commission") }}
        <div class="row" id="search_form">
            <div class="col-md-2">
                <div class="input-group">
                    <span class="input-group-addon">年份</span>
                    <label for="year" class="hidden"></label>
                    <select name="year" id="year" class="form-control widthAuto">
                        <option value="2015">2015</option>
                        <option value="2016">2016</option>
                    </select>
                </div>
            </div>
            <div class="col-md-2">
                <div class="input-group">
                    <span class="input-group-addon">月份</span>
                    <select name="month" id="month" class="form-control widthAuto">
                        <option value="-1">请选择月份</option>
                        <option value="1">一月</option>
                        <option value="2">二月</option>
                        <option value="3">三月</option>
                        <option value="4">四月</option>
                        <option value="5">五月</option>
                        <option value="6">六月</option>
                        <option value="7">七月</option>
                        <option value="8">八月</option>
                        <option value="9">九月</option>
                        <option value="10">十月</option>
                        <option value="11">十一月</option>
                        <option value="12">十二月</option>
                    </select>
                    <label for="month" class="hidden"></label>
                </div>
            </div>
            <div class="col-md-2">
                <div class="input-group">
                    <span class="input-group-addon">置业顾问</span>
                    <label for="search_consultant_name" class="hidden"></label>
                    <input type="text" class="form-control" name="search_consultant_name" id="search_consultant_name"
                           value="{{ req.search_consultant_name }}">
                </div>
            </div>
            <input type="submit" id="submit" class="btn btn-success" value="搜索">
        </div>
    </form>
    {{ function("addCommissionTable") }}
</div>
<script>
    $(document).ready(function () {
        $('form').submit(function () {
            var organization = getOrganization('commission');
            var select = $('#commission_organization').find('select[data-depth]:not(.hidden)');
            if (select.length > 1 && organization == -1) {
                alert('请选择门店');
                return false;
            } else {
                $(this).append('<input type="hidden" name="organization" value="' + organization + '">');
            }
        });

        {% if req %}
            $("#year").val('{{ req.year|default(year) }}');
            $("#month").val('{{ req.month|default(-1) }}');
        {% endif %}
    });
</script>