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(); } 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 { .dl-horizontal {
dt { width: 150px; } dt { width: 160px; }
dd { margin-left: 160px; } dd { margin-left: 170px; }
} }

View file

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

View file

@ -15,7 +15,7 @@ class Ordergroup < Group
has_many :group_orders has_many :group_orders
has_many :orders, :through => :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 validate :uniqueness_of_members
after_create :update_stats! after_create :update_stats!
@ -103,7 +103,7 @@ class Ordergroup < Group
# Make sure, that a user can only be in one ordergroup # Make sure, that a user can only be in one ordergroup
def uniqueness_of_members def uniqueness_of_members
users.each do |user| 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
end end

View file

@ -1,4 +1,4 @@
- title "Ordergroups" - title t('.title')
%table %table
%tr %tr
%th Type %th Type
@ -43,4 +43,4 @@
%td= h ordergroup.contact_person %td= h ordergroup.contact_person
%td= h ordergroup.contact_phone %td= h ordergroup.contact_phone
%td= h ordergroup.contact_address %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 %table.table.table-hover
%thead %thead
%tr %tr
%th Name %th= t '.name'
%th Gebinde %th= t '.unit_quantity'
%th Netto-/Bruttopreis %th= t '.prices'
%th Bestellte Einheiten %th= t '.units_ordered'
- unless order.stockit? - unless order.stockit?
%th Volle Gebinde %th= t '.units_full'
- total_net, total_gross, counter = 0, 0, 0 - total_net, total_gross, counter = 0, 0, 0
%tbody %tbody
- order.articles_grouped_by_category.each do |category_name, order_articles| - 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= "#{order_article.quantity} + #{order_article.tolerance}" if unit_quantity > 1
%td= units %td= units
%p %p
Summe (Netto/Brutto-Preise): = t '.prices_sum'
= "#{number_to_currency(total_net)} / #{number_to_currency(total_gross)}" = "#{number_to_currency(total_net)} / #{number_to_currency(total_gross)}"
%p %p
Bestellte Artikel. = t '.article_count'
= order.order_articles.ordered.count = order.order_articles.ordered.count

View file

@ -4,22 +4,22 @@
= f.input :starts, input_html: {class: 'input-small'} = f.input :starts, input_html: {class: 'input-small'}
= f.input :ends, input_html: {class: 'input-small'} = f.input :ends, input_html: {class: 'input-small'}
%h2 Artikel %h2= t '.title'
- if @order.errors.has_key?(:articles) - if @order.errors.has_key?(:articles)
.alert.alert-error .alert.alert-error
= @order.errors.get(:articles).join(" ") = @order.errors.get(:articles).join(" ")
%table.table.table-hover#articleList %table.table.table-hover#articleList
%tr %tr
%th= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' } %th= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' }
%th Name %th= t '.name'
%th Notiz %th= t '.note'
- if @order.stockit? - if @order.stockit?
%th Verfügbar %th= t '.stockit'
- else - else
%th Herkunft %th= t '.origin'
%th Hersteller %th= t '.supplier'
%th Gebinde %th= t '.unit_quantity'
%th Preis (netto/FC) %th= t '.prices'
- for category_name, articles in @order.articles_for_ordering - for category_name, articles in @order.articles_for_ordering
%tr.article-category %tr.article-category
%td %td
@ -44,11 +44,11 @@
%tr %tr
%td %td
= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' } = 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?) - if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script' = render :partial => 'template_orders_script'
.form-actions .form-actions
= f.submit class: 'btn' = 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 %table.table.table-striped
%thead %thead
%tr %tr
%th= sort_link_helper "Lieferantin", "supplier" %th= sort_link_helper t('.supplier'), "supplier"
%th Start %th= t '.start'
%th= sort_link_helper "Ende", "ends" %th= sort_link_helper t('.ending'), "ends"
%th Status %th= t '.status'
%th{:colspan => "2"} %th{:colspan => "2"}
%tbody %tbody
- @orders.each do |order| - @orders.each do |order|
@ -14,4 +14,4 @@
%td= format_time(order.starts) %td= format_time(order.starts)
%td= format_time(order.ends) %td= format_time(order.ends)
%td= t(order.state, scope: 'orders.state') %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' = render :partial => 'form'

View file

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

View file

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

View file

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

View file

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