Revert 099e2b9b06
This commit is contained in:
parent
8f15cfb446
commit
5dc3fc30ad
12 changed files with 33 additions and 215 deletions
|
@ -3,7 +3,6 @@ class StockitController < ApplicationController
|
|||
def index
|
||||
@stock_articles = StockArticle.includes(:supplier, :article_category).
|
||||
order('suppliers.name, article_categories.name, articles.name')
|
||||
@stock_article_selection = StockArticleSelection.new
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
# encoding: utf-8
|
||||
class StockitSelectionsController < ApplicationController
|
||||
|
||||
def index
|
||||
@stock_article_selections = StockArticleSelection.all
|
||||
end
|
||||
|
||||
def show
|
||||
@stock_article_selection = StockArticleSelection.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@stock_article_selection = StockArticleSelection.new(params[:stock_article_selection])
|
||||
@stock_article_selection.created_by = current_user
|
||||
|
||||
if @stock_article_selection.save
|
||||
redirect_to(@stock_article_selection, :notice => 'Löschvorschlag für gewählte Artikel wurde erstellt.')
|
||||
else
|
||||
@stock_articles = StockArticle.includes(:supplier, :article_category).
|
||||
order('suppliers.name, article_categories.name, articles.name')
|
||||
render 'stockit/index'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy # destroy (open or finished) selection without deleting articles
|
||||
stock_article_selection = StockArticleSelection.find(params[:id])
|
||||
stock_article_selection.destroy
|
||||
|
||||
redirect_to stock_article_selections_path, :notice => 'Löschvorschlag wurde verworfen.'
|
||||
end
|
||||
|
||||
def articles # destroy articles, finish selection
|
||||
stock_article_selection = StockArticleSelection.find(params[:id])
|
||||
|
||||
destroyed_articles_count = 0
|
||||
failed_articles_count = 0
|
||||
stock_article_selection.stock_articles.each do |article|
|
||||
begin
|
||||
article.destroy # article.delete would save some effort, but validations are important
|
||||
destroyed_articles_count += 1
|
||||
rescue => error # recover if article.destroy fails and continue with next article
|
||||
failed_articles_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
if destroyed_articles_count>0 # note that 1 successful article.destroy is enough to destroy selection
|
||||
stock_article_selection.destroy
|
||||
flash[:notice] = "#{destroyed_articles_count} gewählte Artikel sind nun gelöscht."
|
||||
flash[:error] = "#{failed_articles_count} Artikel konnten nicht gelöscht werden." unless 0==failed_articles_count
|
||||
else
|
||||
flash[:error] = "Löschvorgang fehlgeschlagen. Es wurden keine Artikel gelöscht."
|
||||
end
|
||||
|
||||
redirect_to stock_articles_path
|
||||
end
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module StockArticleSelectionsHelper
|
||||
end
|
|
@ -1,18 +1,7 @@
|
|||
# encoding: utf-8
|
||||
module StockitHelper
|
||||
def stock_article_classes(article)
|
||||
class_names = []
|
||||
class_names << "unavailable" if article.quantity_available <= 0
|
||||
class_names.join(" ")
|
||||
end
|
||||
|
||||
def stock_article_delete_checkbox(article)
|
||||
if article.quantity_available <= 0
|
||||
check_box_tag "stock_article_selection[stock_article_ids][]", article.id, false,
|
||||
{ :id => "checkbox_#{article.id}", :title => 'Zum löschen markieren' }
|
||||
else
|
||||
check_box_tag 'checkall', '1', false,
|
||||
{ :disabled => true, :title => 'Verfügbare Artikel können nicht gelöscht werden.', :class => 'unavailable' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# encoding: utf-8
|
||||
class StockArticleSelection < ActiveRecord::Base
|
||||
|
||||
# Associations
|
||||
has_and_belongs_to_many :stock_articles
|
||||
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
|
||||
belongs_to :finished_by, :class_name => 'User', :foreign_key => 'finished_by_user_id'
|
||||
|
||||
# Validations
|
||||
validate :include_stock_articles
|
||||
|
||||
def all_articles
|
||||
all_articles = stock_article_ids
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def include_stock_articles
|
||||
errors.add(:stock_articles, "Es muss mindestens ein Lagerartikel ausgewählt sein.") if stock_articles.empty?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
- content_for :javascript do
|
||||
:javascript
|
||||
$(function() {
|
||||
$('tr.unavailable,input.unavailable').hide();
|
||||
$('tr.unavailable').hide();
|
||||
})
|
||||
|
||||
.well.well-small
|
||||
|
@ -12,7 +12,7 @@
|
|||
Ansichtsoptionen
|
||||
%span.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Nicht verfügbare Artikel zeigen/verstecken", "#", 'data-toggle-this' => 'tr.unavailable,input.unavailable', tabindex: -1
|
||||
%li= link_to "Nicht verfügbare Artikel zeigen/verstecken", "#", 'data-toggle-this' => 'tr.unavailable', tabindex: -1
|
||||
|
||||
.btn-group
|
||||
= link_to_if @current_user.role_orders?, "Lagerbestellung online stellen", new_order_path(supplier_id: 0),
|
||||
|
@ -20,7 +20,6 @@
|
|||
= link_to "Neuen Lagerartikel anlegen", new_stock_article_path, class: 'btn'
|
||||
= link_to "Inventur anlegen", new_stock_taking_path, class: 'btn'
|
||||
= link_to "Inventurübersicht", stock_takings_path, class: 'btn'
|
||||
= link_to 'Löschvorschläge', stock_article_selections_path, class: 'btn'
|
||||
|
||||
.btn-group
|
||||
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do
|
||||
|
@ -30,15 +29,9 @@
|
|||
- Supplier.all.each do |supplier|
|
||||
%li= link_to supplier.name, new_supplier_delivery_path(supplier), tabindex: -1
|
||||
|
||||
= form_for @stock_article_selection do |form|
|
||||
- if @stock_article_selection.errors.has_key?(:stock_articles)
|
||||
.alert.alert-error
|
||||
= @stock_article_selection.errors.get(:stock_articles).join(" ")
|
||||
%table.table.table-hover#articles
|
||||
%table.table.table-hover#articles
|
||||
%thead
|
||||
%tr
|
||||
%th= check_box_tag 'checkall', '1', false,
|
||||
{ 'data-check-all' => 'table#articles tr.unavailable', :title => 'Alle löschbaren Artikel', :class => 'unavailable' }
|
||||
%th Artikel
|
||||
%th im Lager
|
||||
%th davon bestellt
|
||||
|
@ -52,7 +45,6 @@
|
|||
%tbody
|
||||
- for article in @stock_articles
|
||||
%tr{:class => stock_article_classes(article)}
|
||||
%td= stock_article_delete_checkbox(article)
|
||||
%td=h article.name
|
||||
%td= article.quantity
|
||||
%td= article.quantity - article.quantity_available
|
||||
|
@ -64,8 +56,9 @@
|
|||
%td= article.article_category.name
|
||||
%td
|
||||
= link_to "Bearbeiten", edit_stock_article_path(article), class: 'btn btn-mini'
|
||||
= link_to "Löschen", article, :method => :delete, :confirm => "Bist Du sicher?", class: 'btn btn-mini btn-danger', :remote => true
|
||||
%p= submit_tag "Artikel zum Löschen vormerken", { :class => 'unavailable btn' }
|
||||
= link_to "Löschen", article, :method => :delete, :confirm => "Bist Du sicher?",
|
||||
class: 'btn btn-mini btn-danger', :remote => true
|
||||
|
||||
%p
|
||||
Aktueller Lagerwert:
|
||||
= number_to_currency StockArticle.stock_value
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
%table.table.table-hover
|
||||
%tr
|
||||
%th Artikel
|
||||
%th Erstellt am
|
||||
%th Erstellt von
|
||||
%th Optionen
|
||||
|
||||
- stock_article_selections.each do |stock_article_selection|
|
||||
%tr
|
||||
%td=h truncate stock_article_selection.stock_articles.map{ |article| article.name}.join(', ')
|
||||
%td=h stock_article_selection.created_at
|
||||
%td=h link_to_user_message_if_valid stock_article_selection.created_by
|
||||
%td
|
||||
= link_to 'Anzeigen', stock_article_selection, class: 'btn btn-small'
|
||||
= link_to "Artikel löschen", articles_stock_article_selection_path(stock_article_selection), :method => :delete,
|
||||
:confirm => 'Diesen Löschvorschlag wirklich ausführen und markierte Artikel löschen?', class: 'btn btn-small btn-danger'
|
||||
= link_to "Verwerfen", stock_article_selection, :method => :delete,
|
||||
:confirm => 'Diesen Löschvorschlag wirklich verwerfen?', class: 'btn btn-small'
|
|
@ -1,7 +0,0 @@
|
|||
- title "Löschvorschläge für Lagerartikel"
|
||||
- if @stock_article_selections.empty?
|
||||
%p Es gibt keine ausstehenden Löschvorschläge.
|
||||
%ul
|
||||
%li= link_to "Löschvorschlag erstellen", stock_articles_path
|
||||
- else
|
||||
= render :partial => 'overview', :locals => {:stock_article_selections => @stock_article_selections}
|
|
@ -1,18 +0,0 @@
|
|||
- title "Löschvorschlag für #{@stock_article_selection.stock_articles.count} Lagerartikel"
|
||||
|
||||
%dl
|
||||
%dt Löschvorschlag vom:
|
||||
%dd=h @stock_article_selection.created_at
|
||||
%dt Erstellt durch:
|
||||
%dd=h link_to_user_message_if_valid(@stock_article_selection.created_by)
|
||||
%dt Zu löschende Artikel
|
||||
- for article in @stock_article_selection.stock_articles
|
||||
%dd=h article.name
|
||||
|
||||
|
||||
%p
|
||||
= link_to 'Artikel löschen', articles_stock_article_selection_path(@stock_article_selection), :method => :delete,
|
||||
:confirm => 'Diesen Löschvorschlag wirklich ausführen und markierte Artikel löschen?', class: 'btn btn-danger'
|
||||
= link_to 'Verwerfen', @stock_article_selection, :method => :delete,
|
||||
:confirm => 'Diesen Löschvorschlag wirklich verwerfen?', class: 'btn'
|
||||
= link_to 'Alle Löschvorschläge zeigen', stock_article_selections_path, class: 'btn'
|
|
@ -90,14 +90,6 @@ Foodsoft::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :stock_article_selections, :controller => 'stockit_selections',
|
||||
:only => [ :create, :show, :index, :destroy ], :path => "/stock_articles/selections" do
|
||||
member do
|
||||
delete 'articles'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
resources :stock_articles, :to => 'stockit' do
|
||||
collection do
|
||||
get :articles_search
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
class CreateStockArticleSelections < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :stock_article_selections do |t|
|
||||
t.integer :created_by_user_id
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :stock_article_selections_stock_articles, :id => false do |t|
|
||||
t.integer :stock_article_id
|
||||
t.integer :stock_article_selection_id
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :stock_article_selections
|
||||
drop_table :stock_article_selections_stock_articles
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130112121840) do
|
||||
ActiveRecord::Schema.define(:version => 20121230142516) do
|
||||
|
||||
create_table "article_categories", :force => true do |t|
|
||||
t.string "name", :default => "", :null => false
|
||||
|
@ -268,17 +268,6 @@ ActiveRecord::Schema.define(:version => 20130112121840) do
|
|||
add_index "pages", ["permalink"], :name => "index_pages_on_permalink"
|
||||
add_index "pages", ["title"], :name => "index_pages_on_title"
|
||||
|
||||
create_table "stock_article_selections", :force => true do |t|
|
||||
t.integer "created_by_user_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "stock_article_selections_stock_articles", :id => false, :force => true do |t|
|
||||
t.integer "stock_article_id"
|
||||
t.integer "stock_article_selection_id"
|
||||
end
|
||||
|
||||
create_table "stock_changes", :force => true do |t|
|
||||
t.integer "delivery_id"
|
||||
t.integer "order_id"
|
||||
|
|
Loading…
Reference in a new issue