Class: Backend::Cells::LastAnalysesCellsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/cells/last_analyses_cells_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

accounts_range_crit, crit_params, journal_entries_states_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name

Instance Method Details

#showObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/backend/cells/last_analyses_cells_controller.rb', line 4

def show
  if @nature = Nomen::AnalysisNature[params[:nature] || 'cow_milk_analysis']
    months = params[:months].to_i
    months = 12 if months.zero?
    @product = begin
                 Product.find(params[:product_id])
               rescue
                 nil
               end
    @stopped_at = begin
                    params[:stopped_at].to_date
                  rescue
                    Time.zone.today.end_of_month << 1
                  end
    @started_at = begin
                    params[:started_at].to_date
                  rescue
                    @stopped_at.beginning_of_month << (months - 1)
                  end
    @stopped_at = @started_at.end_of_month if @stopped_at < @started_at
  end
end