Initial commit of foodsoft 2

This commit is contained in:
Benjamin Meichsner 2009-01-06 11:49:19 +01:00
commit 5b9a7e05df
657 changed files with 70444 additions and 0 deletions

View file

@ -0,0 +1,72 @@
= error_messages_for 'order'
.single_column
.box_title
%h2=_ "Order"
.column_content
= hidden_field 'order', 'supplier_id'
%p
=h _("Supplier") + ": #{@order.supplier.name}"
%p
%label{:for => 'order_name'}=_ "Name"
%br/
= text_field 'order', 'name'
%p
%label{:for => 'order_note'}=_ "Note"
%br/
= text_area 'order', 'note', :cols => 50, :rows => 5
%p
%label{:for => 'order_starts'}=_ "Start"
%br/
= datetime_select 'order', 'starts', :start_year => Time.now.year - 1
%p
%label{:for => 'order_ends'}=_ "End"
%br/
= datetime_select 'order', 'ends', :start_year => Time.now.year - 1, :include_blank => true
.box_title
%h2=_ "Articles"
.column_content
- if (@template_orders && !@template_orders.empty?)
%p
%label{:for => 'template'}=_ "Use article selection from"
%select{:name => "template_id", :onchange => "useTemplate(this[this.selectedIndex].value)"}
%option{:value => "-1", :selected => "selected"}=_ "Choose an order..."
- i = -1
- for order in @template_orders
%option{:value => (i += 1)}=h order.name
%table.list
%tr
%th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
%th=_ "Name"
%th=_ "Note"
%th=_ "Origin"
%th=_ "Manufacturer"
%th=_ "Unit quantity"
%th=_ "Price"
- for category, articles in Article.group_by_category(@order.supplier.getArticlesAvailableForOrdering)
%tr{:style => "background-color:#EFEFEF"}
%td
%td{:colspan => "6", :style => "text-align:left"}
%b=h category
- for article in articles
/ check if the article is selected
- included = @order.order_articles.detect { |order_article| order_article.article_id == article.id }
%tr{:class => cycle('even', 'odd') + (included ? ' selected' : ''), :id => article.id.to_s, :onclick => "checkRow('#{article.id}')"}
%td= check_box_tag "order[article_ids][]", article.id.to_s, included, { :id => "checkbox_#{article.id}", :onclick => "checkRow('#{article.id}')" }
%td=h article.name
%td=h truncate article.note, 25
%td=h truncate article.origin, 15
%td=h truncate article.manufacturer, 15
%td= "#{article.unit_quantity} x #{article.unit}"
%td= "#{number_to_currency(article.net_price)} / #{number_to_currency(article.gross_price)}"
%tr
%td{:colspan => "6"}
= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
=_ "Select all"
- if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script'

View file

@ -0,0 +1,22 @@
= pagination_links_remote @orders, @per_page, {:sort => params[:sort]}
%table.list{:style => "width: 100%"}
%thead
%tr
%th=_ "Name"
%th[sort_td_class_helper "supplier"]
= sort_link_helper _("Supplier"), "supplier"
%th=_ "Start"
%th[sort_td_class_helper "ends"]
= sort_link_helper _("End"), "ends"
%th=_ "Status"
%th{:colspan => "2"}
%tbody
- @orders.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'orders') + ((!order.finished? and order.ends < Time.now) ? " active" : "")}
%td= link_to order.name, :action => "show", :id => order
%td=h order.supplier ? order.supplier.name : _("nonexistent")
%td=h format_time(order.starts)
%td=h format_time(order.ends)
%td= order.status == _("expired") ? link_to( _("finish now") + (" !!"), {:action => 'finish', :id => order}, :confirm => _("Are you really sure to finish the order?"), :method => "post") : order.status
%td= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => _('Edit')), :action => 'edit', :id => order) unless order.finished?
%td= link_to image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => _("Destroy")), { :action => 'destroy', :id => order }, :confirm => _("Are you really sure you want to destroy the order?"), :method => "post"

View file

