Beispiel #1
0
def print_dc_customer(request, pk):
    lines = 0
    total_amount = 0
    company_info = Company_info.objects.filter(id=1)
    image = Company_info.objects.filter(id=1).first()
    header = DcHeaderCustomer.objects.filter(id=pk).first()
    detail = DcDetailCustomer.objects.filter(dc_id=pk).all()
    cursor = connection.cursor()
    po_client = cursor.execute(
        '''
                                select PO.po_client from customer_poheadercustomer PO
                            inner join customer_dcdetailcustomer DCD on DCD.po_no = PO.id
                            where DCD.dc_id_id = %s
                            group by PO.po_client''', [pk])
    po_client = po_client.fetchall()
    po_client = [x[0] for x in po_client]
    pdf = render_to_pdf(
        'customer/dc_customer_pdf.html', {
            'company_info': company_info,
            'image': image,
            'header': header,
            'detail': detail,
            'po_client': po_client
        })
    if pdf:
        response = HttpResponse(pdf, content_type='application/pdf')
        filename = "DC_Customer_%s.pdf" % (header.dc_no)
        content = "inline; filename='%s'" % (filename)
        response['Content-Disposition'] = content
        return response
    return HttpResponse("Not found")
Beispiel #2
0
def print_po_customer(request, pk):
    lines = 0
    total_amount = 0
    company_info = Company_info.objects.filter(id=1)
    image = Company_info.objects.filter(id=1).first()
    header = PoHeaderCustomer.objects.filter(id=pk).first()
    detail = PoDetailCustomer.objects.filter(po_id=pk).all()
    for value in detail:
        amount = float(value.unit_price * value.quantity)
        total_amount = total_amount + amount
    pdf = render_to_pdf(
        'customer/po_customer_pdf.html', {
            'company_info': company_info,
            'image': image,
            'header': header,
            'detail': detail,
            'total_amount': total_amount
        })
    if pdf:
        response = HttpResponse(pdf, content_type='application/pdf')
        filename = "Quotation_Supplier_%s.pdf" % ("123")
        content = "inline; filename='%s'" % (filename)
        response['Content-Disposition'] = content
        return response
    return HttpResponse("Not found")