Fixed orders form.

This commit is contained in:
benni 2011-06-10 13:53:51 +02:00
parent 9ad93e9c06
commit afb2c26ab3
7 changed files with 77 additions and 94 deletions

View file

@ -12,8 +12,9 @@ module OrdersHelper
end
def options_for_suppliers_to_select
suppliers = Supplier.without_deleted.collect {|s| [ s.name, url_for(:action => "new", :supplier_id => s)] }
stockit = [["Lager", url_for(:action => 'new', :supplier_id => 0)]]
options_for_select(stockit + suppliers)
options = [["Lieferantin/Lager auswählen"]]
options += Supplier.all.map {|s| [ s.name, url_for(:action => "new", :supplier_id => s)] }
options += [["Lager", url_for(:action => 'new', :supplier_id => 0)]]
options_for_select(options)
end
end

View file

@ -37,12 +37,12 @@ class Order < ActiveRecord::Base
def articles_for_ordering
if stockit?
StockArticle.available.without_deleted(:include => :article_category,
StockArticle.available.all(:include => :article_category,
:order => 'article_categories.name, articles.name').reject{ |a|
a.quantity_available <= 0
}.group_by { |a| a.article_category.name }
else
supplier.articles.available.without_deleted.group_by { |a| a.article_category.name }
supplier.articles.available.all.group_by { |a| a.article_category.name }
end
end

View file

@ -1,25 +1,12 @@
= form.error_messages
= simple_form_for @order do |f|
.single_column
.box_title
%h2 Bestellung
%h2 Bestellung für #{@order.supplier.name}
.column_content
= form.hidden_field :supplier_id
%p
Lieferantin:
= @order.name
%p
Notiz
%br/
= form.text_area :note, :cols => 50, :rows => 5
%p
Start
%br/
= form.datetime_select :starts, :start_year => Time.now.year - 1
%p
Ende
%br/
= form.datetime_select :ends, :start_year => Time.now.year - 1, :include_blank => true
= f.hidden_field :supplier_id
= f.input :note
= f.input :starts
= f.input :ends
.box_title
%h2 Artikel
@ -34,7 +21,7 @@
%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= check_box_tag 'checkall', "1", false, { 'data-check-all' => 'form.order' }
%th Name
%th Notiz
- if @order.stockit?
@ -66,8 +53,11 @@
%td= "#{number_to_currency(article.price)} / #{number_to_currency(article.fc_price)}"
%tr
%td{:colspan => "6"}
= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
= check_box_tag 'checkall', "1", false, { 'data-check-all' => 'form.order' }
Alle auswählen
- if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script'
= f.submit
= link_to "oder abbrechen", orders_path

View file

@ -1,7 +1,3 @@
- title _("Edit order")
- title "Bestellung bearbeiten"
- form_for @order do |form|
= render :partial => 'form', :locals => { :form => form }
= submit_tag "Speichern"
|
= link_to "Abbrechen", :action => 'show', :id => @order
= render :partial => 'form'

View file

@ -1,12 +1,12 @@
- title "Bestellungen verwalten"
- if @current_user.role_orders?
%p
- form_tag do
Neue Bestellung anlegen für
%select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"}
%option{:selected => 'selected'} Lieferantin auswählen...
= options_for_suppliers_to_select
= select_tag :switch_supplier,
options_for_suppliers_to_select,
:style => "font-size: 0.9em;margin-left:1em;",
'data-redirect-to' => true
%br/
.left_column{:style => "width:55em"}
.box_title

View file

@ -1,7 +1,3 @@
- title "Neue Bestellung anlegen"
- form_for @order do |form|
= render :partial => 'form', :locals => { :form => form }
= submit_tag "Bestellung online stellen"
|
= link_to "Abbrechen", orders_path
= render :partial => 'form', :locals => { :f => f }

View file

@ -21,7 +21,7 @@ $(function() {
return false;
});
// Check/Uncheck all checkboxes for s specific form
// Check/Uncheck all checkboxes for a specific form
$('input[data-check-all]').live('click', function() {
var status = $(this).is(':checked')
$($(this).data('check-all')).find('input[type="checkbox"]').each(function() {