@ -0,0 +1,30 @@
<table class="list">
<thead>
<tr>
<th><acronym title="Bestellnummer">Nr.</acronym></th>
<th><acronym title="Gebinde insgesamt">Menge</acronym></th>
<th>Artikel</th>
<th><acronym title="Gebindegröße">GebGr</acronym></th>
<th>Einheit</th>
<th>Notiz</th>
<th><acronym title="Bruttopreis inkl. MwSt, Aufschlag, Pfand">Preis</acronym></th>
<th>MwSt</th>
<th>Pfand</th>
</tr>
</thead>
<tbody>
<% for article in @order_articles %>
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>">
<td><%=h article.order_number %></td>
<td><%=h article.units_to_order %></td>
<td><%=h article.name %></td>
<td><%=h article.unit_quantity %></td>
<td><%=h article.unit %></td>
<td><%=h article.note %></td>
<td><%= number_to_currency(article.gross_price) %></td>
<td><%=h article.tax %></td>
<td><%=h article.deposit %></td>
</tr>
<% end %>
</tbody>
</table>

View file

@ -0,0 +1,31 @@
<div class="legend">
<table style="margin-bottom:1em" class="legend">
<tr>
<th colspan="3">Legende</th>
</tr>
<tr>
<td style="width:70%">Bestellgruppe</td>
<td>Menge</td>
<td>Gesamtpreis</td>
</tr>
</table>
</div>
<% for article in @order_articles %>
<table style="margin-bottom:1em">
<thead>
<tr>
<th colspan="3"><%= article.name %> (<%= article.unit %> | <%= article.unit_quantity %> | <%= number_to_currency(article.gross_price) %>)</th>
</tr>
</thead>
<tbody>
<% for result in article.group_order_article_results %>
<tr class="<%= cycle('even', 'odd', :name => 'groups') %>">
<td style="width:70%"><%=h result.group_order_result.group_name %></td>
<td><%=h result.quantity %> (<%=h result.tolerance %>)</td>
<td><%= number_to_currency(article.gross_price * result.quantity) %></td>
</tr>
<% end %>
</tbody>
</table>
<%- reset_cycle("groups") -%>
<% end %>

View file

@ -0,0 +1,45 @@
<div class="legend">
<table style="margin-bottom:1em" class="legend">
<tr>
<th style="width:40%">Name</th>
<th><acronym title="zugeteilte Einheiten (davon aus Toleranzmenge)">Menge</acronym></th>
<th><acronym title="Bruttopreis incl. MwSt, Aufschlag, Pfand">Preis</acronym></th>
<th><acronym title="Gebindegröße">GebGr</acronym></th>
<th>Einheit</th>
<th>Gesamtpreis</th>
</tr>
</table>
</div>
<% for groupOrderResult in @order.group_order_results %>
<table style="margin-bottom:1em">
<thead>
<tr>
<th colspan="6"><%=h groupOrderResult.group_name %></th>
</tr>
</thead>
<tbody>
<%
total = 0
for result in groupOrderResult.group_order_article_results
price = result.order_article_result.gross_price
quantity = result.quantity
subTotal = price * quantity
total += subTotal
%>
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>">
<td style="width:40%"><%=h result.order_article_result.name %></td>
<td><%=h quantity %> (<%=h result.tolerance %>)</td>
<td><%= number_to_currency(price) %></td>
<td><%=h result.order_article_result.unit_quantity %></td>
<td><%=h result.order_article_result.unit %></td>
<td><%= number_to_currency(subTotal) %></td>
</tr>
<% end %>
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>">
<th colspan="5">Summe</th>
<th><%= number_to_currency(total) %></th>
</tr>
</tbody>
</table>
<%- reset_cycle("articles") -%>
<% end %>

View file

