Hide zero results in matrix pdf.

This commit is contained in:
Benjamin Meichsner 2009-04-03 23:32:24 +02:00
parent de1aa2ac38
commit d62d45e4a4
2 changed files with 8 additions and 2 deletions

View file

@ -152,7 +152,12 @@ class OrdersController < ApplicationController
# Renders the matrix PDF. # Renders the matrix PDF.
def matrixPdf def matrixPdf
@order = Order.find(params[:id]) @order = Order.find(params[:id])
unless @order.order_articles.ordered.empty?
prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf" prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf"
else
flash[:error] = "Es sind keine Artikel bestellt worden."
redirect_to @order
end
end end
# adds a Comment to the Order # adds a Comment to the Order

View file

@ -6,6 +6,7 @@ pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do
end end
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
pdf.stroke_horizontal_rule pdf.stroke_horizontal_rule
pdf.move_down 2
pdf.text "Seite #{pdf.page_count}", :size => 8 pdf.text "Seite #{pdf.page_count}", :size => 8
end end
@ -62,7 +63,7 @@ while (page_number * max_order_articles_per_page < total_num_order_articles) do
for order_article in current_order_articles for order_article in current_order_articles
# get the Ordergroup result for this order_article # get the Ordergroup result for this order_article
goa = order_article.group_order_articles.first :conditions => { :group_order_id => group_order.id } goa = order_article.group_order_articles.first :conditions => { :group_order_id => group_order.id }
group_result << ((goa.nil? || goa == 0) ? "" : goa.result.to_i) group_result << ((goa.nil? || goa.result == 0) ? "" : goa.result.to_i)
end end
groups_data << group_result groups_data << group_result
end end