diff --git a/Pearlception/app/controllers/dashboard_controller.rb b/Pearlception/app/controllers/dashboard_controller.rb index 10a757e..02d741b 100644 --- a/Pearlception/app/controllers/dashboard_controller.rb +++ b/Pearlception/app/controllers/dashboard_controller.rb @@ -2,7 +2,29 @@ class DashboardController < ApplicationController before_filter :deny_to_visitors def index - @results = Result.page(params[:page]).per(5) + #This is a temporary fix until runs and results models are properly discussed with bobby + #@results = Result.page(params[:page]).per(5) + if current_user.admin? + puts params + @results = Hash.new + names = (Company.pluck :company_name) - ["IVA"] + names.map!{|tenant| tenant.gsub(/'/,'').gsub(/\s/,'')} + names.each do + |name| + + Apartment::Tenant.switch!(name.gsub(/'/,'').gsub(/\s/,'')) + + if params[:company] == name + @results[name.gsub(/'/,'').gsub(/\s/,'')] = {results: Run.page(params[:page]).per(5), active: true, name: name} + else + @results[name.gsub(/'/,'').gsub(/\s/,'')] = {results: Run.page(params[:page]).per(5), active: false} + end + end + #binding.pry + Apartment::Tenant.switch! + else + @results = Run.page(params[:page]).per(5) + end end diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index 4cbdef9..21783b8 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -87,142 +87,177 @@ <% if current_user.admin? %>

Recent Results From All Companies

+ +
+ + <% ((Company.pluck :company_name) - ["IVA"]).each do |company_name| %> +
+ +
" class="panel-collapse collapse <%= (@results[company_name.gsub(/'/,'').gsub(/\s/,'')][:active] && @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:name] == company_name.gsub(/'/,'').gsub(/\s/,'') ) ? "in" : ""%>"> +
+
+ +
+
+ + + + + + + + + + + + +
+ +
+ <% @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:results].each_slice(1) do |row| %> + + <% row.each do |result| + run = result#Run.find(result.id) %> + + + + + + + + + + + + + + + + + + + + + + <% end %> + + <% end %> + + +
Run DateLocationHarvest TimeSupplierDistributorTotal ProcessedOtherOyster Info
+ <%= run.runDate %> + + <%= run.location ? run.location : "" %> + + <%= "" %> + + + <%= run.supplier ? run.supplier : "" %> + + <%= run.distributor ? run.distributor : "" %> + + "result" + + <%= run.other ? run.other : "" %> + + <%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %> +
+
+ +
+
+ <%= paginate @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:results] , params: {company: company_name.gsub(/'/,'').gsub(/\s/,'')} %>
+ <%= page_entries_info @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:results] %> +
+
+
+
+
+ + <% end %> +
<% else %>

Recent Results

- <% end %> -
- -
-
- - <% if current_user.admin? %> - +
+
Company
+
+
+ + + + + + + + + + + + +
+
+ <% @results.each_slice(1) do |row| %> + + <% row.each do |result| + run = Run.find(result.id) %> + + + + + + + + + + + + + + + + + + + + + + <% end %> + <% end %> - - - - - - - - - - + + +
Run DateLocationHarvest TimeSupplierDistributorTotal ProcessedOtherOyster Info
+ <%= run.runDate %> + + <%= run.location ? run.location : "" %> + + <%= "" %> + + + <%= run.supplier ? run.supplier : "" %> + + <%= run.distributor ? run.distributor : "" %> + + "result" + + <%= run.other ? run.other : "" %> + + <%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %> +
Run DateLocationHarvest TimeSupplierDistributorTotal ProcessedOtherOyster Info
+
+
+
+ <%= paginate @results %>
+ <%= page_entries_info @results %>
-
- - <% if current_user.admin? %> - <% @results.each_slice(1) do |row| %> - - <% row.each do |result| - run = Run.find(result.id) - #company = Company.find(run.company_id) - %> +
+ <% end %> - - - <%= #company.company_name - "Fake Industries" %> - - - - - <%= run.runDate %> - - - - - <%= run.location ? run.location : "" %> - - - - - <%= "" %> - - - - - - <%= run.supplier ? run.supplier : "" %> - - - - - <%= run.distributor ? run.distributor : "" %> - - - - - <%= result.total %> - - - - - <%= run.other ? run.other : "" %> - - - <%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %> - - <% end %> - - <% end %> - <% else %> - <% @results.each_slice(1) do |row| %> - - <% row.each do |result| - run = Run.find(result.id) %> - - - <%= run.runDate %> - - - - - <%= run.location ? run.location : "" %> - - - - - <%= "" %> - - - - - - <%= run.supplier ? run.supplier : "" %> - - - - - <%= run.distributor ? run.distributor : "" %> - - - - - <%= result.total %> - - - - - <%= run.other ? run.other : "" %> - - - <%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %> - - <% end %> - - <% end %> - <% end %> - -
- - -
-
- <%= paginate @results %>
- <%= page_entries_info @results %> -
-