Initial commit of foodsoft 2

This commit is contained in:
Benjamin Meichsner 2009-01-06 11:49:19 +01:00
commit 5b9a7e05df
657 changed files with 70444 additions and 0 deletions

View file

@ -0,0 +1,31 @@
- if controller.action_name == 'myOrders'
= pagination_links_remote @bookedOrders, 10, {:show_all => params[:show_all]}
%table.list
%thead
%tr
%th=_ 'Name'
%th=_ 'Supplier'
%th=_ 'End'
%th=_ 'Sum'
%tbody
- @bookedOrders.each do |order|
- if order.is_a?(GroupOrder) || order.is_a?(GroupOrderResult)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.order.name, :action => 'my_order_result', :id => order.order
%td=h order.order.supplier ? order.order.supplier.name : _("nonexistent")
%td= format_time(order.order.ends)
%td{:class => "currency"}= number_to_currency(order.price)
- else
// check if the OrderGroup has ordered
- if groupOrder = order.group_order(@orderGroup)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.name, :action => 'my_order_result', :id => order
%td=h order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"}= number_to_currency(groupOrder.price)
- else
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders'), :style => "color:grey"}
%td= link_to truncate(order.name), {:action => "my_order_result", :id => order}, :style => "color:grey"
%td= order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"} --

View file

@ -0,0 +1,34 @@
- if @orderGroup
.right_column{:style => "width:70%"}
.box_title
%h2=_ "Running orders"
.column_content
- unless @currentOrders.empty?
%table.list
%thead
%tr
%th=_ "Name"
%th=_ "Supplier"
%th=_ "End"
%th=_ "Who ordered?"
%th=_ "Sum"
%tbody
- total = 0
- @currentOrders.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'current_orders')}
%td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order
%td=h order.supplier.name
%td=h format_time(order.ends) unless order.ends.nil?
- if (groupOrder = order.group_orders.find(:first, :conditions => ["order_group_id = ?", @orderGroup.id]))
- total += groupOrder.price
%td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})"
%td= number_to_currency(groupOrder.price)
- else
%td
%td
- if total > 0
%p
=_ "Total sum"
%b= number_to_currency(total)
- else
%i=_ "There aren't current orders at the moment."

View file

@ -0,0 +1,30 @@
%table.list
%thead
%tr
%th=_ 'Name'
%th=_ 'Supplier'
%th=_ 'End'
%th=_ 'Sum'
%tbody
- @finishedOrders.each do |order|
- if order.is_a?(GroupOrder) or order.is_a?(GroupOrderResult)
%tr{:class=> cycle('even', 'odd', :name => 'bookedOrders')}
%td= link_to order.order.name, :action => 'my_order_result', :id => order.order
%td=h order.order.supplier ? order.order.supplier.name : _("nonexistent")
%td= format_time(order.order.ends)
%td{:class => "currency"}= number_to_currency(order.price)
- else
// check if the OrderGroup has ordered
- if groupOrder = order.group_order(@orderGroup)
%tr{:class=> cycle('even', 'odd', :name => 'finishedOrders')}
%td= link_to order.name, :action => 'my_order_result', :id => order
%td=h order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"}= number_to_currency(groupOrder.price)
- else
%tr{:class=> cycle('even', 'odd', :name => 'finishedOrders'), :style => "color:grey"}
%td= link_to truncate(order.name), {:action => "my_order_result", :id => order}, :style => "color:grey"
%td= order.supplier ? order.supplier.name : _("nonexistent")
%td= format_time(order.ends)
%td{:class => "currency"} --

View file

