<div class="wrap">
    <h2>收佣进度表</h2>
    <form method="get">
        <input type="hidden" name="page" value="commissionList">
        {% include 'selectOrganization.html' %}
        <div id="search_form">
            <label for="year" class="hidden"></label>
            <select name="year" id="year">
                <option value="2015">2015</option>
                <option value="2016">2016</option>
            </select>
            <label for="month" class="hidden"></label>
            <select name="month" id="month">
                <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="search_consultant_name" class="hidden"></label>
            <input type="text" placeholder="请输入置业顾问" name="search_consultant_name" id="search_consultant_name"
                   value="{{ req.search_consultant_name }}">
            <input type="submit" id="submit" class="button action" value="搜索">
        </div>
    </form>
    {{ function("addCommissionTable") }}
</div>
<script>
    $(document).ready(function () {
        $('form').submit(function () {
            var organization = getOrganization();
            var select = $('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>