Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Budget Report View

View _tablehead.html.erb
1 2 3 4 5 6 7 8 9 10
<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>
View _tablehead.html.erb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<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.