diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb index 6ea65633..34a2bd46 100644 --- a/app/controllers/deliveries_controller.rb +++ b/app/controllers/deliveries_controller.rb @@ -1,7 +1,7 @@ class DeliveriesController < ApplicationController - before_filter :find_supplier - + before_filter :find_supplier, :exclude => :fill_new_stock_article_form + def index @deliveries = @supplier.deliveries.find(:all) @@ -99,4 +99,30 @@ class DeliveriesController < ApplicationController page.visual_effect :DropOut, "stock_change_#{stock_change.id}" end end + + def auto_complete_for_article_name + @articles = @supplier.articles.find(:all, + :conditions => [ "LOWER(articles.name) LIKE ?", '%' + params[:article][:name].downcase + '%' ], + :limit => 8) + render :partial => 'shared/auto_complete_articles' + end + + def fill_new_stock_article_form + article = Article.find(params[:article_id]) + @supplier = article.supplier + stock_article = @supplier.stock_articles.build( + article.attributes.reject { |attr| attr == ('id' || 'type')} + ) + + render :partial => 'new_stock_article', :locals => {:stock_article => stock_article} + end + + def in_place_edit_for_stock_quantity + stock_change = StockChange.find(params[:editorId]) + if stock_change.update_attribute(:quantity, params[:value]) + render :inline => params[:value] + else + render :inline => "Ein Fehler ist aufgetreten." + end + end end diff --git a/app/views/deliveries/_form.html.haml b/app/views/deliveries/_form.html.haml deleted file mode 100644 index 5a813fa0..00000000 --- a/app/views/deliveries/_form.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -- form_for([@supplier,@delivery]) do |f| - = f.error_messages - = f.hidden_field :supplier_id - %p - %b= f.label :delivered_on - = f.date_select :delivered_on - - %h2 Artikel - #stock_changes - = yield - %br/ - = add_article_link - %p - = f.submit "Speichern" - -= link_to 'Zurück', supplier_deliveries_path(@supplier) \ No newline at end of file diff --git a/app/views/deliveries/_new_stock_article.html.haml b/app/views/deliveries/_new_stock_article.html.haml index aafc1966..37513911 100644 --- a/app/views/deliveries/_new_stock_article.html.haml +++ b/app/views/deliveries/_new_stock_article.html.haml @@ -1,8 +1,6 @@ - remote_form_for stock_article, :url => add_stock_article_supplier_deliveries_path(@supplier) do |form| = form.error_messages - %p - remote_link_to "Artikel aus dem Katalog wählen"... %p = form.label :name %br/ diff --git a/app/views/deliveries/edit.html.haml b/app/views/deliveries/edit.html.haml index 47c418ad..4a15d1ac 100644 --- a/app/views/deliveries/edit.html.haml +++ b/app/views/deliveries/edit.html.haml @@ -4,13 +4,34 @@ %b Lieferant: = @supplier.name -- render :layout => 'form' do - %table{:style => "width:40em"} - - for stock_change in @delivery.stock_changes - %tr[stock_change] - %td= stock_change.article.name - %td= stock_change.quantity - %td - = link_to_remote "Artikel entfernen", | - :url => drop_stock_change_supplier_delivery_path(@supplier, @delivery, :stock_change_id => stock_change), | - :method => :post | +- form_for([@supplier,@delivery]) do |f| + = f.error_messages + = f.hidden_field :supplier_id + %p + %b= f.label :delivered_on + = f.date_select :delivered_on + + %h2 Artikel + #stock_changes + %table.list{:style => "width:40em"} + %tr + %th Name + %th Menge + %th + - for stock_change in @delivery.stock_changes + %tr[stock_change] + %td= stock_change.stock_article.name + %td + %span{:id => stock_change.id, :style => "width:5em"}= stock_change.quantity + = javascript_tag "new Ajax.InPlaceEditor('#{stock_change.id}', | + '/deliveries/in_place_edit_for_stock_quantity', | + {size: 5, });" | + %td + = link_to_remote "Artikel entfernen", | + :url => drop_stock_change_supplier_delivery_path(@supplier, @delivery, :stock_change_id => stock_change), | + :method => :post | + %p + = f.submit "Speichern" + += link_to 'Zurück', supplier_deliveries_path(@supplier) + \ No newline at end of file diff --git a/app/views/deliveries/new.html.haml b/app/views/deliveries/new.html.haml index ac504f4a..8fc41c09 100644 --- a/app/views/deliveries/new.html.haml +++ b/app/views/deliveries/new.html.haml @@ -20,8 +20,21 @@ .box_title %h2 Neuen Lagerartikel anlegen .column_content + %p + :javascript + function fillNewStockArticle(text, li) { + new Ajax.Updater('new_stock_article', '/deliveries/fill_new_stock_article_form', { + method: 'get', + parameters: {article_id: li.id} + }); + } + Suche nach Artikeln aus dem Katalog: + = text_field_with_auto_complete :article, :name, {}, | + {:url => {:action => 'auto_complete_for_article_name', :supplier_id => @supplier.id}, | + :after_update_element => 'fillNewStockArticle'} | + %hr/ #new_stock_article = render :partial => 'new_stock_article', :locals => {:stock_article => @supplier.stock_articles.build} %p{:style => "clear:both"} - = link_to 'Zurück', supplier_deliveries_path(@supplier) + = link_to 'Zurück', supplier_deliveries_path(@supplier) \ No newline at end of file diff --git a/app/views/orders/_form.html.haml b/app/views/orders/_form.html.haml index 24e7cfde..f725a4b4 100644 --- a/app/views/orders/_form.html.haml +++ b/app/views/orders/_form.html.haml @@ -26,21 +26,24 @@ .column_content - if (@template_orders && !@template_orders.empty?) %p - %label{:for => 'template'}=_ "Use article selection from" + %label{:for => 'template'} Benutze Artikelauswahl von %select{:name => "template_id", :onchange => "useTemplate(this[this.selectedIndex].value)"} - %option{:value => "-1", :selected => "selected"}=_ "Choose an order..." + %option{:value => "-1", :selected => "selected"} Bestellung auswählen... - i = -1 - for order in @template_orders %option{:value => (i += 1)}= "#{h(order.name)} bis #{order.ends.strftime('%d. %b')}" %table.list %tr %th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" } - %th=_ "Name" - %th=_ "Note" - %th=_ "Origin" - %th=_ "Manufacturer" - %th=_ "Unit quantity" - %th=_ "Price" + %th Name + %th Notiz + - if @order.stockit? + %th Verfügbar + - else + %th Herkunft + %th Hersteller + %th Gebinde + %th Preis (netto/FC) - for category_name, articles in @order.articles_for_ordering %tr{:style => "background-color:#EFEFEF"} %td @@ -54,9 +57,12 @@ %td= check_box_tag "order[article_ids][]", article.id, included, { :id => "checkbox_#{article.id}", :onclick => "checkRow('#{article.id}')" } %td=h article.name %td=h truncate article.note, :length => 25 - %td=h truncate article.origin, :length => 15 - %td=h truncate article.manufacturer, :length => 15 - %td= "#{article.unit_quantity} x #{article.unit}" + - if @order.stockit? + %td= "#{article.quantity_available} * #{article.unit}" + - else + %td=h truncate article.origin, :length => 15 + %td=h truncate article.manufacturer, :length => 15 + %td= "#{article.unit_quantity} x #{article.unit}" %td= "#{number_to_currency(article.price)} / #{number_to_currency(article.fc_price)}" %tr %td{:colspan => "6"} diff --git a/app/views/stockit/index.html.haml b/app/views/stockit/index.html.haml index 793a60db..42251524 100644 --- a/app/views/stockit/index.html.haml +++ b/app/views/stockit/index.html.haml @@ -14,7 +14,8 @@ %thead %tr %th Artikel - %th Menge + %th im Lager + %th davon bestellt %th Einheit %th Preis %th Lieferant @@ -24,6 +25,7 @@ %tr{:class => cycle("even", "odd")} %td=h article.name %td= article.quantity + %td= article.quantity - article.quantity_available %td= article.unit %td= article.price %td= link_to article.supplier.name, article.supplier