Finished pdf-replacement. Improved Matrix.
This commit is contained in:
parent
a6c7b04e33
commit
fb5884fbf6
10 changed files with 188 additions and 382 deletions
|
@ -111,8 +111,7 @@ class OrdersController < ApplicationController
|
||||||
# Renders the groups-orderd PDF.
|
# Renders the groups-orderd PDF.
|
||||||
def groupsPdf
|
def groupsPdf
|
||||||
@order = Order.find(params[:id])
|
@order = Order.find(params[:id])
|
||||||
@options_for_rfpdf ||= {}
|
prawnto :filename => "#{Date.today}_#{@order.name}_GruppenSortierung.pdf"
|
||||||
@options_for_rfpdf[:file_name] = "#{Date.today}_#{@order.name}_GruppenSortierung.pdf"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders the articles-orderd PDF.
|
# Renders the articles-orderd PDF.
|
||||||
|
@ -123,23 +122,12 @@ class OrdersController < ApplicationController
|
||||||
:right_margin => 48,
|
:right_margin => 48,
|
||||||
:top_margin => 48,
|
:top_margin => 48,
|
||||||
:bottom_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
|
end
|
||||||
|
|
||||||
# Renders the fax PDF.
|
# Renders the fax PDF.
|
||||||
def faxPdf
|
def faxPdf
|
||||||
@order = Order.find(params[:id])
|
@order = Order.find(params[:id])
|
||||||
# @options_for_rfpdf ||= {}
|
prawnto :filename => "#{Date.today}_#{@order.name}_FAX.pdf"
|
||||||
# @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
|
end
|
||||||
|
|
||||||
# Renders the fax-text-file
|
# Renders the fax-text-file
|
||||||
|
@ -171,8 +159,7 @@ 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])
|
||||||
@options_for_rfpdf ||= {}
|
prawnto :filename => "#{Date.today}_#{@order.name}_Matrix.pdf"
|
||||||
@options_for_rfpdf[:file_name] = "#{Date.today}_#{@order.name}_Matrix.pdf"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# sends a form for adding a new comment
|
# sends a form for adding a new comment
|
||||||
|
|
|
@ -13,11 +13,6 @@ pdf.footer [pdf.margin_box.left, pdf.margin_box.bottom-5] do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Start rendering
|
# 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
|
for article in order_articles
|
||||||
pdf.text "#{article.name} (#{article.unit} | #{article.unit_quantity.to_s} | #{number_to_currency(article.gross_price)})",
|
pdf.text "#{article.name} (#{article.unit} | #{article.unit_quantity.to_s} | #{number_to_currency(article.gross_price)})",
|
||||||
|
@ -32,7 +27,10 @@ for article in order_articles
|
||||||
|
|
||||||
pdf.table data,
|
pdf.table data,
|
||||||
:font_size => 8,
|
:font_size => 8,
|
||||||
|
:headers => ["Bestellgruppe", "Menge", "Preis"],
|
||||||
:widths => { 0 => 200, 1 => 40, 2 => 40 },
|
:widths => { 0 => 200, 1 => 40, 2 => 40 },
|
||||||
:border_style => :grid
|
:border_style => :grid,
|
||||||
|
:row_colors => ['ffffff','ececec'],
|
||||||
|
:vertical_padding => 3
|
||||||
pdf.move_down 10
|
pdf.move_down 10
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<%
|
|
||||||
class PDF < FPDF
|
|
||||||
def Header
|
|
||||||
SetFont('Arial', 'B', 13)
|
|
||||||
Cell(80)
|
|
||||||
Cell(30, 8, @title, 0, 0, 'C')
|
|
||||||
Ln(20)
|
|
||||||
end
|
|
||||||
def Footer
|
|
||||||
SetY(-15)
|
|
||||||
SetFont('Arial', 'I', 8)
|
|
||||||
Cell(0, 8, 'Seite ' + PageNo().to_s + ' | ' + @title + ' | powered by FoodSoft', 0, 0, 'C')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pdf=PDF.new
|
|
||||||
|
|
||||||
@order_articles = @order.order_article_results
|
|
||||||
@starts = @order.starts.strftime('%d.%m.%Y').to_s
|
|
||||||
@ends = @order.ends.strftime('%d.%m.%Y').to_s
|
|
||||||
@title = replace_UTF8(@order.name.to_s) + " | beendet am " + @ends
|
|
||||||
|
|
||||||
pdf.SetAuthor(APP_CONFIG[:name])
|
|
||||||
pdf.SetTitle(replace_UTF8("Artikelsortierung für #{@order.name}, #{format_date(@order.ends)}"))
|
|
||||||
pdf.AliasNbPages()
|
|
||||||
pdf.AddPage()
|
|
||||||
|
|
||||||
# now the legend
|
|
||||||
pdf.SetFont('Arial','I',8)
|
|
||||||
pdf.Cell(80,6,'Bestellgruppe',1)
|
|
||||||
pdf.Cell(12,6,'Menge',1)
|
|
||||||
pdf.Cell(12,6,'Preis',1)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Ln()
|
|
||||||
|
|
||||||
#now the articles
|
|
||||||
for article in @order_articles
|
|
||||||
pdf.SetFont('Arial','B',10)
|
|
||||||
pdf.Cell(150,6,replace_UTF8("#{article.name} (#{article.unit} | #{article.unit_quantity.to_s} | #{number_to_currency(article.gross_price, :unit=> '')} EUR)"),0)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','',9)
|
|
||||||
for result in article.group_order_article_results
|
|
||||||
pdf.Cell(80,6,replace_UTF8(result.group_order_result.group_name),1)
|
|
||||||
pdf.Cell(12,6,result.quantity.to_s,1,0,'C')
|
|
||||||
pdf.Cell(12,6,number_to_currency(article.gross_price * result.quantity, :unit=> ''),1,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
end
|
|
||||||
pdf.Ln()
|
|
||||||
end
|
|
||||||
%><%= pdf.Output %>
|
|
52
app/views/orders/faxPdf.pdf.prawn
Normal file
52
app/views/orders/faxPdf.pdf.prawn
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Get ActiveRecord objects
|
||||||
|
contact = APP_CONFIG[:contact].symbolize_keys
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# From paragraph
|
||||||
|
pdf.bounding_box [pdf.margin_box.right-200,pdf.margin_box.top], :width => 200 do
|
||||||
|
pdf.text APP_CONFIG[:name], :align => :right
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text contact[:street], :align => :right
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text contact[:zip_code] + " " + contact[:city], :align => :right
|
||||||
|
pdf.move_down 10
|
||||||
|
pdf.text contact[:phone], :size => 9, :align => :right
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text contact[:email], :size => 9, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
# Recipient
|
||||||
|
pdf.bounding_box [pdf.margin_box.left,pdf.margin_box.top-60], :width => 200 do
|
||||||
|
pdf.text @order.supplier.name
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text @order.supplier.address
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text "Fax: " + @order.supplier.fax
|
||||||
|
end
|
||||||
|
|
||||||
|
pdf.text Date.today.strftime('%d.%m.%Y'), :align => :right
|
||||||
|
|
||||||
|
pdf.move_down 10
|
||||||
|
pdf.text "Lieferdatum:"
|
||||||
|
pdf.move_down 10
|
||||||
|
pdf.text "Ansprechpartner: " + @order.supplier.contact_person
|
||||||
|
pdf.move_down 10
|
||||||
|
|
||||||
|
# Articles
|
||||||
|
data = @order.order_article_results.collect do |a|
|
||||||
|
[a.order_number, a.units_to_order, a.name,
|
||||||
|
a.unit_quantity, a.unit, a.net_price]
|
||||||
|
end
|
||||||
|
pdf.table data,
|
||||||
|
:font_size => 8,
|
||||||
|
:vertical_padding => 3,
|
||||||
|
:border_style => :grid,
|
||||||
|
:headers => ["BestellNr.", "Menge","Name", "Gebinde", "Einheit","Preis/Einheit"]
|
|
@ -1,78 +0,0 @@
|
||||||
<%
|
|
||||||
class PDF < FPDF
|
|
||||||
def Footer
|
|
||||||
SetY(-15)
|
|
||||||
SetFont('Arial', 'I', 8)
|
|
||||||
Cell(0, 10, 'Seite ' + PageNo().to_s + ' | powered by FoodSoft', 0, 0, 'C')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pdf=PDF.new
|
|
||||||
|
|
||||||
@order_articles = @order.order_article_results
|
|
||||||
|
|
||||||
pdf.SetAuthor(replace_UTF8(APP_CONFIG[:name]))
|
|
||||||
pdf.SetTitle(replace_UTF8("BestellFAX für #{@order.supplier.name}"))
|
|
||||||
pdf.AliasNbPages()
|
|
||||||
pdf.AddPage()
|
|
||||||
|
|
||||||
#the main informations
|
|
||||||
pdf.SetY(15)
|
|
||||||
pdf.SetFont('Arial','',10)
|
|
||||||
pdf.Cell(0,5,replace_UTF8(APP_CONFIG[:name]),0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(0,5,replace_UTF8(APP_CONFIG[:contact].symbolize_keys[:street]),0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(0,5,APP_CONFIG[:contact].symbolize_keys[:zip_code] + " " + replace_UTF8(APP_CONFIG[:contact].symbolize_keys[:city]),0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(0,5,replace_UTF8(APP_CONFIG[:name][:phone]),0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(0,5,replace_UTF8(APP_CONFIG[:name][:email]),0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(0,5,Date.today.strftime('%d.%m.%Y').to_s,0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','B',10)
|
|
||||||
pdf.SetXY(10,30)
|
|
||||||
pdf.MultiCell(0,6,@order.supplier.name.to_s + "\r\n" + replace_UTF8(@order.supplier.address.to_s) + "\r\nFAX: " + @order.supplier.fax.to_s)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','B',10)
|
|
||||||
pdf.Cell(0,9,"Lieferdatum: ",0)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(0,5,"Ansprechpartner: " + @order.supplier.contact_person.to_s,0)
|
|
||||||
pdf.SetY(80)
|
|
||||||
|
|
||||||
#now the articles
|
|
||||||
pdf.SetFont('Arial','B',9)
|
|
||||||
pdf.Cell(16,6,'BestellNr.',1)
|
|
||||||
pdf.Cell(12,6,'Menge',1)
|
|
||||||
pdf.Cell(100,6,'Name',1)
|
|
||||||
#pdf.Cell(30,6,'Produktgruppe',1)
|
|
||||||
pdf.Cell(15,6,'Gebinde',1)
|
|
||||||
pdf.Cell(20,6,'Einheit',1)
|
|
||||||
pdf.Cell(22,6,'Preis/Einheit',1)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','',9)
|
|
||||||
|
|
||||||
for article in @order_articles
|
|
||||||
pdf.Cell(16,5,article.order_number.to_s,1)
|
|
||||||
pdf.Cell(12,5,article.units_to_order.to_s,1,0,'R')
|
|
||||||
pdf.Cell(100,5, replace_UTF8(article.name.to_s),1)
|
|
||||||
#pdf.Cell(30,5,,1)
|
|
||||||
pdf.Cell(15,5,article.unit_quantity.to_s,1,0,'R')
|
|
||||||
pdf.Cell(20,5,replace_UTF8(article.unit.to_s),1,0,'R')
|
|
||||||
pdf.Cell(22,5,number_to_currency(article.net_price, :unit=> "").to_s,1,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
end
|
|
||||||
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','B',10)
|
|
||||||
pdf.Cell(70,9,"Gesamtpreis (netto): ",0)
|
|
||||||
pdf.Cell(15,9,number_to_currency(@order.sumPrice('clear'), :unit=> "").to_s + " EUR",0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(70,9,"Gesamtpreis (brutto, incl. Pfand): ",0)
|
|
||||||
pdf.Cell(15,9,number_to_currency(@order.sumPrice('gross'), :unit=> "").to_s + " EUR",0,0,'R')
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','I',8)
|
|
||||||
pdf.MultiCell(0,4, replace_UTF8("Hinweise: \r\nGebinde und Einheit in der Tabelle beziehen sich auf interne Größen der Foodcoop und können von Ihren Gebinden bzw. Einheiten abweichen. \r\nDie Preise sind exklusive Mehrwertsteuer."))
|
|
||||||
|
|
||||||
%><%= pdf.Output %>
|
|
48
app/views/orders/groupsPdf.pdf.prawn
Normal file
48
app/views/orders/groupsPdf.pdf.prawn
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
end_date = @order.ends.strftime('%d.%m.%Y')
|
||||||
|
title = "Gruppensortierung für #{@order.name}, beendet am #{end_date}"
|
||||||
|
|
||||||
|
# Define header and footer
|
||||||
|
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] 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
|
||||||
|
groups = @order.group_order_results.size
|
||||||
|
counter = 1
|
||||||
|
for group_result in @order.group_order_results
|
||||||
|
pdf.text group_result.group_name, :style => :bold
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text "Gruppe #{counter.to_s}/#{groups.to_s}", :size => 8
|
||||||
|
pdf.move_down 5
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
data = []
|
||||||
|
group_result.group_order_article_results.each do |result|
|
||||||
|
price = result.order_article_result.gross_price
|
||||||
|
quantity = result.quantity
|
||||||
|
sub_total = price * quantity
|
||||||
|
total += sub_total
|
||||||
|
data << [result.order_article_result.name,
|
||||||
|
quantity, price,
|
||||||
|
result.order_article_result.unit_quantity,
|
||||||
|
result.order_article_result.unit,
|
||||||
|
sub_total]
|
||||||
|
end
|
||||||
|
data << [ {:text => "Summe", :colspan => 5}, total]
|
||||||
|
|
||||||
|
pdf.table data,
|
||||||
|
:font_size => 8,
|
||||||
|
:border_style => :grid,
|
||||||
|
:vertical_padding => 3,
|
||||||
|
:headers => ["Artikel", "Menge", "Preis", "GebGr", "Einheit", "Summe"],
|
||||||
|
:widths => { 0 => 250 },
|
||||||
|
:row_colors => ['ffffff','ececec']
|
||||||
|
|
||||||
|
counter += 1
|
||||||
|
pdf.move_down 10
|
||||||
|
end
|
|
@ -1,84 +0,0 @@
|
||||||
<%
|
|
||||||
class PDF < FPDF
|
|
||||||
def Header
|
|
||||||
SetFont('Arial', 'B', 13)
|
|
||||||
Cell(80)
|
|
||||||
Cell(30, 10, @title, 0, 0, 'C')
|
|
||||||
Ln(20)
|
|
||||||
end
|
|
||||||
def Footer
|
|
||||||
SetY(-15)
|
|
||||||
SetFont('Arial', 'I', 8)
|
|
||||||
Cell(0, 10, 'Seite ' + PageNo().to_s + ' | ' + @title + ' | powered by FoodSoft', 0, 0, 'C')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pdf=PDF.new
|
|
||||||
|
|
||||||
@starts = @order.starts.strftime('%d.%m.%Y').to_s
|
|
||||||
@ends = @order.ends.strftime('%d.%m.%Y').to_s
|
|
||||||
@title = replace_UTF8(@order.name.to_s) + " | beendet am " + @ends
|
|
||||||
|
|
||||||
pdf.SetAuthor(APP_CONFIG[:name])
|
|
||||||
pdf.SetTitle(replace_UTF8("GruppenSortierung für #{@order.name}, #{format_date(@order.ends)}"))
|
|
||||||
pdf.SetFillColor(235)
|
|
||||||
pdf.AliasNbPages()
|
|
||||||
pdf.AddPage()
|
|
||||||
|
|
||||||
groups = @order.group_order_results.size
|
|
||||||
counter = 1
|
|
||||||
#now the groups
|
|
||||||
for group_result in @order.group_order_results
|
|
||||||
pdf.SetFont('Arial','B',14)
|
|
||||||
pdf.Cell(160,6,replace_UTF8(group_result.group_name),0, 0, '')
|
|
||||||
pdf.SetFont('Arial','I',9)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(20,5,"Gruppe #{counter.to_s}/#{groups.to_s}",0, 0, '')
|
|
||||||
pdf.Ln()
|
|
||||||
# the legend
|
|
||||||
pdf.SetFont('Arial','I',8)
|
|
||||||
pdf.Cell(100,6,'Artikel',1)
|
|
||||||
pdf.Cell(12,6,'Menge',1)
|
|
||||||
pdf.Cell(12,6,'Preis',1)
|
|
||||||
pdf.Cell(12,6,'GebGr',1)
|
|
||||||
pdf.Cell(12,6,'Einheit',1)
|
|
||||||
pdf.Cell(12,6,'Summe',1)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','',9)
|
|
||||||
total = 0
|
|
||||||
|
|
||||||
index = 0 # used for row-highlighting
|
|
||||||
# and the ordered articles
|
|
||||||
for result in group_result.group_order_article_results
|
|
||||||
index += 1
|
|
||||||
|
|
||||||
# calculating the sum
|
|
||||||
price = result.order_article_result.gross_price
|
|
||||||
quantity = result.quantity
|
|
||||||
subTotal = price * quantity
|
|
||||||
total += subTotal
|
|
||||||
|
|
||||||
if index%2 == 0 # every second row gets a background color
|
|
||||||
pdf.Cell(100,6,replace_UTF8(result.order_article_result.name),1,0,'L',1)
|
|
||||||
pdf.Cell(12,6,quantity.to_s,1,0,'C',1)
|
|
||||||
pdf.Cell(12,6,number_to_currency(price, :unit=> ''),1,0,'R',1)
|
|
||||||
pdf.Cell(12,6,result.order_article_result.unit_quantity.to_s,1,0,'C',1)
|
|
||||||
pdf.Cell(12,6,result.order_article_result.unit,1,0,'C',1)
|
|
||||||
pdf.Cell(12,6,number_to_currency(subTotal, :unit=> ''),1,0,'R',1)
|
|
||||||
else
|
|
||||||
pdf.Cell(100,6,replace_UTF8(result.order_article_result.name),1,0,'L')
|
|
||||||
pdf.Cell(12,6,quantity.to_s,1,0,'C')
|
|
||||||
pdf.Cell(12,6,number_to_currency(price, :unit=> ''),1,0,'R')
|
|
||||||
pdf.Cell(12,6,result.order_article_result.unit_quantity.to_s,1,0,'C')
|
|
||||||
pdf.Cell(12,6,result.order_article_result.unit,1,0,'C')
|
|
||||||
pdf.Cell(12,6,number_to_currency(subTotal, :unit=> ''),1,0,'R')
|
|
||||||
end
|
|
||||||
pdf.Ln()
|
|
||||||
end
|
|
||||||
pdf.SetFont('Arial','B',10)
|
|
||||||
pdf.Cell(148,6,"Summe",1)
|
|
||||||
pdf.Cell(12,6,number_to_currency(total, :unit=> ''),1,0,'R')
|
|
||||||
pdf.AddPage()
|
|
||||||
counter += 1
|
|
||||||
end
|
|
||||||
%><%= pdf.Output %>
|
|
78
app/views/orders/matrixPdf.pdf.prawn
Normal file
78
app/views/orders/matrixPdf.pdf.prawn
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
title = "#{@order.name}, beendet am #{@order.ends.strftime('%d.%m.%Y')}"
|
||||||
|
|
||||||
|
# Define header and footer
|
||||||
|
pdf.header [pdf.margin_box.left,pdf.margin_box.top+20] 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
|
||||||
|
|
||||||
|
max_articles_per_page = 17 # How many articles shoud written on a page
|
||||||
|
articles = @order.order_article_results
|
||||||
|
|
||||||
|
pdf.text "Artikelübersicht", :style => :bold
|
||||||
|
pdf.move_down 5
|
||||||
|
pdf.text "Insgesamt #{articles.size} Artikel", :size => 8
|
||||||
|
pdf.move_down 10
|
||||||
|
|
||||||
|
articles_data = articles.collect do |a|
|
||||||
|
[a.name, a.unit, a.unit_quantity, a.gross_price, a.units_to_order]
|
||||||
|
end
|
||||||
|
pdf.table articles_data,
|
||||||
|
:font_size => 8,
|
||||||
|
:border_style => :grid,
|
||||||
|
:vertical_padding => 3,
|
||||||
|
:headers => ["Artikel", "Einheit", "Gebinde", "Preis", "Menge"]
|
||||||
|
|
||||||
|
|
||||||
|
page_number = 0
|
||||||
|
total_num_articles = articles.size
|
||||||
|
|
||||||
|
while (page_number * max_articles_per_page < total_num_articles) do # Start page generating
|
||||||
|
|
||||||
|
page_number += 1
|
||||||
|
pdf.start_new_page(:layout => :landscape)
|
||||||
|
|
||||||
|
# Collect articles for this page
|
||||||
|
current_articles = articles.select do |a|
|
||||||
|
articles.index(a) >= (page_number-1) * max_articles_per_page and
|
||||||
|
articles.index(a) < page_number * max_articles_per_page
|
||||||
|
end
|
||||||
|
|
||||||
|
# Make articles header
|
||||||
|
header = [""]
|
||||||
|
for header_article in current_articles
|
||||||
|
name = header_article.name.split("-").join(" ").split(".").join(". ").split("/").join(" ")
|
||||||
|
name = name.split.collect { |w| truncate(w, 8, "..") }.join(" ")
|
||||||
|
header << truncate(name, 30, " ..")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Collect group results
|
||||||
|
groups_data = []
|
||||||
|
for group_order_result in @order.group_order_results
|
||||||
|
|
||||||
|
group_result = [truncate(group_order_result.group_name, 20)]
|
||||||
|
|
||||||
|
for article in current_articles
|
||||||
|
# get the OrderGroupResult for this article
|
||||||
|
result = GroupOrderArticleResult.find(:first,
|
||||||
|
:conditions => ['order_article_result_id = ? AND group_order_result_id = ?', article.id, group_order_result.id])
|
||||||
|
group_result << ((result.nil? || result == 0) ? "" : result.quantity.to_i)
|
||||||
|
end
|
||||||
|
groups_data << group_result
|
||||||
|
end
|
||||||
|
|
||||||
|
# Make table
|
||||||
|
widths = { }
|
||||||
|
(max_articles_per_page + 1).times { |i| widths.merge!({ i => 40 }) unless i == 0 }
|
||||||
|
pdf.table groups_data,
|
||||||
|
:font_size => 8,
|
||||||
|
:border_style => :grid,
|
||||||
|
:vertical_padding => 3,
|
||||||
|
:headers => header,
|
||||||
|
:widths => widths,
|
||||||
|
:row_colors => ['ffffff','ececec']
|
||||||
|
|
||||||
|
end
|
|
@ -1,145 +0,0 @@
|
||||||
<%
|
|
||||||
# Use this class instead of FPDF when you need PDF header/footer.
|
|
||||||
# Used by template matrixPdf.rfpdf.
|
|
||||||
class PDF < FPDF
|
|
||||||
def Header
|
|
||||||
SetFont('Arial', 'B', 15)
|
|
||||||
Cell(80)
|
|
||||||
Cell(30, 10, @title, 0, 0, 'C')
|
|
||||||
Ln(20)
|
|
||||||
end
|
|
||||||
def Footer
|
|
||||||
SetY(-15)
|
|
||||||
SetFont('Arial', 'I', 8)
|
|
||||||
Cell(0, 10, 'Seite ' + PageNo().to_s + ' | ' + @title + ' | powered by FoodSoft', 0, 0, 'C')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
MAX_ARTICLES_PER_PAGE = 15 #how many articles shoud written on a page
|
|
||||||
|
|
||||||
pdf=PDF.new
|
|
||||||
pdf.SetAuthor(APP_CONFIG[:name])
|
|
||||||
@starts = @order.starts.strftime('%d.%m.%Y').to_s
|
|
||||||
@ends = @order.ends.strftime('%d.%m.%Y').to_s
|
|
||||||
@title = replace_UTF8(@order.name.to_s) + " | beendet am " + @ends
|
|
||||||
@order_articles = @order.order_article_results
|
|
||||||
|
|
||||||
pdf.SetTitle(@title)
|
|
||||||
pdf.SetFont('Arial','B',10)
|
|
||||||
pdf.SetFillColor(235)
|
|
||||||
pdf.AliasNbPages()
|
|
||||||
pdf.AddPage()
|
|
||||||
pdf.Cell(25,7,'Bestellstart: ',1)
|
|
||||||
pdf.Cell(40,7,@starts,1)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Cell(25,7,'Bestellende: ',1)
|
|
||||||
pdf.Cell(40,7,@ends,1)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.Ln()
|
|
||||||
|
|
||||||
#list all articles
|
|
||||||
total_num_articles = 0
|
|
||||||
index = 0
|
|
||||||
token = Array.new
|
|
||||||
|
|
||||||
pdf.SetFont('Arial','B',9)
|
|
||||||
pdf.Cell(10,6,'Index',1,0,'L',1)
|
|
||||||
pdf.Cell(20,6,replace_UTF8('Kürzel'),1,0,'L',1)
|
|
||||||
pdf.Cell(80,6,'Name',1,0,'L',1)
|
|
||||||
pdf.Cell(20,6,'Einheit',1,0,'L',1)
|
|
||||||
pdf.Cell(15,6,'Gebinde',1,0,'L',1)
|
|
||||||
pdf.Cell(10,6,'Preis',1,0,'L',1)
|
|
||||||
#pdf.Cell(30,6,'Produktgruppe',1,0,'L',1)
|
|
||||||
pdf.Cell(12,6,'Menge',1,0,'L',1)
|
|
||||||
pdf.Ln()
|
|
||||||
pdf.SetFont('Arial','',9)
|
|
||||||
|
|
||||||
for article in @order_articles
|
|
||||||
index += 1
|
|
||||||
# convert the name to correct UTF8
|
|
||||||
name = replace_UTF8(article.name.to_s)
|
|
||||||
if name.length > 11
|
|
||||||
token[index] = name[0..3] + '..' + name[-3..-1]
|
|
||||||
else
|
|
||||||
token[index] = name[0..6]
|
|
||||||
end
|
|
||||||
if index%2 == 0 # every second row gets a background color
|
|
||||||
pdf.Cell(10,6,index.to_s,1,0,'L',1)
|
|
||||||
pdf.Cell(20, 6, token[index],1,0,'L',1)
|
|
||||||
pdf.Cell(80, 6, name, 1,0,'L',1)
|
|
||||||
pdf.Cell(20, 6, replace_UTF8(article.unit.to_s), 1,0,'L',1)
|
|
||||||
pdf.Cell(15, 6, article.unit_quantity.to_s, 1,0,'L',1)
|
|
||||||
pdf.Cell(10, 6, number_to_currency(article.gross_price, :unit => "").to_s, 1,0,'L',1)
|
|
||||||
#pdf.Cell(30, 6, article.category.to_s, 1,0,'L',1)
|
|
||||||
pdf.Cell(12, 6, article.units_to_order.to_s, 1,0,'L',1)
|
|
||||||
else
|
|
||||||
pdf.Cell(10,6,index.to_s,1)
|
|
||||||
pdf.Cell(20, 6, token[index], 1)
|
|
||||||
pdf.Cell(80, 6, name, 1)
|
|
||||||
pdf.Cell(20, 6, replace_UTF8(article.unit.to_s), 1)
|
|
||||||
pdf.Cell(15, 6, article.unit_quantity.to_s, 1)
|
|
||||||
pdf.Cell(10, 6, number_to_currency(article.gross_price, :unit => "").to_s, 1)
|
|
||||||
#pdf.Cell(30, 6, article.category.to_s, 1)
|
|
||||||
pdf.Cell(12, 6, article.units_to_order.to_s, 1)
|
|
||||||
end
|
|
||||||
pdf.Ln()
|
|
||||||
total_num_articles += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
#****************** start with matrix
|
|
||||||
num_site = -1
|
|
||||||
|
|
||||||
while ((num_site + 1) * MAX_ARTICLES_PER_PAGE < total_num_articles) do # page generator
|
|
||||||
|
|
||||||
num_site += 1
|
|
||||||
|
|
||||||
pdf.AddPage('L') # 'L' means landscape
|
|
||||||
pdf.SetFont('Arial','',9)
|
|
||||||
pdf.Cell(40,5,'',1,0,'L',1)
|
|
||||||
|
|
||||||
# show tokens
|
|
||||||
articleNum = 0
|
|
||||||
j = 1
|
|
||||||
index.times do
|
|
||||||
articleNum += 1
|
|
||||||
#check, if the article should be written on the current page
|
|
||||||
if ( articleNum > (MAX_ARTICLES_PER_PAGE * num_site) && articleNum <= (MAX_ARTICLES_PER_PAGE * (num_site+1)))
|
|
||||||
pdf.Cell(16, 5, token[j], 1,0,'L',1)
|
|
||||||
end
|
|
||||||
j += 1
|
|
||||||
end
|
|
||||||
pdf.Ln()
|
|
||||||
|
|
||||||
group_index = 0
|
|
||||||
for group_order_result in @order.group_order_results
|
|
||||||
group_index += 1
|
|
||||||
pdf.SetFont('Arial','B',10) # make bold
|
|
||||||
group_index%2 == 0 ? pdf.Cell(40,5, replace_UTF8(group_order_result.group_name[0..20]),1,0,'L',1) : pdf.Cell(40,5, replace_UTF8(group_order_result.group_name[0..21]),1)
|
|
||||||
pdf.SetFont('Arial','',9)
|
|
||||||
|
|
||||||
# show quantity results
|
|
||||||
articleNum = 0
|
|
||||||
j = 1
|
|
||||||
for article in @order_articles
|
|
||||||
articleNum += 1
|
|
||||||
#check, if the article should be written on the current page
|
|
||||||
if ( articleNum > (MAX_ARTICLES_PER_PAGE * num_site) && articleNum <= (MAX_ARTICLES_PER_PAGE * (num_site+1)))
|
|
||||||
|
|
||||||
# get the OrderGroupResult for this article
|
|
||||||
groupResult = GroupOrderArticleResult.find(:first, :conditions => ['order_article_result_id = ? AND group_order_result_id = ?', article.id, group_order_result.id])
|
|
||||||
if group_index%2 == 0
|
|
||||||
groupResult ? pdf.Cell(8,5,groupResult.quantity.to_s,1,0,'L',1) : pdf.Cell(8, 5, '--', 1,0,'L',1)
|
|
||||||
pdf.Cell(8,5,"",1,0,'C',1)
|
|
||||||
else
|
|
||||||
groupResult ? pdf.Cell(8,5,groupResult.quantity.to_s,1) : pdf.Cell(8, 5, '--', 1)
|
|
||||||
pdf.Cell(8, 5, "", 1,0,'C')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
j += 1
|
|
||||||
end
|
|
||||||
pdf.Ln()
|
|
||||||
end
|
|
||||||
|
|
||||||
end # page generator
|
|
||||||
%>
|
|
||||||
<%= pdf.Output %>
|
|
|
@ -53,16 +53,16 @@
|
||||||
= link_to_remote _("All articles"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'normal'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
= link_to_remote _("All articles"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'normal'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
||||||
|
|
|
|
||||||
= link_to_remote _("Sort by groups"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'groups'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
= link_to_remote _("Sort by groups"), :update => 'result', :url => {:action => 'show', :id => @order, :view => 'groups'}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
|
||||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'groupsPdf', :id => @order }, { :title => _("Download file") }
|
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'groupsPdf', :id => @order, :format => :pdf }, { :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_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, :format => :pdf}, { :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" + ":"
|
=_ "Matrix" + ":"
|
||||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'matrixPdf', :id => @order }, { :title => _("Download file") }
|
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'matrixPdf', :id => @order, :format => :pdf }, { :title => _("Download file") }
|
||||||
|
|
|
|
||||||
=_ "FAX-template" + ":"
|
=_ "FAX-template" + ":"
|
||||||
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'faxPdf', :id => @order }, { :title => _("Download file") }
|
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'faxPdf', :id => @order, :format => :pdf }, { :title => _("Download file") }
|
||||||
= link_to image_tag("text_file.png", :size => "16x16", :border => "0", :alt => "Textdatei erstellen"), { :action => 'text_fax_template', :id => @order }, { :title => _("Download file") }
|
= link_to image_tag("text_file.png", :size => "16x16", :border => "0", :alt => "Textdatei erstellen"), { :action => 'text_fax_template', :id => @order }, { :title => _("Download file") }
|
||||||
|
|
|
|
||||||
= link_to 'Kommentare', '#comments'
|
= link_to 'Kommentare', '#comments'
|
||||||
|
|
Loading…
Reference in a new issue