Big feactoring and bug fixing, Mailer, Tasks, GroupOrders
This commit is contained in:
parent
c936813967
commit
5fb0bc2444
43 changed files with 95 additions and 118 deletions
152
app/views/group_orders/_form.html.haml
Normal file
152
app/views/group_orders/_form.html.haml
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
- content_for :head do
|
||||
:javascript
|
||||
$(function() {
|
||||
#{data_to_js(@ordering_data)}
|
||||
setGroupBalance(#{@ordering_data[:available_funds]});
|
||||
setDecimalSeparator(",");
|
||||
setToleranceBehaviour(#{Foodsoft.config[:tolerance_is_costly]});
|
||||
setStockit(#{@order.stockit?});
|
||||
});
|
||||
|
||||
- title "Bestellen"
|
||||
|
||||
.left_column{:style => "width:49em"}
|
||||
.box_title
|
||||
%h2=h @order.name
|
||||
.column_content
|
||||
%table
|
||||
%tr{:valign => "top"}
|
||||
%td{:width => "60%"}
|
||||
%p
|
||||
%b Lieferantin:
|
||||
=h @order.name
|
||||
%p
|
||||
%b Ende:
|
||||
=h format_time(@order.ends)
|
||||
- if @group_order && @group_order.updated_by
|
||||
%p
|
||||
%b Zuletzt bestellt:
|
||||
=h @group_order.updated_by.nick if @group_order.updated_by
|
||||
= "(#{format_time(@group_order.updated_on)})"
|
||||
%p
|
||||
%b Verfügbares Guthaben:
|
||||
= number_to_currency(@ordering_data[:available_funds])
|
||||
%td
|
||||
- unless @order.note.empty?
|
||||
%p
|
||||
%b Notiz:
|
||||
= simple_format(@order.note)
|
||||
- unless @order.stockit? || @order.supplier.min_order_quantity.blank?
|
||||
%p
|
||||
%b Mindestellmenge:
|
||||
=h @order.supplier.min_order_quantity
|
||||
%p
|
||||
%b Gesamtbestellmenge bisher:
|
||||
= number_to_currency @order.sum
|
||||
|
||||
= render :partial => 'switch_order', :locals => {:current_order => @order}
|
||||
|
||||
= 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
|
||||
- unless @order.stockit?
|
||||
%th{:style => "width:70px;"} Fehlende Einheiten
|
||||
%th#col_required Menge
|
||||
%th#col_tolerance Toleranz
|
||||
- else
|
||||
%th(style="width:20px") Verfügbar
|
||||
%th#col_required Menge
|
||||
%th{:style => "width:15px;"} Summe
|
||||
%tbody
|
||||
- @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|
|
||||
%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
|
||||
- if @order.stockit?
|
||||
= @ordering_data[:order_articles][order_article.id][:quantity_available]
|
||||
- else
|
||||
%span{:id => "missing_units_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][: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}
|
||||
|
||||
%td.tolerance{:style => ('display:none' if @order.stockit?)}
|
||||
%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(@ordering_data[:order_articles][order_article.id][:total_price], :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/
|
||||
#order-footer
|
||||
#info-box
|
||||
#total-sum
|
||||
%table
|
||||
%tr
|
||||
%td Gesamtbetrag:
|
||||
%td.currency
|
||||
%span#total_price= @group_order.price
|
||||
€
|
||||
%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 - @group_order.price
|
||||
€
|
||||
#order-button
|
||||
= submit_tag( "Bestellung speichern", :id => 'submit_button' )
|
||||
oder #{link_to "abbrechen", group_orders_path}
|
||||
%input#total_balance{:name => "total_balance", :type => "hidden", :value => @ordergroup.account_balance - @group_order.price}/
|
||||
%input{:name => "version", :type => "hidden", :value => @version}/
|
||||
17
app/views/group_orders/_orders.html.haml
Normal file
17
app/views/group_orders/_orders.html.haml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
- if pagination
|
||||
= pagination_links_remote @closed_orders, :per_page => 10, :update => 'closed_orders'
|
||||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
%th Lieferantin
|
||||
%th Ende
|
||||
%th Summe
|
||||
%tbody
|
||||
- for order in orders
|
||||
- group_order = order.group_order(@ordergroup) # Get GroupOrder if possible
|
||||
- order_class = group_order ? "" : "color:grey"
|
||||
%tr{:class=> cycle('even', 'odd', :name => 'orders'), :style => order_class}
|
||||
%td= group_order.present? ? link_to(order.name, group_order_path(group_order)) : order.name
|
||||
%td= format_time(order.ends)
|
||||
%td{:class => "currency"}= group_order ? number_to_currency(group_order.price) : "--"
|
||||
|
||||
12
app/views/group_orders/_switch_order.html.haml
Normal file
12
app/views/group_orders/_switch_order.html.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
- orders = Order.open.reject{ |order| order == current_order }
|
||||
- unless orders.empty?
|
||||
.right_column{:style => "width:22em"}
|
||||
.box_title
|
||||
%h2 Laufende Bestellungen
|
||||
.column_content
|
||||
%table
|
||||
- for order in orders
|
||||
%tr
|
||||
%td
|
||||
= link_to_ordering(order, 'data-confirm_switch_order' => true)
|
||||
%td= "noch #{time_ago_in_words(order.ends)}" if order.ends
|
||||
17
app/views/group_orders/archive.html.haml
Normal file
17
app/views/group_orders/archive.html.haml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
- title "Bestellungen der #{@ordergroup.name}"
|
||||
%p
|
||||
Siehe hier alle
|
||||
= link_to "laufenden Bestellungen.", group_orders_path
|
||||
|
||||
.single_column{:style => "width:50em"}
|
||||
.box_title
|
||||
%h2 beendet/nicht abgerechnet
|
||||
.column_content
|
||||
= render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false}
|
||||
|
||||
.single_column{:style => "width:50em"}
|
||||
.box_title
|
||||
%h2 abgerechnet
|
||||
.column_content
|
||||
#closed_orders
|
||||
= render :partial => "orders", :locals => {:orders => @closed_orders, :pagination => true}
|
||||
1
app/views/group_orders/edit.html.haml
Normal file
1
app/views/group_orders/edit.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render 'form'
|
||||
43
app/views/group_orders/index.html.haml
Normal file
43
app/views/group_orders/index.html.haml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
- title "Bestellüberblick"
|
||||
|
||||
// Ordergroups Account Balance
|
||||
.left_column{:style => "width:26%"}
|
||||
.box_title
|
||||
%h2=h @ordergroup.name
|
||||
.column_content
|
||||
%table
|
||||
%tr
|
||||
%td Kontostand:
|
||||
%td{:class => "currency", :style => "width:5em"}= number_to_currency(@ordergroup.account_balance)
|
||||
%tr
|
||||
%td= "- laufende Bestellungen:"
|
||||
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_open_orders)
|
||||
%tr
|
||||
%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%"}
|
||||
= render :partial => "shared/open_orders", :locals => {:ordergroup => @ordergroup}
|
||||
|
||||
// finished orders
|
||||
- unless Order.finished.empty?
|
||||
.box_title
|
||||
%h2 Nicht abgerechnete Bestellungen
|
||||
.column_content
|
||||
= render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false}
|
||||
- if @ordergroup.value_of_finished_orders > 0
|
||||
%p
|
||||
Gesamtsumme:
|
||||
%b= number_to_currency(@ordergroup.value_of_finished_orders)
|
||||
|
||||
// closed orders
|
||||
- unless Order.closed.empty?
|
||||
.box_title
|
||||
%h2 Abgerechnete Bestellungen
|
||||
.column_content
|
||||
= render :partial => "orders", :locals => {:orders => Order.closed.all(:limit => 5), :pagination => false}
|
||||
%br/
|
||||
= link_to "mehr...", archive_group_orders_path
|
||||
1
app/views/group_orders/new.html.haml
Normal file
1
app/views/group_orders/new.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render 'form'
|
||||
88
app/views/group_orders/order.html.haml
Normal file
88
app/views/group_orders/order.html.haml
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
- content_for :head do
|
||||
= render 'data'
|
||||
|
||||
= render :partial => 'order_head'
|
||||
|
||||
- form_tag(:action => 'saveOrder', :id => @order) do
|
||||
.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
|
||||
- i = 0
|
||||
- @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 = @price[i] * (@tolerance[i] + @quantity[i])
|
||||
- else
|
||||
- article_total = @price[i] * @quantity[i]
|
||||
- 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(@price[i])
|
||||
%td= order_article.article.unit
|
||||
%td
|
||||
%span{:id => "missing_units_#{i}"}
|
||||
- if @order.stockit?
|
||||
- order_article.article.quantity_available
|
||||
- else
|
||||
- missing_units = @unit[i] - (((@quantity[i] + @others_quantity[i]) % @unit[i]) + @tolerance[i] + @others_tolerance[i])
|
||||
- missing_units < 0 ? 0 : missing_units
|
||||
%td.quantity
|
||||
%input{:id => "q_#{i}", :name => "ordered[#{order_article.id}][quantity]", :size => "2", :type => "hidden", :value => @quantity[i]}/
|
||||
%span.used{:id => "q_used_#{i}"}= @used_quantity[i]
|
||||
+
|
||||
%span.unused{:id => "q_unused_#{i}"}= @quantity[i] - @used_quantity[i]
|
||||
= button_to_function('+', "increaseQuantity(#{i})")
|
||||
= button_to_function('-', "decreaseQuantity(#{i})")
|
||||
- unless @order.stockit?
|
||||
%td.tolerance
|
||||
%input{:id => "t_#{i}", :name => "ordered[#{order_article.id}][tolerance]", :size => "2", :type => "hidden", :value => @tolerance[i]}/
|
||||
- if (@unit[i] > 1)
|
||||
%span.used{:id => "t_used_#{i}"}= @used_tolerance[i]
|
||||
+
|
||||
%span.unused{:id => "t_unused_#{i}"}= @tolerance[i] - @used_tolerance[i]
|
||||
= button_to_function('+', "increaseTolerance(#{i})")
|
||||
= button_to_function('-', "decreaseTolerance(#{i})")
|
||||
%td{:id => "td_price_#{i}", :style => "text-align:right; padding-right:10px; width:4em"}
|
||||
%span{:id => "price_#{i}_display"}= number_to_currency(article_total, :unit => "")
|
||||
€
|
||||
.article-info
|
||||
%h3= order_article.article.name
|
||||
.right
|
||||
Volle Gebinde:
|
||||
%span{:id => "units_#{i}"}= order_article.units_to_order
|
||||
%br/
|
||||
Gesamt-Einheiten:
|
||||
%span{:id => "q_total_#{i}"}= @quantity[i] + @others_quantity[i]
|
||||
%br/
|
||||
Gesamt-Toleranz:
|
||||
%span{:id => "t_total_#{i}"}= @tolerance[i] + @others_tolerance[i]
|
||||
%br/
|
||||
.left
|
||||
Hersteller: #{order_article.article.manufacturer}
|
||||
%br/
|
||||
Gebinde: #{@order.stockit? ? order_article.article.quantity_available : @unit[i]} * #{h order_article.article.unit}
|
||||
%br/
|
||||
Notiz: #{order_article.article.note}
|
||||
%br/
|
||||
- i = i + 1
|
||||
= render "order_footer", :total => total
|
||||
111
app/views/group_orders/show.html.haml
Normal file
111
app/views/group_orders/show.html.haml
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
- content_for :head do
|
||||
:javascript
|
||||
$(function() {
|
||||
$('tr.ignored').hide();
|
||||
});
|
||||
|
||||
- title "Dein Bestellergebnis für #{@order.name}"
|
||||
|
||||
// Order summary
|
||||
.left_column{:style => "width:45em"}
|
||||
.box_title
|
||||
%h2 Zusammenfassung
|
||||
.column_content
|
||||
%table
|
||||
%tr{:valign => "top"}
|
||||
%td{:style => "width:50%"}
|
||||
%p
|
||||
Lieferantin:
|
||||
%b=h @order.name
|
||||
- unless @order.note.blank?
|
||||
%p
|
||||
Notiz:
|
||||
=h @order.note
|
||||
%p
|
||||
Ende:
|
||||
%b=h format_time(@order.ends)
|
||||
%p
|
||||
Bestellsumme:
|
||||
- if @group_order
|
||||
%b=h number_to_currency(@group_order.price)
|
||||
- else
|
||||
%b Du hast nicht bestellt.
|
||||
- if @order.closed?
|
||||
%p
|
||||
= "Abgerechnet von #{@order.updated_by.nick}"
|
||||
= link_to "Kommentare lesen/schreiben", "#comments"
|
||||
|
||||
= render :partial => "switch_order", :locals => {:current_order => @order}
|
||||
|
||||
// Article box
|
||||
.single_column{:style => "clear:both; width:70em;"}
|
||||
.box_title
|
||||
%h2 Artikelübersicht
|
||||
.column_content#result
|
||||
- if @group_order
|
||||
%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
|
||||
%th{:style => "width:40%"} Name
|
||||
%th Gebinde
|
||||
%th Einzelpreis
|
||||
%th
|
||||
%abbr{:title => "Menge + Toleranz"} Bestellt
|
||||
%th
|
||||
%abbr{:title => "Unter Berücksichtigung der derzeitigen Bestellungen aller Gruppen"}
|
||||
- if @order.open?
|
||||
Zu
|
||||
Erhalten
|
||||
%th Gesamtpreis
|
||||
%tbody
|
||||
- total = 0 #set counter for order-sum
|
||||
- for category_name, order_articles in @order.articles_grouped_by_category
|
||||
%tr{:style => "background-color:#EFEFEF"}
|
||||
%td{:style => "text-align:left;"}=h category_name
|
||||
%td{:colspan => "9"}
|
||||
- for oa in order_articles
|
||||
- # get the order-results for the ordergroup
|
||||
- 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
|
||||
%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?
|
||||
= image_tag("lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{oa.id}').show();", :onmouseout => "$('note_#{oa.id}').hide();"})
|
||||
%td= "#{oa.price.unit_quantity} x #{oa.article.unit}"
|
||||
%td= number_to_currency(oa.price.fc_price)
|
||||
%td
|
||||
= quantity
|
||||
= "+ #{tolerance}" if oa.price.unit_quantity > 1
|
||||
%td= result > 0 ? result : "0"
|
||||
%td= number_to_currency(sub_total)
|
||||
- unless oa.article.note.blank?
|
||||
%tr{:id => "note_#{oa.id}", :class => "note even", :style => "display:none"}
|
||||
%td{:colspan => "6"}=h oa.article.note
|
||||
%tr{:class => cycle('even', 'odd', :name => 'articles')}
|
||||
%th{:colspan => "5"} Summe
|
||||
%th= number_to_currency(total)
|
||||
%br/
|
||||
= link_to_top
|
||||
- else
|
||||
- if @order.open?
|
||||
Du hast noch nicht bestellt.
|
||||
= link_to "Das ist Deine Chance!", :action => "order", :id => @order
|
||||
- else
|
||||
Die Bestellung is leider schon zu Ende. Beim nächsten mal früher aufstehen...
|
||||
|
||||
// Comments box
|
||||
.single_column{:style => "width:70em;"}
|
||||
.box_title
|
||||
%h2 Kommentare
|
||||
.column_content
|
||||
#comments
|
||||
= render :partial => 'shared/comments', :locals => { :comments => @order.comments }
|
||||
#new_comment= render :partial => 'order_comments/form', :locals => { :order_comment => @order.comments.build(:user => current_user)}
|
||||
= link_to_top
|
||||
Loading…
Add table
Add a link
Reference in a new issue