2012-04-16 08:48:01 +02:00
|
|
|
# encoding: utf-8
|
2009-01-08 16:33:27 +01:00
|
|
|
class DeliveriesController < ApplicationController
|
|
|
|
|
2009-02-10 20:06:08 +01:00
|
|
|
before_filter :find_supplier, :exclude => :fill_new_stock_article_form
|
|
|
|
|
2009-01-08 16:33:27 +01:00
|
|
|
def index
|
2014-02-20 15:04:53 +01:00
|
|
|
@deliveries = @supplier.deliveries.order('delivered_on DESC')
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@delivery = Delivery.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@delivery = @supplier.deliveries.build
|
2013-06-26 15:16:52 +02:00
|
|
|
@delivery.delivered_on = Date.today #TODO: move to model/database
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@delivery = Delivery.new(params[:delivery])
|
2013-06-13 23:33:24 +02:00
|
|
|
|
|
|
|
if @delivery.save
|
|
|
|
flash[:notice] = I18n.t('deliveries.create.notice')
|
|
|
|
redirect_to [@supplier, @delivery]
|
|
|
|
else
|
|
|
|
render :action => "new"
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-02-06 16:26:35 +01:00
|
|
|
def edit
|
|
|
|
@delivery = Delivery.find(params[:id])
|
|
|
|
end
|
|
|
|
|
2009-01-08 16:33:27 +01:00
|
|
|
def update
|
|
|
|
@delivery = Delivery.find(params[:id])
|
|
|
|
|
2013-06-13 23:33:24 +02:00
|
|
|
if @delivery.update_attributes(params[:delivery])
|
|
|
|
flash[:notice] = I18n.t('deliveries.update.notice')
|
|
|
|
redirect_to [@supplier,@delivery]
|
|
|
|
else
|
|
|
|
render :action => "edit"
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@delivery = Delivery.find(params[:id])
|
|
|
|
@delivery.destroy
|
|
|
|
|
2013-04-10 17:02:16 +02:00
|
|
|
flash[:notice] = I18n.t('deliveries.destroy.notice')
|
2013-06-13 23:33:24 +02:00
|
|
|
redirect_to supplier_deliveries_url(@supplier)
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|
2013-07-07 14:14:32 +02:00
|
|
|
|
2013-12-07 16:42:25 +01:00
|
|
|
def add_stock_change
|
|
|
|
@stock_change = StockChange.new
|
|
|
|
@stock_change.stock_article = StockArticle.find(params[:stock_article_id])
|
2013-07-07 14:14:32 +02:00
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
2013-12-07 16:42:25 +01:00
|
|
|
def form_on_stock_article_create # See publish/subscribe design pattern in /doc.
|
|
|
|
@stock_article = StockArticle.find(params[:id])
|
2013-06-13 23:33:24 +02:00
|
|
|
|
2013-06-11 13:10:18 +02:00
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
2013-12-07 16:42:25 +01:00
|
|
|
def form_on_stock_article_update # See publish/subscribe design pattern in /doc.
|
|
|
|
@stock_article = StockArticle.find(params[:id])
|
2013-06-13 23:33:24 +02:00
|
|
|
|
|
|
|
render :layout => false
|
2009-02-10 20:06:08 +01:00
|
|
|
end
|
2013-06-13 23:33:24 +02:00
|
|
|
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|