Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <% @punches_days.sort.each do |day, punches|%>
- <h3><%= day.strftime('%A %D') %></h3>
- <table>
- <tr>
- <th>Status</th>
- <th>Comment</th>
- <th>Time</th>
- <th></th>
- <th></th>
- </tr>
- <% for punch in punches %>
- <tr>
- <td><%= punch.status %></td>
- <td><%= punch.comment %></td>
- <td><%= punch.created_at.in_time_zone(punch.user.time_zone)%></td>
- <td><%= link_to 'Show', punch %></td>
- <td><%= link_to 'Edit', edit_punch_path(punch) %></td>
- <td><%= link_to 'Destroy', punch, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
- <% end %>
- </table>
- <% end %>
- Sunday 11/06/11
- Status Comment Time
- In 2011-11-06 08:00:00 -0500 Show Edit Destroy
- Lunch 2011-11-06 12:00:00 -0500 Show Edit Destroy
- In 2011-11-06 13:00:00 -0500 Show Edit Destroy
- Out 2011-11-06 16:00:00 -0500 Show Edit Destroy
- Tuesday 11/08/11
- Status Comment Time
- In 2011-11-08 08:00:00 -0500 Show Edit Destroy
- Lunch 2011-11-08 12:15:00 -0500 Show Edit Destroy
- In 2011-11-08 13:00:00 -0500 Show Edit Destroy
- Out 2011-11-08 16:41:00 -0500 Show Edit Destroy
- def timecard
- @punches = Punch.timecard(params[:user])
- @punches_days = @punches.group_by { |t| t.created_at.beginning_of_day}
- @in_out_lengths = @punches.each_slice(2).map { |a| a[1].created_at - a[0].created_at }
- @total = ((@in_out_lengths.inject(:+))/1.hour).round
- respond_to do |format|
- format.html # timecard.html.erb
- format.json { render :json => @punches }
- end
- end
- in_out_lengths = punches.each_slice(2).map { |a| a[1].created_at - a[0].created_at }
- total = in_out_lengths.inject(:+)
- punches.each_slice(2).map { |a| a.last.created_at - a.first.created_at }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement