Merge remote-tracking branch 'bennibu/rails3' into rails3
Conflicts: app/controllers/admin/ordergroups_controller.rb app/controllers/finance/balancing_controller.rb app/controllers/suppliers_controller.rb app/views/articles/_article.html.haml app/views/finance/balancing/_summary.haml app/views/finance/balancing/new.html.haml app/views/group_orders/_form.html.haml app/views/home/_apple_bar.html.haml app/views/suppliers/index.haml
This commit is contained in:
commit
7af796c09c
47 changed files with 325 additions and 240 deletions
|
|
@ -10,28 +10,30 @@ class Finance::BalancingController < Finance::BaseController
|
|||
flash.now.alert = t('finance.balancing.new.alert') if @order.closed?
|
||||
@comments = @order.comments
|
||||
|
||||
if params['sort']
|
||||
sort = case params['sort']
|
||||
when "name" then "articles.name"
|
||||
when "order_number" then "articles.order_number"
|
||||
when "name_reverse" then "articles.name DESC"
|
||||
when "order_number_reverse" then "articles.order_number DESC"
|
||||
end
|
||||
else
|
||||
sort = "id"
|
||||
end
|
||||
@articles = @order.order_articles.ordered.includes(:article, :article_price,
|
||||
group_order_articles: {group_order: :ordergroup})
|
||||
|
||||
@articles = @order.order_articles.ordered.includes(:article).order(sort)
|
||||
|
||||
if params[:sort] == "order_number"
|
||||
@articles = @articles.to_a.sort { |a,b| a.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> b.article.order_number.gsub(/[^[:digit:]]/, "").to_i }
|
||||
elsif params[:sort] == "order_number_reverse"
|
||||
@articles = @articles.to_a.sort { |a,b| b.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> a.article.order_number.gsub(/[^[:digit:]]/, "").to_i }
|
||||
end
|
||||
sort_param = params['sort'] || 'name'
|
||||
@articles = case sort_param
|
||||
when 'name' then
|
||||
OrderArticle.sort_by_name(@articles)
|
||||
when 'name_reverse' then
|
||||
OrderArticle.sort_by_name(@articles).reverse
|
||||
when 'order_number' then
|
||||
OrderArticle.sort_by_order_number(@articles)
|
||||
when 'order_number_reverse' then
|
||||
OrderArticle.sort_by_order_number(@articles).reverse
|
||||
else
|
||||
@articles
|
||||
end
|
||||
|
||||
render layout: false if request.xhr?
|
||||
end
|
||||
|
||||
def update_summary
|
||||
@order = Order.find(params[:id])
|
||||
end
|
||||
|
||||
def edit_note
|
||||
@order = Order.find(params[:id])
|
||||
render :layout => false
|
||||
|
|
@ -55,7 +57,7 @@ class Finance::BalancingController < Finance::BaseController
|
|||
def close
|
||||
@order = Order.find(params[:id])
|
||||
@order.close!(@current_user)
|
||||
redirect_to finance_root_url, notice: t('finance.balancing.close.notice')
|
||||
redirect_to finance_order_index_url, notice: t('finance.balancing.close.notice')
|
||||
|
||||
rescue => error
|
||||
redirect_to new_finance_order_url(order_id: @order.id), alert: t('finance.balancing.close.alert', message: error.message)
|
||||
|
|
@ -65,9 +67,9 @@ class Finance::BalancingController < Finance::BaseController
|
|||
def close_direct
|
||||
@order = Order.find(params[:id])
|
||||
@order.close_direct!(@current_user)
|
||||
redirect_to finance_balancing_url, notice: t('finance.balancing.close_direct.notice')
|
||||
redirect_to finance_order_index_url, notice: t('finance.balancing.close_direct.notice')
|
||||
rescue => error
|
||||
redirect_to finance_balancing_url, alert: t('finance.balancing.close_direct.alert', message: error.message)
|
||||
redirect_to finance_order_index_url, alert: t('finance.balancing.close_direct.alert', message: error.message)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue