Refactoring of articles and article_categories. articles are now a nested resource of supplier.

This commit is contained in:
Benjamin Meichsner 2009-01-16 16:19:26 +01:00
parent b38025869a
commit 936e6ef69a
36 changed files with 597 additions and 589 deletions

View File

@ -151,4 +151,8 @@ class ApplicationController < ActionController::Base
call_rake :send_emails unless Message.pending.empty? call_rake :send_emails unless Message.pending.empty?
end end
# Get supplier in nested resources
def find_supplier
@supplier = Supplier.find(params[:supplier_id]) if params[:supplier_id]
end
end end

View File

@ -0,0 +1,68 @@
class ArticleCategoriesController < ApplicationController
before_filter :authenticate_article_meta
def new
@article_category = ArticleCategory.new
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
page['category_form'].show
end
end
def edit
@article_category = ArticleCategory.find(params[:id])
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
page['category_form'].show
end
end
def create
@article_category = ArticleCategory.new(params[:article_category])
if @article_category.save
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
end
end
end
def update
@article_category = ArticleCategory.find(params[:id])
if @article_category.update_attributes(params[:article_category])
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
end
end
end
def destroy
@article_category = ArticleCategory.find(params[:id])
@article_category.destroy
#id = @article_category.id.to_s #save the id before destroying the object
if @article_category.destroy
render :update do |page|
page['category_'+@article_category.id].visual_effect :drop_out
end
end
end
end

View File

