Skip to content

@bodagetta /_tablehead.html.erb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Budget Report View
<table class="table table-striped table-bordered table-condensed">
<tr>
<th><div class="first-column"><%= title %></div></th>
<% @period.each do |period| %>
<th><div class="period-header"><%= period.start_date %></div></th>
<% end %>
<th>Total</th>
</tr>
<div class="page-header">
<h1><%= @contract.name %></h1>
<h2>Contract Number: <%= @contract.number %></h2>
<h3>Contract Start: <%= @contract.start_date %></h3>
<h3>Contract End: <%= @contract.end_date %></h3>
<%= render 'tablehead', :title => "Hours" %>
<% @resource.each do |resource| %>
<tr>
<% total = 0 %>
<td><%= resource.full_resource %></td>
<% @period.each do |period| %>
<td>
<% myHour = @hour.find(:all, :conditions => ["period_id=? and resource_id=?", period.id, resource.id]) %>
<% if myHour.first != nil %>
<%= simple_form_for(myHour) do |f| %>
<%= f.input :number_of_hours, :as => :string, :label => false, :input_html => { :class => "hoursinput" } %>
<%= f.button :submit, "Update", :class => "btn-mini small-btn" %>
<% end %>
<% total += myHour.first.number_of_hours %>
<% else %>
<% Hour.create(:contract_id => @contract.id, :number_of_hours => 0, :period_id => period.id, :resource_id => resource.id) %>
<% end %>
</td>
<% end %>
<td><%= total %></td>
</tr>
<% end %>
</table>
<%= render 'tablehead', :title => "Direct Rates" %>
<% @resource.each do |resource| %>
<tr>
<td><%= resource.full_resource %></td>
<% @period.each do |period| %>
<td>
<% myDirectRate = DirectRate.find(:all, :conditions => ["employee_id=? and start_date<=? and end_date>=?", resource.employee.id, period.start_date, period.start_date]) %>
<% if myDirectRate.first != nil %>
<%= myDirectRate.first.rate %>
<% else %>
0
<% end %>
</td>
<% end %>
</tr>
<% end %>
</table>
<%= render 'tablehead', :title => "Direct Labor Dollars" %>
<% total = 0 %>
<% @resource.each do |resource| %>
<tr>
<td><%= resource.full_resource %></td>
<% @period.each do |period| %>
<td>
<% myDirectRate = DirectRate.find(:all, :conditions => ["employee_id=? and start_date<=? and end_date>=?", resource.employee.id, period.start_date, period.start_date]) %>
<% myHour = @hour.find(:all, :conditions => ["period_id=? and resource_id=?", period.id, resource.id]) %>
<% if myDirectRate.first != nil && myHour.first != nil %>
<%= myDirectRate.first.rate * myHour.first.number_of_hours %>
<% total += myDirectRate.first.rate * myHour.first.number_of_hours %>
<% else %>
0
<% end %>
</td>
<% end %>
<td><%= total %>
</tr>
<% end %>
<tr>
<td>Total </td>
<% @period.each do |period| %>
<% myTotal = 0 %>
<td><% myHours = @hour.find(:all, :conditions => ["period_id=?", period.id]) %>
<% myHours.each do |myHour| %>
<%
myDirectRate = DirectRate.find(:all, :conditions => ["employee_id=? and start_date<=? and end_date>=?", myHour.resource.employee.id, period.start_date, period.start_date]) %>
<% if myDirectRate.first != nil %>
<% myTotal += myHour.number_of_hours * myDirectRate.first.rate %>
<% end %>
<% end %>
<%= myTotal %> </td>
<% end %>
</tr>
</table>
<%= render 'tablehead', :title => "Indirect Rates" %>
<% RateType.all.each do |ratetype| %>
<tr>
<td><%= ratetype.name %></td>
<% @period.each do |period| %>
<td>
<% myRate = IndirectRate.find(:all, :conditions => ["rate_type_id=? and start_date<=? and end_date>=?", ratetype.id, period.start_date, period.start_date]) %>
<% if myRate.first != nil %>
<%= myRate.first.rate %>
<% else %>
0
<% end %>
<% end %>
</td>
</tr>
<% end %>
</table>
<%= render 'tablehead', :title => "Total Fringe Dollars" %>
<% RateType.find(:all, :conditions => ["name=?", "Fringe"]).each do |ratetype| %>
<tr>
<td><%= ratetype.name %></td>
<% @period.each do |period| %>
<td>
<% myLaborDollars = 0 %>
<% @resource.each do |resource| %>
<% myIndirectRate = IndirectRate.find(:all, :conditions => ["rate_type_id=? and start_date<=? and end_date>=?", ratetype.id, period.start_date, period.start_date]) %>
<% myDirectRate = DirectRate.find(:all, :conditions => ["employee_id=? and start_date<=? and end_date>=?", resource.employee.id, period.start_date, period.start_date]) %>
<% myHour = @hour.find(:all, :conditions => ["period_id=? and resource_id=?", period.id, resource.id]) %>
<% if myDirectRate.first != nil && myHour.first != nil && myIndirectRate.first != nil %>
<% myLaborDollars += myDirectRate.first.rate * myHour.first.number_of_hours * myIndirectRate.first.rate %>
<% total += myDirectRate.first.rate * myHour.first.number_of_hours * myIndirectRate.first.rate %>
<% end %>
<% end %>
<%= myLaborDollars %>
<% end %>
</td>
</tr>
<% end %>
</table>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.