finish ordergroups and orders i18n + controller

This commit is contained in:
wvengen 2013-02-08 01:52:20 +01:00
parent d818ea5d53
commit e06524ca37
14 changed files with 185 additions and 84 deletions

View file

@ -204,9 +204,9 @@ tr.unavailable {
dd { .clearfix(); }
}
// need more space for supplier information (in German, at least)
// need more space for supplier&order information (in German, at least)
.dl-horizontal {
dt { width: 150px; }
dd { margin-left: 160px; }
dt { width: 160px; }
dd { margin-left: 170px; }
}

View file

@ -62,7 +62,7 @@ class OrdersController < ApplicationController
@order = Order.new(params[:order])
@order.created_by = current_user
if @order.save
flash[:notice] = "Die Bestellung wurde erstellt."
flash[:notice] = I18n.t('orders.create.notice')
redirect_to @order
else
logger.debug "[debug] order errors: #{@order.errors.messages}"
@ -80,7 +80,7 @@ class OrdersController < ApplicationController
def update
@order = Order.find params[:id]
if @order.update_attributes params[:order]
flash[:notice] = "Die Bestellung wurde aktualisiert."
flash[:notice] = I18n.t('orders.update.notice')
redirect_to :action => 'show', :id => @order
else
render :action => 'edit'
@ -97,7 +97,7 @@ class OrdersController < ApplicationController
def finish
order = Order.find(params[:id])
order.finish!(@current_user)
redirect_to order, notice: "Die Bestellung wurde beendet."
redirect_to order, notice: I18n.t('order.finish.notice')
end
# Renders the fax-text-file
@ -106,14 +106,14 @@ class OrdersController < ApplicationController
order = Order.find(params[:id])
supplier = order.supplier
contact = FoodsoftConfig[:contact].symbolize_keys
text = "Bestellung für" + " #{FoodsoftConfig[:name]}"
text += "\n" + "Kundennummer" + ": #{supplier.customer_number}" unless supplier.customer_number.blank?
text += "\n" + "Liefertag" + ": "
text += "\n\n#{supplier.name}\n#{supplier.address}\nFAX: #{supplier.fax}\n\n"
text += "****** " + "Versandadresse" + "\n\n"
text = I18n.t('orders.fax.heading', :name => FoodsoftConfig[:name])
text += "\n" + I18n.t('orders.fax.customer_number') + ': #{supplier.customer_number}' unless supplier.customer_number.blank?
text += "\n" + I18n.t('orders.fax.delivery_day')
text += "\n\n#{supplier.name}\n#{supplier.address}\n" + I18n.t('simple_form.suppliers.labels.fax') + ": #{supplier.fax}\n\n"
text += "****** " + I18n.t('orders.fax.to_address') + "\n\n"
text += "#{FoodsoftConfig[:name]}\n#{contact[:street]}\n#{contact[:zip_code]} #{contact[:city]}\n\n"
text += "****** " + "Artikel" + "\n\n"
text += "Nummer" + " " + "Menge" + " " + "Name" + "\n"
text += "****** " + I18n.t('orders.fax.articles') + "\n\n"
text += I18n.t('.nummer') + " " + I18n.t('.amount') + " " + I18n.t('.name') + "\n"
# now display all ordered articles
order.order_articles.ordered.all(:include => [:article, :article_price]).each do |oa|
number = oa.article.order_number

View file

@ -15,7 +15,7 @@ class Ordergroup < Group
has_many :group_orders
has_many :orders, :through => :group_orders
validates_numericality_of :account_balance, :message => 'ist keine gültige Zahl'
validates_numericality_of :account_balance, :message => I18n.t('ordergroups.model.invalid_balance')
validate :uniqueness_of_members
after_create :update_stats!
@ -103,7 +103,7 @@ class Ordergroup < Group
# Make sure, that a user can only be in one ordergroup
def uniqueness_of_members
users.each do |user|
errors.add :user_tokens, "#{user.nick} ist schon in einer anderen Bestellgruppe" if user.groups.where(:type => 'Ordergroup').size > 1
errors.add :user_tokens, I18n.t('ordergroups.model.error_single_group', :user => user.nick) if user.groups.where(:type => 'Ordergroup').size > 1
end
end

View file

@ -1,4 +1,4 @@
- title "Ordergroups"
- title t('.title')
%table
%tr
%th Type
@ -43,4 +43,4 @@
%td= h ordergroup.contact_person
%td= h ordergroup.contact_phone
%td= h ordergroup.contact_address
%td= link_to "Edit", edit_ordergroup_path(ordergroup)
%td= link_to t('ui.edit'), edit_ordergroup_path(ordergroup)

View file

@ -1,12 +1,12 @@
%table.table.table-hover
%thead
%tr
%th Name
%th Gebinde
%th Netto-/Bruttopreis
%th Bestellte Einheiten
%th= t '.name'
%th= t '.unit_quantity'
%th= t '.prices'
%th= t '.units_ordered'
- unless order.stockit?
%th Volle Gebinde
%th= t '.units_full'
- total_net, total_gross, counter = 0, 0, 0
%tbody
- order.articles_grouped_by_category.each do |category_name, order_articles|
@ -32,8 +32,8 @@
%td= "#{order_article.quantity} + #{order_article.tolerance}" if unit_quantity > 1
%td= units
%p
Summe (Netto/Brutto-Preise):
= t '.prices_sum'
= "#{number_to_currency(total_net)} / #{number_to_currency(total_gross)}"
%p
Bestellte Artikel.
= t '.article_count'
= order.order_articles.ordered.count

View file

@ -4,22 +4,22 @@
= f.input :starts, input_html: {class: 'input-small'}
= f.input :ends, input_html: {class: 'input-small'}
%h2 Artikel
%h2= t '.title'
- if @order.errors.has_key?(:articles)
.alert.alert-error
= @order.errors.get(:articles).join(" ")
%table.table.table-hover#articleList
%tr
%th= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' }
%th Name
%th Notiz
%th= t '.name'
%th= t '.note'
- if @order.stockit?
%th Verfügbar
%th= t '.stockit'
- else
%th Herkunft
%th Hersteller
%th Gebinde
%th Preis (netto/FC)
%th= t '.origin'
%th= t '.supplier'
%th= t '.unit_quantity'
%th= t '.prices'
- for category_name, articles in @order.articles_for_ordering
%tr.article-category
%td
@ -44,11 +44,11 @@
%tr
%td
= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' }
%td{:colspan => "6"} Alle auswählen
%td{:colspan => "6"}= t '.select_all'
- if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script'
.form-actions
= f.submit class: 'btn'
= link_to "oder abbrechen", orders_path
= link_to t('.cancel'), orders_path

View file

@ -2,10 +2,10 @@
%table.table.table-striped
%thead
%tr
%th= sort_link_helper "Lieferantin", "supplier"
%th Start
%th= sort_link_helper "Ende", "ends"
%th Status
%th= sort_link_helper t('.supplier'), "supplier"
%th= t '.start'
%th= sort_link_helper t('.ending'), "ends"
%th= t '.status'
%th{:colspan => "2"}
%tbody
- @orders.each do |order|
@ -14,4 +14,4 @@
%td= format_time(order.starts)
%td= format_time(order.ends)
%td= t(order.state, scope: 'orders.state')
%td= link_to "Anzeigen", order, class: 'btn btn-small'
%td= link_to t('ui.show'), order, class: 'btn btn-small'

View file

@ -1,3 +1,3 @@
- title "Bestellung bearbeiten"
- title t('.title')
= render :partial => 'form'

View file

@ -1,23 +1,23 @@
- title "Bestellungen verwalten"
- title t('.title')
- content_for :actionbar do
.btn-group
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn btn-primary dropdown-toggle' do
Neue Bestellung anlegen
= t '.new_order'
%span.caret
%ul.dropdown-menu
- Supplier.all.each do |supplier|
%li= link_to supplier.name, new_order_path(supplier_id: supplier.id), tabindex: -1
.well
%h2 Laufende Bestellungen
%h2= t '.open_orders'
- unless @open_orders.empty?
%table.table.table-striped
%thead
%tr
%th Lieferantin
%th Ende
%th Notiz
%th= t '.supplier'
%th= t '.ending'
%th= t '.note'
%th{colspan: "2"}
%tbody
- for order in @open_orders
@ -26,18 +26,18 @@
%td= order.name
%td= format_time(order.ends) unless order.ends.nil?
%td= truncate(order.note)
%td= link_to "Beenden", finish_order_path(order),
confirm: "Willst Du wirklich die Bestellung \"#{order.name}\" beenden? Es gibt kein zurück.",
method: :post, class: 'btn btn-small btn-success'
%td= link_to t('.action_end'), finish_order_path(order),
confirm: t('.confirm_end', order: order.name), method: :post,
class: 'btn btn-small btn-success'
%td
= link_to "Anzeigen", order, class: 'btn btn-small'
= link_to "Bearbeiten", edit_order_path(order), class: 'btn btn-small'
= link_to "Löschen", order, confirm: "Willst Du wirklich die Bestellung löschen?", method: :delete,
= link_to t('ui.show'), order, class: 'btn btn-small'
= link_to t('ui.edit'), edit_order_path(order), class: 'btn btn-small'
= link_to t('ui.delete'), order, confirm: t('.confirm_delete'), method: :delete,
class: 'btn btn-small btn-danger'
- else
Derzeit gibt es keine laufende Bestellungen.
= t '.no_open_orders'
%h2 Beendete Bestellungen
%h2= t '.ended_orders'
#orders_table
= render partial: 'orders'

