<%
  only_custom_fields ||= false
  custom_fields_key = params[:custom_fields_key] || :time_entry
  modal ||= params[:modal]
%>

<% if @time_entry.project.present? && !only_custom_fields %>
  <p>
    <%= label_for_field :spent_on, {:required => true } -%><%= text_field_tag :spent_on, @time_entry.spent_on, :size => 10, :class => 'spent_on', :autocomplete => 'off' -%><%= calendar_for('spent_on') unless in_mobile_view? -%>
  </p>
  <%= javascript_tag do %>
    $('#spent_on').change(function(){
      fillFormTextAreaFromCKEditor('<%= "#{'modal_' if modal}time_entry_comment" %>');
      $.ajax({url: '<%= j bulk_time_entries_path(:spent_on_changed => '1', :format => 'js').html_safe %>', data: $('#bulk-time-entry-form').serialize()});
    });
  <% end -%>
  <div id="timelog-user-time-entry-container">
    <% tag_name_prefix = 'time_entry' %>
    <%= render :partial => 'timelog/user_time_entry', :locals => {
      :required => true,
      :tag_name_prefix => tag_name_prefix,
      :time_entry => @time_entry,
      :activities => @activity_collection,
      :modal => modal,
      :project => @time_entry.project, :issue => @time_entry.issue}
    -%>
  </div>
<% end %>
<div class="splitcontent">
  <div class="splitcontentleft">
    <% split_on = (@time_entry.visible_custom_field_values.count / 2.0).round %>
    <% @time_entry.visible_custom_field_values.each_with_index do |value, i| %>
      <% if i == split_on -%>
      </div>
      <div class="splitcontentright">
      <% end -%>
      <p><%= custom_field_tag_with_label(custom_fields_key, value) %></p>
    <% end %>
  </div>
  <div style="clear:both;"></div>
</div>
