Fixed ordering view.
This commit is contained in:
parent
adbe93f39e
commit
f3773314a7
6 changed files with 417 additions and 291 deletions
43
app/views/ordering/_data.html.erb
Normal file
43
app/views/ordering/_data.html.erb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<script>
|
||||
//<![CDATA[
|
||||
$(function() {
|
||||
<% if Foodsoft.config[:tolerance_is_costly]
|
||||
for i in 0...@price.size %>
|
||||
addData(<%= @price[i] %>,
|
||||
<%= @unit[i] %>,
|
||||
<%= @price[i] * (@tolerance[i] + @quantity[i])%>,
|
||||
<%= @others_quantity[i] %>,
|
||||
<%= @others_tolerance[i] %>,
|
||||
<%= @used_quantity[i] %>,
|
||||
0);
|
||||
<% end
|
||||
else
|
||||
for j in 0...@price.size -%>
|
||||
addData(<%= @price[j] %>,
|
||||
<%= @unit[j] %>,
|
||||
<%= @price[j] * @quantity[j]%>,
|
||||
<%= @others_quantity[j] %>,
|
||||
<%= @others_tolerance[j] %>,
|
||||
<%= @used_quantity[j] %>,
|
||||
0);
|
||||
<% end
|
||||
end%>
|
||||
setGroupBalance(<%= @availableFunds %>);
|
||||
|
||||
// localization
|
||||
setDecimalSeparator(",");
|
||||
|
||||
// configuration
|
||||
setToleranceBehaviour(<%= Foodsoft.config[:tolerance_is_costly] %>);
|
||||
|
||||
// initialize javascript
|
||||
updateBalance();
|
||||
|
||||
// show article info on row hover
|
||||
<%#*$$('tbody tr').observer('hover', function() {%>
|
||||
|
||||
<%#*});%>
|
||||
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
88
app/views/ordering/order.html.haml
Normal file
88
app/views/ordering/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
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
<%= render :partial => 'order_head' %>
|
||||
|
||||
<% form_tag(:action => 'saveOrder', :id => @order) do %>
|
||||
<div class="single_column" style="clear:both;margin-bottom:7em;">
|
||||
<div class="box_title">
|
||||
<h2>Artikel</h2>
|
||||
</div>
|
||||
<div class="column_content">
|
||||
<table id="order" class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th style="width:13px;"></th>
|
||||
<th style="width:4.5em;">Preis</th>
|
||||
<th style="width:4.5em;">Einheit</th>
|
||||
<th style="width:70px;">Fehlende Einheiten</th>
|
||||
<th id="col_required">Menge</th>
|
||||
<% if not @order.stockit? -%>
|
||||
<th id="col_tolerance">Toleranz</th>
|
||||
<% end %>
|
||||
<th style="width:15px;">Summe</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<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 %></b></td>
|
||||
<td colspan="9"></td>
|
||||
</tr>
|
||||
<%-
|
||||
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]
|
||||
end
|
||||
total += article_total
|
||||
-%>
|
||||
<tr class="<%= cycle('even', 'odd', :name => 'articles') %> order-article" valign="top">
|
||||
<td class="name"><%= order_article.article.name %></td>
|
||||
<td><%=h order_article.article.origin %></td>
|
||||
<td><%= number_to_currency(@price[i]) %></td>
|
||||
<td><%= order_article.article.unit %></td>
|
||||
<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
|
||||
end %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="quantity">
|
||||
<input type="hidden" id="q_<%= i %>" name="<%= "ordered[#{order_article.id}][quantity]" %>" value="<%= @quantity[i] %>" size="2" />
|
||||
<span id="q_used_<%= i %>" class="used"><%= @used_quantity[i] %></span> +
|
||||
<span id="q_unused_<%= i %>" class="unused"><%= @quantity[i] - @used_quantity[i] %></span>
|
||||
<%= button_to_function('+', "increaseQuantity(#{i})") %>
|
||||
<%= button_to_function('-', "decreaseQuantity(#{i})") %>
|
||||
</td>
|
||||
<% if not @order.stockit? -%>
|
||||
<td class="tolerance">
|
||||
<input type="hidden" id="t_<%= i %>" name="<%= "ordered[#{order_article.id}][tolerance]" %>" value="<%= @tolerance[i] %>" size="2" />
|
||||
<% if (@unit[i] > 1) -%>
|
||||
<span id="t_used_<%= i %>" class="used"><%= @used_tolerance[i] %></span> +
|
||||
<span id="t_unused_<%= i %>" class="unused"><%= @tolerance[i] - @used_tolerance[i] %></span>
|
||||
<%= button_to_function('+', "increaseTolerance(#{i})") %>
|
||||
<%= button_to_function('-', "decreaseTolerance(#{i})") %>
|
||||
<% end -%>
|
||||
</td>
|
||||
<% end %>
|
||||
<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 => "") %></span> €
|
||||
<div class="article-info">
|
||||
<h3><%= order_article.article.name -%></h3>
|
||||
<div class="right">
|
||||
Volle Gebinde: <span id="units_<%= i %>"><%= order_article.units_to_order %></span><br/>
|
||||
Gesamt-Einheiten: <span id="q_total_<%= i %>"><%= @quantity[i] + @others_quantity[i] %></span><br/>
|
||||
Gesamt-Toleranz: <span id="t_total_<%= i %>"><%= @tolerance[i] + @others_tolerance[i] %></span><br/>
|
||||
</div>
|
||||
<div class="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 />
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<%- i = i + 1
|
||||
end
|
||||
end -%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<%= render "order_footer", :total => total %>
|
||||
<% end %>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
// preset data
|
||||
<% if Foodsoft.config[:tolerance_is_costly]
|
||||
for i in 0...@price.size -%>
|
||||
addData(<%= @price[i] %>, <%= @unit[i] %>, <%= @price[i] * (@tolerance[i] + @quantity[i])%>, <%= @others_quantity[i] %>, <%= @others_tolerance[i] %>, <%= @used_quantity[i] %>, 0);
|
||||
<% end
|
||||
else
|
||||
for j in 0...@price.size -%>
|
||||
addData(<%= @price[j] %>, <%= @unit[j] %>, <%= @price[j] * @quantity[j]%>, <%= @others_quantity[j] %>, <%= @others_tolerance[j] %>, <%= @used_quantity[j] %>, 0);
|
||||
<% end
|
||||
end%>
|
||||
setGroupBalance(<%= @availableFunds %>);
|
||||
|
||||
// localization
|
||||
setDecimalSeparator(",");
|
||||
|
||||
// configuration
|
||||
setToleranceBehaviour(<%= Foodsoft.config[:tolerance_is_costly] %>);
|
||||
|
||||
// initialize javascript
|
||||
updateBalance();
|
||||
|
||||
// show article info on row hover
|
||||
<%#*$$('tbody tr').observer('hover', function() {%>
|
||||
|
||||
<%#*});%>
|
||||
//]]>
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue