Project

General

Profile

Patch #230 » _calendar.rhtml

Go MAEDA, 2008-02-03 11:01

 
<h3><%= l(:label_calendar) %></h3>

<% form_tag() do %>
<%= check_box_tag('cal_hide_not_assigned_to_me', 1, params[:cal_hide_not_assigned_to_me]) %>hide issues not assigned to me
<%= check_box_tag('cal_hide_closed', @user.id, params[:cal_hide_closed]) %>hide closed issues
<%= submit_tag l(:button_apply), :class => 'button-small' %>
<% end %>

<%
@date_from = Date.today - (Date.today.cwday-1)
@date_to = Date.today + (7-Date.today.cwday)
hide_not_assigned_to_me = params[:cal_hide_not_assigned_to_me] == nil ? 0 : 1
hide_closed = params[:cal_hide_closed] == nil ? 0 : 1
@issues = Issue.find :all,
:conditions => ["#{Issue.table_name}.project_id in (#{@user.projects.collect{|m| m.id}.join(',')}) AND ((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) AND (? = 0 or assigned_to_id = ?) AND (? = 0 or #{IssueStatus.table_name}.is_closed = ?)", @date_from, @date_to, @date_from, @date_to, hide_not_assigned_to_me, @user.id, hide_closed, false],
:include => [:project, :tracker, :status] unless @user.projects.empty?
@issues ||= []
%>

<table class="cal">
<thead><tr>
<td></td>
<% 1.upto(7) do |d| %>
<th align="center" width="14%"><%= day_name(d) %></th>
<% end %>
</tr></thead>
<tbdoy>
<tr height="100">
<% day = @date_from
while day <= @date_to
if day.cwday == 1 %>
<th valign="middle"><%= day.cweek %></th>
<% end %>
<td valign="top" width="14%" class="<%= day.month==@month ? "even" : "odd" %>">
<p align="right"><%= day==Date.today ? "<b>#{day.day}</b>" : day.day %></p>
<% day_issues = []
@issues.each { |i| day_issues << i if i.start_date == day or i.due_date == day }
day_issues.each do |i| %>
<%= if day == i.start_date and day == i.due_date
image_tag('arrow_bw.png')
elsif day == i.start_date
image_tag('arrow_from.png')
elsif day == i.due_date
image_tag('arrow_to.png')
end %>
<small><%= link_to_issue i %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small><br />
<% end %>
</td>
<%= '</tr><tr height="100">' if day.cwday >= 7 and day!=@date_to %>
<%
day = day + 1
end %>
</tr>
</tbody>
</table>
(1-1/2)