@ -1,26 +1,7 @@
class ArticlesController < ApplicationController class ArticlesController < ApplicationController
before_filter :authenticate_article_meta before_filter :authenticate_article_meta, :find_supplier
verify :method => :post,
:only => [ :destroyArticle, :createArticle, :updateArticle,
:update_all, :createArticlesFromFile, :update_selected_articles ],
:redirect_to => { :action => :list }
# messages
ERROR_NO_SELECTED_ARTICLES = 'Du hast keine Artikel ausgewählt'
MSG_ALL_CHECKED_DESTROYED = 'Alle gewählten Artikel wurden gelöscht'
MSG_ALL_CHECKED_UNAVAILABLE = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
MSG_ALL_CHECKED_AVAILABLE = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
ERROR_NO_SELECTED_ACTION = 'Keine Aktion ausgewählt!'
ERROR_UPDATE_ARTICLES = 'Ein Fehler ist aufgetreten: '
def index def index
@suppliers = Supplier.find(:all)
end
def list
if params[:id]
@supplier = Supplier.find(params[:id])
@suppliers = Supplier.find(:all)
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 500) if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 500)
@per_page = params[:per_page].to_i @per_page = params[:per_page].to_i
else else
@ -58,25 +39,22 @@ class ArticlesController < ApplicationController
format.html # list.haml format.html # list.haml
format.js do format.js do
render :update do |page| render :update do |page|
page.replace_html 'table', :partial => "list" page.replace_html 'table', :partial => "articles"
end end
end end
end end
else
redirect_to :action => 'index'
end
end end
def newArticle def new
@supplier = Supplier.find(params[:supplier]) @article = @supplier.articles.build(:tax => 7.0)
@article = Article.new(:supplier => @supplier, :tax => 7.0)
render :update do |page| render :update do |page|
page["edit_article"].replace_html :partial => 'new' page["edit_article"].replace_html :partial => 'new'
page["edit_article"].show page["edit_article"].show
end end
end end
def createArticle def create
@article = Article.new(params[:article]) @article = Article.new(params[:article])
if @article.valid? and @article.save if @article.valid? and @article.save
render :update do |page| render :update do |page|
@ -99,8 +77,9 @@ class ArticlesController < ApplicationController
end end
# edit an article and its price # edit an article and its price
def editArticle def edit
@article = Article.find(params[:id]) @article = Article.find(params[:id])
render :update do |page| render :update do |page|
page["edit_article"].replace_html :partial => 'edit' page["edit_article"].replace_html :partial => 'edit'
page["edit_article"].show page["edit_article"].show
@ -109,8 +88,9 @@ class ArticlesController < ApplicationController
end end
# Updates one Article and highlights the line if succeded # Updates one Article and highlights the line if succeded
def updateArticle def update
@article = Article.find(params[:id]) @article = Article.find(params[:id])
if @article.update_attributes(params[:article]) if @article.update_attributes(params[:article])
render :update do |page| render :update do |page|
page["edit_article"].hide page["edit_article"].hide
@ -138,9 +118,10 @@ class ArticlesController < ApplicationController
end end
# Deletes article from database. send error msg, if article is used in a current order # Deletes article from database. send error msg, if article is used in a current order
def destroyArticle def destroy
@article = Article.find(params[:id]) @article = Article.find(params[:id])
@order = @article.inUse #if article is in an active Order, the Order will be returned
@order = @article.inUse # If article is in an active Order, the Order will be returned
if @order if @order
render :update do |page| render :update do |page|
page.insert_html :after, @article.id.to_s, :partial => 'destroyActiveArticle' page.insert_html :after, @article.id.to_s, :partial => 'destroyActiveArticle'
@ -155,7 +136,10 @@ class ArticlesController < ApplicationController
# Renders a form for editing all articles from a supplier # Renders a form for editing all articles from a supplier
def edit_all def edit_all
@supplier = Supplier.find(params[:id]) @articles = @supplier.articles.find :all,
:order => 'article_categories.name, articles.name',
:include => [:article_category]
end end
# Updates all article of specific supplier # Updates all article of specific supplier
@ -164,14 +148,11 @@ class ArticlesController < ApplicationController
currentArticle = nil # used to find out which article caused a validation exception currentArticle = nil # used to find out which article caused a validation exception
begin begin
Article.transaction do Article.transaction do
@supplier = Supplier.find(params[:supplier][:id]) if params[:supplier][:id] unless params[:articles].blank?
unless params[:article].blank?
# Update other article attributes... # Update other article attributes...
i = 0 for id, attributes in params[:articles]
for id in params[:article].keys
currentArticle = Article.find(id) currentArticle = Article.find(id)
currentArticle.update_attributes!(params[:article].values[i]) currentArticle.update_attributes!(attributes)
i += 1
end end
end end
# delete articles # delete articles
@ -181,118 +162,50 @@ class ArticlesController < ApplicationController
end end
# Successfully done. # Successfully done.
flash[:notice] = 'Alle Artikel und Preise wurden aktalisiert' flash[:notice] = 'Alle Artikel und Preise wurden aktalisiert'
redirect_to :action => 'list', :id => @supplier redirect_to supplier_articles_path(@supplier)
rescue => e rescue => e
# An error has occurred, transaction has been rolled back. # An error has occurred, transaction has been rolled back.
if currentArticle if currentArticle
@failedArticle = currentArticle @failedArticle = currentArticle
flash[:error] = "Es trat ein Fehler beim Aktualisieren des Artikels '#{currentArticle.name}' auf: #{e.message}" flash[:error] = "Es trat ein Fehler beim Aktualisieren des Artikels '#{currentArticle.name}' auf: #{e.message}"
params[:sync] ? redirect_to(:action => "list", :id => @supplier) : render(:action => 'edit_all') params[:sync] ? redirect_to(supplier_articles_path(@supplier)) : render(:action => 'edit_all')
else else
flash[:error] = "Es trat ein Fehler beim Aktualisieren der Artikel auf: #{e.message}" flash[:error] = "Es trat ein Fehler beim Aktualisieren der Artikel auf: #{e.message}"
redirect_to :action => "index" redirect_to supplier_articles_path(@supplier)
end end
end end
end end
# makes different actions on selected articles # makes different actions on selected articles
def update_selected_articles def update_selected
@supplier = Supplier.find(params[:supplier]) raise 'Du hast keine Artikel ausgewählt' if params[:selected_articles].nil?
articles = Array.new articles = Article.find(params[:selected_articles])
begin
raise ERROR_NO_SELECTED_ARTICLES if params[:selected_articles].nil?
params[:selected_articles].each do |article|
articles << Article.find(article) # put selected articles in an array
end
case params[:selected_action].to_s case params[:selected_action]
when 'destroy' when 'destroy'
articles.each {|a| a.destroy } articles.each {|a| a.destroy }
flash[:notice] = MSG_ALL_CHECKED_DESTROYED flash[:notice] = 'Alle gewählten Artikel wurden gelöscht'
when 'setNotAvailable' when 'setNotAvailable'
articles.each {|a| a.update_attribute(:availability, false) } articles.each {|a| a.update_attribute(:availability, false) }
flash[:notice] = MSG_ALL_CHECKED_UNAVAILABLE flash[:notice] = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
when 'setAvailable' when 'setAvailable'
articles.each {|a| a.update_attribute(:availability, true) } articles.each {|a| a.update_attribute(:availability, true) }
flash[:notice] = MSG_ALL_CHECKED_AVAILABLE flash[:notice] = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
else else
flash[:error] = ERROR_NO_SELECTED_ACTION flash[:error] = 'Keine Aktion ausgewählt!'
end end
# action succeded # action succeded
redirect_to :action => 'list', :id => @supplier redirect_to supplier_articles_path(@supplier)
rescue => e rescue => e
flash[:error] = ERROR_UPDATE_ARTICLES + e flash[:error] = 'Ein Fehler ist aufgetreten: ' + e
redirect_to :action => 'list', :id => @supplier redirect_to supplier_articles_path(@supplier)
end
end
#************** start article categories ************************
def newCategory
@article_category = ArticleCategory.new
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/new'
page['category_form'].show
end
end
def createCategory
@article_category = ArticleCategory.new(params[:article_category])
if @article_category.save
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/new'
end
end
end
def editCategory
@article_category = ArticleCategory.find(params[:id])
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/edit'
page['category_form'].show
end
end
def updateCategory
@article_category = ArticleCategory.find(params[:id])
if @article_category.update_attributes(params[:article_category])
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/edit'
end
end
end
def destroyCategory
@article_category = ArticleCategory.find(params[:id])
id = @article_category.id.to_s #save the id before destroying the object
if @article_category.destroy
render :update do |page|
page['category_'+id].visual_effect :drop_out
end
end
end end
# lets start with parsing articles from uploaded file, yeah # lets start with parsing articles from uploaded file, yeah
# Renders the upload form # Renders the upload form
def upload_articles def upload
end end
# parses the articles from a csv and creates a form-table with the parsed data. # parses the articles from a csv and creates a form-table with the parsed data.
@ -301,7 +214,7 @@ class ArticlesController < ApplicationController
# the first line will be ignored. # the first line will be ignored.
# field-seperator: ";" # field-seperator: ";"
# text-seperator: "" # text-seperator: ""
def parse_articles def parse_upload
begin begin
@articles = Array.new @articles = Array.new
articles, outlisted_articles = FoodsoftFile::parse(params[:articles]["file"]) articles, outlisted_articles = FoodsoftFile::parse(params[:articles]["file"])
@ -320,44 +233,38 @@ class ArticlesController < ApplicationController
:tax => row[:tax]) :tax => row[:tax])
# stop parsing, when an article isn't valid # stop parsing, when an article isn't valid
unless article.valid? unless article.valid?
raise article.errors.full_messages.join(", ") + _(" ..in line ") + (articles.index(row) + 2).to_s raise article.errors.full_messages.join(", ") + " ..in line " + (articles.index(row) + 2).to_s
end end
@articles << article @articles << article
end end
flash.now[:notice] = @articles.size.to_s + _(" articles are parsed successfully.") flash.now[:notice] = @articles.size.to_s + " articles are parsed successfully."
rescue => e rescue => e
flash[:error] = _("An error has occurred: ") + e.message flash[:error] = "An error has occurred: " + e.message
redirect_to :action => 'upload_articles' redirect_to upload_supplier_articles_path(@supplier)
end end
end end
# creates articles from form # creates articles from form
def create_articles_from_file def create_from_upload
@supplier = Supplier.find(params[:supplier][:id])
begin begin
Article.transaction do Article.transaction do
i = 0 for article_attributes in params[:articles]
params[:article].each do @supplier.articles.create!(article_attributes)
@article = Article.new(params[:article][i])
@article.supplier = @supplier
@article.save!
i += 1
end end
end end
# Successfully done. # Successfully done.
flash[:notice] = _("The articles are saved successfully") flash[:notice] = "The articles are saved successfully"
redirect_to :action => 'list', :id => @supplier redirect_to supplier_articles_path(@supplier)
rescue => e rescue => error
# An error has occurred, transaction has been rolled back. # An error has occurred, transaction has been rolled back.
flash[:error] = _("An error occured: ") + " #{e.message}" flash[:error] = "An error occured: #{error.message}"
redirect_to :action => 'upload_articles' redirect_to upload_supplier_articles_path(@supplier)
end end
end end
# renders a view to import articles in local database # renders a view to import articles in local database
# #
def list_shared_articles def shared
@supplier = Supplier.find(params[:id])
conditions = [] conditions = []
conditions << "supplier_id = #{@supplier.shared_supplier.id}" conditions << "supplier_id = #{@supplier.shared_supplier.id}"
# check for keywords # check for keywords
@ -374,8 +281,8 @@ class ArticlesController < ApplicationController
end end
# fills a form whith values of the selected shared_article # fills a form whith values of the selected shared_article
def new_import def import
shared_article = SharedArticle.find(params[:id]) shared_article = SharedArticle.find(params[:shared_article_id])
@article = Article.new( @article = Article.new(
:supplier_id => params[:supplier_id], :supplier_id => params[:supplier_id],
:name => shared_article.name, :name => shared_article.name,
@ -399,12 +306,12 @@ class ArticlesController < ApplicationController
# sync all articles with the external database # sync all articles with the external database
# renders a form with articles, which should be updated # renders a form with articles, which should be updated
def sync_articles def sync
@supplier = Supplier.find(params[:id]) @supplier = Supplier.find(params[:id])
# check if there is an shared_supplier # check if there is an shared_supplier
unless @supplier.shared_supplier unless @supplier.shared_supplier
flash[:error]= @supplier.name + _(" ist not assigned to an external database.") flash[:error]= @supplier.name + _(" ist not assigned to an external database.")
redirect_to :action => "list", :id => @supplier redirect_to supplier_articles_path(@supplier)
end end
# sync articles against external database # sync articles against external database
@updated_articles, @outlisted_articles = @supplier.sync_all @updated_articles, @outlisted_articles = @supplier.sync_all
@ -412,7 +319,7 @@ class ArticlesController < ApplicationController
@updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)} @updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)}
if @updated_articles.empty? && @outlisted_articles.empty? if @updated_articles.empty? && @outlisted_articles.empty?
flash[:notice] = _("The database is up to date.") flash[:notice] = _("The database is up to date.")
redirect_to :action => 'list', :id => @supplier redirect_to supplier_articles_path(@supplier)
end end
end end
end end

