Replaced rfpdf with prawn and prawnto. Start to convert pdf-views.

This commit is contained in:
Benjamin Meichsner 2009-01-07 15:29:23 +01:00
parent da309f03b0
commit a6c7b04e33
165 changed files with 723 additions and 28123 deletions

View file

@ -7,6 +7,7 @@ class OrdersController < ApplicationController
# Define layout exceptions for PDF actions:
layout "application", :except => [:faxPdf, :matrixPdf, :articlesPdf, :groupsPdf]
prawnto :prawn => { :page_size => 'A4' }
# List orders
def index
@ -117,15 +118,28 @@ class OrdersController < ApplicationController
# Renders the articles-orderd PDF.
def articlesPdf
@order = Order.find(params[:id])
@options_for_rfpdf ||= {}
@options_for_rfpdf[:file_name] = "#{Date.today}_#{@order.name}_ArtikelSortierung.pdf"
prawnto :filename => "#{Date.today}_#{@order.name}_ArtikelSortierung.pdf",
:prawn => { :left_margin => 48,
:right_margin => 48,
:top_margin => 48,
:bottom_margin => 48 }
# @options_for_rfpdf ||= {}
# @options_for_rfpdf[:file_name] = "#{Date.today}_#{@order.name}_ArtikelSortierung.pdf"
# send_data PdfGenerator.order_articles(@order),
# :filename => "#{Date.today}_#{@order.name}_ArtikelSortierung.pdf",
# :type => 'application/pdf', :disposition => 'inline'
end
# Renders the fax PDF.
def faxPdf
@order = Order.find(params[:id])
@options_for_rfpdf ||= {}
@options_for_rfpdf[:file_name] = "#{Date.today}_#{@order.name}_FAX.pdf"
# @options_for_rfpdf ||= {}
# @options_for_rfpdf[:file_name] = "#{Date.today}_#{@order.name}_FAX.pdf"
send_data PdfGenerator.order_fax(@order),
:filename => "#{Date.today}_#{@order.name}_FAX.pdf",
:type => 'application/pdf', :disposition => 'inline'
end
# Renders the fax-text-file

View file

@ -0,0 +1,38 @@
# Get ActiveRecord objects
order_articles = @order.order_article_results
end_date = @order.ends.strftime('%d.%m.%Y')
title = "#{@order.name} | beendet am #{end_date}"
# Define header and footer
pdf.header [pdf.margin_box.left,pdf.margin_box.top+30] do
pdf.text title, :size => 10, :align => :center
end
pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
pdf.stroke_horizontal_rule
pdf.text "Seite #{pdf.page_count}", :size => 8
end
# Start rendering
pdf.table [["Bestellgruppe", "Menge", "Preis"]],
:font_size => 8,
:font_style => :italic,
:widths => { 0 => 200, 1 => 40, 2 => 40 }
pdf.move_down 10
for article in order_articles
pdf.text "#{article.name} (#{article.unit} | #{article.unit_quantity.to_s} | #{number_to_currency(article.gross_price)})",
:style => :bold, :size => 10
pdf.move_down 5
data = []
for result in article.group_order_article_results
data << [result.group_order_result.group_name,
result.quantity,
article.gross_price * result.quantity]
end
pdf.table data,
:font_size => 8,
:widths => { 0 => 200, 1 => 40, 2 => 40 },
:border_style => :grid
pdf.move_down 10
end

View file

@ -56,7 +56,7 @@
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'groupsPdf', :id => @order }, { :title => _("Download file") }
|
= link_to_remote _("Sort by articles"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'articles'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'articlesPdf', :id => @order }, { :title => _("Download file") }
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'articlesPdf', :id => @order, :format => :pdf}, { :title => _("Download file") }
|
=_ "Matrix" + ":"
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'matrixPdf', :id => @order }, { :title => _("Download file") }