Example #1
0
def index():
    if not g.user.is_finance():
        abort(404)
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    year = int(request.values.get('year', datetime.datetime.now().year))
    orders = set([
        invoice.client_medium_order for invoice in ClientMediumInvoice.get_invoices_status(INVOICE_STATUS_APPLYPASS)])
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_invoice_info.lower()]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    for k in orders:
        k.apply_count = len(k.get_invoice_by_status(3))
    return tpl('/finance/client_medium_order/invoice/index.html', orders=orders, locations=select_locations,
               location_id=location_id, statuses=select_statuses,
               now_date=datetime.date.today(), search_info=search_info, year=year,
               params='?&searchinfo=%s&selected_location=%s&year=%s' %
                      (search_info, location_id, str(year)))
def index():
    if not g.user.is_finance():
        abort(404)
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    year = int(request.values.get('year', datetime.datetime.now().year))
    orders = set([
        invoice.client_order for invoice in MediumRebateInvoice.get_invoices_status(INVOICE_STATUS_APPLYPASS)])
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [k for k in orders if k.client_start.year ==
              year or k.client_end.year == year]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_invoice_info.lower()]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    for k in orders:
        k.apply_count = len(k.get_medium_rebate_invoice_by_status(3))
    return tpl('/finance/client_order/medium_rebate_invoice/index.html', orders=orders,
               locations=select_locations,
               location_id=location_id, statuses=select_statuses,
               now_date=datetime.date.today(), search_info=search_info, year=year,
               params='?&searchinfo=%s&selected_location=%s&year=%s' %
                      (search_info, location_id, str(year)))
Example #3
0
def apply():
    if not g.user.is_finance():
        abort(404)
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    orders = list(AgentInvoicePay.query.filter_by(pay_status=4))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.agent_invoice.client_order.locations]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.agent_invoice.client_order.search_invoice_info.lower()]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    for i in orders:
        client_order = i.agent_invoice.client_order
        agent_invoices = [k.id for k in AgentInvoice.query.filter_by(client_order=client_order)]
        pays = [k for k in AgentInvoicePay.all() if k.agent_invoice_id in agent_invoices]
        i.apply_num = len([k for k in pays if k.pay_status == 4])
        i.pay_num = len([k for k in pays if k.pay_status == 0])
    return tpl('/finance/client_order/agent_pay/index_pass.html', orders=orders, title=u'申请中的客户付款',
               locations=select_locations,
               location_id=location_id, statuses=select_statuses,
               now_date=datetime.date.today(), search_info=search_info,
               params='?&searchinfo=%s&selected_location=%s' %
                      (search_info, location_id))
Example #4
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(ClientOrder.all())
    if request.args.get('selected_status'):
        status_id = int(request.args.get('selected_status'))
    else:
        status_id = -1

    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    # page = max(1, page)
    # start = (page - 1) * ORDER_PAGE_NUM
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    if status_id >= 0:
        orders = [o for o in orders if o.contract_status == status_id]
    orders = [
        k for k in orders
        if k.client_start.year == year or k.client_end.year == year
    ]
    if search_info != '':
        orders = [
            o for o in orders
            if search_info.lower() in o.search_invoice_info.lower()
        ]
    if orderby and len(orders):
        orders = sorted(orders,
                        key=lambda x: getattr(x, orderby),
                        reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)

    return tpl(
        '/finance/client_order/medium_back_money/index.html',
        orders=orders,
        locations=select_locations,
        location_id=location_id,
        statuses=select_statuses,
        status_id=status_id,
        orderby=orderby,
        now_date=datetime.date.today(),
        search_info=search_info,
        page=page,
        year=year,
        params=
        '&orderby=%s&searchinfo=%s&selected_location=%s&selected_status=%s&year=%s'
        % (orderby, search_info, location_id, status_id, str(year)))
Example #5
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(ClientOrder.all())
    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [
        k for k in orders
        if k.client_start.year == year or k.client_end.year == year
    ]
    if search_info != '':
        orders = [
            o for o in orders
            if search_info.lower() in o.search_invoice_info.lower()
        ]
    if orderby and len(orders):
        orders = sorted(orders,
                        key=lambda x: getattr(x, orderby),
                        reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    for k in orders.object_list:
        k.ex_money = sum([
            i.ex_money
            for i in OutsourceInvoice.query.filter_by(client_order=k)
        ])
        k.pay_num = sum([i.pay_num for i in k.get_outsources_by_status(4)])
        apply_outsources = []
        for i in [1, 2, 3, 5]:
            apply_outsources += k.get_outsources_by_status(i)
        k.apply_money = sum([j.pay_num for j in apply_outsources])
    return tpl(
        '/finance/client_order/outsource/invoice.html',
        orders=orders,
        locations=select_locations,
        location_id=location_id,
        statuses=select_statuses,
        orderby=orderby,
        now_date=datetime.date.today(),
        search_info=search_info,
        page=page,
        year=year,
        params='&orderby=%s&searchinfo=%s&selected_location=%s&year=%s' %
        (orderby, search_info, location_id, year))
Example #6
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(ClientOrder.all())
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [
        k for k in orders
        if k.client_start.year == year or k.client_end.year == year
    ]
    if search_info != '':
        orders = [
            o for o in orders
            if search_info.lower() in o.search_invoice_info.lower()
        ]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    for i in orders.object_list:
        client_order = i
        agent_invoices = [
            k.id
            for k in AgentInvoice.query.filter_by(client_order=client_order)
        ]
        pays = [
            k for k in AgentInvoicePay.all()
            if k.agent_invoice_id in agent_invoices
        ]
        i.apply_num = len([k for k in pays if k.pay_status == 4])
        i.pay_num = len([k for k in pays if k.pay_status == 0])
    return tpl('/finance/client_order/agent_pay/index.html',
               orders=orders,
               title=u'全部客户付款',
               locations=select_locations,
               location_id=location_id,
               statuses=select_statuses,
               now_date=datetime.date.today(),
               search_info=search_info,
               page=page,
               year=year,
               params='&&searchinfo=%s&selected_location=%s&year=%s' %
               (search_info, location_id, str(year)))
Example #7
0
def index_pass():
    if not g.user.is_finance():
        abort(404)
    orders = list(ClientMediumOrder.all())
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    year = int(request.values.get('year', datetime.datetime.now().year))
    page = int(request.args.get('p', 1))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [
        k for k in orders
        if k.client_start.year == year or k.client_end.year == year
    ]
    if search_info != '':
        orders = [
            o for o in orders
            if search_info.lower() in o.search_invoice_info.lower()
        ]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    type = request.args.get('type', '')
    if type == 'excel':
        orders = set([
            invoice.client_medium_order for invoice in
            ClientMediumInvoice.get_invoices_status(INVOICE_STATUS_PASS)
        ])
        xls = write_excel(list(orders))
        response = get_download_response(
            xls,
            ("%s-%s.xls" %
             (u"申请过的发票信息", datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
             ).encode('utf-8'))
        return response
    return tpl('/finance/client_medium_order/invoice/index_pass.html',
               orders=orders,
               locations=select_locations,
               location_id=location_id,
               statuses=select_statuses,
               now_date=datetime.date.today(),
               search_info=search_info,
               page=page,
               year=year,
               params='&searchinfo=%s&selected_location=%s&year=%s' %
               (search_info, location_id, str(year)))
Example #8
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(ClientOrder.all())
    if request.args.get('selected_status'):
        status_id = int(request.args.get('selected_status'))
    else:
        status_id = -1

    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    # page = max(1, page)
    # start = (page - 1) * ORDER_PAGE_NUM
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    if status_id >= 0:
        orders = [o for o in orders if o.contract_status == status_id]
    orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_invoice_info.lower()]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    for i in orders.object_list:
        client_order = i
        medium_invoices = [k.id for k in MediumInvoice.query.filter_by(client_order=client_order)]
        pays = [k for k in MediumInvoicePay.all() if k.medium_invoice_id in medium_invoices]
        i.apply_num = len([k for k in pays if k.pay_status == 4])
        i.pay_num = len([k for k in pays if k.pay_status == 0])
    return tpl('/finance/client_order/medium_pay/index_pass.html', orders=orders, title=u'申请中的媒体付款',
               locations=select_locations, location_id=location_id,
               statuses=select_statuses, status_id=status_id,
               orderby=orderby, now_date=datetime.date.today(),
               search_info=search_info, page=page, year=year,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&selected_status=%s&year=%s' %
                      (orderby, search_info, location_id, status_id, str(year)))
Example #9
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(ClientOrder.all())
    if request.args.get('selected_status'):
        status_id = int(request.args.get('selected_status'))
    else:
        status_id = -1

    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    # page = max(1, page)
    # start = (page - 1) * ORDER_PAGE_NUM
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    if status_id >= 0:
        orders = [o for o in orders if o.contract_status == status_id]
    orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_invoice_info.lower()]
    if orderby and len(orders):
        orders = sorted(
            orders, key=lambda x: getattr(x, orderby), reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)

    return tpl('/finance/client_order/medium_back_money/index.html', orders=orders,
               locations=select_locations, location_id=location_id,
               statuses=select_statuses, status_id=status_id,
               orderby=orderby, now_date=datetime.date.today(),
               search_info=search_info, page=page, year=year,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&selected_status=%s&year=%s' %
                      (orderby, search_info, location_id, status_id, str(year)))
