<% unless @events_by_day.empty? %>
  <div id="activity" class="users-activity">
    <div class="users-activity-root">
      <h3><%= link_to l(:label_activity), :controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %></h3>
      <% if EasyAttendance.enabled? %>
        <div class="at-work">
          <% if @user.is_in_work? %>
            <%= content_tag(:strong, l(:text_easy_attendance_user_detail_online_at)) %>: <span class="icon icon-time-add"><%= format_time(@user.current_attendance.arrival, false) %></span>
          <% else %>
            <% if @user.last_today_attendance && !@user.last_today_attendance.departure.nil? %>
              <%= content_tag(:strong, l(:text_easy_attendance_user_detail_offline_at)) %>: <span class="icon icon-time"><%= format_time(@user.last_today_attendance.departure, false) %></span>
            <% else %>
              <%= l(:text_easy_attendance_user_detail_no_data_today) %>
            <% end -%>
            <%= link_to('', {:controller => 'easy_attendances', :action => 'new_notify_after_arrived', :user_id => @user }, :remote => true, :class => 'icon icon-add', :title => l(:label_easy_attendance_user_arrival_add_notify_title)) %>
            <div id="easy_attendance_user_arrival_notify_form" style="display:none">
            </div>
          <% end -%>
        </div>
      <% end -%>
    </div>
    <div class="clear"></div>
    <% @events_by_day.keys.sort.reverse.each do |day| %>
      <div class="users-activity-item">
        <h4 class="users-activity-item-title"><%= format_activity_day(day) %></h4>
        <dl class="users-activity-item-list">
          <% @events_by_day[day].sort { |x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
            <dt class="<%= e.event_type %>">
              <span class="time"><%= format_time(e.event_datetime, false) %></span>
              <%= link_to format_activity_title(e.event_title), e.event_url %></dt>
            <dd><div class="description"><%= format_activity_description(e.event_description) %></div>
              <%= content_tag('span', e.project, :class => 'project') %></dd>
          <% end -%>
        </dl>
      </div>
    <% end -%>
  </div>
  <% easy_other_formats_links do |f| %>
    <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %>
  <% end %>
  <% content_for :header_tags do %>
    <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :user_id => @user, :format => :atom, :key => User.current.rss_key) %>
  <% end %>
<% else %>
  <p class="nodata"><%= l(:label_no_data) -%></p>
<% end %>