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 # List orders
def index def index
@open_orders = Order.open @open_orders = Order.open.includes(:supplier)
@orders_in_progress = Order.finished_not_closed.includes(:supplier)
@per_page = 15 @per_page = 15
if params['sort'] if params['sort']
sort = case params['sort'] sort = case params['sort']
@ -20,7 +21,7 @@ class OrdersController < ApplicationController
else else
sort = "ends DESC" sort = "ends DESC"
end 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 end
# Gives a view for the results to a specific order # 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 %li= link_to supplier.name, new_order_path(supplier_id: supplier.id), tabindex: -1
.well .well
%h2= t '.open_orders' - if not @open_orders.empty?
- unless @open_orders.empty? %h2= t '.open_orders'
- 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 %table.table.table-striped
%thead %thead
%tr %tr
@ -20,23 +25,45 @@
%th= heading_helper Order, :note %th= heading_helper Order, :note
%th{colspan: "2"} %th{colspan: "2"}
%tbody %tbody
- for order in @open_orders - unless @open_orders.empty?
- tr_class = " active" if order.expired? - for order in @open_orders
%tr{class: tr_class} - tr_class = " active" if order.expired?
%td= order.name %tr{class: tr_class}
%td= format_time(order.ends) unless order.ends.nil? %td= order.name
%td= truncate(order.note) %td= format_time(order.ends) unless order.ends.nil?
%td= link_to t('.action_end'), finish_order_path(order), %td= truncate(order.note)
confirm: t('.confirm_end', order: order.name), method: :post, %td= link_to t('.action_end'), finish_order_path(order),
class: 'btn btn-small btn-success' confirm: t('.confirm_end', order: order.name), method: :post,
class: 'btn btn-small btn-success'
%td %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.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, = link_to t('ui.delete'), order, confirm: t('.confirm_delete'), method: :delete,
class: 'btn btn-small btn-danger' class: 'btn btn-small btn-danger'
- else
= t '.no_open_orders' - 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
%tr
%td{colspan: 6}= t '.no_orders_in_progress'
%h2= t '.ended_orders' %h2= t '.ended_orders'
#orders_table #orders_table