Ordering refactored: Made everything RESTful.
This commit is contained in:
parent
45e0048490
commit
eb4705857b
19 changed files with 340 additions and 222 deletions
|
|
@ -28,7 +28,7 @@
|
|||
:active => ["orders", "ordering"],
|
||||
:subnav => [
|
||||
{ :name => "Bestellen!", :url => ordering_path },
|
||||
{ :name => "Meine Bestellungen", :url => my_orders_path },
|
||||
{ :name => "Meine Bestellungen", :url => archive_group_orders_path },
|
||||
{ :name => "Bestellverwaltung", :url => orders_path, :access_denied? => (!u.role_orders?) }
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<script>
|
||||
//<![CDATA[
|
||||
$(function() {
|
||||
<% for row in @add_data_to_js %>
|
||||
<% for row in data_to_js(@ordering_data) %>
|
||||
addData(<%= row.join(", ") %>);
|
||||
<% end %>
|
||||
setGroupBalance(<%= @availableFunds %>);
|
||||
setGroupBalance(<%= @ordering_data[:available_funds] %>);
|
||||
|
||||
// localization
|
||||
setDecimalSeparator(",");
|
||||
|
|
|
|||
23
app/views/ordering/_footer.html.haml
Normal file
23
app/views/ordering/_footer.html.haml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#order-footer
|
||||
#info-box
|
||||
#total-sum
|
||||
%table
|
||||
%tr
|
||||
%td Gesamtbetrag:
|
||||
%td.currency
|
||||
%span#total_price= total
|
||||
€
|
||||
%tr
|
||||
%td Verfügbares Guthaben:
|
||||
%td.currency= number_to_currency(@ordering_data[:available_funds])
|
||||
%tr
|
||||
%td Neuer Kontostand:
|
||||
%td.currency
|
||||
%strong
|
||||
%span#new_balance= @ordergroup.account_balance - total
|
||||
€
|
||||
#order-button
|
||||
= submit_tag( "Bestellung speichern", :id => 'submit_button' )
|
||||
oder #{link_to "abbrechen", :controller => 'ordering'}
|
||||
%input#total_balance{:name => "total_balance", :type => "hidden", :value => @ordergroup.account_balance - total}/
|
||||
%input{:name => "version", :type => "hidden", :value => @version}/
|
||||
90
app/views/ordering/_form.html.haml
Normal file
90
app/views/ordering/_form.html.haml
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
- content_for :head do
|
||||
= render 'data'
|
||||
|
||||
= render :partial => 'order_head'
|
||||
|
||||
- form_for @group_order do |f|
|
||||
= f.hidden_field :lock_version
|
||||
= f.hidden_field :order_id
|
||||
= f.hidden_field :updated_by_user_id
|
||||
= f.hidden_field :ordergroup_id
|
||||
.single_column{:style => "clear:both;margin-bottom:7em;"}
|
||||
.box_title
|
||||
%h2 Artikel
|
||||
.column_content
|
||||
%table#order.list
|
||||
%thead
|
||||
%tr
|
||||
%th Name
|
||||
%th{:style => "width:13px;"}
|
||||
%th{:style => "width:4.5em;"} Preis
|
||||
%th{:style => "width:4.5em;"} Einheit
|
||||
%th{:style => "width:70px;"} Fehlende Einheiten
|
||||
%th#col_required Menge
|
||||
- if not @order.stockit?
|
||||
%th#col_tolerance Toleranz
|
||||
%th{:style => "width:15px;"} Summe
|
||||
%tbody
|
||||
- total = 0
|
||||
- @order.articles_grouped_by_category.each do |category, order_articles|
|
||||
%tr{:style => "background-color:#EFEFEF"}
|
||||
%td{:style => "text-align:left"}
|
||||
%b= h category
|
||||
%td{:colspan => "9"}
|
||||
- order_articles.each do |order_article|
|
||||
- if Foodsoft.config[:tolerance_is_costly]
|
||||
- article_total = @ordering_data[:order_articles][order_article.id][:price] * (@ordering_data[:order_articles][order_article.id][:tolerance] + @ordering_data[:order_articles][order_article.id][:quantity])
|
||||
- else
|
||||
- article_total = @ordering_data[:order_articles][order_article.id][:price] * @ordering_data[:order_articles][order_article.id][:quantity]
|
||||
- total += article_total
|
||||
%tr{:class => "#{cycle('even', 'odd', :name => 'articles')} order-article", :valign => "top"}
|
||||
%td.name= order_article.article.name
|
||||
%td= h order_article.article.origin
|
||||
%td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price])
|
||||
%td= order_article.article.unit
|
||||
%td
|
||||
%span{:id => "missing_units_#{order_article.id}"}
|
||||
- if @order.stockit?
|
||||
- order_article.article.quantity_available
|
||||
- else
|
||||
- missing_units = @ordering_data[:order_articles][order_article.id][:unit] - (((@ordering_data[:order_articles][order_article.id][:quantity] + @ordering_data[:order_articles][order_article.id][:others_quantity]) % @ordering_data[:order_articles][order_article.id][:unit]) + @ordering_data[:order_articles][order_article.id][:tolerance] + @ordering_data[:order_articles][order_article.id][:others_tolerance])
|
||||
- missing_units < 0 ? 0 : missing_units
|
||||
%td.quantity
|
||||
%input{:id => "q_#{order_article.id}", :name => "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", :size => "2", :type => "hidden", :value => @ordering_data[:order_articles][order_article.id][:quantity]}/
|
||||
%span.used{:id => "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||
+
|
||||
%span.unused{:id => "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||
%input{:type => 'button', :value => '+', 'data-increase_quantity' => order_article.id}
|
||||
%input{:type => 'button', :value => '-', 'data-decrease_quantity' => order_article.id}
|
||||
- unless @order.stockit?
|
||||
%td.tolerance
|
||||
%input{:id => "t_#{order_article.id}", :name => "group_order[group_order_articles_attributes][#{order_article.id}][tolerance]", :size => "2", :type => "hidden", :value => @ordering_data[:order_articles][order_article.id][:tolerance]}/
|
||||
- if (@ordering_data[:order_articles][order_article.id][:unit] > 1)
|
||||
%span.used{:id => "t_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_tolerance]
|
||||
+
|
||||
%span.unused{:id => "t_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] - @ordering_data[:order_articles][order_article.id][:used_tolerance]
|
||||
%input{:type => 'button', :value => '+', 'data-increase_tolerance' => order_article.id}
|
||||
%input{:type => 'button', :value => '-', 'data-decrease_tolerance' => order_article.id}
|
||||
%td{:id => "td_price_#{order_article.id}", :style => "text-align:right; padding-right:10px; width:4em"}
|
||||
%span{:id => "price_#{order_article.id}_display"}= number_to_currency(article_total, :unit => "")
|
||||
€
|
||||
.article-info
|
||||
%h3= order_article.article.name
|
||||
.right
|
||||
Volle Gebinde:
|
||||
%span{:id => "units_#{order_article.id}"}= order_article.units_to_order
|
||||
%br/
|
||||
Gesamt-Einheiten:
|
||||
%span{:id => "q_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] + @ordering_data[:order_articles][order_article.id][:others_quantity]
|
||||
%br/
|
||||
Gesamt-Toleranz:
|
||||
%span{:id => "t_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] + @ordering_data[:order_articles][order_article.id][:others_tolerance]
|
||||
%br/
|
||||
.left
|
||||
Hersteller: #{order_article.article.manufacturer}
|
||||
%br/
|
||||
Gebinde: #{@order.stockit? ? order_article.article.quantity_available : @ordering_data[:order_articles][order_article.id][:unit]} * #{h order_article.article.unit}
|
||||
%br/
|
||||
Notiz: #{order_article.article.note}
|
||||
%br/
|
||||
= render "footer", :total => total
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
= "(#{format_time(@group_order.updated_on)})"
|
||||
%p
|
||||
%b Verfügbares Guthaben:
|
||||
= number_to_currency(@availableFunds)
|
||||
= number_to_currency(@ordering_data[:available_funds])
|
||||
%td
|
||||
- unless @order.note.empty?
|
||||
%p
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
- title "Bestellungen der #{@ordergroup.name}"
|
||||
%p
|
||||
Siehe hier alle
|
||||
= link_to "laufenden Bestellungen.", :action => "index"
|
||||
= link_to "laufenden Bestellungen.", ordering_path
|
||||
|
||||
.single_column{:style => "width:50em"}
|
||||
.box_title
|
||||
1
app/views/ordering/edit.html.haml
Normal file
1
app/views/ordering/edit.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render 'form'
|
||||
|
|
@ -10,18 +10,17 @@
|
|||
%td Kontostand:
|
||||
%td{:class => "currency", :style => "width:5em"}= number_to_currency(@ordergroup.account_balance)
|
||||
%tr
|
||||
%td - laufende Bestellungen:
|
||||
%td= "- laufende Bestellungen:"
|
||||
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_open_orders)
|
||||
%tr
|
||||
%td - nicht abgerechnete Bestellungen:
|
||||
%td= "- nicht abgerechnete Bestellungen:"
|
||||
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_finished_orders)
|
||||
%tr
|
||||
%th verfügbares Guthaben:
|
||||
%th{:class => "currency"}= number_to_currency(@ordergroup.get_available_funds)
|
||||
|
||||
.right_column{:style => "width:70%"}
|
||||
// open orders
|
||||
= render :partial => "shared/open_orders"
|
||||
= render :partial => "shared/open_orders", :locals => {:ordergroup => @ordergroup}
|
||||
|
||||
// finished orders
|
||||
- unless Order.finished.empty?
|
||||
|
|
@ -41,4 +40,4 @@
|
|||
.column_content
|
||||
= render :partial => "orders", :locals => {:orders => Order.closed.all(:limit => 5), :pagination => false}
|
||||
%br/
|
||||
= link_to "mehr...", :action => "myOrders"
|
||||
= link_to "mehr...", archive_group_orders_path
|
||||
1
app/views/ordering/new.html.haml
Normal file
1
app/views/ordering/new.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render 'form'
|
||||
|
|
@ -1,21 +1,10 @@
|
|||
- content_for :head do
|
||||
:javascript
|
||||
document.observe("dom:loaded", function() {
|
||||
// initially hide all ignored articles
|
||||
$$('tr.ignored').invoke('hide');
|
||||
$(function() {
|
||||
$('tr.ignored').hide();
|
||||
});
|
||||
function toggleIgnoredArticles() {
|
||||
$$('tr.ignored').invoke('toggle');
|
||||
};
|
||||
|
||||
|
||||
- title "Dein Bestellergebnis für #{@order.name}"
|
||||
#element_navigation
|
||||
= link_to_unless @order.previous == @order, "<< #{@order.previous.name}", :action => "my_order_result", :id => @order.previous
|
||||
|
|
||||
= link_to "Übersicht", :controller => 'ordering'
|
||||
|
|
||||
= link_to_unless @order.next == @order, "#{@order.next.name} >>", :action => "my_order_result", :id => @order.next
|
||||
|
||||
// Order summary
|
||||
.left_column{:style => "width:45em"}
|
||||
|
|
@ -54,7 +43,7 @@
|
|||
%table
|
||||
- for order in Order.open
|
||||
%tr
|
||||
%td= link_to order.name, :action => 'order', :id => order
|
||||
%td= link_to_ordering(order)
|
||||
%td= "("+ time_ago_in_words(order.ends) + ")" if order.ends
|
||||
|
||||
// Article box
|
||||
|
|
@ -63,8 +52,8 @@
|
|||
%h2 Artikelübersicht
|
||||
.column_content#result
|
||||
- if @group_order
|
||||
%p(style="float:right")= link_to_function "Zeige/Verstecke nicht bestellte Artikel", "toggleIgnoredArticles();"
|
||||
%p= link_to("Bestellung ändern", :action => "order", :id => @order) if @order.open?
|
||||
%p(style="float:right")= link_to "Zeige/Verstecke nicht bestellte Artikel", '#', 'data-toggle-this' => 'tr.ignored'
|
||||
%p= link_to("Bestellung ändern", edit_group_order_path(@group_order, :order_id => @order.id)) if @order.open?
|
||||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
|
|
@ -87,26 +76,13 @@
|
|||
%td{:colspan => "9"}
|
||||
- for oa in order_articles
|
||||
- # get the order-results for the ordergroup
|
||||
- goa = oa.group_order_articles.first :conditions => {:group_order_id => @group_order.id}
|
||||
- if goa
|
||||
- quantity = goa.quantity
|
||||
- tolerance = goa.tolerance
|
||||
- result = goa.result
|
||||
- if @order.open?
|
||||
- if Foodsoft.config[:tolerance_is_costly]
|
||||
- sub_total = oa.price.fc_price * (quantity + tolerance)
|
||||
- else
|
||||
- sub_total = oa.price.fc_price * quantity
|
||||
- else
|
||||
- sub_total = oa.price.fc_price * result
|
||||
- else
|
||||
- quantity, tolerance, result, sub_total = 0, 0, 0, 0
|
||||
- goa = oa.group_order_articles.find_by_group_order_id(@group_order.id)
|
||||
- quantity = goa.quantity
|
||||
- tolerance = goa.tolerance
|
||||
- result = goa.result
|
||||
- sub_total = goa.total_price
|
||||
- total += sub_total
|
||||
- # give the article different colors, dependent on order-result
|
||||
- class_name = "ignored"
|
||||
- if (quantity + tolerance > 0)
|
||||
- class_name = result > 0 ? 'success' : 'failed'
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles') + " " + class_name}
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles') + " " + order_article_class_name(quantity, tolerance, result)}
|
||||
%td{:style => "width:40%"}
|
||||
=h oa.article.name
|
||||
- unless oa.article.note.blank?
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
- total = 0
|
||||
- Order.open.each do |order|
|
||||
%tr{:class => cycle('even', 'odd', :name => 'open_orders')}
|
||||
%td= link_to h(order.name), :controller => 'ordering', :action => 'order', :id => order
|
||||
%td= link_to_ordering(order)
|
||||
%td=h format_time(order.ends) unless order.ends.nil?
|
||||
- if group_order = order.group_order(ordergroup)
|
||||
- total += group_order.price
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue