foodsoft/app/views/group_orders/_form.html.haml

162 lines
7.9 KiB
Text
Raw Normal View History

- content_for :javascript do
:javascript
$(function() {
#{data_to_js(@ordering_data)}
setGroupBalance(#{@ordering_data[:available_funds]});
setMinimumBalance(#{FoodsoftConfig[:minimum_balance] or 0});
setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]});
setStockit(#{@order.stockit?});
// create List for search-feature (using list.js, http://listjs.com)
2013-10-04 18:28:45 +02:00
var listjsResetPlugin = ['reset', {highlightClass: 'btn-primary'}];
var listjsDelayPlugin = ['delay', {delayedSearchTime: 500}];
new List(document.body, {
valueNames: ['name'],
engine: 'unlist',
plugins: [listjsResetPlugin, listjsDelayPlugin],
// make large pages work too (as we don't have paging - articles may disappear!)
page: 10000,
indexAsync: true
});
});
2013-02-09 02:01:31 +01:00
- title t('.title'), false
.row-fluid
.well.pull-left
%button{type: "button", class: "close", data: {dismiss: 'alert'}}= '×'.html_safe
%h2= @order.name
%dl.dl-horizontal
- unless @order.note.blank?
2013-02-09 02:01:31 +01:00
%dt= t '.note'
%dd= @order.note
2013-02-09 02:01:31 +01:00
%dt= t '.created_by'
%dd= link_to_user_message_if_valid(@order.created_by)
2013-02-09 02:01:31 +01:00
%dt= t '.ending'
%dd= format_time(@order.ends)
- unless @order.stockit? or @order.supplier.min_order_quantity.blank?
2013-02-09 02:01:31 +01:00
%dt= t '.min_quantity'
%dd= @order.supplier.min_order_quantity
2013-02-09 02:01:31 +01:00
%dt= t '.sum_amount'
%dd= number_to_currency @order.sum
2013-02-09 02:01:31 +01:00
%dt= t '.last_update'
%dd
= @group_order.updated_by.nick if @group_order.updated_by
(#{format_time(@group_order.updated_on)})
2013-02-09 02:01:31 +01:00
%dt= t '.funds'
%dd= number_to_currency(@ordering_data[:available_funds])
.well.pull-right
%button{type: "button", class: "close", data: {dismiss: 'alert'}}= '×'.html_safe
= render 'switch_order', current_order: @order
.row-fluid
.well.clear
.form-search
.input-append
2013-10-04 18:28:45 +02:00
= text_field_tag :article, params[:article], placeholder: t('.search_article'), class: 'search-query delayed-search resettable'
%button.add-on.btn.reset-search{:type => :button, :title => t('.reset_article_search')}
%i.icon.icon-remove
= 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
%table.table.table-hover
%thead
%tr
2013-02-09 02:01:31 +01:00
%th= t '.name'
- if @order.stockit?
%th{style: 'width:120px'}= t '.supplier'
%th{style: "width:13px;"}
2013-02-09 02:01:31 +01:00
%th{style: "width:4.5em;"}= t '.price'
%th{style: "width:4.5em;"}= t '.unit'
- unless @order.stockit?
2013-02-09 02:01:31 +01:00
%th{style: "width:70px;"}= t '.unit_missing'
%th#col_required= t '.amount'
%th#col_tolerance= t '.tolerance'
- else
2013-02-09 02:01:31 +01:00
%th(style="width:20px")= t '.available'
%th#col_required= t '.amount'
%th{style: "width:15px;"}= t '.sum'
%tbody.list
- @order.articles_grouped_by_category.each do |category, order_articles|
%tr.list-heading.article-category
%td
= category
%i.icon-tag
%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
- if @order.stockit?
%td= truncate order_article.article.supplier.name, length: 15
%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])
.article-info
.article-name= order_article.article.name
.pull-right
2013-02-09 02:01:31 +01:00
= t('.units_full') + ':'
%span{id: "units_#{order_article.id}"}= order_article.units_to_order
%br/
2013-02-09 02:01:31 +01:00
= t('.units_total') + ':'
%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/
2013-02-09 02:01:31 +01:00
= t('.total_tolerance') + ':'
%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/
.pull-left
2013-02-09 02:01:31 +01:00
#{t '.manufacturer'}: #{order_article.article.manufacturer}
%br/
2013-02-09 02:01:31 +01:00
#{t '.units'}: #{@order.stockit? ? order_article.article.quantity_available : @ordering_data[:order_articles][order_article.id][:unit]} * #{h order_article.article.unit}
%br/
2013-02-09 02:01:31 +01:00
#{t '.note'}: #{order_article.article.note}
%br/
#order-footer
#info-box
#total-sum
%table
%tr
2013-02-09 02:01:31 +01:00
%td= t('.total_sum_amount') + ':'
%td.currency
%span#total_price= number_to_currency(@group_order.price)
%tr
2013-02-09 02:01:31 +01:00
%td= t('.available_funds') + ':'
%td.currency= number_to_currency(@ordering_data[:available_funds])
%tr
2013-02-09 02:01:31 +01:00
%td= t('.new_funds') + ':'
%td.currency
%strong
%span#new_balance= number_to_currency(@ordering_data[:available_funds] - @group_order.price)
#order-button
2013-02-09 02:01:31 +01:00
= submit_tag( t('.action_save'), id: 'submit_button', class: 'btn btn-primary' )
#{link_to t('ui.or_cancel'), group_orders_path}
%input#total_balance{name: "total_balance", type: "hidden", value: @ordergroup.account_balance - @group_order.price}/
2013-02-09 02:01:31 +01:00
%input{name: "version", type: "hidden", value: @version}/