Refactored stockit, delivery an stock_takings.
This commit is contained in:
parent
d4715fef4b
commit
fc1d130113
20 changed files with 145 additions and 296 deletions
|
|
@ -92,11 +92,7 @@ class DeliveriesController < ApplicationController
|
|||
end
|
||||
|
||||
def add_stock_change
|
||||
|
||||
render :update do |page|
|
||||
page.insert_html :bottom, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => StockChange.new, :supplier => @supplier}
|
||||
end
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def fill_new_stock_article_form
|
||||
|
|
|
|||
|
|
@ -1,76 +1,17 @@
|
|||
class StockTakingsController < ApplicationController
|
||||
|
||||
def index
|
||||
@stock_takings = StockTaking.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @stock_takings }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @stock_taking }
|
||||
end
|
||||
end
|
||||
inherit_resources
|
||||
|
||||
def new
|
||||
@stock_taking = StockTaking.new
|
||||
StockArticle.without_deleted.each { |a| @stock_taking.stock_changes.build(:stock_article => a) }
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @stock_taking }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
StockArticle.all.each { |a| @stock_taking.stock_changes.build(:stock_article => a) }
|
||||
end
|
||||
|
||||
def create
|
||||
@stock_taking = StockTaking.new(params[:stock_taking])
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_taking.save
|
||||
flash[:notice] = 'StockTaking was successfully created.'
|
||||
format.html { redirect_to(@stock_taking) }
|
||||
format.xml { render :xml => @stock_taking, :status => :created, :location => @stock_taking }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @stock_taking.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
create!(:notice => "Inventur wurde erfolgreich angelegt.")
|
||||
end
|
||||
|
||||
def update
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_taking.update_attributes(params[:stock_taking])
|
||||
flash[:notice] = 'StockTaking was successfully updated.'
|
||||
format.html { redirect_to(@stock_taking) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @stock_taking.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@stock_taking = StockTaking.find(params[:id])
|
||||
@stock_taking.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(stock_takings_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
update!(:notice => "Inventur wurde aktualisiert.")
|
||||
end
|
||||
|
||||
def fill_new_stock_article_form
|
||||
|
|
|
|||
|
|
@ -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