Example #10
0
def apply():
    if not g.user.is_finance():
        abort(404)
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    orders = list(AgentInvoicePay.query.filter_by(pay_status=4))
    if location_id >= 0:
        orders = [
            o for o in orders
            if location_id in o.agent_invoice.client_order.locations
        ]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in
            o.agent_invoice.client_order.search_invoice_info.lower()
        ]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    for i in orders:
        client_order = i.agent_invoice.client_order
        agent_invoices = [
            k.id
            for k in AgentInvoice.query.filter_by(client_order=client_order)
        ]
        pays = [
            k for k in AgentInvoicePay.all()
            if k.agent_invoice_id in agent_invoices
        ]
        i.apply_num = len([k for k in pays if k.pay_status == 4])
        i.pay_num = len([k for k in pays if k.pay_status == 0])
    return tpl('/finance/client_order/agent_pay/index_pass.html',
               orders=orders,
               title=u'申请中的客户付款',
               locations=select_locations,
               location_id=location_id,
               statuses=select_statuses,
               now_date=datetime.date.today(),
               search_info=search_info,
               params='?&searchinfo=%s&selected_location=%s' %
               (search_info, location_id))
def index_pass():
    if not g.user.is_finance():
        abort(404)
    orders = list(searchAdClientOrder.all())
    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [k for k in orders if k.client_start.year ==
              year or k.client_end.year == year]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_info.lower()]
    if orderby and len(orders):
        orders = sorted(
            orders, key=lambda x: getattr(x, orderby), reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    type = request.args.get('type', '')
    if type == 'excel':
        orders = set([invoice.client_order for invoice in searchAdMediumRebateInvoice.get_invoices_status(
            INVOICE_STATUS_PASS)])
        xls = write_medium_rebate_invoice_excel(list(orders))
        response = get_download_response(
            xls, ("%s-%s.xls" % (u"申请过的媒体返点发票信息", datetime.datetime.now().strftime('%Y%m%d%H%M%S'))).encode('utf-8'))
        return response
    return tpl('/finance/searchAd_order/medium_rebate_invoice/index_pass.html', orders=orders, locations=select_locations,
               location_id=location_id, statuses=select_statuses, orderby=orderby,
               now_date=datetime.date.today(), search_info=search_info, page=page, year=year,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&year=%s' %
                      (orderby, search_info, location_id, str(year)))
Example #12
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(searchAdRebateOrder.all())
    if request.args.get('selected_status'):
        status_id = int(request.args.get('selected_status'))
    else:
        status_id = -1

    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    # page = max(1, page)
    # start = (page - 1) * ORDER_PAGE_NUM
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    if status_id >= 0:
        orders = [o for o in orders if o.contract_status == status_id]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_info.lower()]
    if orderby and len(orders):
        orders = sorted(
            orders, key=lambda x: getattr(x, orderby), reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    return tpl('/finance/searchAd_rebate_order/agent_pay/index.html', orders=orders, title=u'申请中的代理打款',
               locations=select_locations, location_id=location_id,
               statuses=select_statuses, status_id=status_id,
               orderby=orderby, now_date=datetime.date.today(),
               search_info=search_info, page=page,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&selected_status=%s' %
                      (orderby, search_info, location_id, status_id))
Example #13
0
def index():
    if not g.user.is_finance():
        abort(404)
    orders = list(DoubanOrder.all())
    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '')
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))
    if location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_info.lower()]
    if orderby and len(orders):
        orders = sorted(
            orders, key=lambda x: getattr(x, orderby), reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    for k in orders.object_list:
        k.ex_money = sum(
            [i.ex_money for i in DoubanOutsourceInvoice.query.filter_by(douban_order=k)])
        k.pay_num = sum([i.pay_num for i in k.get_outsources_by_status(4)])
        apply_outsources = []
        for i in [1, 2, 3, 5]:
            apply_outsources += k.get_outsources_by_status(i)
        k.apply_money = sum([j.pay_num for j in apply_outsources])
    return tpl('/finance/douban_order/outsource/invoice.html', orders=orders, locations=select_locations,
               location_id=location_id, statuses=select_statuses, orderby=orderby,
               now_date=datetime.date.today(), search_info=search_info, page=page, year=year,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&year=%s' %
                      (orderby, search_info, location_id, str(year)))
Example #14
0
def apply():
    if not g.user.is_finance():
        abort(404)
    medium_id = int(request.args.get('medium_id', 0))
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    page = int(request.args.get('p', 1))

    orders = list(MediumInvoicePay.query.filter_by(pay_status=4))
    if location_id >= 0:
        orders = [
            o for o in orders if location_id in o.medium_invoice.client_order.locations]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.medium_invoice.client_order.search_invoice_info.lower()]
    if medium_id:
        orders = [o for o in orders if medium_id == o.medium_invoice.medium_id]
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    for i in orders.object_list:
        client_order = i.medium_invoice.client_order
        medium_invoices = [k.id for k in MediumInvoice.query.filter_by(client_order=client_order)]
        pays = [k for k in MediumInvoicePay.all() if k.medium_invoice_id in medium_invoices]
        i.apply_num = len([k for k in pays if k.pay_status == 4])
        i.pay_num = len([k for k in pays if k.pay_status == 0])
    return tpl('/finance/client_order/medium_pay/index.html', orders=orders, title=u'申请中的媒体付款',
               locations=select_locations, location_id=location_id,
               now_date=datetime.date.today(),
               search_info=search_info, page=page,
               mediums=[(k.id, k.name) for k in Medium.all()], medium_id=medium_id,
               params='&searchinfo=%s&selected_location=%s&medium_id=%s' %
                      (search_info, location_id, str(medium_id)))
