app/controllers/pages_controller.rb
# Retrieves and sets information related to the group and/or service selected by the user on the 
# home page. Will not retrieve information if neither a group nor service is selected.
Retrieves and sets information related to the group and/or service selected by the user on the
home page. Will not retrieve information if neither a group nor service is selected.
Retrieves and sets information related to the group and / or service selected by the user on the home page . Will not retrieve information if neither a group nor service is selected .
def home_search
    @group = Group.find(params[:group][:id]) unless params[:group].blank? || 
        params[:group][:id].blank?
    @service = Service.find(params[:service][:id]) unless params[:service].blank? || 
        params[:service][:id].blank?
    data_array = []
    @data_title_1 = t(:full_time_employees)
    @data_title_2 = t(:employee_headcount)
    if @group && @service.nil?
      @services = @group.services(@year)
      @employees = @group.employees.order(:last_name, :first_name)
      @graph_title = t(:allocations_for_group) + @group.name
      @x_axis_title = t(:service)
      @employee_headcount = @group.employees.length
      @full_time_employees = @group.get_total_service_allocation(@year, @allocation_precision)
      @services.each do |service|
        data_array << service.total_allocation_within_group(@group, @year, @allocation_precision)
      end
    end
    if @group.nil? && @service
      @groups = @service.groups(@year)
      @employees = @service.employees.order(:last_name, :first_name)
      @graph_title = t(:allocations_for_service) + @service.name 
      @x_axis_title = t(:group)
      @employee_headcount = @service.employees.length
      @full_time_employees = @service.get_total_allocation(@year, @allocation_precision)
      @groups.each do |group|
        data_array << @service.total_allocation_for_group(group, @year, @allocation_precision)
      end
    end
    if @group && @service
      @services = @group.services(@year)
      @groups = @service.groups(@year)
      @employees = Employee.joins(:groups, :services).where(
                  :groups => {:id => 1}, :employee_allocations => {:fiscal_year_id => 1},
                  :services => {:id => 1}).order(:last_name, :first_name)
      @graph_title = t(:allocations_for_group) + @group.name + t(:and_service) + @service.name
      @x_axis_title = t(:employee)
      data_array = @service.employee_allocations_within_group(@group, @year, @allocation_precision)
      @employee_headcount = data_array.length
      @full_time_employees = @service.total_allocation_for_group(@group, @year,
            @allocation_precision)[1]
    end
    @data_to_graph = data_array.to_json if @group || @service
    render :home
  end
def home_search @group = Group . find ( params [ :group ] [ :id ] ) unless params [ :group ] . blank? || params [ :group ] [ :id ] . blank? @service = Service . find ( params [ :service ] [ :id ] ) unless params [ :service ] . blank? || params [ :service ] [ :id ] . blank? data_array = [ ] @data_title_1 = t ( :full_time_employees ) @data_title_2 = t ( :employee_headcount ) if @group && @service . nil? @services = @group . services ( @year ) @employees = @group . employees . order ( :last_name , :first_name ) @graph_title = t ( :allocations_for_group ) + @group . name @x_axis_title = t ( :service ) @employee_headcount = @group . employees . length @full_time_employees = @group . get_total_service_allocation ( @year , @allocation_precision ) @services . each do | service | data_array << service . total_allocation_within_group ( @group , @year , @allocation_precision ) end end if @group . nil? && @service @groups = @service . groups ( @year ) @employees = @service . employees . order ( :last_name , :first_name ) @graph_title = t ( :allocations_for_service ) + @service . name @x_axis_title = t ( :group ) @employee_headcount = @service . employees . length @full_time_employees = @service . get_total_allocation ( @year , @allocation_precision ) @groups . each do | group | data_array << @service . total_allocation_for_group ( group , @year , @allocation_precision ) end end if @group && @service @services = @group . services ( @year ) @groups = @service . groups ( @year ) @employees = Employee . joins ( :groups , :services ) . where ( :groups => { :id => 1 } , :employee_allocations => { :fiscal_year_id => 1 } , :services => { :id => 1 } ) . order ( :last_name , :first_name ) @graph_title = t ( :allocations_for_group ) + @group . name + t ( :and_service ) + @service . name @x_axis_title = t ( :employee ) data_array = @service . employee_allocations_within_group ( @group , @year , @allocation_precision ) @employee_headcount = data_array . length @full_time_employees = @service . total_allocation_for_group ( @group , @year , @allocation_precision ) [ 1 ] end @data_to_graph = data_array . to_json if @group || @service render :home end
Retrieves and sets information related to the group and/or service selected by the user on the
home page.
Retrieves and sets information related to the group and / or service selected by the user on the home page .