@ -0,0 +1,33 @@
%table.list
%thead
%tr
%th{:style => "width:40%"}=_ "Name"
%th=_ "Unit quantity"
%th=_ "Unit price"
%th=_ "Received"
%th=_ "Total price"
%tbody
- for article in @groupOrderResult.group_order_article_results
- price = article.order_article_result.gross_price
- quantity = article.quantity
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%td{:style=>"width:40%"}
=h article.order_article_result.name
- unless article.order_article_result.note.nil?
= image_tag "lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{article.id}').show();", :onmouseout => "$('note_#{article.id}').hide();" }
%td
= article.order_article_result.unit_quantity
x
= article.order_article_result.unit
%td= number_to_currency(price)
%td= quantity
%td= number_to_currency(quantity * price)
- unless article.order_article_result.note.nil?
%tr{:id => "note_#{article.id}", :style => "display:none"}
%td{:colspan => "5"}
Notiz:
=h article.order_article_result.note
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "4"}=_ "Sum"
%th= number_to_currency(@groupOrderResult.price)

View file

@ -0,0 +1,54 @@
%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 anderen Gruppen"} Zugeteilt
%th Gesamtpreis
%tbody
- total = 0 #set counter for order-sum
- for category, order_articles in @order.get_articles
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left;"}=h category
%td{:colspan => "9"}
- for order_article in order_articles
- article = order_article.article
- # get the order-results for the ordergroup
- group_order_article = GroupOrderArticle.find_by_group_order_id_and_order_article_id @group_order.id, order_article.id
- if group_order_article
- quantity = group_order_article.quantity
- tolerance = group_order_article.tolerance
- result = group_order_article.orderResult[:quantity] + group_order_article.orderResult[:tolerance]
- sub_total = article.gross_price * (quantity + tolerance)
- else
- quantity, tolerance, result, sub_total = 0, 0, 0, 0
- total += sub_total
- # give the article different colors, dependent on order-result
- style = "grey"
- if (quantity > 0)
- style = result > 0 ? 'green' : 'red'
%tr{:class => cycle('even', 'odd', :name => 'articles'), :style => "color:#{style}"}
%td{:style => "width:40%"}
=h order_article.article.name
- unless order_article.article.note.empty?
= image_tag("lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{order_article.id}').show();", :onmouseout => "$('note_#{order_article.id}').hide();"})
%td= "#{article.unit_quantity} x #{order_article.article.unit}"
%td= number_to_currency(article.gross_price)
%td
= quantity
= "+ #{tolerance}" if article.unit_quantity > 1
%td= result > 0 ? result : "0"
%td= number_to_currency(sub_total)
- unless order_article.article.note.empty?
%tr{:id => "note_#{order_article.id}", :class => "note even", :style => "display:none"}
%td{:colspan => "6"}=h order_article.article.note
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "5"} Summe
%th= number_to_currency(total)

View file

@ -0,0 +1,45 @@
%h1= _('Order Overview')
// OrderGroups Account Balance
.left_column{:style => "width:26%"}
.box_title
%h2=h @orderGroup.name
.column_content
%table
%tr
%td= _('Account balance')
%td{:class => "currency", :style => "width:5em"}= number_to_currency(@orderGroup.account_balance)
%tr
%td= "- " + _('Current orders')
%td{:class => "currency"}= number_to_currency(@currentOrdersValue)
%tr
%td= "- " +_('Unrecorded orders')
%td{:class => "currency"}= number_to_currency(@nonbookedOrdersValue)
%tr
%th= _('Available')
%th{:class => "currency"}= number_to_currency(@orderGroup.account_balance - @currentOrdersValue - @nonbookedOrdersValue)
// Current Orders
= render :partial => "currentOrders"
// finished, nonbooked Orders
- unless @finishedOrders.empty?
.right_column{:style => "width:70%"}
.box_title
%h2= _('unrecorded orders')
.column_content
= render :partial => "finishedOrders"
- if @nonbookedOrdersValue > 0
%p
= _('total order value')
%b= number_to_currency(@nonbookedOrdersValue)
// bookedOrders
- unless @bookedOrders.empty?
.right_column{:style => "width:70%"}
.box_title
%h2= _('balanced orders')
.column_content
= render :partial => "bookedOrders"
%br/
= link_to _('more...'), :action => "myOrders"

