Improved delivery creating/updating prozess.

This commit is contained in:
Benjamin Meichsner 2009-08-12 13:38:03 +02:00
parent 16346e3529
commit 83e741c1af
3 changed files with 12 additions and 10 deletions

View file

@ -22,7 +22,6 @@ class DeliveriesController < ApplicationController
def new def new
@delivery = @supplier.deliveries.build @delivery = @supplier.deliveries.build
@delivery.stock_changes.build(:stock_article => @supplier.stock_articles.first)
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
@ -35,7 +34,7 @@ class DeliveriesController < ApplicationController
respond_to do |format| respond_to do |format|
if @delivery.save if @delivery.save
flash[:notice] = 'Delivery was successfully created.' flash[:notice] = 'Lieferung wurde erstellt. Bitte nicht vergessen die Rechnung anzulegen!'
format.html { redirect_to([@supplier,@delivery]) } format.html { redirect_to([@supplier,@delivery]) }
format.xml { render :xml => @delivery, :status => :created, :location => @delivery } format.xml { render :xml => @delivery, :status => :created, :location => @delivery }
else else
@ -54,7 +53,7 @@ class DeliveriesController < ApplicationController
respond_to do |format| respond_to do |format|
if @delivery.update_attributes(params[:delivery]) if @delivery.update_attributes(params[:delivery])
flash[:notice] = 'Delivery was successfully updated.' flash[:notice] = 'Lieferung wurde aktualisiert.'
format.html { redirect_to([@supplier,@delivery]) } format.html { redirect_to([@supplier,@delivery]) }
format.xml { head :ok } format.xml { head :ok }
else else
@ -68,6 +67,7 @@ class DeliveriesController < ApplicationController
@delivery = Delivery.find(params[:id]) @delivery = Delivery.find(params[:id])
@delivery.destroy @delivery.destroy
flash[:notice] = "Lieferung wurde gelöscht."
respond_to do |format| respond_to do |format|
format.html { redirect_to(supplier_deliveries_url(@supplier)) } format.html { redirect_to(supplier_deliveries_url(@supplier)) }
format.xml { head :ok } format.xml { head :ok }

View file

@ -1,4 +1,4 @@
.left_column .left_column(style="width:55%")
- form_for([@supplier,@delivery]) do |f| - form_for([@supplier,@delivery]) do |f|
.box_title .box_title
%h2 Lieferung anlegen %h2 Lieferung anlegen
@ -12,10 +12,10 @@
= stock_change_form.select :stock_article_id, stock_articles_for_select(@supplier) = stock_change_form.select :stock_article_id, stock_articles_for_select(@supplier)
Menge Menge
= stock_change_form.text_field :quantity, :size => 5, :autocomplete => 'off' = stock_change_form.text_field :quantity, :size => 5, :autocomplete => 'off'
Entfernen = stock_change_form.hidden_field :_delete
= stock_change_form.check_box :_delete = link_to_function "Artikel aus Lieferung entfernen", "$(this).previous('input').value = 1; $(this).up('p').hide();"
%p %p
= remote_link_to "Lagerartikel hinzufügen", :url => {:action => 'add_stock_change', :supplier_id => @supplier.id} = remote_link_to "Lagerartikel der Lieferung hinzufügen", :url => {:action => 'add_stock_change', :supplier_id => @supplier.id}
%hr/ %hr/
%p %p
%b= f.label :delivered_on, "Lieferdatum" %b= f.label :delivered_on, "Lieferdatum"
@ -23,11 +23,13 @@
%p %p
%b= f.label :note, "Notiz" %b= f.label :note, "Notiz"
%br/ %br/
= f.text_area :note, :size => "35x8" = f.text_area :note, :size => "35x4"
%p %p
= f.submit "Lieferung speichern" = f.submit "Lieferung speichern"
oder
= link_to "Abbrechen", supplier_deliveries_path(@supplier)
.right_column{:style => "width:35em;"} .right_column{:style => "width:35%;"}
.box_title .box_title
%h2 Neuen Lagerartikel anlegen %h2 Neuen Lagerartikel anlegen
.column_content .column_content

View file

@ -3,4 +3,4 @@
= form.select :stock_article_id, stock_articles_for_select(supplier) = form.select :stock_article_id, stock_articles_for_select(supplier)
Menge Menge
= form.text_field :quantity, :size => 5, :autocomplete => 'off' = form.text_field :quantity, :size => 5, :autocomplete => 'off'
= link_to_function "entfernen", "$(this).up('p').remove()" = link_to_function "Artikel aus Lieferung entfernen", "$(this).up('p').remove()"