View File

@ -83,10 +83,4 @@ class DeliveriesController < ApplicationController
page.visual_effect(:DropOut, "stock_change_#{stock_change.id}") page.visual_effect(:DropOut, "stock_change_#{stock_change.id}")
end end
end end
protected
def find_supplier
@supplier = Supplier.find(params[:supplier_id]) if params[:supplier_id]
end
end end

View File

@ -7,9 +7,8 @@ class SuppliersController < ApplicationController
MSG_SUPPLIER_CREATED = "Lieferant wurde erstellt" MSG_SUPPLIER_CREATED = "Lieferant wurde erstellt"
def index def index
@supplier_column_names = ["Name", "Telefon", "Email", "Kundennummer"] @suppliers = Supplier.all :order => 'name'
@supplier_columns = ["name", "phone", "email", "customer_number"] #@categories = ArticleCategory.all :order => 'name'
@suppliers = Supplier.find :all
end end
def show def show

View File

@ -58,11 +58,11 @@ module ApplicationHelper
return result return result
end end
def sort_link_helper(text, param, per_page = 10) def sort_link_helper(text, param, per_page = (@per_page || 10) )
key = param key = param
key += "_reverse" if params[:sort] == param key += "_reverse" if params[:sort] == param
options = { options = {
:url => {:action => 'list', :params => params.merge({:sort => key, :page => nil, :per_page => per_page})}, :url => url_for(:params => params.merge({:sort => key, :page => nil, :per_page => per_page})),
:before => "Element.show('loader')", :before => "Element.show('loader')",
:success => "Element.hide('loader')", :success => "Element.hide('loader')",
:method => :get :method => :get
@ -102,4 +102,13 @@ module ApplicationHelper
def tab_is_active?(tab) def tab_is_active?(tab)
tab[:active].detect {|c| c == controller.controller_path } tab[:active].detect {|c| c == controller.controller_path }
end end
def icon(name, options={})
icons = { :delete => { :file => 'b_drop.png', :alt => 'Löschen'},
:edit => { :file => 'b_edit.png', :alt => 'Bearbeiten'}}
options.merge!({:size => '16x16',:border => "0"})
options.merge!({:alt => icons[name][:alt]}) unless options[:alt]
image_tag icons[name][:file], options
end
end end

View File

@ -0,0 +1,2 @@
module ArticleCategoriesHelper
end

View File

@ -4,4 +4,11 @@ module ArticlesHelper
def highlight_new(unequal_attributes, attribute) def highlight_new(unequal_attributes, attribute)
unequal_attributes.detect {|a| a == attribute} ? "background-color: yellow" : "" unequal_attributes.detect {|a| a == attribute} ? "background-color: yellow" : ""
end end
def row_classes(article)
classes = ""
classes += ' unavailable' if article.availability
classes += " just_updated" if @article.recently_updated && @article.availability
classes
end
end end

View File

@ -1,7 +0,0 @@
<% remote_form_for :article_category, :url => { :action => 'updateCategory', :id => @article_category },
:before => "Element.show('loader')",
:success => "Element.hide('loader')" do |@f| %>
<%= render :partial => '/article_categories/form' %>
<br />
<%= submit_tag "Speichern" %> | <%= link_to_function("Abbrechen", "Element.hide('category_form')") %>
<% end %>

View File

@ -1,17 +1,24 @@
<%= error_messages_for 'article_category' %> <% remote_form_for @article_category,
:before => "Element.show('loader')",
:success => "Element.hide('loader')" do |@f| %>
<!--[form:article_category]--> <%= @f.error_messages %>
<table> <table>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Beschreibung</th> <th>Beschreibung</th>
</tr> </tr>
<tr> <tr>
<td><label for="article_category_name"> <td>
<%= @f.text_field 'name', :size => 20 %></label></td> <%= @f.text_field :name, :size => 20 %>
<td><label for="article_category_description"> </td>
<%= @f.text_field 'description', :size => 30 %></label></td> <td>
<%= @f.text_field :description, :size => 30 %>
</td>
</tr> </tr>
</tabel> </table>
<!--[eoform:article_category]-->
<br />
<%= submit_tag "Speichern" %> | <%= link_to_function("Abbrechen", "Element.hide('category_form')") %>
<% end %>

View File

@ -4,19 +4,24 @@
<th>Beschreibung</th> <th>Beschreibung</th>
<th colspan="2"></th> <th colspan="2"></th>
</tr> </tr>
<% for article_category in ArticleCategory.find(:all) %> <% for article_category in ArticleCategory.find(:all) -%>
<tr class="<%= cycle("even","odd", :name => 'category') %>" id="category_<%= article_category.id %>"> <tr class="<%= cycle("even","odd", :name => 'category') -%>" id="category_<%= article_category.id -%>">
<td><%=h article_category.name %></td> <td><%=h article_category.name -%></td>
<td><%=h article_category.description %></td> <td><%=h article_category.description -%></td>
<td><%= link_to_remote(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Katgerie bearbeiten'), <td><%= link_to_remote icon(:edit),
:url => {:action => 'editCategory', :id => article_category}, :url => edit_article_category_path(article_category),
:method => :get,
:before => "Element.show('loader')", :before => "Element.show('loader')",
:success => "Element.hide('loader')" ) %></td> :success => "Element.hide('loader')" -%></td>
<td><%= link_to_remote(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Kategorie löschen'), :url => {:action => 'destroyCategory', :id => article_category }, :confirm => 'Are you sure?' )%></td> <td><%= link_to_remote icon(:delete),
:url => article_category,
:method => :delete,
:confirm => 'Are you sure?' -%></td>
</tr> </tr>
<% end %> <% end -%>
</table> </table>
<br /> <br />
<%= link_to_remote('Neue Kategorie', :url => {:action => :newCategory}, <%= link_to_remote 'Neue Kategorie', :url => new_article_category_path,
:method => :get,
:before => "Element.show('loader')", :before => "Element.show('loader')",
:success => "Element.hide('loader')") -%> :success => "Element.hide('loader')" %>

View File

@ -1,7 +0,0 @@
<% remote_form_for :article_category, :url => { :action => 'createCategory', :id => @article_category },
:before => "Element.show('loader')",
:success => "Element.hide('loader')" do |@f| %>
<%= render :partial => '/article_categories/form' %>
<br />
<%= submit_tag "Speichern" %> | <%= link_to_function("Abbrechen", "Element.hide('category_form')") %>
<% end %>

View File

@ -1,27 +1,32 @@
<td> <td>
<%= check_box_tag 'selected_articles[]', @article.id.to_s, false, {:id => "checkbox_#{@article.id.to_s}", :onclick => "checkRow('#{@article.id.to_s}')"} %> <%= check_box_tag 'selected_articles[]', @article.id.to_s, false,
{:id => "checkbox_#{@article.id.to_s}", :onclick => "checkRow('#{@article.id.to_s}')"} %>
</td> </td>
<td><%=h @article.name %></td> <td><%=h @article.name -%></td>
<td><%= @article.origin %></td> <td><%= @article.origin -%></td>
<td><%=h truncate(@article.article_category.name, 11) if @article.article_category%></td> <td><%=h truncate(@article.article_category.name, :length => 11) if @article.article_category -%></td>
<td><%=h @article.unit %></td> <td><%=h @article.unit -%></td>
<td><%=h truncate(@article.note, 15) %></td> <td><%=h truncate(@article.note, :length => 11) -%></td>
<td><%= @article.unit_quantity %></td> <td><%= @article.unit_quantity -%></td>
<td class="currency"> <td class="currency">
<acronym title="zuletzt geändert: <%= format_date(@article.updated_at) %> <acronym title="zuletzt geändert: <%= format_date(@article.updated_at) -%>
| Brutto: <%= number_to_currency(@article.gross_price) %>"> | Brutto: <%= number_to_currency(@article.gross_price) -%>">
<%= number_to_currency(@article.net_price) %> <%= number_to_currency(@article.net_price) -%>
</acronym> </acronym>
</td> </td>
<td><%= number_to_percentage(@article.tax) if @article.tax != 0 %></td> <td><%= number_to_percentage(@article.tax) if @article.tax != 0 -%></td>
<td><%= number_to_currency(@article.deposit) if @article.deposit != 0 %></td> <td><%= number_to_currency(@article.deposit) if @article.deposit != 0 -%></td>
<td><%= link_to_remote(image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Artikel ändern', :onclick => "checkRow('#{@article.id.to_s}')"), <td>
:url => {:action => 'editArticle', :id => @article }, <%= link_to_remote icon(:edit, :onclick => "checkRow('#{@article.id.to_s}')"),
:url => edit_supplier_article_path(@supplier, @article),
:method => :get,
:before => "Element.show('loader')", :before => "Element.show('loader')",
:success => "Element.hide('loader')") %> :success => "Element.hide('loader')" %>
<%= link_to_remote(image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'Artikel löschen', :onclick => "checkRow('#{@article.id.to_s}')"), <%= link_to_remote icon(:delete, :onclick => "checkRow('#{@article.id.to_s}')"),
:url => { :action => 'destroyArticle', :id => @article }, :url => [@supplier, @article],
:method => :delete,
:confirm => 'Bist du sicher?', :confirm => 'Bist du sicher?',
:before => "Element.show('loader')", :before => "Element.show('loader')",
:success => "Element.hide('loader')")%></td> :success => "Element.hide('loader')" %>
</td>

View File

@ -16,14 +16,14 @@
%tr %tr
%th %th
%th[sort_td_class_helper "name"] %th[sort_td_class_helper "name"]
= sort_link_helper _("Name"), "name", @supplier.id = sort_link_helper _("Name"), "name"
%th %th
%th[sort_td_class_helper "category"] %th[sort_td_class_helper "category"]
= sort_link_helper _("Category"), "category", @supplier.id = sort_link_helper _("Category"), "category"
%th[sort_td_class_helper "unit"] %th[sort_td_class_helper "unit"]
= sort_link_helper _("Unit"), "unit", @supplier.id = sort_link_helper _("Unit"), "unit"
%th[sort_td_class_helper "note"] %th[sort_td_class_helper "note"]
= sort_link_helper _("Note"), "note", @supplier.id = sort_link_helper _("Note"), "note"
%th{:style => "width: 4em;"}=_ 'UnitQu' %th{:style => "width: 4em;"}=_ 'UnitQu'
%th{:style => "width: 4em;"}=_ 'Price' %th{:style => "width: 4em;"}=_ 'Price'
%th{:style => "width: 3.5em;"}=_ 'Tax' %th{:style => "width: 3.5em;"}=_ 'Tax'
@ -34,20 +34,19 @@
- if @total > 0 - if @total > 0
- for @article in @articles - for @article in @articles
%tr{ :class => cycle('even','odd') + (!@article.availability ? ' unavailable' : '') + ((@article.recently_updated && @article.availability) ? " just_updated" : ""), | %tr{ :class => cycle('even','odd') + row_classes(@article), :id => @article.id, :onclick => "checkRow('#{@article.id.to_s}')"}
:id => @article.id, :onclick => "checkRow('#{@article.id.to_s}')"} |
= render :partial => 'article_row' = render :partial => 'article_row'
%tfoot %tfoot
%tr %tr
%td{:colspan => '10'} %td{:colspan => '11'}
%input{:type => 'checkbox', :name => 'checkall', :onclick => 'checkUncheckAll(this)'}/ = check_box_tag :checkall, 1, false, :onclick => 'checkUncheckAll(this)'
%select{:name => "selected_action"} %select{:name => "selected_action"}
%option{:value => '', :selected => 'selected'} Aktion wählen ... %option{:value => '', :selected => 'selected'} Aktion wählen ...
%option{:value => "destroy", :onclick => "if (confirm('Willst Du wirklich alle gewählten Artikel löschen?')) { formSubmit(); }; return false;"} Artikel löschen %option{:value => "destroy", :onclick => "if (confirm('Willst Du wirklich alle gewählten Artikel löschen?')) { formSubmit(); }; return false;"} Artikel löschen
%option{:value => "setNotAvailable", :onclick => 'formSubmit();'} Artikel sind nicht mehr verfügbar %option{:value => "setNotAvailable", :onclick => 'formSubmit();'} Artikel sind nicht mehr verfügbar
%option{:value => "setAvailable", :onclick => 'formSubmit();'} Artikel sind verfügbar %option{:value => "setAvailable", :onclick => 'formSubmit();'} Artikel sind verfügbar
= hidden_field_tag 'supplier', @supplier.id = hidden_field_tag 'supplier_id', @supplier.id
%p %p
= pagination_links_remote @articles, :params => {:sort => params[:sort]} = pagination_links_remote @articles, :params => {:sort => params[:sort]}

View File

@ -4,11 +4,4 @@
zuletzt aktualisiert am: zuletzt aktualisiert am:
= format_time(@article.updated_at) = format_time(@article.updated_at)
- form_remote_tag :url => { :action => 'updateArticle', :id => @article}, :html => {:id => "edit"}, | = render :partial => "form"
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= render :partial => "form"
= submit_tag "Speichern"
|
= link_to_function "Abbrechen", "Element.hide('edit_article')"

View File

@ -0,0 +1,45 @@
- remote_form_for [@supplier, @article], :before => "Element.show('loader')", |
:success => "Element.hide('loader')" do |form| |
= form.error_messages
%p
%b Verfügbar?
= form.check_box :availability
%table{ :style => "width: 20em"}
%tr
%th Name
%th Herkunft
%th Hersteller
%th Einheit
%th Notiz
%th kategorie
%tbody
%tr
%td= form.text_field :name, :size => 15
%td= form.text_field :origin, :size => 5
%td= form.text_field :manufacturer, :size => 8
%td= form.text_field :unit, :size => 5
%td= form.text_field :note, :size => 15
%td= form.select :article_category_id, ArticleCategory.find(:all, :order => 'name').collect {|a| [ a.name, a.id ] }
%br/
%table{ :style=>"width:35em"}
%tr
%th Nettopreis
%th Gebindegröße
%th Bestellnummer
%th MwSt
%th Pfand
%tbody
%tr
%td= form.text_field :net_price, :size => 5
%td= form.text_field :unit_quantity, :size => 5
%td= form.text_field :order_number, :size => 10
%td= form.text_field :tax, :size => 5
%td= form.text_field :deposit, :size => 5
= form.hidden_field :shared_updated_on
= form.hidden_field :supplier_id
= submit_tag "Speichern"
|
= link_to_function "Abbrechen", "Element.hide('edit_article')"

View File

@ -1,69 +0,0 @@
<%= error_messages_for 'article' %>
<!--[form:article]-->
<p>
<b>Verfügbar?</b> <label for="article_availability"><%= check_box 'article', 'availability' %></label>
</p>
<table style="width: 20em">
<tr>
<th>Name</th>
<th>Herkunft</th>
<th>Herstellerin</th>
<th>Einheit</th>
<th>Notiz</th>
<th>Kategorie</th>
</tr>
<tbody>
<tr>
<td>
<label for="article_name"><%= text_field 'article', 'name', :size => 15 %></label>
</td>
<td>
<label for="article_origin"><%= text_field 'article', 'origin', :size => 5 %></label>
</td>
<td>
<label for="article_manufacturer"><%= text_field 'article', 'manufacturer', :size => 8 %></label>
</td>
<td>
<label for="article_unit"><%= text_field 'article', 'unit', :size => 5 %></label>
</td>
<td>
<label for="article_note"><%= text_field 'article', 'note', :size => 15 %></label>
</td>
<td>
<label for="article_article_category"><%= select('article', 'article_category_id', ArticleCategory.find(:all, :order => 'name').collect {|a| [ a.name, a.id ] }) %></label>
</td>
</tr>
</tbody>
</table>
<br />
<table style="width:35em">
<tr>
<th>netto Preis</th>
<th>Gebindegröße</th>
<th>Artikelnummer</th>
<th>Steuer</th>
<th>Pfand</th>
</tr>
<tbody>
<tr>
<td><label for="article_net_price">
<%= text_field 'article', 'net_price', :size => 5%></label></td>
<td><label for="article_unit_quantity">
<%= text_field 'article', 'unit_quantity', :size => 5%></label></td>
<td><label for="article_order_number">
<%= text_field 'article', 'order_number', :size => 10%></label></td>
<td><label for="article_tax">
<%= text_field 'article', 'tax', :size => 5%></label></td>
<td><label for="article_deposit">
<%= text_field 'article', 'deposit', :size => 5%></label></td>
</tr>
</tbody>
</table>
<%= hidden_field 'article', 'shared_updated_on' %>
<%= hidden_field 'article', 'supplier_id' %>
<!--[eoform:article]-->

View File

@ -21,5 +21,7 @@
%td= number_to_currency(article.price) %td= number_to_currency(article.price)
%td= article.unit %td= article.unit
%td= article.unit_quantity %td= article.unit_quantity
%td= link_to_remote 'importieren', :url => {:action => 'new_import', :id => article, :supplier_id => @supplier.id} %td= link_to_remote 'importieren', |
:url => import_supplier_articles_path(@supplier, :shared_article_id => article.id), |
:method => :get |

View File

@ -1,5 +1,2 @@
%h3 Neuer Artikel %h3 Neuer Artikel
- form_remote_tag :url => { :action => 'createArticle'} do = render :partial => 'form'
= render :partial => 'articles/form'
= submit_tag "Speichern"
= link_to_function('Abbrechen', 'Element.hide("edit_article")')

View File

@ -1,25 +1,26 @@
<h1>Alle Artikel von <%= @supplier.name %> bearbeiten</h1> <h1>Alle Artikel von <%= @supplier.name %> bearbeiten</h1>
<div class="single_column" style="width:100%"> <div class="single_column" style="width:100%">
<div class="box_title">
<h2>
<div id="change_supplier"> <div id="change_supplier">
<% form_tag do -%> <% form_tag do -%>
<select onchange="redirectTo(this)" style="font-size: 0.9em;margin-left:1em;"> <%= select_tag :switch_supplier,
<%= options_for_select(Supplier.find(:all).collect {|s| [ s.name, url_for(:action => "edit_all", :id => s)] }, url_for(:action => "edit_all", :id => @supplier.id)) %> options_for_select( Supplier.all.collect {|s| [s.name, url_for(edit_all_supplier_articles_path(s))] },
</select> url_for(edit_all_supplier_articles_path(@supplier)) ),
:onchange => "redirectTo(this)",
:style => "font-size: 0.9em;margin-left:1em;" %>
<% end %> <% end %>
</div> </div>
</h2> <div class="box_title">
<h2></h2>
</div> </div>
<div class="box column_content"> <div class="box column_content">
<div id="links"><%= link_to 'zurück zur Liste', :action => 'list', :id => @supplier.id %></div> <div id="links"><%= link_to 'zurück zur Liste', supplier_articles_path(@supplier) -%></div>
<p> <p>
<i> <i>
Pflichtfelder sind: Name, Einheit, (netto) Preis und Bestellnummer. Pflichtfelder sind: Name, Einheit, (netto) Preis und Bestellnummer.
</i> </i>
</p> </p>
<% form_tag(:action => 'update_all', :id => @supplier) do %> <% form_tag(update_all_supplier_articles_path(@supplier)) do %>
<table id="articles_table" class="list"> <table id="articles_table" class="list">
<thead> <thead>
<tr> <tr>
@ -35,27 +36,29 @@
<th>Pfand</th> <th>Pfand</th>
</tr> </tr>
<tbody> <tbody>
<% @supplier.articles.find(:all, :order => 'article_categories.name, articles.name', :include => [:article_category]).each do |@article| %> <% for article in @articles %>
<tr class="<%= cycle('even', 'odd') %>"<%= ' style="background-color: yellow"' if @failedArticle == @article %>> <% fields_for 'articles[]', article do |form| %>
<td colspan="2"><label for="article_availability"><%= check_box 'article[]', 'availability' %></label> <tr class="<%= cycle('even', 'odd') %>"<%= ' style="background-color: yellow"' if @failedArticle == article %>>
<label for="article_name"><%= text_field( 'article[]', 'name', :size => 0) %></label></td> <td colspan="2">
<td><label for="article_unit"><%= text_field 'article[]', 'unit', :size => 5 %></label></td> <%= form.check_box 'availability' -%>
<td><label for="article_net_price"><%= text_field 'article[]', 'net_price', :size => 4 %></label></td> <%= form.text_field 'name', :size => 0 -%>
<td><label for="article_unit_quantity"><%= text_field 'article[]', 'unit_quantity', :size => 4 %></label></td> </td>
<td><label for="article_order_number"><%= text_field 'article[]', 'order_number', :size => 6 %></label></td> <td><%= form.text_field 'unit', :size => 5 -%></td>
<td><label for="article_note"><%= text_field 'article[]', 'note', :size => 15 %></label></td> <td><%= form.text_field 'net_price', :size => 4 -%></td>
<td><label for="article_article_category"><%= select('article[]', 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }, { :include_blank => true })%></label></td> <td><%= form.text_field 'unit_quantity', :size => 4 -%></td>
<td><label for="article_tax"><%= text_field 'article[]', 'tax', :size => 4 %></label></td> <td><%= form.text_field 'order_number', :size => 6 -%></td>
<td><label for="article_deposit"><%= text_field 'article[]', 'deposit', :size => 4 %></label></td> <td><%= form.text_field 'note', :size => 15 -%></td>
<td><%= form.select 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }, { :include_blank => true } -%></td>
<td><%= form.text_field 'tax', :size => 4 -%></td>
<td><%= form.text_field 'deposit', :size => 4 -%></td>
</tr> </tr>
<% end %> <% end %>
<% end %>
<!--[eoform:article]--> <!--[eoform:article]-->
</tbody> </tbody>
</table><br /> </table><br />
<i>Achtung, alle Artikel werden aktualisiert!</i><br /> <i>Achtung, alle Artikel werden aktualisiert!</i><br />
<%= hidden_field 'supplier', 'id' %> <%= submit_tag 'Alle Artikel aktualisieren'%> | <%= link_to 'Abbrechen', supplier_articles_path(@supplier) %>
<%= submit_tag 'Alle aktualisieren'%>
| <%= link_to 'Abbrechen', :action => 'list', :id => @supplier.id %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@ -1,29 +1,73 @@
%h1 Manage die Artikeldatenbank - title "Artikel von #{@supplier.name}"
.left_column{:style => "width:44%"}
.box_title
%h2 Artikel anzeigen
.column_content
%p
%i
Hier kannst du Artikel anzeigen, ändern und neue erstellen
%br/
Wähle einen Lieferanten:
%ul
- @suppliers.each do |supplier|
%li
%b= link_to supplier.name, :action => "list", :id => supplier.id
(
= supplier.articles.count
Artikel )
%hr/
%p
%i
hier kannst du neue Artikel aus einer csv-Datei in die Datenbank
= link_to 'hochladen', :action => 'upload_articles'
.right_column{:style => "width:53%"} // import menu
- unless @supplier.shared_supplier.nil?
.menu{:style => 'width: 14em'}
%ul
%li
=_ 'External database'
%ul
%li= link_to_function _('search/import'), "Element.toggle('import')"
%li= link_to _('sync'), sync_supplier_articles_path(@supplier), :method => :post
#change_supplier{:style => "padding:0 0 0.5em 0.7em;"}
%span{:style => "float:left"}
=_ 'Change supplier:'
- form_tag do
= select_tag :switch_supplier, |
options_for_select( Supplier.all.collect {|s| [s.name, url_for(supplier_articles_path(s))] }, |
url_for(supplier_articles_path(@supplier)) ), |
:onchange => "redirectTo(this)", |
:style => "font-size: 0.9em;margin-left:1em;" |
- unless @supplier.shared_supplier.nil?
#import.single_column{:style => "display:none; clear:both"}
.box_title .box_title
%h2 Artikelkategorien %h2=_ 'Import articles'
.column_content#categories .column_content
#category_form.box.edit_form{:style => "display:none;margin-bottom:1em;"} #search{:style => "padding-bottom:3em"}
#category_list= render :partial => 'article_categories/list' - form_remote_tag :url => shared_supplier_articles_path(@supplier), |
:before => "Element.show('loader')", :success => "Element.hide('loader')", |
:method => :get do |
= text_field_tag :import_query, params['import_query'], :size => 10
= submit_tag _('Search articles')
- if @supplier.shared_supplier.lists
=_ "Search in following lists: "
- @supplier.shared_supplier.lists.each do |token, name|
= check_box_tag "lists[#{token}]", "1", true
= name
|
=_ "only regional:"
= check_box_tag "regional", "1", false
#search_results
// "import_search_results" will be rendered
= link_to_function _('Close'), "Element.hide('import')"
.single_column{:style => 'width:100%; clear:both'}
.box_title
.column_content
#links
%b= link_to_remote _('New article'), :url => new_supplier_article_path(@supplier), :before => "Element.show('loader')", :success => "Element.hide('loader')", :method => :get
|
= link_to _('Edit all'), edit_all_supplier_articles_path(@supplier)
|
= link_to _('Upload articles'), upload_supplier_articles_path(@supplier)
|
= link_to_if @current_user.role_orders?, _('Create order'), {:controller => 'orders', :action => 'new', :id => @supplier }
#article_filter
#article_search_form{:style=>"display:inline;"}
- form_remote_tag :url => supplier_articles_path(@supplier), |
:before => "Element.show('loader')", :success => "Element.hide('loader')", |
:method => :get do |
%label{:for => 'article_name'}=_ "Search in article name: "
= text_field_tag("query", params['query'], :size => 10 )
= submit_tag _('Search')
%form{ :action => url_for(update_selected_supplier_articles_path(@supplier)), :method => "post", :id => "articlesInListForm" }
#table= render :partial => 'articles'
%br/
= link_to _('Back'), :action => 'index'
#edit_article{:style => "display:none"}

View File

@ -1,70 +0,0 @@
%h1
=_ 'Articles from'
= @supplier.name
// import menu
- unless @supplier.shared_supplier.nil?
.menu{:style => 'width: 14em'}
%ul
%li
=_ 'External database'
%ul
%li= link_to_function _('search/import'), "Element.toggle('import')"
%li= link_to _('sync'), :action => 'sync_articles', :id => @supplier
#change_supplier{:style => "padding:0 0 0.5em 0.7em;"}
%span{:style => "float:left"}
=_ 'Change supplier:'
- form_tag do
%select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"}
= options_for_select(@suppliers.collect {|s| [ s.name, url_for(:action => "list", :id => s)] }, url_for(:action => "list", :id => @supplier.id))
- unless @supplier.shared_supplier.nil?
#import.single_column{:style => "display:none; clear:both"}
.box_title
%h2=_ 'Import articles'
.column_content
#search{:style => "padding-bottom:3em"}
- form_remote_tag :url => {:action => "list_shared_articles", :id => @supplier}, :before => "Element.show('loader')", :success => "Element.hide('loader')" do
= text_field_tag :import_query, params['import_query'], :size => 10
= submit_tag _('Search articles')
- if @supplier.shared_supplier.lists
=_ "Search in following lists: "
- @supplier.shared_supplier.lists.each do |token, name|
= check_box_tag "lists[#{token}]", "1", true
= name
|
=_ "only regional:"
= check_box_tag "regional", "1", false
#search_results
// "import_search_results" will be rendered
= link_to_function _('Close'), "Element.hide('import')"
.single_column{:style => 'width:100%; clear:both'}
.box_title
.column_content
#links
%b= link_to_remote( _('New article'), :url => {:action => 'newArticle', :supplier => @supplier}, :before => "Element.show('loader')", :success => "Element.hide('loader')")
|
= link_to _('Edit all'), :action => 'edit_all', :id => @supplier
|
= link_to _('Upload articles'), :action => 'upload_articles'
|
= link_to_if @current_user.role_orders?, _('Create order'), {:controller => 'orders', :action => 'new', :id => @supplier }
#article_filter
#article_search_form{:style=>"display:inline;"}
- form_remote_tag :url => {:action => "list", :id => @supplier}, :before => "Element.show('loader')", :success => "Element.hide('loader')" do
%label{:for => 'article_name'}=_ "Search in article name: "
= text_field_tag("query", params['query'], :size => 10 )
= submit_tag _('Search')
%form{ :method => 'post', :action => url_for(:action => 'update_selected_articles', :only_path => true), :id => 'articlesInListForm'}
#table
= render :partial => 'list'
%br/
= link_to _('Back'), :action => 'index'
#edit_article{:style => "display:none"}

View File

@ -1,40 +0,0 @@
%h1=_ "Upload Articles"
%p
%i
=_ "Please check the parsed articles and choose a supplier at the end of page."
%br/
=_ "At the moment there is now checking of dublicate articles."
- form_tag(:action => 'create_articles_from_file') do
%table.list
%tr
%th=_ "Number"
%th=_ "Name"
%th=_ "Note"
%th=_ "Manufacturer"
%th=_ "Origin"
%th=_ "Unit"
%th=_ "Net price"
%th=_ "Tax"
%th=_ "Deposit"
%th=_ "Unit quantity"
%th=_ "Category"
- for @article in @articles
%tr{:class => cycle('even', 'odd')}
%td= text_field 'article[]', 'order_number', :size => 6
%td= text_field 'article[]', 'name', :size => 0
%td= text_field 'article[]', 'note', :size => 15
%td= text_field 'article[]', 'manufacturer', :size => 6
%td= text_field 'article[]', 'origin', :size => 6
%td= text_field 'article[]', 'unit', :size => 5
%td= text_field 'article[]', 'net_price', :size => 4
%td= text_field 'article[]', 'tax', :size => 4
%td= text_field 'article[]', 'deposit', :size => 4
%td= text_field 'article[]', 'unit_quantity', :size => 4
%td= select('article[]', 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] })
%p
=_ "Choose a supplier:"
= select('supplier', 'id', Supplier.find(:all).collect {|s| [ s.name, s.id ] }, :selected => nil)
= submit_tag _("Save articles")
%p= link_to _("Back"), :action => 'upload_articles'