View file

@ -0,0 +1,27 @@
%h1
=_ "Orders of"
= @orderGroup.name
%p
%i
=_ "See current orders in"
= link_to _("Overview"), :action => "index"
%p
%i{:style => "float:left"}=_ "Also show orders, your ordergroup haven't participated:"
- form_tag({:action => "myOrders"}, :method => "get") do
-unless @show_all
%input{:type => "checkbox", :name => :show_all, :value => "1", :onclick => "submit();"}
-else
%input{:type => "checkbox", :name => :show_all, :value => "0", :checked => "checked", :onclick => "submit();"}
.single_column{:style => "width:50em"}
.box_title
%h2=_ "finished/not balanced"
.column_content
= render :partial => "finishedOrders"
.single_column{:style => "width:50em"}
.box_title
%h2=_ "balanced"
.column_content
#bookedOrders
= render :partial => "bookedOrders"

View file

@ -0,0 +1,86 @@
%h1= _("Your result for") + " #{@order.name}"
#element_navigation
= link_to_unless @order.previous == @order, _("Previous order"), :action => "my_order_result", :id => @order.previous
|
= link_to _("Overview"), :controller => 'ordering'
|
= link_to_unless @order.next == @order, _("Next order"), :action => "my_order_result", :id => @order.next
// Order summary
.left_column{:style => "width:45em"}
.box_title
%h2=_ "Summary"
.column_content
%table
%tr{:valign => "top"}
%td{:style => "width:50%"}
%p
= _("Name") + ":"
%b=h @order.name
|
= _("Supplier") + ":"
%b=h @order.supplier ? @order.supplier.name : _("nonexistent")
- unless @order.note.empty?
%p
= _("Note") + ":"
=h @order.note
%p
= _("End") + ":"
%b=h format_time(@order.ends)
%p
= _("Order value") + ":"
- if @order_value
%b=h number_to_currency(@order_value)
- else
%b --
%p
- if @finished
= @order.booked ? _("Cleared by") + " #{@order.updated_by.nick}" : "<b>" + _("Order isn't balanced yet") + "</b>"
= link_to _("read/add comments"), "#comments"
// directly switch to active orders
.right_column{:style => "width:23em;"}
.box_title
%h2= _("Running orders")
.column_content
%table
- @current_orders.each do |order|
%tr
%td= link_to order.name, :action => 'order', :id => order
%td= "("+ time_ago_in_words(order.ends) + ")" if @order.ends
// Article box
.single_column{:style => "clear:both; width:70em;"}
.box_title
%h2=_ "Overview of articles"
.column_content#result
- if @finished
// order is finished, show results ...
- unless @groupOrderResult.nil?
= render :partial => "finished_order_result"
- else
=_ "You haven't ordered"
- else
// order isn't finished yet, show ordered articles
- if @group_order
%p= link_to("Bestellung ändern", :action => "order", :id => @order) if @order.current?
= render :partial => 'unfinished_order_result'
%br/
= link_to_top
- else
= _("You haven't ordered yet.")
= link_to _("Order now"), :action => "order", :id => @order
// Comments box
- if @finished
.single_column{:style => "width:70em;"}
.box_title
%h2=_ "Comments"
.column_content#comments
= render :partial => 'shared/comments'
%p
= link_to_remote _("New comment"), :url => {:action => 'newComment', :id => @order}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
#newComment
= link_to_top

View file

@ -0,0 +1,179 @@
<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> <%= FoodSoft::getCurrencyUnit %></td>
</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> <%= FoodSoft::getCurrencyUnit %></td>
</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> <%= FoodSoft::getCurrencyUnit %></strong></td>
</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("<%= FoodSoft::getDecimalSeparator %>");
// initialize javascript
updateBalance();
//]]>
</script>