<div class="contextual">
<%= link_to l(:button_log_time), 
            _new_time_entry_path(@project, @query.filtered_issue_id),
            :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
</div>

<h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2>

<%= form_tag(_time_entries_path(@project, nil), :method => :get, :id => 'query_form') do %>
<%= render :partial => 'date_range' %>
<% end %>

<% if @query.valid? %>
<% if @entries.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<%= render_query_totals(@query) %>
<%= render :partial => 'list', :locals => { :entries => @entries }%>
<span class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></span>

<% other_formats_links do |f| %>
  <%= f.link_to_with_query_parameters 'Atom', :key => User.current.rss_key %>
  <%= f.link_to_with_query_parameters 'CSV', {}, :onclick => "showModal('csv-export-options', '330px'); return false;" %>
<% end %>

<div id="csv-export-options" style="display:none;">
  <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
  <%= form_tag(_time_entries_path(@project, nil, :format => 'csv'), :method => :get, :id => 'csv-export-form') do %>
  <%= query_as_hidden_field_tags @query %>
  <p>
    <label><%= radio_button_tag 'c[]', '', true %> <%= l(:description_selected_columns) %></label><br />
    <label><%= radio_button_tag 'c[]', 'all_inline' %> <%= l(:description_all_columns) %></label>
  </p>
  <%= export_csv_encoding_select_tag %>
  <p class="buttons">
    <%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);", :data => { :disable_with => false } %>
    <%= link_to_function l(:button_cancel), "hideModal(this);" %>
  </p>
  <% end %>
</div>
<% end %>
<% end %>

<% content_for :sidebar do %>
  <%= render_sidebar_queries(TimeEntryQuery, @project) %>
<% end %>

<% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_details)) %>

<% content_for :header_tags do %>
    <%= auto_discovery_link_tag(:atom, {:issue_id => @issue, :format => 'atom', :key => User.current.rss_key}, :title => l(:label_spent_time)) %>
<% end %>
