foodsoft/app/views/ordering/order.rhtml

179 lines
8 KiB
Text
Raw Normal View History

2009-01-06 11:49:19 +01:00
<h1>Bestellen</h1>
<div class="left_column" style="width:49em">
<div class="box_title"><h2><%=h @order.name %></h2></div>
<div class="column_content">
<table>
<tr valign="top">
<td width="60%">
<p><b><%=_ "Supplier" %>:</b> <%=h @order.supplier.name %></p>
<p><b><%=_ "End" %>:</b> <%=h format_time(@order.ends) %></p>
<% if @group_order && @group_order.updated_by -%>
<p><b><%=_ "person ordered at last" %>:</b> <%=h @group_order.updated_by.nick if @group_order.updated_by %> (<%= format_time(@group_order.updated_on) %>)</p>
<% end -%>
<p><b><%=_ "Credit available"%>:</b> <%= number_to_currency(@availableFunds) %></p>
</td>
<td>
<% unless @order.note.empty? %>
<p>
<b><%=_ "Note" %>:</b>
</p>
<%= simple_format(@order.note) %>
<% end %>
<% unless @order.supplier.min_order_quantity.nil? || @order.supplier.min_order_quantity.empty? %>
<p>
<b><%=_ "Minimum order quantity" %>:</b>
<%=h @order.supplier.min_order_quantity %>
</p>
<% end %>
<p>
<b><%=_ "Order quanitity so far" %>:</b>
<%= number_to_currency @order.sumPrice %>
</p>
</td>
</tr>
</table>
</div>
</div>
<%- if !@other_orders.empty? -%>
<div class="right_column" style="width:22em">
<div class="box_title">
<h2><%=_ "Other orders" %></h2>
</div>
<div class="column_content">
<table>
<% for order in @other_orders -%>
<tr>
<td>
<%= link_to_function order.name, "if (confirmSwitchOrder()) (window.location = '#{ url_for(:action => 'order', :id => order) }' )" %>
</td>
<td>noch <%= time_ago_in_words(order.ends) if order.ends -%></td>
</tr>
<% end -%>
</table>
</div>
</div>
<%- end -%>
<br style="clear:both" />
<div class="single_column">
<% form_tag(:action => 'saveOrder', :id => @order) do %>
<div class="box_title">
<h2><%=_ "Articles" %></h2>
</div>
<div class="column_content">
<table id="order" class="list">
<thead>
<tr>
<th><%=_ "Name" %></th>
<th></th>
<th><%=_ "Manufacturer" %></th>
<th style="width:7em;"><%=_ "Package" %></th>
<th style="width:4.5em;"><%=_ "Price" %></th>
<th id="col_packages"><acronym title="<%=_ "totally ordered packages" %>"><%=_ "Ord."%></acronym></th>
<th id="col_required"><%=_ "Quantity" %></th>
<th id="col_tolerance"><%=_ "Tolerance" %></th>
<th><%=_ "Amount" %></th>
</tr>
</thead>
<tbody>
<%-
total = 0
i = 0
@articles_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|
article_total = @price[i] * (@tolerance[i] + @quantity[i]);
total += article_total
-%>
<tr class="<%= cycle('even', 'odd', :name => 'articles') %>" valign="top">
<td class="name">
<% unless order_article.article.note.empty? %>
<%= order_article.article.name %> <%= image_tag "lamp_grey.png", {:alt => _("Show note"), :size => "15x16", :border => "0", :onmouseover => "$('note_#{i}').show();", :onmouseout => "$('note_#{i}').hide();" }%>
<% else %>
<%= order_article.article.name %>
<% end %>
</td>
<td><%=h order_article.article.origin %></td>
<td><%=h truncate order_article.article.manufacturer, 11 %></td>
<td><%= @unit[i] %> * <%=h order_article.article.unit %></td>
<td><%= number_to_currency(@price[i]) %></td>
<td id="units_<%= i %>"><%= order_article.units_to_order %></td>
<td style="text-align:right;">
<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>
<span class="total">(<span id="q_total_<%= i %>"><%= @quantity[i] + @others_quantity[i] %></span>)</span>
<%= button_to_function('+', "increaseQuantity(#{i})") %>
<%= button_to_function('-', "decreaseQuantity(#{i})") %>
</td>
<td style="text-align:right;">
<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>
<span class="total">(<span id="t_total_<%= i %>"><%= @tolerance[i] + @others_tolerance[i] %></span>)</span>
<%= button_to_function('+', "increaseTolerance(#{i})") %>
<%= button_to_function('-', "decreaseTolerance(#{i})") %>
<% end -%>
</td>
<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> <%= l18n.number.currency.format.unit %></td>
2009-01-06 11:49:19 +01:00
</tr>
<% unless order_article.article.note.empty? -%>
<tr id="note_<%= i %>" class="note" style="display:none">
<td colspan="10"><%=h order_article.article.note %> | <%=h order_article.article.manufacturer %></td>
</tr>
<% end -%>
<%- i = i + 1
end
end -%>
</tbody>
<tfoot>
<tr>
<td colspan="6"></td>
<td colspan="3" class="currency"><%=_ "Total amount" %>: <span id="total_price"><%= total %></span> <%= l18n.number.currency.format.unit %></td>
2009-01-06 11:49:19 +01:00
</tr>
<tr>
<td colspan="6"></td>
<td colspan="3" class="currency"><%=_ "Credit available"%>: <%= number_to_currency(@availableFunds) %></td>
</tr>
<tr>
<td colspan="6"></td>
<td colspan="3" class="currency"><%=_ "New account balance"%>: <strong><span id="new_balance"><%= @order_group.account_balance - total %></span> <%= l18n.number.currency.format.unit %></strong></td>
2009-01-06 11:49:19 +01:00
</tr>
<tr>
<td style="text-align:left;"><%= link_to_top %></td>
<td colspan="5"></td>
<td colspan="3" style="text-align:right;"><span style="font-size:1.2em"><%= submit_tag( _("Save order"), :id => 'submit_button' ) %></span> | <%= link_to _("Cancel"), :controller => 'ordering' %></td>
</tr>
</tfoot>
</table>
</div>
<input type="hidden" id="total_balance" name="total_balance" value="<%= @order_group.account_balance - total %>"/>
<input type="hidden" name="version" value="<%= @version %>"/>
<% end %>
</div>
<script type="text/javascript">
//<![CDATA[
// preset data
<% 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] %>);
<% end -%>
setGroupBalance(<%= @availableFunds %>);
// localization
setDecimalSeparator("<%= l18n.number.currency.format.separator %>");
2009-01-06 11:49:19 +01:00
// initialize javascript
updateBalance();
//]]>
</script>