Class: E9Crm::DatedCostsController

Inherits:
ResourcesController show all
Includes:
E9Rails::Controllers::Orderable
Defined in:
app/controllers/e9_crm/dated_costs_controller.rb

Instance Method Summary collapse

Methods inherited from ResourcesController

#create, defaults, #update

Instance Method Details

#bulk_createObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/e9_crm/dated_costs_controller.rb', line 33

def bulk_create
  params[:id].zip(params[:cost]) do |id, cost|
    DatedCost.create(
      :costable_id   => id,
      :costable_type => AdvertisingCampaign.base_class.name,
      :date          => params[:date],
      :cost          => cost
    )
  end

  flash[:notice] = "Advertising Costs Added"
  redirect_to :marketing_report
end

#indexObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/e9_crm/dated_costs_controller.rb', line 16

def index
  if params[:advertising_campaign_id]
    @index_title = "Advertising Costs for #{parent.name}" if parent
    index!
  else
    @advertising_campaigns = AdvertisingCampaign.all
    render 'bulk_form'
  end
end

#newObject



26
27
28
29
30
31
# File 'app/controllers/e9_crm/dated_costs_controller.rb', line 26

def new
  new! do |format|
    format.html
    format.json { render :json => { :html => render_html_for_action } }
  end
end