View File

@ -0,0 +1,40 @@
- title "#{@supplier.name} / Artikel hochladen"
%p
%i
=_ "Please check the parsed articles and choose a supplier at the end of page."
%br/
=_ "At the moment there is no checking of dublicate articles."
- form_tag(create_from_upload_supplier_articles_path(@supplier)) do
%table
%tr
%th=_ "Number"
%th=_ "Name"
%th=_ "Note"
%th=_ "Manufacturer"
%th=_ "Origin"
%th=_ "Unit"
%th=_ "Net price"
%th=_ "Tax"
%th=_ "Deposit"
%th=_ "Unit quantity"
%th=_ "Category"
- for article in @articles
- fields_for "articles[]", article do |form|
%tr{:class => cycle('even', 'odd')}
%td= form.text_field 'order_number', :size => 6
%td= form.text_field 'name', :size => 0
%td= form.text_field 'note', :size => 15
%td= form.text_field 'manufacturer', :size => 6
%td= form.text_field 'origin', :size => 6
%td= form.text_field 'unit', :size => 5
%td= form.text_field 'net_price', :size => 4
%td= form.text_field 'tax', :size => 4
%td= form.text_field 'deposit', :size => 4
%td= form.text_field 'unit_quantity', :size => 4
%td= form.select 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }
%p
= submit_tag "Save new Articles for #{@supplier.name}"
|
= link_to _("Back"), upload_supplier_articles_path(@supplier)

