_calendar.rhtml

Go MAEDA, 2008-02-03 11:01

Download (2.09 KB)

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

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

    
9
<%
10
@date_from = Date.today - (Date.today.cwday-1)
11
@date_to = Date.today + (7-Date.today.cwday)
12
hide_not_assigned_to_me = params[:cal_hide_not_assigned_to_me] == nil ? 0 : 1
13
hide_closed = params[:cal_hide_closed] == nil ? 0 : 1 
14
@issues = Issue.find :all,
15
                     :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],
16
                     :include => [:project, :tracker, :status]  unless @user.projects.empty?
17
@issues ||= []
18
%>
19

    
20
<table class="cal">
21
<thead><tr>
22
<td></td>
23
<% 1.upto(7) do |d| %>
24
    <th align="center" width="14%"><%= day_name(d) %></th>
25
<% end %>
26
</tr></thead>
27
<tbdoy>
28
<tr height="100">
29
<% day = @date_from
30
while day <= @date_to
31
        if day.cwday == 1 %>
32
        <th valign="middle"><%= day.cweek %></th>
33
        <% end %>        
34
        <td valign="top" width="14%" class="<%= day.month==@month ? "even" : "odd" %>">
35
        <p align="right"><%= day==Date.today ? "<b>#{day.day}</b>" : day.day %></p>        
36
        <% day_issues = []
37
        @issues.each { |i| day_issues << i if i.start_date == day or i.due_date == day } 
38
        day_issues.each do |i| %>        
39
                <%= if day == i.start_date and day == i.due_date
40
                    image_tag('arrow_bw.png')
41
                elsif day == i.start_date
42
                    image_tag('arrow_from.png') 
43
                elsif day == i.due_date
44
                    image_tag('arrow_to.png') 
45
                end %>
46
                <small><%= link_to_issue i %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small><br />
47
        <% end %>
48
    </td>
49
        <%= '</tr><tr height="100">' if day.cwday >= 7 and day!=@date_to %>
50
        <%
51
        day = day + 1
52
end %>
53
</tr>
54
</tbody>
55
</table>