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 end
def options_for_suppliers_to_select def options_for_suppliers_to_select
suppliers = Supplier.without_deleted.collect {|s| [ s.name, url_for(:action => "new", :supplier_id => s)] } options = [["Lieferantin/Lager auswählen"]]
stockit = [["Lager", url_for(:action => 'new', :supplier_id => 0)]] options += Supplier.all.map {|s| [ s.name, url_for(:action => "new", :supplier_id => s)] }
options_for_select(stockit + suppliers) options += [["Lager", url_for(:action => 'new', :supplier_id => 0)]]
options_for_select(options)
end end
end end

View file

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

View file

@ -1,25 +1,12 @@
= form.error_messages = simple_form_for @order do |f|
.single_column
.single_column
.box_title .box_title
%h2 Bestellung %h2 Bestellung für #{@order.supplier.name}
.column_content .column_content
= form.hidden_field :supplier_id = f.hidden_field :supplier_id
%p = f.input :note
Lieferantin: = f.input :starts
= @order.name = f.input :ends
%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
.box_title .box_title
%h2 Artikel %h2 Artikel
@ -34,7 +21,7 @@
%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, { 'data-check-all' => 'form.order' }
%th Name %th Name
%th Notiz %th Notiz
- if @order.stockit? - if @order.stockit?
@ -66,8 +53,11 @@
%td= "#{number_to_currency(article.price)} / #{number_to_currency(article.fc_price)}" %td= "#{number_to_currency(article.price)} / #{number_to_currency(article.fc_price)}"
%tr %tr
%td{:colspan => "6"} %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 Alle auswählen
- if (@template_orders && !@template_orders.empty?) - if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script' = 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'
= render :partial => 'form', :locals => { :form => form }
= submit_tag "Speichern"
|
= link_to "Abbrechen", :action => 'show', :id => @order

View file

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

View file

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

View file

@ -21,7 +21,7 @@ $(function() {
return false; 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() { $('input[data-check-all]').live('click', function() {
var status = $(this).is(':checked') var status = $(this).is(':checked')
$($(this).data('check-all')).find('input[type="checkbox"]').each(function() { $($(this).data('check-all')).find('input[type="checkbox"]').each(function() {