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,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
%h2 Bestellung
.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
.box_title
%h2 Artikel
.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, { 'data-check-all' => 'form.order' }
%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, { 'data-check-all' => 'form.order' }
Alle auswählen
.box_title
%h2 Artikel
.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?)
= render :partial => 'template_orders_script'
- 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
%p
- form_tag do
Neue Bestellung anlegen für
= 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() {