View file

@ -1,3 +1,3 @@
- title "Neue Bestellung anlegen"
- title t('.title')
= render 'form'

View file

@ -1,60 +1,61 @@
- title "Bestellung: #{@order.name}"
- title t('.title', name: @order.name)
- if @order.finished? and !@order.closed?
.alert.alert-warning Achtung, Bestellung wurde noch nicht abgerechnet.
.alert.alert-warning
= t '.warn_not_closed'
// Order summary
.well
%dl.dl-horizontal
%dt Lieferantin
%dt= t '.supplier'
%dd= @order.name
- if @note.present?
%dt Notiz
%dt= t '.note'
%dd= @order.note
%dt Erstellt von
%dt= t '.created_by'
%dd= link_to_user_message_if_valid(@order.created_by)
%dt Beginn
%dt= t '.begin'
%dd= format_time(@order.starts)
%dt Ende
%dt= t '.ending'
%dd= format_time(@order.ends)
%dt Gruppenbestellungen:
%dt= t '.group_orders'
%dd #{@order.group_orders.count} (#{@order.group_orders.includes(:ordergroup).all.map {|g| g.ordergroup.name}.join(', ')})
%dt Netto/Bruttosumme aller Artikel:
%dt= t '.amounts'
%dd= "#{number_to_currency(@order.sum(:net))} / #{number_to_currency(@order.sum(:gross))}"
%dt Bestellte Artikel:
%dt= t '.articles_ordered'
%dd= @order.order_articles.ordered.count
.form-actions
- if @order.open?
= link_to "Bearbeiten", edit_order_path(@order), class: 'btn'
= link_to 'Beenden!', finish_order_path(@order), method: :post, class: 'btn btn-success',
confirm: "Willst Du wirklich die Bestellung beenden?\nEs gibt kein zurück.."
= link_to t('ui.edit'), edit_order_path(@order), class: 'btn'
= link_to t('.action_end'), finish_order_path(@order), method: :post, class: 'btn btn-success',
confirm: t('.confirm_end')
- unless @order.closed?
= link_to "Löschen", @order, confirm: "Willst du wirklich die Bestellung löschen?", method: :delete,
= link_to t('ui.delete'), @order, confirm: t('.confirm_delete'), method: :delete,
class: 'btn btn-danger'
- unless @order.open?
%ul.nav.nav-pills
%li= update_articles_link(@order, "Artikelübersicht", :default)
%li= update_articles_link(@order, "Sortiert nach Gruppen", :groups)
%li= update_articles_link(@order, "Sortiert nach Artikeln", :articles)
%li= link_to 'Kommentare', '#comments'
%li= update_articles_link(@order, t('.articles'), :default)
%li= update_articles_link(@order, t('.sort_group'), :groups)
%li= update_articles_link(@order, t('.sort_article'), :articles)
%li= link_to t('.comments_link'), '#comments'
%li.dropdown
= link_to '#', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do
Download
= t '.download.title'
%b.caret
%ul.dropdown-menu
%li= order_pdf(@order, :groups, "Gruppenpdf")
%li= order_pdf(@order, :articles, "Artikelpdf")
%li= order_pdf(@order, :matrix, "Matrix")
%li= order_pdf(@order, :fax, "Fax PDF")
%li= link_to "Fax Text", {action: 'text_fax_template', id: @order }, {title: "Download file"}
%li= order_pdf(@order, :groups, t('.group_pdf'))
%li= order_pdf(@order, :articles, t('.article_pdf'))
%li= order_pdf(@order, :matrix, t('.matrix_pdf'))
%li= order_pdf(@order, :fax, t('.fax_pdf'))
%li= link_to t('.fax_txt'), {action: 'text_fax_template', id: @order }, {title: t('.download_file')}
%section#articles_table
= render 'articles', order: @order
%h2 Kommentare
%h2= t '.comments.title'
#comments
= render partial: 'shared/comments', locals: { comments: @order.comments }
#new_comment= render partial: 'order_comments/form', locals: { order_comment: @order.comments.build(user: current_user)}