View File

@ -1,6 +1,6 @@
%h1 Artikel mit externer Datenbank synchronisieren %h1 Artikel mit externer Datenbank synchronisieren
- form_tag :action => 'update_all', :id => @supplier, :sync => "1" do - form_tag update_all_supplier_articles_path(@supplier, :sync => "1") do
%h2 Auslisten ... %h2 Auslisten ...
%p %p
- unless @outlisted_articles.empty? - unless @outlisted_articles.empty?

View File

@ -1,4 +1,4 @@
%h1=_ "Upload articles" - title "#{@supplier.name} / Artikel hochladen"
%p %p
%i %i
=_ 'The file-type must be "csv" (textfile). Use a semicolon (";") to seperate the fields and double quotes ("Bananas...") for the text.' =_ 'The file-type must be "csv" (textfile). Use a semicolon (";") to seperate the fields and double quotes ("Bananas...") for the text.'
@ -13,6 +13,6 @@
_("Scale quantity"), _("Scale price"), _("Category")].join(" | ") | _("Scale quantity"), _("Scale price"), _("Category")].join(" | ") |
#uploadArticles.uploadForm #uploadArticles.uploadForm
- form_for(:articles, :url => {:action => 'parse_articles'}, :html => { :multipart => true }) do |form| - form_for(:articles, :url => parse_upload_supplier_articles_path(@supplier), :html => { :multipart => true }) do |form|
%p= form.file_field("file") %p= form.file_field("file")
%p= submit_tag _("Upload articles") %p= submit_tag _("Upload articles")

View File

@ -23,11 +23,11 @@
{ :name => "Manage orders", :url => "/orders", :access? => (u.role_orders?) } { :name => "Manage orders", :url => "/orders", :access? => (u.role_orders?) }
] ]
}, },
{ :name => "Articles", :url => "/articles", :active => ["articles", "suppliers", "deliveries"], { :name => "Articles", :url => "/suppliers", :active => ["articles", "suppliers", "deliveries", "article_categories"],
:access? => (u.role_article_meta? || u.role_suppliers?), :access? => (u.role_article_meta? || u.role_suppliers?),
:subnav => [ :subnav => [
{ :name => "Show articles", :url => "/articles/list" }, { :name => "Show articles", :url => "/suppliers" },
{ :name => "Categories", :url => "/articles" }, { :name => "Categories", :url => "/suppliers" },
{ :name => "Suppliers", :url => suppliers_path, :access? => (u.role_suppliers?) } { :name => "Suppliers", :url => suppliers_path, :access? => (u.role_suppliers?) }
] ]
}, },

