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 Invoice.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_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_pass(): 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')) 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_order for invoice in Invoice.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_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)))
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 Invoice.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_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_pass(): 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')) 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_order for invoice in Invoice.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_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)))