Sha256: fe614a262ddbb111a099887c99bad9aa34eb382ba1c7e5747cfe974588031b5d

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module Admin::ActivityTypeFieldHelper
  
  include Admin::IsActiveColumnHelper

  def client_form_column(record, options) 
    select_tag(
      options[:name], 
      options_for_select(
        (Client.find(
          :all, 
          :select => 'id, company_name', 
          :order => 'company_name ASC'
        ).collect {|c| [ c.company_name, c.id ] })+[['(Select Client)',nil]],
        record.activity.client_id
      ),
      options_for_column('client')
    )
  end
  
  def occurred_on_form_column(record, options)
    datetime_select "record", "occurred_on"
  end
  
  def cost_column(record)
    h_money (record.cost) ? record.cost : Money.new(0)
  end
  
  def tax_column(record)
    h_money (record.tax) ? record.tax : Money.new(0)
  end

  def cost_form_column(record,options)
    text_field_tag options[:name], (@record.cost.nil?) ? nil : ("%.2f" % @record.cost), :size => 10, :id => "record_cost_#{record.id}"
  end
  
  def tax_form_column(record,options)
    text_field_tag options[:name], (@record.tax.nil?) ? nil : ("%.2f" % @record.tax), :size => 10, :id => "record_tax_#{record.id}"
  end
  
  # Not all the activities have this, but many do:
  def comments_form_column(record,options)
    text_area_tag options[:name], record.comments, :cols => 80, :rows => 22, :id => "record_comments_#{record.id}"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 app/helpers/admin/activity_type_field_helper.rb
brisk-bills-0.8.1 app/helpers/admin/activity_type_field_helper.rb