def pdf(buyer_order_id): """ 文件下载 :param buyer_order_id: :return: """ buyer_order_info = get_buyer_order_row_by_id(buyer_order_id) # 检查资源是否存在 if not buyer_order_info: abort(404) # 检查资源是否删除 if buyer_order_info.status_delete == STATUS_DEL_OK: abort(410) buyer_order_print_date = time_utc_to_local( buyer_order_info.update_time).strftime('%Y-%m-%d') buyer_order_code = '%s%s' % ( g.BUYER_ORDER_PREFIX, time_utc_to_local( buyer_order_info.create_time).strftime('%y%m%d%H%M%S')) # 获取渠道公司信息 supplier_info = get_supplier_row_by_id(buyer_order_info.supplier_cid) # 获取渠道联系方式 supplier_contact_info = get_supplier_contact_row_by_id( buyer_order_info.supplier_contact_id) # 获取询价人员信息 user_info = get_user_row_by_id(buyer_order_info.uid) buyer_order_items = get_buyer_order_items_rows( buyer_order_id=buyer_order_id) # 文档信息 document_info = DOCUMENT_INFO.copy() document_info['TITLE'] = _('buyer order pdf') template_name = 'buyer/order/pdf.html' html = render_template(template_name, buyer_order_id=buyer_order_id, buyer_order_info=buyer_order_info, supplier_info=supplier_info, supplier_contact_info=supplier_contact_info, user_info=user_info, buyer_order_items=buyer_order_items, buyer_order_print_date=buyer_order_print_date, buyer_order_code=buyer_order_code, **document_info) # return html return render_pdf( html=HTML(string=html), stylesheets=[CSS(string='@page {size:A4; margin:35px;}')], download_filename='采购订单.pdf'.encode('utf-8'))
def filter_supplier_contact_name(contact_id, default='-'): """ 渠道联系人员 :param contact_id: :param default: :return: """ if not contact_id: return default supplier_contact_info = get_supplier_contact_row_by_id(contact_id) return supplier_contact_info.name if supplier_contact_info else default
def pdf(enquiry_id): """ 文件下载 :param enquiry_id: :return: """ enquiry_info = get_enquiry_row_by_id(enquiry_id) # 检查资源是否存在 if not enquiry_info: abort(404) # 检查资源是否删除 if enquiry_info.status_delete == STATUS_DEL_OK: abort(410) enquiry_print_date = time_utc_to_local( enquiry_info.update_time).strftime('%Y-%m-%d') enquiry_code = '%s%s' % ( g.ENQUIRIES_PREFIX, time_utc_to_local( enquiry_info.create_time).strftime('%y%m%d%H%M%S')) # 获取客户公司信息 supplier_info = get_supplier_row_by_id(enquiry_info.supplier_cid) # 获取客户联系方式 supplier_contact_info = get_supplier_contact_row_by_id( enquiry_info.supplier_contact_id) # 获取询价人员信息 user_info = get_user_row_by_id(enquiry_info.uid) enquiry_items = get_enquiry_items_rows(enquiry_id=enquiry_id) # 文档信息 document_info = DOCUMENT_INFO.copy() document_info['TITLE'] = _('enquiry edit') template_name = 'enquiry/pdf.html' html = render_template(template_name, enquiry_id=enquiry_id, enquiry_info=enquiry_info, supplier_info=supplier_info, supplier_contact_info=supplier_contact_info, user_info=user_info, enquiry_items=enquiry_items, enquiry_print_date=enquiry_print_date, enquiry_code=enquiry_code, **document_info) # return html return render_pdf( html=HTML(string=html), stylesheets=[CSS(string='@page {size:A4; margin:35px;}')], download_filename='询价单.pdf'.encode('utf-8'))
def pdf(purchase_id): """ 文件下载 :param purchase_id: :return: """ purchase_info = get_purchase_row_by_id(purchase_id) # 检查资源是否存在 if not purchase_info: abort(404) # 检查资源是否删除 if purchase_info.status_delete == STATUS_DEL_OK: abort(410) purchase_print_date = time_utc_to_local( purchase_info.update_time).strftime('%Y-%m-%d') purchase_code = '%s%s' % ( g.ENQUIRIES_PREFIX, time_utc_to_local( purchase_info.create_time).strftime('%y%m%d%H%M%S')) # 获取渠道公司信息 supplier_info = get_supplier_row_by_id(purchase_info.supplier_cid) # 获取渠道联系方式 supplier_contact_info = get_supplier_contact_row_by_id( purchase_info.supplier_contact_id) # 获取进货人员信息 user_info = get_user_row_by_id(purchase_info.uid) purchase_items = get_purchase_items_rows(purchase_id=purchase_id) # 文档信息 document_info = DOCUMENT_INFO.copy() document_info['TITLE'] = _('purchase pdf') template_name = 'purchase/pdf.html' html = render_template(template_name, purchase_id=purchase_id, purchase_info=purchase_info, supplier_info=supplier_info, supplier_contact_info=supplier_contact_info, user_info=user_info, purchase_items=purchase_items, purchase_print_date=purchase_print_date, purchase_code=purchase_code, **document_info) # return html return render_pdf( html=HTML(string=html), stylesheets=[CSS(string='@page {size:A4; margin:35px;}')], download_filename='销售出货.pdf'.encode('utf-8'))
def preview(buyer_order_id): """ 打印预览 :param buyer_order_id: :return: """ buyer_order_info = get_buyer_order_row_by_id(buyer_order_id) # 检查资源是否存在 if not buyer_order_info: abort(404) # 检查资源是否删除 if buyer_order_info.status_delete == STATUS_DEL_OK: abort(410) buyer_order_print_date = time_utc_to_local( buyer_order_info.update_time).strftime('%Y-%m-%d') buyer_order_code = '%s%s' % ( g.BUYER_ORDER_PREFIX, time_utc_to_local( buyer_order_info.create_time).strftime('%y%m%d%H%M%S')) # 获取渠道公司信息 supplier_info = get_supplier_row_by_id(buyer_order_info.supplier_cid) # 获取渠道联系方式 supplier_contact_info = get_supplier_contact_row_by_id( buyer_order_info.supplier_contact_id) # 获取询价人员信息 user_info = get_user_row_by_id(buyer_order_info.uid) buyer_order_items = get_buyer_order_items_rows( buyer_order_id=buyer_order_id) # 文档信息 document_info = DOCUMENT_INFO.copy() document_info['TITLE'] = _('buyer order preview') template_name = 'buyer/order/preview.html' return render_template(template_name, buyer_order_id=buyer_order_id, buyer_order_info=buyer_order_info, supplier_info=supplier_info, supplier_contact_info=supplier_contact_info, user_info=user_info, buyer_order_items=buyer_order_items, buyer_order_print_date=buyer_order_print_date, buyer_order_code=buyer_order_code, **document_info)
def info(enquiry_id): """ 询价详情 :param enquiry_id: :return: """ # 详情数据 enquiry_info = get_enquiry_row_by_id(enquiry_id) # 检查资源是否存在 if not enquiry_info: abort(404) # 检查资源是否删除 if enquiry_info.status_delete == STATUS_DEL_OK: abort(410) enquiry_print_date = time_utc_to_local( enquiry_info.update_time).strftime('%Y-%m-%d') enquiry_code = '%s%s' % ( g.ENQUIRIES_PREFIX, time_utc_to_local( enquiry_info.create_time).strftime('%y%m%d%H%M%S')) # 获取渠道公司信息 supplier_info = get_supplier_row_by_id(enquiry_info.supplier_cid) # 获取渠道联系方式 supplier_contact_info = get_supplier_contact_row_by_id( enquiry_info.supplier_contact_id) # 获取询价人员信息 user_info = get_user_row_by_id(enquiry_info.uid) enquiry_items = get_enquiry_items_rows(enquiry_id=enquiry_id) # 文档信息 document_info = DOCUMENT_INFO.copy() document_info['TITLE'] = _('enquiry info') template_name = 'enquiry/info.html' return render_template(template_name, enquiry_id=enquiry_id, enquiry_info=enquiry_info, supplier_info=supplier_info, supplier_contact_info=supplier_contact_info, user_info=user_info, enquiry_items=enquiry_items, enquiry_print_date=enquiry_print_date, enquiry_code=enquiry_code, **document_info)
def preview(purchase_id): """ 打印预览 :param purchase_id: :return: """ purchase_info = get_purchase_row_by_id(purchase_id) # 检查资源是否存在 if not purchase_info: abort(404) # 检查资源是否删除 if purchase_info.status_delete == STATUS_DEL_OK: abort(410) purchase_print_date = time_utc_to_local( purchase_info.update_time).strftime('%Y-%m-%d') purchase_code = '%s%s' % ( g.ENQUIRIES_PREFIX, time_utc_to_local( purchase_info.create_time).strftime('%y%m%d%H%M%S')) # 获取渠道公司信息 supplier_info = get_supplier_row_by_id(purchase_info.supplier_cid) # 获取渠道联系方式 supplier_contact_info = get_supplier_contact_row_by_id( purchase_info.supplier_contact_id) # 获取进货人员信息 user_info = get_user_row_by_id(purchase_info.uid) purchase_items = get_purchase_items_rows(purchase_id=purchase_id) # 文档信息 document_info = DOCUMENT_INFO.copy() document_info['TITLE'] = _('purchase preview') template_name = 'purchase/preview.html' return render_template(template_name, purchase_id=purchase_id, purchase_info=purchase_info, supplier_info=supplier_info, supplier_contact_info=supplier_contact_info, user_info=user_info, purchase_items=purchase_items, purchase_print_date=purchase_print_date, purchase_code=purchase_code, **document_info)