diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 4b41a16e..f270b932 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -152,7 +152,12 @@ class OrdersController < ApplicationController # Renders the matrix PDF. def matrixPdf @order = Order.find(params[:id]) - prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf" + unless @order.order_articles.ordered.empty? + prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf" + else + flash[:error] = "Es sind keine Artikel bestellt worden." + redirect_to @order + end end # adds a Comment to the Order diff --git a/app/views/orders/matrixPdf.pdf.prawn b/app/views/orders/matrixPdf.pdf.prawn index 121d44dd..8b5d2bd4 100644 --- a/app/views/orders/matrixPdf.pdf.prawn +++ b/app/views/orders/matrixPdf.pdf.prawn @@ -6,6 +6,7 @@ pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] do end pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do pdf.stroke_horizontal_rule + pdf.move_down 2 pdf.text "Seite #{pdf.page_count}", :size => 8 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 # get the Ordergroup result for this order_article 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 groups_data << group_result end