Refactored stockit, delivery an stock_takings.
This commit is contained in:
parent
d4715fef4b
commit
fc1d130113
20 changed files with 145 additions and 296 deletions
|
|
@ -1,10 +1,8 @@
|
|||
class StockitController < ApplicationController
|
||||
|
||||
def index
|
||||
@stock_articles = StockArticle.without_deleted.all(
|
||||
:include => [:supplier, :article_category],
|
||||
:order => 'suppliers.name, article_categories.name, articles.name'
|
||||
)
|
||||
@stock_articles = StockArticle.joins(:supplier, :article_category).
|
||||
order('suppliers.name, article_categories.name, articles.name')
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
@ -14,8 +12,7 @@ class StockitController < ApplicationController
|
|||
def create
|
||||
@stock_article = StockArticle.new(params[:stock_article])
|
||||
if @stock_article.save
|
||||
flash[:notice] = "Lagerartikel wurde gespeichert."
|
||||
redirect_to stock_articles_path
|
||||
redirect_to stock_articles_path, :notice => "Lagerartikel wurde gespeichert."
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
|
|
@ -28,8 +25,7 @@ class StockitController < ApplicationController
|
|||
def update
|
||||
@stock_article = StockArticle.find(params[:id])
|
||||
if @stock_article.update_attributes(params[:stock_article])
|
||||
flash[:notice] = "Lagerartikel wurde gespeichert."
|
||||
redirect_to stock_articles_path
|
||||
redirect_to stock_articles_path, :notice => "Lagerartikel wurde gespeichert."
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
|
|
@ -43,16 +39,10 @@ class StockitController < ApplicationController
|
|||
redirect_to stock_articles_path
|
||||
end
|
||||
|
||||
def auto_complete_for_article_name
|
||||
conditions = [ "LOWER(articles.name) LIKE ?", '%' + params[:article][:name].downcase + '%' ]
|
||||
|
||||
if params[:supplier_id]
|
||||
@supplier = Supplier.find(params[:supplier_id])
|
||||
@articles = @supplier.articles.without_deleted.all(:conditions => conditions, :limit => 8)
|
||||
else
|
||||
@articles = Article.without_deleted.not_in_stock.all(:conditions => conditions, :limit => 8)
|
||||
end
|
||||
render :partial => 'shared/auto_complete_articles'
|
||||
#TODO: Fix this!!
|
||||
def articles_search
|
||||
@articles = Article.not_in_stock.limit(8).where(:name.matches => params[:term])
|
||||
render :json => @articles.map(&:name)
|
||||
end
|
||||
|
||||
def fill_new_stock_article_form
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue