foodsoft/app/helpers/orders_helper.rb

38 lines
1.2 KiB
Ruby
Raw Normal View History

# encoding: utf-8
2009-01-06 11:49:19 +01:00
module OrdersHelper
def update_articles_link(order, text, view)
link_to text, order_path(order, view: view), remote: true
end
def order_pdf(order, document, text)
2013-04-10 17:29:06 +02:00
link_to text, order_path(order, document: document, format: :pdf), title: I18n.t('helpers.orders.order_pdf')
2009-01-06 11:49:19 +01:00
end
def options_for_suppliers_to_select
2013-04-10 17:29:06 +02:00
options = [[I18n.t('helpers.orders.option_choose')]]
options += Supplier.all.map {|s| [ s.name, url_for(action: "new", supplier_id: s)] }
2013-04-10 17:29:06 +02:00
options += [[I18n.t('helpers.orders.option_stock'), url_for(action: 'new', supplier_id: 0)]]
2011-06-10 13:53:51 +02:00
options_for_select(options)
end
2013-12-18 22:08:02 +01:00
def units_history_line(order_article)
if order_article.order.open?
nil
else
units_info = "#{order_article.units_to_order} ordered"
units_info += ", #{order_article.units_billed} billed" unless order_article.units_billed.nil?
units_info += ", #{order_article.units_received} received" unless order_article.units_received.nil?
end
end
2014-01-02 22:30:04 +01:00
# can be article or article_price
def pkg_helper(article, icon=true)
if icon
"<i class='package'> &times; #{article.unit_quantity}</i>".html_safe
else
"<span class='package'> &times; #{article.unit_quantity}</span>".html_safe
end
end
2009-01-06 11:49:19 +01:00
end