@ -0,0 +1,33 @@
%table
%tr
%th=_ "Name"
%th=_ "Unit quantity"
%th=_ "Price"
%th=_ "Units ordered"
%th=_ "Result/Unit quantity"
- totalNetto, totalBrutto, counter = 0, 0, 0
- @order_articles.each do |category, order_articles|
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left; color: grey;"}=h category
%td{:colspan => "9"}
- order_articles.each do |order_article|
- nettoPrice = order_article.article.net_price
- bruttoPrice = order_article.article.gross_price
- units = order_article.units_to_order
- unitQuantity = order_article.article.unit_quantity
- totalNetto += units * unitQuantity * nettoPrice
- totalBrutto += units * unitQuantity * bruttoPrice
- counter += 1 if units > 0
%tr{:class => cycle('even', 'odd', :name => 'articles'), :style => "color: #{units > 0 ? 'green' : 'red'}"}
%td=h order_article.article.name
%td= "#{unitQuantity} x #{order_article.article.unit}"
%td= "#{number_to_currency(nettoPrice)} / #{number_to_currency(bruttoPrice)}"
%td= "#{order_article.quantity} + #{order_article.tolerance}" if unitQuantity > 1
%td= units
%p
=_ "Total value"
=_ "(net/gross)"
= "#{number_to_currency(totalNetto)} / #{number_to_currency(totalBrutto)}"
%p
=_ "Ordered articles:"
= counter

View file

@ -0,0 +1,18 @@
<script type="text/javascript">
//<![CDATA[
// Preset selected order articles per template order:
var template = new Array();
<% i = -1; for order in @template_orders -%>
template[<%= i += 1 %>] = new Array(<%= @order.supplier.getArticlesAvailableForOrdering.collect{|a| !order.order_article_results.detect{|t| t.name == a.name }.nil?}.join(', ') %>);
<% end -%>
// Call with index into template-array to select order articles from template.
function useTemplate(id) {
if (id >= 0 && id < template.length) {
<% i = -1; for article in @order.supplier.getArticlesAvailableForOrdering -%>
var status = template[id][<%= i += 1 %>]
$('checkbox_<%= article.id %>').checked = status;
highlightRow('<%= article.id %>',status);
<% end -%>}
}
//]]>
</script>

View file

@ -0,0 +1,50 @@
<%
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(FoodSoft.getFoodcoopName)
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 %>

View file

@ -0,0 +1,7 @@
- title _("Edit order")
- form_tag :action => 'update', :id => @order do
= render :partial => 'form'
= submit_tag _("Save")
|
= link_to _("Cancel"), :action => 'show', :id => @order

View file

