From 6761a41048e196ad978dfa7513527cdb71433359 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Tue, 4 Aug 2009 13:35:52 +0200 Subject: [PATCH] Hide articles with a stock amount of zero. Closes #17 --- app/controllers/stockit_controller.rb | 15 +++++++++++---- app/views/stockit/index.html.haml | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/stockit_controller.rb b/app/controllers/stockit_controller.rb index cd8220fb..0f9840a2 100644 --- a/app/controllers/stockit_controller.rb +++ b/app/controllers/stockit_controller.rb @@ -1,10 +1,17 @@ class StockitController < ApplicationController def index - @stock_articles = StockArticle.without_deleted.all( - :include => [:supplier, :article_category], - :order => 'suppliers.name, article_categories.name, articles.name' - ) + unless params[:show_not_available] == "1" + @stock_articles = StockArticle.without_deleted.available.all( + :include => [:supplier, :article_category], + :order => 'suppliers.name, article_categories.name, articles.name' + ) + else + @stock_articles = StockArticle.without_deleted.all( + :include => [:supplier, :article_category], + :order => 'suppliers.name, article_categories.name, articles.name' + ) + end end def new diff --git a/app/views/stockit/index.html.haml b/app/views/stockit/index.html.haml index c28fe097..ac15034b 100644 --- a/app/views/stockit/index.html.haml +++ b/app/views/stockit/index.html.haml @@ -20,6 +20,11 @@ %b= link_to "Inventur anlegen", new_stock_taking_path | = link_to "Inventurübersicht", stock_takings_path + | + - unless params[:show_not_available] == "1" + = link_to "Zeige auch nicht verfügbare Lagerartikel", stock_articles_path(:show_not_available => 1) + - else + = link_to "Verstecke nicht verfügbare Artikel", stock_articles_path #articles{:style => "clear:both;margin-top:1em"} %table.list