add receive to order screen, and distinguish between finished and closed orders to put it in nicely

This commit is contained in:
wvengen 2013-12-18 19:21:39 +01:00
parent 1ab09b41bd
commit 94b4454a1b
2 changed files with 48 additions and 20 deletions

View file

@ -8,7 +8,8 @@ class OrdersController < ApplicationController
# List orders
def index
@open_orders = Order.open
@open_orders = Order.open.includes(:supplier)
@orders_in_progress = Order.finished_not_closed.includes(:supplier)
@per_page = 15
if params['sort']
sort = case params['sort']
@ -20,7 +21,7 @@ class OrdersController < ApplicationController
else
sort = "ends DESC"
end
@orders = Order.page(params[:page]).per(@per_page).order(sort).where("state != 'open'").includes(:supplier)
@orders = Order.closed.page(params[:page]).per(@per_page).includes(:supplier).order(sort)
end
# Gives a view for the results to a specific order

View file

@ -10,8 +10,13 @@
%li= link_to supplier.name, new_order_path(supplier_id: supplier.id), tabindex: -1
.well
- if not @open_orders.empty?
%h2= t '.open_orders'
- unless @open_orders.empty?
- elsif not @orders_in_progress.empty?
%h2= t '.orders_in_progress'
- else
= t '.no_open_orders'
- unless @open_orders.empty? and @orders_in_progress.empty?
%table.table.table-striped
%thead
%tr
@ -20,6 +25,7 @@
%th= heading_helper Order, :note
%th{colspan: "2"}
%tbody
- unless @open_orders.empty?
- for order in @open_orders
- tr_class = " active" if order.expired?
%tr{class: tr_class}
@ -31,12 +37,33 @@
class: 'btn btn-small btn-success'
%td
= link_to t('ui.show'), order, class: 'btn btn-small'
= link_to t('ui.edit'), edit_order_path(order), class: 'btn btn-small'
= link_to t('ui.show'), order, class: 'btn btn-small'
= link_to t('ui.delete'), order, confirm: t('.confirm_delete'), method: :delete,
class: 'btn btn-small btn-danger'
- unless @orders_in_progress.empty?
- unless @open_orders.empty?
%tr
%td{colspan: 6}
%h2= t '.orders_in_progress'
- for order in @orders_in_progress
%tr
%td= order.name
%td= format_time(order.ends)
%td= truncate(order.note)
%td
-# TODO btn-success class only if not received before
= link_to t('.receive'), edit_finance_receive_path(order), class: 'btn btn-small btn-success'
%td
= link_to t('ui.edit'), '#', class: 'btn btn-small disabled'
= link_to t('ui.show'), order, class: 'btn btn-small'
= link_to t('ui.delete'), order, confirm: t('.confirm_delete'), method: :delete,
class: 'btn btn-small btn-danger'
- else
= t '.no_open_orders'
%tr
%td{colspan: 6}= t '.no_orders_in_progress'
%h2= t '.ended_orders'
#orders_table