@ -0,0 +1,78 @@
<%
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(FoodSoft.getFoodcoopName))
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(FoodSoft.getFoodcoopName),0,0,'R')
pdf.Ln()
pdf.Cell(0,5,replace_UTF8(FoodSoft.getFoodcoopContact[:street]),0,0,'R')
pdf.Ln()
pdf.Cell(0,5,FoodSoft.getFoodcoopContact[:zip_code] + " " + replace_UTF8(FoodSoft.getFoodcoopContact[:city]),0,0,'R')
pdf.Ln()
pdf.Cell(0,5,replace_UTF8(FoodSoft.getFoodcoopName[:phone]),0,0,'R')
pdf.Ln()
pdf.Cell(0,5,replace_UTF8(FoodSoft.getFoodcoopName[: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 %>

View file

@ -0,0 +1,84 @@
<%
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(FoodSoft.getFoodcoopName)
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 %>

View file

@ -0,0 +1,41 @@
- title _("Manage orders")
- if @current_user.role_orders?
%p
- form_tag do
=_ "New Order"
=_ "for"
%select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"}
%option{:selected => 'selected'}=_ "Choose a supplier..."
= options_for_select(Supplier.find(:all).collect {|s| [ s.name, url_for(:action => "new", :id => s)] })
%br/
.left_column{:style => "width:55em"}
.box_title
%h2=_ "Running orders"
.column_content
- if (@current_orders.length > 0)
%table.list
%thead
%tr
%th=_ "Name"
%th=_ "Supplier"
%th=_ "End"
%th{:colspan => "2"}
%tbody
- for order in @current_orders
%tr{:class => cycle('even', 'odd', :name => 'current_orders')}
%td= link_to order.name, :controller => 'orders', :action => 'show', :id => order
%td=h order.supplier.name
%td=h format_time(order.ends) unless order.ends.nil?
%td= link_to _("finish"), {:action => 'finish', :id => order}, :confirm => _("Are you really sure to finish the order?"), :method => "post"
%td
= link_to image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => _("Edit")), :action => 'edit', :id => order
= link_to image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => _("Destroy")), { :action => 'destroy', :id => order }, :confirm => _("Are you really sure you want to destroy the order?"), :method => "post"
- else
=_ "There aren't current orders at the moment."
.left_column{:style => "width:75em"}
.box_title
%h2=_ "Expired/finished orders"
.column_content#orders_table
= render :partial => 'list'

View file

@ -0,0 +1,145 @@
<%
# 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(FoodSoft.getFoodcoopName)
@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 %>

View file

@ -0,0 +1,7 @@
- title _("New order")
- form_tag :action => 'create' do
= render :partial => 'form'
= submit_tag _("Put the order online")
|
= link_to _("Cancel"), :action => 'index'

View file

@ -0,0 +1,90 @@
- title _("Show order")
#element_navigation
= link_to_unless @order.previous == @order, _("Previous order"), :action => "show", :id => @order.previous
|
= link_to _("Overview"), :controller => 'orders'
|
= link_to_unless @order.next == @order, _("Next order"), :action => "show", :id => @order.next
// Order summary
.left_column{:style => "width:55em"}
.box_title
%h2=_ "Summary"
.column_content
- if !@order.booked? and @finished
%p
%b{:style => "color:red"}=_ "Order isn't balanced yet"
%p
= _("Name") + ":"
%b=h @order.name
|
= _("Supplier") + ":"
%b=h @order.supplier ? @order.supplier.name : _('nonexistent')
- unless @order.note.empty?
%p
= _("Note") + ":"
=h @order.note
%p
= _("Begin") + ":"
%b=h format_time(@order.starts)
|
= _("End") + ":"
%b=h format_time(@order.ends)
%p
= _("Groups ordered") + ":"
%b= @group_orders.size
- unless @finished
= "[#{@group_orders.collect{|g| g.order_group.name}.join(', ')}]" unless @group_orders.empty?
- else
= "[#{@group_orders.collect{|g| g.group_name}.join(', ')}]" unless @group_orders.empty?
%p
=_ "Total price"
%b= number_to_currency(@order.sumPrice('gross'))
- if @order.finished
|
=_ "Ordered articles:"
%b= @order_articles.size
- unless @finished
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Edit'), :action => 'edit', :id => @order)
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Delete'), { :action => 'destroy', :id => @order }, :confirm => "Willst du wirklich die Bestellung '#{@order.name}' löschen?", :method => "post")
= link_to('[beenden]', {:action => 'finish', :id => @order}, :confirm => "Willst du wirklich die Bestellung '#{@order.name}' beenden?", :method => "post")
- else
%p
= 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 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") }
|
=_ "Matrix" + ":"
= link_to image_tag("save_pdf.png", :size => "16x16", :border => "0", :alt => "PDF erstellen"), { :action => 'matrixPdf', :id => @order }, { :title => _("Download file") }
|
=_ "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("text_file.png", :size => "16x16", :border => "0", :alt => "Textdatei erstellen"), { :action => 'text_fax_template', :id => @order }, { :title => _("Download file") }
|
= link_to 'Kommentare', '#comments'
// Ordered articles
.single_column{:style => "clear:both; width:70em;"}
.box_title
%h2=_ "Articles"
.column_content#result
- unless @finished
= render :partial => "show_unfinished"
- else
= render :partial => "showResult"
// comments
- if @finished
.single_column{:style => "width:70em;"}
.box_title
%h2=_ "Comments"
.column_content#comments
= render :partial => "/shared/comments"
%p
= link_to_remote "neuer Kommentar", :url => {:action => 'newComment', :id => @order}
#newComment
= link_to_top