Example #15
0
 def __init__(self, *args, **kwargs):
     super(NewTeamForm, self).__init__(*args, **kwargs)
     self.type.choices = TEAM_TYPE_CN.items()
     self.location.choices = TEAM_LOCATION_CN.items()
     self.admins.choices = [(m.id, m.name) for m in User.all()]
Example #16
0
def display_orders(orders, template, title, operaters):
    if request.args.get('selected_status'):
        status_id = int(request.args.get('selected_status'))
    else:
        status_id = -1
    orderby = request.args.get('orderby', '')
    search_info = request.args.get('searchinfo', '').strip()
    location_id = int(request.args.get('selected_location', '-1'))
    status = request.args.get('status', '')
    page = int(request.args.get('p', 1))
    year = int(request.values.get('year', datetime.datetime.now().year))

    if g.user.team.type == TEAM_TYPE_LEADER:
        status = 'apply'
        location_id = g.user.team.location

    # Oscar的查看内容
    if int(g.user.id) == 16:
        status = 'apply_upper'
        location_id = TEAM_LOCATION_HUANAN

    if isinstance(location_id, list):
        orders = [o for o in orders if len(
            set(location_id) & set(o.locations)) > 0]
    elif location_id >= 0:
        orders = [o for o in orders if location_id in o.locations]
    orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year]
    if status_id >= 0:
        orders = [o for o in orders if o.contract_status == status_id]
    if search_info != '':
        orders = [
            o for o in orders if search_info.lower() in o.search_info.lower()]

    if status == 'apply':
        orders = [o for o in orders if o.get_outsources_by_status(1)]
    if status == 'apply_upper':
        orders = [o for o in orders if o.get_outsources_by_status(5)]
    if status == 'pass':
        orders = [o for o in orders if o.get_outsources_by_status(2)]
    if status == 'money':
        orders = [o for o in orders if o.get_outsources_by_status(3)]
    if status == 'pay':
        orders = [o for o in orders if o.get_outsources_by_status(4)]

    if orderby and len(orders):
        orders = sorted(
            orders, key=lambda x: getattr(x, orderby), reverse=True)
    select_locations = TEAM_LOCATION_CN.items()
    select_locations.insert(0, (-1, u'全部区域'))
    select_statuses = CONTRACT_STATUS_CN.items()
    select_statuses.insert(0, (-1, u'全部合同状态'))
    paginator = Paginator(orders, ORDER_PAGE_NUM)
    try:
        orders = paginator.page(page)
    except:
        orders = paginator.page(paginator.num_pages)
    return tpl(template, title=title, orders=orders, year=year,
               locations=select_locations, location_id=location_id,
               statuses=select_statuses, status_id=status_id,
               orderby=orderby or 'create_time', status=status,
               search_info=search_info, page=page, operaters=operaters,
               params='&orderby=%s&searchinfo=%s&selected_location=%s&selected_status=%s&year=%s' %
                      (orderby or 'create_time', search_info, location_id, status_id, year))