Class: Admin::ActivitiesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::ActivitiesController
show all
- Includes:
- ActivityTaxControllerHelper, AdminLayoutHelper, ExtensibleObjectHelper
- Defined in:
- app/controllers/admin/activities_controller/labor/slimtimer.rb,
app/controllers/admin/activities_controller/adjustment.rb,
app/controllers/admin/activities_controller/proposal.rb,
app/controllers/admin/activities_controller/material.rb,
app/controllers/admin/activities_controller/labor.rb,
app/controllers/admin/activities_controller.rb
Class Method Summary
collapse
Instance Method Summary
collapse
append_features
append_features, #controller_url, #define_layout_variables
#controller_id, #define_application_layout_variables, #h_money, #money_for_input
Class Method Details
.activities_scaffold_config(&block) ⇒ Object
6
7
8
9
|
# File 'app/controllers/admin/activities_controller.rb', line 6
def self.activities_scaffold_config(&block)
@activities_scaffold_configs ||= []
@activities_scaffold_configs << block.to_proc
end
|
.activities_scaffold_init ⇒ Object
11
12
13
14
15
16
|
# File 'app/controllers/admin/activities_controller.rb', line 11
def self.activities_scaffold_init
configs = @activities_scaffold_configs
active_scaffold(:activity){|c| configs.each{|ac| ac.call c if ac.respond_to? :call} }
end
|
Instance Method Details
#labor_do_edit_with_slimtimer ⇒ Object
Also known as:
labor_do_edit
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/admin/activities_controller/labor/slimtimer.rb', line 14
def labor_do_edit_with_slimtimer
begin
@record.client_id = @record.labor.slimtimer_time_entry.slimtimer_task.default_client_id if @record.client_id.nil?
rescue
end
labor_do_edit_without_slimtimer
end
|
#labor_do_edit_without_slimtimer ⇒ Object
12
|
# File 'app/controllers/admin/activities_controller/labor/slimtimer.rb', line 12
alias labor_do_edit_without_slimtimer labor_do_edit
|
#labor_do_list(records) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'app/controllers/admin/activities_controller/labor.rb', line 104
def labor_do_list(records)
records.each do |record|
begin
record.client_id = record.labor.slimtimer_time_entry.slimtimer_task.default_client_id if record.client_id.nil?
labor_rate = record.labor.employee.labor_rate_for record.client_id
record.labor.hourly_rate = labor_rate.hourly_rate
rescue
end
end
end
|
#on_labor_observation ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/controllers/admin/activities_controller/labor.rb', line 25
def on_labor_observation
render :update do |page|
begin
raise StandardError, "No record_id provided" unless params.has_key? :record_id and params[:record_id].length > 0
raise StandardError, "Missing duration" unless params.has_key? :duration
raise StandardError, "Missing input name" unless params.has_key? :observed_column and params[:observed_column].length > 0
record_id = params[:record_id].to_i
jsid_suffix = (params[:eid]) ? "#{params[:eid]}_#{record_id}" : record_id.to_s
@activity = Activity.find record_id, :include => [:labor]
raise StandardError, "Activity Not Found" if @activity.nil?
input_name = params[:observed_column].to_sym
@activity.client_id = params[:client_id].to_i if params.has_key? :client_id and params[:client_id].length > 0
@activity.labor.employee_id = params[:employee_id].to_i if params.has_key? :employee_id and params[:employee_id].length > 0
old_cost = @activity.cost
labor_rate = (@activity.labor.employee and @activity.client) ? @activity.labor.employee.labor_rate_for(@activity.client) : nil
begin
record_duration_js_id = "record_duration_#{jsid_suffix}"
old_clock_duration ||= @activity.labor.clock_duration
old_clock_duration ||= 0
@activity.labor.duration = params[:duration]
raise StandardError unless @activity.labor.valid?
page[record_duration_js_id].value = @activity.labor.clock_duration if old_clock_duration != @activity.labor.clock_duration
rescue
page[record_duration_js_id].value = old_clock_duration
page[record_duration_js_id].focus
page.visual_effect :highlight, record_duration_js_id, :duration => 3, :startcolor => "#FF0000"
end
record_cost_js_id = "record_cost_#{jsid_suffix}"
if input_name == :cost then
begin
raise StandardError unless /^([\d]+|[\d]+\.[\d]{1,2})$/.match(params[:cost])
new_cost = params[:cost]
rescue
page[record_cost_js_id].value = old_clock_duration
page[record_cost_js_id].focus
page.visual_effect :highlight, record_cost_js_id, :duration => 3, :startcolor => "#FF0000"
end
end
new_cost ||= @activity.labor.minute_duration.to_f/60*labor_rate.hourly_rate.to_f unless labor_rate.nil? or labor_rate.hourly_rate.nil? or @activity.labor.minute_duration.nil?
page[record_cost_js_id].value = money_for_input new_cost
rescue
page.alert 'Error updating form Record(%s) "%s"' % [params[:record_id], $!]
end
end
end
|
#row ⇒ Object
138
139
140
141
142
143
144
145
146
147
|
# File 'app/controllers/admin/activities_controller.rb', line 138
def row
record = find_if_allowed(params[:id], :read)
do_list_action = "#{record.activity_type}_do_list".to_sym
self.send( do_list_action, [record]) if self.respond_to? do_list_action
render :partial => 'list_record', :locals => {:record => record}
end
|