Skip to content

Commit

Permalink
updated time sheet report to include drive time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Hoyt authored and Jonathan Hoyt committed Feb 4, 2009
1 parent dd84e27 commit a94bd9d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion app/controllers/report/time_sheet_controller.rb
Expand Up @@ -7,7 +7,7 @@ def index
start_date = params[:start_date] + " 00:00:00"
end_date = params[:end_date] + " 23:59:59"
entries = TicketEntry.find(:all, :conditions => {:created_at.gte => start_date, :created_at.lte => end_date, :time.gt => 0})
technicians = Hash.new {|h,k| h[k] = {:name => User.find(k).name, :onsite => 0.0, :instore => 0.0, :remote => 0.0, :system_build => 0.0, :billable => 0.0, :non_billable => 0.0}}
technicians = Hash.new {|h,k| h[k] = {:name => User.find(k).name, :onsite => 0.0, :instore => 0.0, :remote => 0.0, :system_build => 0.0, :drive_time => 0.0, :billable => 0.0, :non_billable => 0.0}}
entries.each do |entry|
if entry.labor_type == "Onsite"
technicians[entry.creator_id][:onsite] += entry.time
Expand All @@ -20,8 +20,16 @@ def index
end
if entry.billable == true
technicians[entry.creator_id][:billable] += entry.time
if !entry.drive_time.blank?
technicians[entry.creator_id][:drive_time] += entry.drive_time
technicians[entry.creator_id][:billable] += entry.drive_time
end
else
technicians[entry.creator_id][:non_billable] += entry.time
if !entry.drive_time.blank?
technicians[entry.creator_id][:drive_time] += entry.drive_time
technicians[entry.creator_id][:non_billable] += entry.drive_time
end
end
end
@technicians = technicians.values
Expand Down
3 changes: 2 additions & 1 deletion app/views/report/time_sheet/index.html.erb
Expand Up @@ -13,7 +13,7 @@
<% if @technicians %>
<table class="itu">
<thead>
<tr><th class="first">Technician</th><th>Onsite</th><th>Instore</th><th>Remote</th><th>System Build</th><th>Billable</th><th>Non-Billable</th></tr>
<tr><th class="first">Technician</th><th>Onsite</th><th>Instore</th><th>Remote</th><th>System Build</th><th>Drive Time</th><th>Billable</th><th>Non-Billable</th></tr>
</thead>
<tbody>
<% @technicians.each do |technician| %>
Expand All @@ -23,6 +23,7 @@
<td><%= technician[:instore]/60 %></td>
<td><%= technician[:remote]/60 %></td>
<td><%= technician[:system_build]/60 %></td>
<td><%= technician[:drive_time]/60 %></td>
<td><%= technician[:billable]/60 %></td>
<td><%= technician[:non_billable]/60 %></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/ticket_entries/show.html.erb
@@ -1,7 +1,7 @@
<div class="ticket_entry" detail="<%= @entry.detail %>" entry_id="<%= @entry.id %>">
<div class="ticket_entry_mugshot"><%= image_tag @entry.creator.avatar.url(:avatar) %></div>
<p class="ticket_entry_byline">Entry by <b><%= @entry.creator.name %></b> on <%= @entry.updated_at.strftime("%H:%M %m/%d/%Y") %></p>
<p class="ticket_entry_details">Time Spent: <b><%= @entry.time %> minutes</b> - Labor Type: <b><%= @entry.labor_type %></b> - Billable? <b><%= billable(@entry) %></b> - Private? <b><%= is_this_private(@entry) %></b></p>
<p class="ticket_entry_details">Time Spent: <b><%= @entry.time %> minutes</b> - Labor Type: <b><%= @entry.labor_type %></b> - Billable? <b><%= billable(@entry) %></b> - Drive Time: <b><%= @entry.drive_time %></b></p>
<div class="ticket_entry_note"><%= textile_to_html(@entry.note) %></div>
<div class="ticket_entry_parts"><b>Parts</b><br /><%= textile_to_html(@entry.parts) %></div>
<div class="delete_button hide"><%= link_to_remote image_tag("/images/icons/delete.png"), :url => ticket_entry_url(@entry), :method => :delete %></div>
Expand Down

0 comments on commit a94bd9d

Please sign in to comment.