Improved the creation/updating of deliveries.
This commit is contained in:
parent
67743cd014
commit
cd9636a650
7 changed files with 93 additions and 43 deletions
|
@ -1,6 +1,6 @@
|
||||||
class DeliveriesController < ApplicationController
|
class DeliveriesController < ApplicationController
|
||||||
|
|
||||||
before_filter :find_supplier
|
before_filter :find_supplier, :exclude => :fill_new_stock_article_form
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@deliveries = @supplier.deliveries.find(:all)
|
@deliveries = @supplier.deliveries.find(:all)
|
||||||
|
@ -99,4 +99,30 @@ 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
|
||||||
|
|
||||||
|
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
|
end
|
||||||
|
|
|
@ -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)
|
|
|
@ -1,8 +1,6 @@
|
||||||
- remote_form_for stock_article, :url => add_stock_article_supplier_deliveries_path(@supplier) do |form|
|
- remote_form_for stock_article, :url => add_stock_article_supplier_deliveries_path(@supplier) do |form|
|
||||||
= form.error_messages
|
= form.error_messages
|
||||||
|
|
||||||
%p
|
|
||||||
remote_link_to "Artikel aus dem Katalog wählen"...
|
|
||||||
%p
|
%p
|
||||||
= form.label :name
|
= form.label :name
|
||||||
%br/
|
%br/
|
||||||
|
|
|
@ -4,13 +4,34 @@
|
||||||
%b Lieferant:
|
%b Lieferant:
|
||||||
= @supplier.name
|
= @supplier.name
|
||||||
|
|
||||||
- render :layout => 'form' do
|
- form_for([@supplier,@delivery]) do |f|
|
||||||
%table{:style => "width:40em"}
|
= 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
|
- for stock_change in @delivery.stock_changes
|
||||||
%tr[stock_change]
|
%tr[stock_change]
|
||||||
%td= stock_change.article.name
|
%td= stock_change.stock_article.name
|
||||||
%td= stock_change.quantity
|
%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
|
%td
|
||||||
= link_to_remote "Artikel entfernen", |
|
= link_to_remote "Artikel entfernen", |
|
||||||
:url => drop_stock_change_supplier_delivery_path(@supplier, @delivery, :stock_change_id => stock_change), |
|
:url => drop_stock_change_supplier_delivery_path(@supplier, @delivery, :stock_change_id => stock_change), |
|
||||||
:method => :post |
|
:method => :post |
|
||||||
|
%p
|
||||||
|
= f.submit "Speichern"
|
||||||
|
|
||||||
|
= link_to 'Zurück', supplier_deliveries_path(@supplier)
|
||||||
|
|
|
@ -20,6 +20,19 @@
|
||||||
.box_title
|
.box_title
|
||||||
%h2 Neuen Lagerartikel anlegen
|
%h2 Neuen Lagerartikel anlegen
|
||||||
.column_content
|
.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
|
#new_stock_article
|
||||||
= render :partial => 'new_stock_article', :locals => {:stock_article => @supplier.stock_articles.build}
|
= render :partial => 'new_stock_article', :locals => {:stock_article => @supplier.stock_articles.build}
|
||||||
|
|
||||||
|
|
|
@ -26,21 +26,24 @@
|
||||||
.column_content
|
.column_content
|
||||||
- if (@template_orders && !@template_orders.empty?)
|
- if (@template_orders && !@template_orders.empty?)
|
||||||
%p
|
%p
|
||||||
%label{:for => 'template'}=_ "Use article selection from"
|
%label{:for => 'template'} Benutze Artikelauswahl von
|
||||||
%select{:name => "template_id", :onchange => "useTemplate(this[this.selectedIndex].value)"}
|
%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
|
- i = -1
|
||||||
- for order in @template_orders
|
- for order in @template_orders
|
||||||
%option{:value => (i += 1)}= "#{h(order.name)} bis #{order.ends.strftime('%d. %b')}"
|
%option{:value => (i += 1)}= "#{h(order.name)} bis #{order.ends.strftime('%d. %b')}"
|
||||||
%table.list
|
%table.list
|
||||||
%tr
|
%tr
|
||||||
%th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
|
%th= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
|
||||||
%th=_ "Name"
|
%th Name
|
||||||
%th=_ "Note"
|
%th Notiz
|
||||||
%th=_ "Origin"
|
- if @order.stockit?
|
||||||
%th=_ "Manufacturer"
|
%th Verfügbar
|
||||||
%th=_ "Unit quantity"
|
- else
|
||||||
%th=_ "Price"
|
%th Herkunft
|
||||||
|
%th Hersteller
|
||||||
|
%th Gebinde
|
||||||
|
%th Preis (netto/FC)
|
||||||
- for category_name, articles in @order.articles_for_ordering
|
- for category_name, articles in @order.articles_for_ordering
|
||||||
%tr{:style => "background-color:#EFEFEF"}
|
%tr{:style => "background-color:#EFEFEF"}
|
||||||
%td
|
%td
|
||||||
|
@ -54,6 +57,9 @@
|
||||||
%td= check_box_tag "order[article_ids][]", article.id, included, { :id => "checkbox_#{article.id}", :onclick => "checkRow('#{article.id}')" }
|
%td= check_box_tag "order[article_ids][]", article.id, included, { :id => "checkbox_#{article.id}", :onclick => "checkRow('#{article.id}')" }
|
||||||
%td=h article.name
|
%td=h article.name
|
||||||
%td=h truncate article.note, :length => 25
|
%td=h truncate article.note, :length => 25
|
||||||
|
- if @order.stockit?
|
||||||
|
%td= "#{article.quantity_available} * #{article.unit}"
|
||||||
|
- else
|
||||||
%td=h truncate article.origin, :length => 15
|
%td=h truncate article.origin, :length => 15
|
||||||
%td=h truncate article.manufacturer, :length => 15
|
%td=h truncate article.manufacturer, :length => 15
|
||||||
%td= "#{article.unit_quantity} x #{article.unit}"
|
%td= "#{article.unit_quantity} x #{article.unit}"
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th Artikel
|
%th Artikel
|
||||||
%th Menge
|
%th im Lager
|
||||||
|
%th davon bestellt
|
||||||
%th Einheit
|
%th Einheit
|
||||||
%th Preis
|
%th Preis
|
||||||
%th Lieferant
|
%th Lieferant
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
%tr{:class => cycle("even", "odd")}
|
%tr{:class => cycle("even", "odd")}
|
||||||
%td=h article.name
|
%td=h article.name
|
||||||
%td= article.quantity
|
%td= article.quantity
|
||||||
|
%td= article.quantity - article.quantity_available
|
||||||
%td= article.unit
|
%td= article.unit
|
||||||
%td= article.price
|
%td= article.price
|
||||||
%td= link_to article.supplier.name, article.supplier
|
%td= link_to article.supplier.name, article.supplier
|
||||||
|
|
Loading…
Reference in a new issue