mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 03:37:40 +00:00
Added admin global company lookup for result data
- currently a bug that is not displaying data
This commit is contained in:
parent
eab7216058
commit
4c141c7a2c
@ -2,7 +2,22 @@ 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?
|
||||
@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/,''))
|
||||
@results[name.gsub(/'/,'').gsub(/\s/,'')] = Run.page(params[:page]).per(5)
|
||||
end
|
||||
Apartment::Tenant.switch!
|
||||
else
|
||||
@results = Run.page(params[:page]).per(5)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -87,142 +87,174 @@
|
||||
|
||||
<% if current_user.admin? %>
|
||||
<h2 class="sub-header">Recent Results From All Companies</h2>
|
||||
|
||||
<div class="panel-group" id="accordion">
|
||||
<% ((Company.pluck :company_name) - ["IVA"]).each do |company_name| %>
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title text-center">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
|
||||
<%= company_name %> </a>
|
||||
</h3>
|
||||
</div>
|
||||
<div id="collapse1" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive panel panel-primary">
|
||||
<table class="table table-striped">
|
||||
<div class="panel-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Run Date</th>
|
||||
<th>Location</th>
|
||||
<th>Harvest Time</th>
|
||||
<th>Supplier</th>
|
||||
<th>Distributor</th>
|
||||
<th>Total Processed</th>
|
||||
<th>Other</th>
|
||||
<th>Oyster Info</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<tbody>
|
||||
<% @results[company_name.gsub(/'/,'').gsub(/\s/,'')].each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id) %>
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
"result"
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="center-block">
|
||||
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||
<%= paginate @results[company_name.gsub(/'/,'').gsub(/\s/,'')] %></br>
|
||||
<%= page_entries_info @results[company_name.gsub(/'/,'').gsub(/\s/,'')] %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<h2 class="sub-header">Recent Results</h2>
|
||||
<% end %>
|
||||
<div class="table-responsive panel panel-primary">
|
||||
<table class="table table-striped">
|
||||
<div class="panel-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if current_user.admin? %>
|
||||
<th>Company</th>
|
||||
<div class="table-responsive panel panel-primary">
|
||||
<table class="table table-striped">
|
||||
<div class="panel-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Run Date</th>
|
||||
<th>Location</th>
|
||||
<th>Harvest Time</th>
|
||||
<th>Supplier</th>
|
||||
<th>Distributor</th>
|
||||
<th>Total Processed</th>
|
||||
<th>Other</th>
|
||||
<th>Oyster Info</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<tbody>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id) %>
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
"result"
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<th>Run Date</th>
|
||||
<th>Location</th>
|
||||
<th>Harvest Time</th>
|
||||
<th>Supplier</th>
|
||||
<th>Distributor</th>
|
||||
<th>Total Processed</th>
|
||||
<th>Other</th>
|
||||
<th>Oyster Info</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
<div class="center-block">
|
||||
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||
<%= paginate @results %></br>
|
||||
<%= page_entries_info @results %>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<tbody>
|
||||
<% if current_user.admin? %>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id)
|
||||
#company = Company.find(run.company_id)
|
||||
%>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- company name -->
|
||||
<td>
|
||||
<%= #company.company_name
|
||||
"Fake Industries" %>
|
||||
</td>
|
||||
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
<%= result.total %>
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id) %>
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
<%= result.total %>
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
<div class="center-block">
|
||||
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||
<%= paginate @results %></br>
|
||||
<%= page_entries_info @results %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user