Class: Admin::PayrollController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
# File 'app/controllers/admin/payroll_controller.rb', line 3

def index
  @users = User.with_unpaid_work_units
  @work_units = WorkUnit.unpaid
end

#showObject



8
9
10
11
12
13
# File 'app/controllers/admin/payroll_controller.rb', line 8

def show
  @user = User.find(params[:id])
  @work_units = @user.work_units.unpaid
  redirect_to admin_payroll_index_path, :notice => "All payroll is filled for user " + @user.to_s unless @work_units.size > 0
  @clients = @work_units.collect { |wu| wu.client }.uniq
end

#updateObject



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

def update
  params[:work_unit].each do |key, value|
    if key =~ /\d+/
      unless value.blank?
        work_unit = WorkUnit.find(key.to_i)
        if work_unit
          work_unit.update_attributes(:paid => value)
        end
      end
    end
  end

  redirect_to admin_payroll_path
end