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
|
|
@ -3,7 +3,7 @@ class Admin::OrdergroupsController < Admin::BaseController
|
|||
inherit_resources
|
||||
|
||||
def index
|
||||
@ordergroups = Ordergroup.order('name ASC')
|
||||
@ordergroups = Ordergroup.undeleted.order('name ASC')
|
||||
|
||||
# if somebody uses the search field:
|
||||
unless params[:query].blank?
|
||||
|
|
@ -15,7 +15,7 @@ class Admin::OrdergroupsController < Admin::BaseController
|
|||
|
||||
def destroy
|
||||
@ordergroup = Ordergroup.find(params[:id])
|
||||
@ordergroup.destroy
|
||||
@ordergroup.mark_as_deleted
|
||||
redirect_to admin_ordergroups_url, notice: t('admin.ordergroups.destroy.notice')
|
||||
rescue => error
|
||||
redirect_to admin_ordergroups_url, alert: t('admin.ordergroups.destroy.error')
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class ArticlesController < ApplicationController
|
|||
sort = "article_categories.name, articles.name"
|
||||
end
|
||||
|
||||
@articles = Article.where(supplier_id: @supplier, :type => nil).includes(:article_category).order(sort)
|
||||
@articles = Article.undeleted.where(supplier_id: @supplier, :type => nil).includes(:article_category).order(sort)
|
||||
@articles = @articles.where('articles.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@articles = @articles.page(params[:page]).per(@per_page)
|
||||
|
|
@ -64,13 +64,13 @@ class ArticlesController < ApplicationController
|
|||
# Deletes article from database. send error msg, if article is used in a current order
|
||||
def destroy
|
||||
@article = Article.find(params[:id])
|
||||
@article.destroy unless @order = @article.in_open_order # If article is in an active Order, the Order will be returned
|
||||
@article.mark_as_deleted unless @order = @article.in_open_order # If article is in an active Order, the Order will be returned
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
# Renders a form for editing all articles from a supplier
|
||||
def edit_all
|
||||
@articles = @supplier.articles
|
||||
@articles = @supplier.articles.undeleted
|
||||
end
|
||||
|
||||
# Updates all article of specific supplier
|
||||
|
|
@ -92,7 +92,7 @@ class ArticlesController < ApplicationController
|
|||
end
|
||||
# delete articles
|
||||
if params[:outlisted_articles]
|
||||
params[:outlisted_articles].keys.each {|id| Article.find(id).destroy }
|
||||
params[:outlisted_articles].keys.each {|id| Article.find(id).mark_as_deleted }
|
||||
end
|
||||
end
|
||||
# Successfully done.
|
||||
|
|
@ -114,23 +114,24 @@ class ArticlesController < ApplicationController
|
|||
def update_selected
|
||||
raise 'Du hast keine Artikel ausgewählt' if params[:selected_articles].nil?
|
||||
articles = Article.find(params[:selected_articles])
|
||||
|
||||
case params[:selected_action]
|
||||
when 'destroy'
|
||||
articles.each {|a| a.destroy }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden gelöscht'
|
||||
when 'setNotAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, false) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
|
||||
when 'setAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, true) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
|
||||
else
|
||||
flash[:alert] = 'Keine Aktion ausgewählt!'
|
||||
Article.transaction do
|
||||
case params[:selected_action]
|
||||
when 'destroy'
|
||||
articles.each(&:mark_as_deleted)
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden gelöscht'
|
||||
when 'setNotAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, false) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
|
||||
when 'setAvailable'
|
||||
articles.each {|a| a.update_attribute(:availability, true) }
|
||||
flash[:notice] = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
|
||||
else
|
||||
flash[:alert] = 'Keine Aktion ausgewählt!'
|
||||
end
|
||||
end
|
||||
# action succeded
|
||||
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page])
|
||||
|
||||
|
||||
rescue => error
|
||||
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page]),
|
||||
:alert => "Ein Fehler ist aufgetreten: #{error}"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class Finance::OrderArticlesController < ApplicationController
|
|||
@order = Order.find(params[:order_id])
|
||||
@order_article = OrderArticle.find(params[:id])
|
||||
begin
|
||||
@order_article.update_article_and_price!(params[:article], params[:article_price], params[:order_article])
|
||||
@order_article.update_article_and_price!(params[:order_article], params[:article], params[:article_price])
|
||||
rescue
|
||||
render action: :edit
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Finance::OrdergroupsController < Finance::BaseController
|
|||
sort = "name"
|
||||
end
|
||||
|
||||
@ordergroups = Ordergroup.order(sort)
|
||||
@ordergroups = Ordergroup.undeleted.order(sort)
|
||||
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class Foodcoop::OrdergroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@ordergroups = Ordergroup.order('name DESC')
|
||||
@ordergroups = Ordergroup.undeleted.order('name DESC')
|
||||
|
||||
unless params[:name].blank? # Search by name
|
||||
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:name]}%")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class StockitController < ApplicationController
|
||||
|
||||
def index
|
||||
@stock_articles = StockArticle.includes(:supplier, :article_category).
|
||||
@stock_articles = StockArticle.undeleted.includes(:supplier, :article_category).
|
||||
order('suppliers.name, article_categories.name, articles.name')
|
||||
end
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ class StockitController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@article = StockArticle.find(params[:id])
|
||||
@article.destroy
|
||||
@article.mark_as_deleted
|
||||
render :layout => false
|
||||
rescue => error
|
||||
render :partial => "destroy_fail", :layout => false,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class SuppliersController < ApplicationController
|
|||
helper :deliveries
|
||||
|
||||
def index
|
||||
@suppliers = Supplier.order(:name)
|
||||
@suppliers = Supplier.undeleted.order(:name)
|
||||
@deliveries = Delivery.recent
|
||||
end
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class SuppliersController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@supplier = Supplier.find(params[:id])
|
||||
@supplier.destroy
|
||||
@supplier.mark_as_deleted
|
||||
flash[:notice] = I18n.t('suppliers.destroy.notice')
|
||||
redirect_to suppliers_path
|
||||
rescue => e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue