<%= labelled_fields_for :time_entry, @time_entry do |time_entry| %>
  <div id="issue_timeentry_fields">
    <%= toggling_container("#{dom_id(@time_entry)}_edit_issue_timeentry_fields", User.current, {:heading => l(:label_time_entry_plural), :wrapping_heading_element_classes => ' icon icon-time-add', :default_button_state => true, :ajax_call => false}) do %>
      <%= content_tag :p, :class => 'issue-edit-time-entry-spent_on' do %>
        <%= time_entry.text_field :spent_on, :value => (@time_entry && @time_entry.spent_on) || User.current.today , :size => 10, :required => true -%><%= calendar_for('time_entry_spent_on') -%>
      <% end if EasyGlobalTimeEntrySetting.value('time_entry_spent_on_at_issue_update_enabled', User.current.roles_for_project(@time_entry.project)) %>
      <%= render :partial => 'issues/edit_issue_time_entry_visible', :locals => {:f => f, :time_entry => @time_entry} %>
      <%= render :partial => 'issues/edit_issue_time_entry_hidden', :locals => {:f => f, :time_entry => @time_entry} %>
    <% end -%>
  </div>
<% end %>

<%= javascript_tag do %>
  $('#issue_timeentry_fields .timeentry-activity').change(function(){
    $.ajax({url: '<%= j bulk_time_entries_path(:activity_changed => '1', :only_custom_fields => '1', :custom_fields_key => :time_entry_custom_fields, :format => 'js').html_safe %>', data: $('form#issue-form input[name^=time_entry]').serialize()});
  });
<% end %>