View file

@ -272,6 +272,7 @@ de:
close: 'Schließen'
edit: 'Bearbeiten'
delete: 'Löschen'
show: 'Anzeigen'
marks:
close: 'x'

View file

@ -0,0 +1,12 @@
de:
ordergroups:
index:
title: 'Bestellgruppen'
edit:
title: 'Bestellgruppe bearbeiten'
submit: 'Bearbeiten'
# used by model
model:
invalid_balance: 'ist keine gültige Zahl'
error_single_group: '%{user} ist schon in einer anderen Bestellgruppe'

View file

@ -0,0 +1,87 @@
de:
orders:
articles:
name: 'Name'
unit_quantity: 'Gebinde'
prices: 'Netto-/Bruttopreis'
units_ordered: 'Bestellte Einheiten'
units_full: 'Volle Gebinde'
prices_sum: 'Summe (Netto/Brutto-Preise):'
article_count: 'Bestellte Artikel:'
edit:
title: 'Bestellung bearbeiten'
new:
title: 'Neue Bestellung anlegen'
form:
title: 'Artikel'
name: 'Name'
note: 'Notiz'
stockit: 'Verfügbar'
origin: 'Herkunft'
supplier: 'Hersteller'
unit_quantity: 'Gebinde'
prices: 'Price (netto/FC)'
select_all: 'Alle auswählen'
cancel: 'oder abbrechen'
index:
title: 'Bestellungen verwalten'
new_order: 'Neue Bestellung anlegen'
open_orders: 'Laufende Bestellungen'
supplier: 'Lieferantin'
ending: 'Ende'
note: 'Notiz'
action_end: 'Beenden'
confirm_end: 'Willst Du wirklich die Bestellung %{order} beenden? Es gibt kein zurück.'
confirm_delete: 'Willst Du wirklich die Bestellung löschen?'
no_open_orders: 'Derzeit gibt es keine laufende Bestellungen.'
ended_orders: 'Beendete Bestellungen'
orders:
supplier: 'Lieferantin'
start: 'Start'
ending: 'Ende'
status: 'Status'
show:
title: 'Bestellung: %{name}'
warn_not_closed: 'Achtung, Bestellung wurde noch nicht abgerechnet.'
supplier: 'Lieferantin:'
note: 'Notiz:'
created_by: 'Erstellt von:'
begin: 'Beginn:'
ending: 'Ende:'
group_orders: 'Gruppenbestellungen:'
amounts: 'Netto/Bruttosumme:'
articles_ordered: 'Bestellte Artikel:'
action_end: 'Beenden!'
confirm_end: "Willst Du wirklich die Bestellung %{order} beenden?\nEs gibt kein zurück."
confirm_delete: 'Willst Du wirklich die Bestellung löschen?'
articles: 'Artikelübersicht'
sort_group: 'Sortiert nach Gruppen'
sort_article: 'Sortiert nach Artikeln'
comments_link: 'Kommentare'
download:
title: 'Download'
group_pdf: 'Gruppen PDF'
article_pdf: 'Artikel PDF'
matrix_pdf: 'Matrix PDF'
fax_pdf: 'Fax PDF'
fax_txt: 'Fax Text'
download_file: 'Download file'
comments:
title: 'Kommentare'
# used by controller
create:
notice: 'Die Bestellung wurde erstellt.'
update:
notice: 'Die Bestellung wurde aktualisiert.'
finish:
notice: 'Die Bestellung wurde beendet.'
fax:
heading: 'Bestellung für %{name}'
customer_number: 'Kundennummer'
delivery_day: 'Liefertag'
to_address: 'Versandaddresse'
articles: 'Artikel'
number: 'Nummer'
amount: 'Menge'
name: 'Name'