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,73 +1,63 @@
= form.error_messages = simple_form_for @order do |f|
.single_column
.box_title
%h2 Bestellung für #{@order.supplier.name}
.column_content
= f.hidden_field :supplier_id
= f.input :note
= f.input :starts
= f.input :ends
.single_column .box_title
.box_title %h2 Artikel
%h2 Bestellung .column_content
.column_content - if (@template_orders && !@template_orders.empty?)
= form.hidden_field :supplier_id %p
%p %label{:for => 'template'} Benutze Artikelauswahl von
Lieferantin: %select{:name => "template_id", :onchange => "useTemplate(this[this.selectedIndex].value)"}
= @order.name %option{:value => "-1", :selected => "selected"} Bestellung auswählen...
%p - i = -1
Notiz - for order in @template_orders
%br/ %option{:value => (i += 1)}= "#{h(order.name)} bis #{order.ends.strftime('%d. %b')}"
= form.text_area :note, :cols => 50, :rows => 5 %table.list
%p %tr
Start %th= check_box_tag 'checkall', "1", false, { 'data-check-all' => 'form.order' }
%br/ %th Name
= form.datetime_select :starts, :start_year => Time.now.year - 1 %th Notiz
%p - if @order.stockit?
Ende %th Verfügbar
%br/ - else
= form.datetime_select :ends, :start_year => Time.now.year - 1, :include_blank => true %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
%td{:colspan => "6", :style => "text-align:left"}
%b=h category_name
- for article in articles
/ check if the article is selected
- included = @order.order_articles.detect { |order_article| order_article.article_id == article.id }
- included_class = included ? ' selected' : ''
%tr{:class => cycle('even', 'odd') + ' click-me' + included_class, :id => article.id.to_s, :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 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.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"}
= check_box_tag 'checkall', "1", false, { 'data-check-all' => 'form.order' }
Alle auswählen
.box_title - if (@template_orders && !@template_orders.empty?)
%h2 Artikel = render :partial => 'template_orders_script'
.column_content
- if (@template_orders && !@template_orders.empty?)
%p
%label{:for => 'template'} Benutze Artikelauswahl von
%select{:name => "template_id", :onchange => "useTemplate(this[this.selectedIndex].value)"}
%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 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
%td{:colspan => "6", :style => "text-align:left"}
%b=h category_name
- for article in articles
/ check if the article is selected
- included = @order.order_articles.detect { |order_article| order_article.article_id == article.id }
- included_class = included ? ' selected' : ''
%tr{:class => cycle('even', 'odd') + ' click-me' + included_class, :id => article.id.to_s, :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 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.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"}
= check_box_tag 'checkall', "1", false, { :onclick => "checkUncheckAll(this)" }
Alle auswählen
- if (@template_orders && !@template_orders.empty?) = f.submit
= render :partial => 'template_orders_script' = 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_tag :switch_supplier,
%select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"} options_for_suppliers_to_select,
%option{:selected => 'selected'} Lieferantin auswählen... :style => "font-size: 0.9em;margin-left:1em;",
= options_for_suppliers_to_select '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() {