2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/package_calculator_controller.rb', line 2
def index
@index = Index.find_by_name("package_calculator")
@enriched = Course.find_by_name("Enriched Air Nitrox").id
@deep = Course.find_by_name("Deep").id
@emergency = Course.find_by_name("Emergency First Responder").id
unless(params[:current].nil? || params[:desired].nil?)
unless(@courses = Course.calculate(params[:current], params[:desired])).empty?
@discount = Course.discount? @courses
@courses_total = @courses.sum{|cp| cp.course_price(@discount)}
@materials_prices_total = @courses.sum(&:materials_price)
@application_prices_total = @courses.sum(&:application_price)
@total = @application_prices_total + @materials_prices_total + @courses_total
@rec = Course.rec?(params[:desired])
@pro = Course.pro?(params[:desired])
@tec = Course.tec?(params[:desired])
end
end
params[:current] ||= {}
params[:desired] ||= {}
end
|