<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
<%= hidden_field_tag 'back_url', url_for(:params => request.query_parameters), :id => nil %>
<ul class="cal">
  <li scope="col" title="<%= l(:label_week) %>" class="calhead week-number"></li>
  <% 7.times do |i| %>
    <li scope="col" class="calhead"><%= day_name((calendar.first_wday + i) % 7) %></li>
  <% end %>
  <% calendar.format_month.each_slice(7) do |week| %>
    <li class='week-number'>
      <span class="label-week"><%= l(:label_week) %></span> <%= calendar.week_number week.first %>
    </li>
    <% week.each do |day| %>
    <li class="<%= calendar.day_css_classes day %> calbody">
      <p class="day-num"><%= day.day %>
        <span class="abbr-day">(<%= abbr_day_name(day.cwday) %>)</span>
      </p>
      <% calendar.events_on(day).each do |i| %>
        <% if i.is_a? Issue %>
          <% starting = day == i.start_date %>
          <% ending = day == i.due_date %>
          <%= tag.div class: [ i.css_classes, 'tooltip hascontextmenu', starting: starting, ending: ending] do %>
            <%= "#{i.project} -" unless @project && @project == i.project %>
            <%= sprite_icon('bullet-go') if starting && starting != ending %>
            <%= sprite_icon('bullet-end') if ending && starting != ending %>
            <%= sprite_icon('bullet-go-end') if starting && ending %>
            <%= link_to_issue i, :truncate => 30 %>
            <span class="tip"><%= render_issue_tooltip i %></span>
            <%= check_box_tag 'ids[]', i.id, false, :style => 'display:none;', :id => nil %>
          <% end %>
        <% else %>
          <span class="icon icon-package">
            <%= sprite_icon 'package' %>
            <%= "#{i.project} -" unless @project && @project == i.project %>
            <%= link_to_version i %>
          </span>
        <% end %>
      <% end %>
    </li>
    <% end %>
  <% end %>
</ul>
<% end %>
<%= context_menu %>
