Class: Admin::InvoicesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/invoices_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
# File 'app/controllers/admin/invoices_controller.rb', line 6

def index
  @clients = Client.for(@work_units)
end

#showObject



10
11
12
# File 'app/controllers/admin/invoices_controller.rb', line 10

def show
  @tickets = @work_units.collect{ |wu| wu.ticket }.uniq
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/invoices_controller.rb', line 14

def update
  params[:work_units].each do |key, value|
    if key =~ /\d+/
      work_unit = WorkUnit.find(key.to_i)
      if work_unit && !value["invoiced"].blank? && !value["invoiced_at"].blank?
        value.each do |k, v|
          work_unit.update_attributes(k.to_sym => v)
        end
      end
    end
  end

  redirect_to admin_invoices_path
end