app/views/stats/index.html.erb
<% title "Stats" %>
<div id="left_stuff">
<fieldset class="index" id="date_selector">
<%= form_tag(stats_path, method: :post) do %>
<% if current_user.is_admin_of?(current_department) %>
<%= label_tag :calendar, "Calendar, leave blank to see all active stats" %><br />
<%= select_tag :calendar, options_from_collection_for_select(current_department.calendars, :id, :name, params[:calendar]), include_blank: true %><br />
<% end %>
<%= label_tag :start_date %><br />
<%= date_select(:stat, :start_date, default: @start_date)%>
<br />
<%= label_tag :end_date %><br />
<%= date_select(:stat, :end_date, default: @end_date)%>
<br />
<%= submit_tag 'Update dates' %>
<% end %>
</fieldset>
</div>
<h2 id="user_click" ><a href="#">User Stats</a></h2>
<div id="user_slide">
<table id="user_stats_table" class="tablesorter">
<thead>
<tr>
<th align="left">First Name</th>
<th align="left">Last Name</th>
<% unless mobile_device?%>
<th align="left">Total Shifts</th>
<th align="left">Late</th>
<th align="left">Left Early</th>
<th align="left">Missed</th>
<th align="left">Total Scheduled Hours</th>
<th align="left">Updates/Hour</th>
<% end %>
<% if current_user.is_admin_of?(current_department)%>
<th align="left">Email</th>
<% end %>
</tr>
</thead>
<tbody id="user_list">
<% if @user_stats == {} %>
<tr><td colspan="6">There are no stats for this period.</td></tr>
<% end %>
<% @user_stats.each do |key, stat| %>
<tr>
<td><%= link_to stat[:first_name], {controller: :stats, action: 'for_user', id: stat[:u_id], start_date: @start_date, end_date: @end_date} %></td>
<td><%= stat[:last_name] %></td>
<% unless mobile_device?%>
<td><%= stat[:num_shifts] %></td>
<td><%= stat[:num_late] %></td>
<td><%= stat[:num_left_early] %></td>
<td><%= stat[:num_missed] %></td>
<td><%= sprintf("%.1f", stat[:hours_scheduled]) %></td>
<td><%= sprintf("%.1f", stat[:updates]) if stat[:updates] %></td>
<% end %>
<% if current_user.is_admin_of?(current_department)%>
<td><%= stat[:email] %></td>
<td><a href="mailto:<%=stat[:email]%>?cc=decal@yale.edu&subject=Missed+Shift+&BODY=This%20week%20you%20have%20missed%20<%=stat[:num_missed]%>%20of%20your%20scheduled%20shifts%2C%20without%20an%20excuse.%0A%0AIf%20you're%20having%20trouble%2C%20please%20contact%20us%20or%20your%20coordinators.%20The%20only%20time%20STs%20are%20truly%20reprimanded%20are%20when%20they%20don't%20communicate.%20You%20haven't%20communicated.%0A%0APlease%20be%20more%20careful%20in%20the%20future%20or%20we'll%20have%20to%20talk%20with%20you.">[email]</a></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<h2 id="location_click" ><a href="#">Location Stats</a></h2>
<div id="location_slide">
<table id="location_stats_table" class="tablesorter">
<thead>
<tr>
<th align="left">Name</th>
<% unless mobile_device?%>
<th align="left">Total Shifts</th>
<th align="left">Late</th>
<th align="left">Left Early</th>
<th align="left">Missed</th>
<% end %>
</tr>
</thead>
<tbody id="user_list">
<% if @location_stats == {} %>
<tr><td colspan="6">There are no stats for this period.</td></tr>
<% end %>
<% @location_stats.each do |key, stat| %>
<tr>
<td><%= link_to stat[:name], {controller: :stats, action: 'for_location', id: stat[:l_id], start_date: @start_date, end_date: @end_date } %></td>
<% unless mobile_device?%>
<td><%= stat[:num_shifts] %></td>
<td><%= stat[:num_late] %></td>
<td><%= stat[:num_left_early] %></td>
<td><%= stat[:num_missed] %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>