cleanup orders and add search
Conflicts: app/assets/stylesheets/bootstrap_and_overrides.css.less app/views/orders/_articles.html.haml app/views/orders/show.html.haml
This commit is contained in:
parent
bab28d2770
commit
42d622d1b2
11 changed files with 130 additions and 70 deletions
|
@ -246,6 +246,23 @@ tr.unavailable {
|
||||||
dd { margin-left: 170px; }
|
dd { margin-left: 170px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get rid of extra bottom margin inside well
|
||||||
|
.well p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// center table rows vertically (including form elements)
|
||||||
|
table.table {
|
||||||
|
td, th {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
select, textarea, input, .uneditable-input,
|
||||||
|
.input-append, .input-prepend {
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.settings {
|
.settings {
|
||||||
.settings-group {
|
.settings-group {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
module OrdersHelper
|
module OrdersHelper
|
||||||
|
|
||||||
def update_articles_link(order, text, view)
|
def update_articles_link(order, text, view, options={})
|
||||||
link_to text, order_path(order, view: view), remote: true
|
options.merge!({remote: true, id: "view_#{view}_btn"})
|
||||||
|
link_to text, order_path(order, view: view), options
|
||||||
end
|
end
|
||||||
|
|
||||||
def order_pdf(order, document, text)
|
def order_pdf(order, document, text)
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
%th= 'Members'
|
%th= 'Members'
|
||||||
%th= t '.units_full'
|
%th= t '.units_full'
|
||||||
- total_net, total_gross, counter = 0, 0, 0
|
- total_net, total_gross, counter = 0, 0, 0
|
||||||
%tbody
|
%tbody.list
|
||||||
- order.articles_grouped_by_category.each do |category_name, order_articles|
|
- order.articles_grouped_by_category.each do |category_name, order_articles|
|
||||||
%tr.article-category
|
%tr.list-heading.article-category
|
||||||
%td
|
%td
|
||||||
= category_name
|
= category_name
|
||||||
%i.icon-tag
|
%i.icon-tag
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
- total_gross += units * unit_quantity * gross_price
|
- total_gross += units * unit_quantity * gross_price
|
||||||
- cssclass = (units > 0 ? 'used' : (order_article.quantity > 0 ? 'unused' : 'unavailable'))
|
- cssclass = (units > 0 ? 'used' : (order_article.quantity > 0 ? 'unused' : 'unavailable'))
|
||||||
%tr{:class => cycle('even', 'odd', :name => 'articles') + ' ' + cssclass}
|
%tr{:class => cycle('even', 'odd', :name => 'articles') + ' ' + cssclass}
|
||||||
%td=h order_article.article.name
|
%td.name=h order_article.article.name
|
||||||
%td= order_article.article.unit
|
%td= order_article.article.unit
|
||||||
%td= "#{number_to_currency(net_price)} / #{number_to_currency(gross_price)}"
|
%td= "#{number_to_currency(net_price)} / #{number_to_currency(gross_price)}"
|
||||||
- if order.stockit?
|
- if order.stockit?
|
||||||
|
|
1
app/views/orders/index.js.erb
Normal file
1
app/views/orders/index.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$('#orders_table').html('<%= escape_javascript(render('orders')) %>');
|
|
@ -1 +0,0 @@
|
||||||
$('#orders_table').html('#{escape_javascript(render('orders'))}');
|
|
|
@ -1,59 +1,94 @@
|
||||||
- title t('.title', name: @order.name)
|
- title t('.title', name: @order.name)
|
||||||
|
|
||||||
- if @order.finished? and !@order.closed?
|
- content_for :javascript do
|
||||||
|
:javascript
|
||||||
|
function activate_search(view, placeholder) {
|
||||||
|
new List(document.body, {
|
||||||
|
valueNames: ['name'],
|
||||||
|
engine: 'unlist',
|
||||||
|
plugins: [
|
||||||
|
['reset', {highlightClass: 'btn-primary'}],
|
||||||
|
['delay', {delayedSearchTime: 500}],
|
||||||
|
],
|
||||||
|
// make large pages work too (as we don't have paging)
|
||||||
|
page: 10000,
|
||||||
|
indexAsync: true
|
||||||
|
});
|
||||||
|
$('#query').attr('placeholder', placeholder);
|
||||||
|
}
|
||||||
|
$(function() {
|
||||||
|
activate_search('default', '#{j t('.search_placeholder.default')}');
|
||||||
|
});
|
||||||
|
|
||||||
|
.well
|
||||||
|
%button{type: "button", class: "close", data: {dismiss: 'alert'}}= t('ui.marks.close').html_safe
|
||||||
|
%p
|
||||||
|
#{@order.state.capitalize} order from
|
||||||
|
#{link_to @order.supplier.name, supplier_path(@order.supplier)}
|
||||||
|
created by #{show_user_link @order.created_by},
|
||||||
|
open from #{format_time @order.starts} until #{format_time @order.ends}.
|
||||||
|
%br
|
||||||
|
%abbr{title: @order.group_orders.includes(:ordergroup).all.map {|g| g.ordergroup.name}.join(', ')}
|
||||||
|
#{@order.group_orders.count} #{Ordergroup.model_name.human count: @order.group_orders.count}
|
||||||
|
ordered #{@order.order_articles.ordered.count} articles with a total value of
|
||||||
|
#{number_to_currency(@order.sum(:net))} / #{number_to_currency(@order.sum(:gross))} (net / gross).
|
||||||
|
|
||||||
|
- if @note.present?
|
||||||
|
%p
|
||||||
|
= heading_helper(Order, :note) + ': '
|
||||||
|
= @order.note
|
||||||
|
|
||||||
|
-# Proposing to remove this warning, since there is a valid period when the order is not settled yet.
|
||||||
|
-# Perhaps when the pickup day has been, or when the order isn't settled a week after it has been
|
||||||
|
-# closed, this message could be shown.
|
||||||
|
-#- if @order.finished? and !@order.closed?
|
||||||
.alert.alert-warning
|
.alert.alert-warning
|
||||||
= t '.warn_not_closed'
|
= t '.warn_not_closed'
|
||||||
|
|
||||||
// Order summary
|
.well.well-small
|
||||||
.well
|
.btn-toolbar
|
||||||
%dl.dl-horizontal
|
.form-search.pull-right
|
||||||
%dt= heading_helper(Order, :name) + ':'
|
.input-append
|
||||||
%dd= @order.name
|
= text_field_tag :query, params[:query], class: 'search-query delayed-search resettable'
|
||||||
- if @note.present?
|
%button.add-on.btn.reset-search{:type => :button, :title => t('.search_reset')}
|
||||||
%dt= heading_helper(Order, :note) + ':'
|
%i.icon.icon-remove
|
||||||
%dd= @order.note
|
|
||||||
%dt= heading_helper(Order, :created_by) + ':'
|
.btn-toolbar
|
||||||
%dd= show_user_link(@order.created_by)
|
.btn-group.view_buttons
|
||||||
%dt= heading_helper(Order, :starts) + ':'
|
= update_articles_link @order, t('.articles'), :default, class: 'btn active'
|
||||||
%dd= format_time(@order.starts)
|
= update_articles_link @order, t('.sort_group'), :groups, class: 'btn'
|
||||||
%dt= heading_helper(Order, :ends) + ':'
|
= update_articles_link @order, t('.sort_article'), :articles, class: 'btn'
|
||||||
%dd= format_time(@order.ends)
|
|
||||||
%dt= t '.group_orders'
|
- unless @order.open?
|
||||||
%dd #{@order.group_orders.count} (#{@order.group_orders.includes(:ordergroup).all.map {|g| g.ordergroup.name}.join(', ')})
|
.btn-group
|
||||||
%dt= t '.amounts'
|
= link_to '#', class: 'btn dropdown-toggle', data: {toggle: 'dropdown'} do
|
||||||
%dd= "#{number_to_currency(@order.sum(:net))} / #{number_to_currency(@order.sum(:gross))}"
|
= t '.download.title'
|
||||||
%dt= t '.articles_ordered'
|
%span.caret
|
||||||
%dd= @order.order_articles.ordered.count
|
%ul.dropdown-menu
|
||||||
|
%li= order_pdf(@order, :groups, t('.download.group_pdf'))
|
||||||
|
%li= order_pdf(@order, :articles, t('.download.article_pdf'))
|
||||||
|
%li= order_pdf(@order, :matrix, t('.download.matrix_pdf'))
|
||||||
|
%li= order_pdf(@order, :fax, t('.download.fax_pdf'))
|
||||||
|
%li= link_to t('.download.fax_txt'), order_path(@order, format: :txt), {title: t('.download.download_file')}
|
||||||
|
|
||||||
|
- if @order.open?
|
||||||
|
= link_to t('.action_end'), finish_order_path(@order), method: :post, class: 'btn btn-success',
|
||||||
|
confirm: t('.confirm_end', order: @order.name)
|
||||||
|
= link_to t('ui.edit'), edit_order_path(@order), class: 'btn'
|
||||||
|
- elsif not @order.closed? and not @order.stockit?
|
||||||
|
-# TODO btn-success class only if not received before
|
||||||
|
= link_to t('orders.index.action_receive'), receive_order_path(@order), class: 'btn btn-success'
|
||||||
|
- unless @order.closed?
|
||||||
|
= link_to t('ui.delete'), @order, confirm: t('.confirm_delete'), method: :delete,
|
||||||
|
class: 'btn btn-danger'
|
||||||
|
|
||||||
|
|
||||||
.form-actions
|
-# unless @order.open?
|
||||||
- if @order.open?
|
|
||||||
= link_to t('ui.edit'), edit_order_path(@order), class: 'btn'
|
|
||||||
= link_to t('.action_end'), finish_order_path(@order), method: :post, class: 'btn btn-success',
|
|
||||||
confirm: t('.confirm_end', order: @order.name)
|
|
||||||
- elsif not @order.closed? and not @order.stockit?
|
|
||||||
-# TODO btn-success class only if not received before
|
|
||||||
= link_to t('orders.index.action_receive'), receive_order_path(@order), class: 'btn btn-success'
|
|
||||||
- unless @order.closed?
|
|
||||||
= link_to t('ui.delete'), @order, confirm: t('.confirm_delete'), method: :delete,
|
|
||||||
class: 'btn btn-danger'
|
|
||||||
|
|
||||||
- unless @order.open?
|
|
||||||
%ul.nav.nav-pills
|
%ul.nav.nav-pills
|
||||||
%li= update_articles_link(@order, t('.articles'), :default)
|
%li= update_articles_link(@order, t('.articles'), :default)
|
||||||
%li= update_articles_link(@order, t('.sort_group'), :groups)
|
%li= update_articles_link(@order, t('.sort_group'), :groups)
|
||||||
%li= update_articles_link(@order, t('.sort_article'), :articles)
|
%li= update_articles_link(@order, t('.sort_article'), :articles)
|
||||||
%li= link_to t('.comments_link'), '#comments'
|
%li= link_to t('.comments_link'), '#comments'
|
||||||
%li.dropdown
|
|
||||||
= link_to '#', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do
|
|
||||||
= t '.download.title'
|
|
||||||
%b.caret
|
|
||||||
%ul.dropdown-menu
|
|
||||||
%li= order_pdf(@order, :groups, t('.download.group_pdf'))
|
|
||||||
%li= order_pdf(@order, :articles, t('.download.article_pdf'))
|
|
||||||
%li= order_pdf(@order, :matrix, t('.download.matrix_pdf'))
|
|
||||||
%li= order_pdf(@order, :fax, t('.download.fax_pdf'))
|
|
||||||
%li= link_to t('.download.fax_txt'), order_path(@order, format: :txt), {title: t('.download.download_file')}
|
|
||||||
|
|
||||||
%section#articles_table
|
%section#articles_table
|
||||||
= render 'articles', order: @order
|
= render 'articles', order: @order
|
||||||
|
|
7
app/views/orders/show.js.erb
Normal file
7
app/views/orders/show.js.erb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
$('#articles_table').html('<%= j render(@partial, order: @order) %>');
|
||||||
|
|
||||||
|
$('.view_buttons a').each(function() {
|
||||||
|
$(this).toggleClass('active', $(this).attr('id') == 'view_<%= j params[:view] %>_btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
activate_search('<%= j params[:view] %>', '<%= j I18n.t("orders.show.search_placeholder.#{params[:view]}") %>');
|
|
@ -1,2 +0,0 @@
|
||||||
$('#articles_table').html('#{escape_javascript(render(@partial, order: @order))}');
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%table.table.table-hover
|
%table.table.table-hover.list
|
||||||
%thead
|
%thead.list-heading
|
||||||
%tr
|
%tr
|
||||||
%th{:style => 'width:70%'}= t '.ordergroup'
|
%th{:style => 'width:70%'}= t '.ordergroup'
|
||||||
%th
|
%th
|
||||||
|
@ -9,12 +9,11 @@
|
||||||
%th= t '.price'
|
%th= t '.price'
|
||||||
|
|
||||||
- for order_article in order.order_articles.ordered.all(:include => [:article, :article_price])
|
- for order_article in order.order_articles.ordered.all(:include => [:article, :article_price])
|
||||||
%thead
|
%tbody
|
||||||
%tr
|
%tr
|
||||||
%th{:colspan => "4"}
|
%th.name{:colspan => "4"}
|
||||||
= order_article.article.name
|
= order_article.article.name
|
||||||
= "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.gross_price)})"
|
= "(#{order_article.article.unit} | #{order_article.price.unit_quantity} | #{number_to_currency(order_article.price.gross_price)})"
|
||||||
%tbody
|
|
||||||
- for goa in order_article.group_order_articles.ordered
|
- for goa in order_article.group_order_articles.ordered
|
||||||
%tr{:class => [cycle('even', 'odd', :name => 'groups'), if goa.result == 0 then 'unavailable' end]}
|
%tr{:class => [cycle('even', 'odd', :name => 'groups'), if goa.result == 0 then 'unavailable' end]}
|
||||||
%td{:style => "width:70%"}=h goa.group_order.ordergroup.name
|
%td{:style => "width:70%"}=h goa.group_order.ordergroup.name
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%table.table.table-hover
|
%table.table.table-hover.list
|
||||||
%thead
|
%thead.list-heading
|
||||||
%tr
|
%tr
|
||||||
%th{:style => "width:40%"}= heading_helper Article, :name
|
%th{:style => "width:40%"}= heading_helper Article, :name
|
||||||
%th
|
%th
|
||||||
|
@ -14,18 +14,17 @@
|
||||||
%th= t '.price'
|
%th= t '.price'
|
||||||
|
|
||||||
- for group_order in order.group_orders.ordered
|
- for group_order in order.group_orders.ordered
|
||||||
%thead
|
%tbody
|
||||||
%tr
|
%tr
|
||||||
%th{:colspan => "7"}
|
%th{:colspan => "7"}
|
||||||
%h4= group_order.ordergroup.name
|
%h4.name= group_order.ordergroup.name
|
||||||
%tbody
|
|
||||||
- total = 0
|
- total = 0
|
||||||
- for goa in group_order.group_order_articles.ordered.all(:include => :order_article)
|
- for goa in group_order.group_order_articles.ordered.all(:include => :order_article)
|
||||||
- fc_price = goa.order_article.price.fc_price
|
- fc_price = goa.order_article.price.fc_price
|
||||||
- subTotal = fc_price * goa.result
|
- subTotal = fc_price * goa.result
|
||||||
- total += subTotal
|
- total += subTotal
|
||||||
%tr{:class => [cycle('even', 'odd', :name => 'articles'), if goa.result == 0 then 'unavailable' end]}
|
%tr{:class => [cycle('even', 'odd', :name => 'articles'), if goa.result == 0 then 'unavailable' end]}
|
||||||
%td{:style => "width:40%"}=h goa.order_article.article.name
|
%td.name{:style => "width:40%"}=h goa.order_article.article.name
|
||||||
%td= "#{goa.quantity} + #{goa.tolerance}"
|
%td= "#{goa.quantity} + #{goa.tolerance}"
|
||||||
%td
|
%td
|
||||||
%b= goa.result
|
%b= goa.result
|
||||||
|
@ -33,10 +32,9 @@
|
||||||
%td= goa.order_article.price.unit_quantity
|
%td= goa.order_article.price.unit_quantity
|
||||||
%td= goa.order_article.article.unit
|
%td= goa.order_article.article.unit
|
||||||
%td= number_to_currency(subTotal)
|
%td= number_to_currency(subTotal)
|
||||||
|
%tr{:class => cycle('even', 'odd', :name => 'articles')}
|
||||||
%tr{:class => cycle('even', 'odd', :name => 'articles')}
|
%th{:colspan => "6"} Summe
|
||||||
%th{:colspan => "6"} Summe
|
%th= number_to_currency(total)
|
||||||
%th= number_to_currency(total)
|
%tr
|
||||||
%tr
|
%th(colspan="7")
|
||||||
%th(colspan="7")
|
- reset_cycle("articles")
|
||||||
- reset_cycle("articles")
|
|
||||||
|
|
|
@ -1178,6 +1178,11 @@ en:
|
||||||
matrix_pdf: Matrix PDF
|
matrix_pdf: Matrix PDF
|
||||||
title: Download
|
title: Download
|
||||||
group_orders: ! 'Group orders:'
|
group_orders: ! 'Group orders:'
|
||||||
|
search_placeholder:
|
||||||
|
default: Search for articles...
|
||||||
|
groups: Search for ordergroups...
|
||||||
|
articles: Search for articles...
|
||||||
|
search_reset: Reset search
|
||||||
sort_article: Sorted in articles
|
sort_article: Sorted in articles
|
||||||
sort_group: Sorted in groups
|
sort_group: Sorted in groups
|
||||||
title: ! 'Order: %{name}'
|
title: ! 'Order: %{name}'
|
||||||
|
|
Loading…
Reference in a new issue