View File

@ -0,0 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>ArticleCategories: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<p style="color: green"><%= flash[:notice] %></p>
<%= yield %>
</body>
</html>

View File

@ -1,6 +1,9 @@
- title "LieferantInnen" - title "Artikeldatenbank"
- if @current_user.role_suppliers? .left_column{:style => "width:50%"}
.box_title
%h2 Lieferanten
.column_content
%p %p
%i %i
Erstelle eine Erstelle eine
@ -8,22 +11,24 @@
oder oder
= link_to 'importiere', shared_suppliers_suppliers_path = link_to 'importiere', shared_suppliers_suppliers_path
aus der externen ArtikelDatenbank. aus der externen ArtikelDatenbank.
%table.list
.left_column{:style => "width:100%"} %thead
.box_title
%h2 Übersicht
.column_content
%table
%tr %tr
- for column in @supplier_column_names %th Name
%th= column %th Telefon
%th KundenNr
%th %th
%tbody
- for supplier in @suppliers - for supplier in @suppliers
%tr{:class => cycle('even','odd', :name => 'suppliers')} %tr{:class => cycle('even','odd', :name => 'suppliers')}
- for column in @supplier_columns %td= link_to "<b>#{h(supplier.name)}</b> (#{supplier.articles.count})", supplier_articles_path(supplier)
%td %td=h supplier.phone
- if column == 'name' %td=h supplier.customer_number
= link_to supplier[column], supplier %td= link_to "Anzeigen", supplier
- else
=h supplier[column] .right_column{:style => "width:47%"}
%td= link_to 'Artikel anzeigen', :controller => 'articles', :action => 'list', :id => supplier .box_title
%h2 Artikelkategorien
.column_content#categories
#category_form.box.edit_form{:style => "display:none;margin-bottom:1em;"}
#category_list= render :partial => 'article_categories/list'

View File

@ -1,4 +1,5 @@
ActionController::Routing::Routes.draw do |map| ActionController::Routing::Routes.draw do |map|
map.my_profile '/home/profile', :controller => 'home', :action => 'profile' map.my_profile '/home/profile', :controller => 'home', :action => 'profile'
map.my_tasks '/home/tasks', :controller => 'tasks', :action => 'myTasks' map.my_tasks '/home/tasks', :controller => 'tasks', :action => 'myTasks'
@ -19,7 +20,12 @@ ActionController::Routing::Routes.draw do |map|
map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers| map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers|
suppliers.resources :deliveries, :member => { :drop_stock_change => :post } suppliers.resources :deliveries, :member => { :drop_stock_change => :post }
suppliers.resources :articles,
:collection => { :update_selected => :post, :edit_all => :get, :update_all => :post,
:upload => :get, :parse_upload => :post, :create_from_upload => :post,
:shared => :get, :import => :get, :sync => :post }
end end
map.resources :article_categories
map.root :controller => 'home', :action => 'index' map.root :controller => 'home', :action => 'index'

View File

@ -252,7 +252,7 @@ div.edit_form {
position: fixed; position: fixed;
top: 23%; top: 23%;
left: 10em; left: 10em;
width: 50em; width: 55em;
background: #FBFBFB; background: #FBFBFB;
padding: 3em; padding: 3em;
padding-top: 1em; padding-top: 1em;

View File

@ -252,7 +252,7 @@ div.edit_form {
position: fixed; position: fixed;
top: 23%; top: 23%;
left: 10em; left: 10em;
width: 50em; width: 55em;
background: #FBFBFB; background: #FBFBFB;
padding: 3em; padding: 3em;
padding-top: 1em; padding-top: 1em;

View File

@ -33,24 +33,23 @@ h3.error {
#errorExplanation { #errorExplanation {
width: 40em; width: 40em;
border: 2px solid red;
padding: 7px; padding: 7px;
padding-bottom: 12px; padding-bottom: 12px;
margin-bottom: 20px; color: #ed0606; }
background-color: #f0f0f0; }
#errorExplanation h2 { #errorExplanation h2 {
color: #ed0606;
text-align: left; text-align: left;
font-weight: bold; font-weight: bold;
padding: 5px 5px 5px 15px; margin: 0;
font-size: 12px; padding: 5px 5px 5px 5px;
margin: -7px; font-size: 15px; }
background-color: #ed0606;
color: #fff; }
#errorExplanation p { #errorExplanation p {
color: #333; margin: 0;
margin-bottom: 0;
padding: 5px; } padding: 5px; }
#errorExplanation ul li { #errorExplanation ul, #errorExplanation li {
margin: 0; }
#errorExplanation li {
padding: 0;
font-size: 12px; font-size: 12px;
list-style: square; } list-style: square; }

View File

@ -281,7 +281,7 @@ div.edit_form
:position fixed :position fixed
:top 23% :top 23%
:left 10em :left 10em
:width 50em :width 55em
:background #FBFBFB :background #FBFBFB
:padding 3em :padding 3em
:padding-top 1em :padding-top 1em

View File

@ -33,24 +33,23 @@ h3.error
#errorExplanation #errorExplanation
:width 40em :width 40em
:border 2px solid red
:padding 7px :padding 7px
:padding-bottom 12px :padding-bottom 12px
:margin-bottom 20px :color = !main_red
:background-color #f0f0f0
h2 h2
:color = !main_red
:text-align left :text-align left
:font-weight bold :font-weight bold
:padding 5px 5px 5px 15px :margin 0
:font-size 12px :padding 5px 5px 5px 5px
:margin -7px :font-size 15px
:background-color = !main_red
:color #fff
p p
:color #333 :margin 0
:margin-bottom 0
:padding 5px :padding 5px
ul li ul, li
:margin 0
li
:padding 0
:font-size 12px :font-size 12px
:list-style square :list-style square

View File

@ -0,0 +1,45 @@
require 'test_helper'
class ArticleCategoriesControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:article_categories)
end
test "should get new" do
get :new
assert_response :success
end
test "should create article_category" do
assert_difference('ArticleCategory.count') do
post :create, :article_category => { }
end
assert_redirected_to article_category_path(assigns(:article_category))
end
test "should show article_category" do
get :show, :id => article_categories(:one).id
assert_response :success
end
test "should get edit" do
get :edit, :id => article_categories(:one).id
assert_response :success
end
test "should update article_category" do
put :update, :id => article_categories(:one).id, :article_category => { }
assert_redirected_to article_category_path(assigns(:article_category))
end
test "should destroy article_category" do
assert_difference('ArticleCategory.count', -1) do
delete :destroy, :id => article_categories(:one).id
end
assert_redirected_to article_categories_path
end
end