예제 #1
0
def monthly(request,template_name="reports/report.html"):
    postdata = request.POST.copy()
    form = ReportForm()
    date = postdata.get('date',)
    resp = HttpResponse(mimetype='application/pdf')
    orders = Order.objects.filter(date = date)
    report = ReportOrders(queryset=orders)
    try:
        report.generate_by(PDFGenerator, filename=resp)
        return resp
    except EmptyQueryset, e:
        print e
예제 #2
0
def report(request,template_name="reports/report.html"):
    if request.method == 'POST':
        form = ReportForm(request.POST)
        if form.is_valid():
            resp = HttpResponse(mimetype='application/pdf')
            date = form.data['date']
            orders = Order.objects.filter(date = date)
            report = ReportOrders(queryset=orders)
            try:
                report.generate_by(PDFGenerator, filename=resp)
                return resp
            except EmptyQueryset, e:
                print e