def index(): if not g.user.is_super_admin(): abort(403) form = FrameworkOrderForm(request.form) if request.method == 'POST' and form.validate(): order = FrameworkOrder.add(group=Group.get(form.group.data), agents=Agent.gets(form.agents.data), description=form.description.data, money=int( round(float(form.money.data or 0))), client_start=form.client_start.data, client_end=form.client_end.data, reminde_date=form.reminde_date.data, direct_sales=User.gets( form.direct_sales.data), agent_sales=User.gets(form.agent_sales.data), contract_type=form.contract_type.data, creator=g.user, contract_status=2, contract=request.values.get('contract'), create_time=datetime.now()) order.add_comment(g.user, u"导入了框架订单") flash(u'导入框架订单成功', 'success') return redirect(order.info_path()) else: form.client_start.data = datetime.now().date() form.client_end.data = datetime.now().date() form.reminde_date.data = datetime.now().date() return tpl('insert_framework_order.html', form=form)
def info(order_id): if not g.user.is_finance(): abort(404) order = FrameworkOrder.get(order_id) if not order or order.status == 0: abort(404) return tpl('/finance/framework_order/info.html', order=order)
def index(): if not g.user.is_finance(): abort(404) orders = list(FrameworkOrder.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)) 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] 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()] orders = [k for k in orders if k.client_start.year == year or k.client_end.year == year] 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/framework_order/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)))
def get_framework_order_count(self): return len([k for k in FrameworkOrder.all() if self in k.agents])
def framework_douban_apply(order_id): order = FrameworkOrder.get(order_id) order.add_comment(g.user, u"向豆瓣发送合同号申请邮件") return contract_apply(order)
def finish_framework_order_upload(): order_id = request.values.get('order') order = FrameworkOrder.get(order_id) return attachment_upload(order, FILE_TYPE_FINISH)
def framework_order_files(order_id): fo = FrameworkOrder.get(order_id) return tpl("order_files.html", order=fo)
def framework_contract_upload(): order_id = request.values.get('order') order = FrameworkOrder.get(order_id) return attachment_upload(order, FILE_TYPE_CONTRACT)
def framework_schedule_upload(): order_id = request.values.get('order') order = FrameworkOrder.get(order_id) return attachment_upload(order, FILE_TYPE_SCHEDULE)
def framework_others_upload(): order_id = request.values.get('order') order = FrameworkOrder.get(order_id) return attachment_upload(order, FILE_TYPE_OTHERS)
medium_money=i[ 'medium_money'], medium_money2=i[ 'medium_money2'], sale_money=i[ 'sale_money'], month_day=i['month'], days=i['days'], create_time=None) er.save() return True if __name__ == '__main__': client_orders = ClientOrder.all() douban_orders = DoubanOrder.all() framework_orders = FrameworkOrder.all() medium_framework_orders = MediumFrameworkOrder.all() search_client_orders = searchAdClientOrder.all() search_rebate_orders = searchAdRebateOrder.all() search_framework_orders = searchAdFrameworkOrder.all() for c in client_orders: c.client_start_year = c.client_start.year c.client_end_year = c.client_end.year c.save() _insert_zhiqu_executive_report(c, 'reload') for d in douban_orders: d.client_start_year = d.client_start.year d.client_end_year = d.client_end.year d.save()