Merge branch 'rails3' of http://github.com/bennibu/foodsoft into rails3

Conflicts:
	app/helpers/application_helper.rb
This commit is contained in:
Julius 2013-01-27 22:01:53 +01:00
commit 524819b86f
12 changed files with 73 additions and 50 deletions

View file

@ -157,13 +157,13 @@ function updateBalance() {
var bgcolor = '';
if (balance < 0) {
bgcolor = '#FF0000';
$('#submit_button').disabled = true;
$('#submit_button').attr('disabled', 'disabled')
} else {
$('#submit_button').disabled = false;
$('#submit_button').removeAttr('disabled')
}
// update bgcolor
for (i in itemTotal) {
$('#ltd_price_' + i).css('background-color', bgcolor);
$('#td_price_' + i).css('background-color', bgcolor);
}
}

View file

@ -142,7 +142,8 @@ module ApplicationHelper
# offers a link for writing message to user
# checks for nil (useful for relations)
def link_to_user_message_if_valid(user)
user.nil? ? '??' : ( link_to user.nick, new_message_path(:message => {:mail_to => user.id}), :title => 'Nachricht schreiben' )
user.nil? ? '??' : link_to(user.nick, new_message_path('message[mail_to]' => user.id),
:title => 'Nachricht schreiben')
end
def bootstrap_flash

View file

@ -38,20 +38,23 @@ class GroupOrder < ActiveRecord::Base
# load prices and other stuff....
data[:order_articles] = {}
order.order_articles.each do |order_article|
data[:order_articles][order_article.id] = {
:price => order_article.article.fc_price,
:unit => order_article.article.unit_quantity,
:quantity => (new_record? ? 0 : goas[order_article.id][:quantity]),
:others_quantity => order_article.quantity - (new_record? ? 0 : goas[order_article.id][:quantity]),
:used_quantity => (new_record? ? 0 : goas[order_article.id][:quantity_result]),
:tolerance => (new_record? ? 0 : goas[order_article.id][:tolerance]),
:others_tolerance => order_article.tolerance - (new_record? ? 0 : goas[order_article.id][:tolerance]),
:used_tolerance => (new_record? ? 0 : goas[order_article.id][:tolerance_result]),
:total_price => (new_record? ? 0 : goas[order_article.id][:total_price]),
:missing_units => order_article.missing_units,
:quantity_available => (order.stockit? ? order_article.article.quantity_available : 0)
}
#order.order_articles.each do |order_article|
order.articles_grouped_by_category.each do |article_category, order_articles|
order_articles.each do |order_article|
data[:order_articles][order_article.id] = {
:price => order_article.article.fc_price,
:unit => order_article.article.unit_quantity,
:quantity => (new_record? ? 0 : goas[order_article.id][:quantity]),
:others_quantity => order_article.quantity - (new_record? ? 0 : goas[order_article.id][:quantity]),
:used_quantity => (new_record? ? 0 : goas[order_article.id][:quantity_result]),
:tolerance => (new_record? ? 0 : goas[order_article.id][:tolerance]),
:others_tolerance => order_article.tolerance - (new_record? ? 0 : goas[order_article.id][:tolerance]),
:used_tolerance => (new_record? ? 0 : goas[order_article.id][:tolerance_result]),
:total_price => (new_record? ? 0 : goas[order_article.id][:total_price]),
:missing_units => order_article.missing_units,
:quantity_available => (order.stockit? ? order_article.article.quantity_available : 0)
}
end
end
data

View file

@ -82,9 +82,10 @@ class Order < ActiveRecord::Base
# The array has the following form:
# e.g: [["drugs",[teethpaste, toiletpaper]], ["fruits" => [apple, banana, lemon]]]
def articles_grouped_by_category
order_articles.includes([:article_price, :group_order_articles, :article => :article_category]).
@articles_grouped_by_category ||= order_articles.
includes([:article_price, :group_order_articles, :article => :article_category]).
order('articles.name').
group_by { |a| a.article.article_category.name }.
group_by { |a| a.article.article_category.name }.
sort { |a, b| a[0] <=> b[0] }
end

View file

@ -12,31 +12,34 @@
})
});
.row-fluid
.span6
= simple_form_for [@supplier, @delivery], validate: true do |f|
= f.hidden_field :supplier_id
#stock_changes
= f.fields_for :stock_changes do |stock_change_form|
%p
= stock_change_form.select :stock_article_id, stock_articles_for_select(@supplier)
Menge
= stock_change_form.text_field :quantity, size: 5, autocomplete: 'off'
= stock_change_form.hidden_field :_destroy
= link_to "Artikel aus Lieferung entfernen", "#", class: 'destroy_stock_change'
= simple_form_for [@supplier, @delivery], validate: true do |f|
= f.hidden_field :supplier_id
#stock_changes
= f.fields_for :stock_changes do |stock_change_form|
%p
= link_to "Lagerartikel der Lieferung hinzufügen", {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true
%hr/
= f.input :delivered_on, as: :date_picker
= f.input :note, input_html: {size: '35x4'}
.form-actions
= f.submit class: 'btn btn-primary'
= link_to "oder abbrechen", supplier_deliveries_path(@supplier)
= stock_change_form.select :stock_article_id, stock_articles_for_select(@supplier)
Menge
= stock_change_form.text_field :quantity, size: 5, autocomplete: 'off'
= stock_change_form.hidden_field :_destroy
= link_to "Artikel aus Lieferung entfernen", "#", class: 'destroy_stock_change'
%p
= link_to "Lagerartikel der Lieferung hinzufügen", {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true
%p
%small
Ist ein Artikel noch nicht in der Lagerverwaltung, muss er erst
#{link_to("neu angelegt", new_stock_article_path)} werden.
%hr/
= f.input :delivered_on, as: :date_picker
= f.input :note, input_html: {size: '35x4'}
.form-actions
= f.submit class: 'btn btn-primary'
= link_to "oder abbrechen", supplier_deliveries_path(@supplier)
/
TODO: Fix this!!
.span6
%h2 Neuen Lagerartikel anlegen
%p
//TODO: Fix this!!
Suche nach Artikeln aus dem
%i= @supplier.name
Katalog:

View file

@ -130,7 +130,7 @@
%td Neuer Kontostand:
%td.currency
%strong
%span#new_balance= @ordergroup.account_balance - @group_order.price
%span#new_balance= @ordering_data[:available_funds] - @group_order.price
#order-button
= submit_tag( "Bestellung speichern", id: 'submit_button', class: 'btn btn-primary' )

View file

@ -15,9 +15,9 @@
%li= link_to "Nicht verfügbare Artikel zeigen/verstecken", "#", 'data-toggle-this' => 'tr.unavailable,input.unavailable', tabindex: -1
.btn-group
= link_to "Neuen Lagerartikel anlegen", new_stock_article_path, class: 'btn btn-primary'
= link_to_if @current_user.role_orders?, "Lagerbestellung online stellen", new_order_path(supplier_id: 0),
class: 'btn'
class: 'btn', class: 'btn btn-primary'
= link_to "Neuen Lagerartikel anlegen", new_stock_article_path, class: 'btn'
= link_to "Inventur anlegen", new_stock_taking_path, class: 'btn'
= link_to "Inventurübersicht", stock_takings_path, class: 'btn'
= link_to 'Löschvorschläge', stock_article_selections_path, class: 'btn'

View file

@ -13,7 +13,9 @@
})
%p
/
TODO: Fix this
%p
Suche nach Artikeln aus allen Katalogen:
= text_field_tag 'article_search'
#stock_article_form